Lines Matching +full:4 +full:- +full:byte
2 * Copyright (c) 2006-2018, RT-Thread Development Team
4 * SPDX-License-Identifier: Apache-2.0
8 * 2011-12-16 aozima the first version
28 #define MC_ID_SST25VF040B (0x8D) /* 4Mbit */
58 return rt_spi_sendrecv8(spi_flash->rt_spi_device, CMD_RDSR); in sst25vfxx_read_status()
68 * \param page uint32_t unit : byte (4096 * N,1 page = 4096byte)
70 * \param size uint32_t unit : byte ( 4096*N )
80 page &= ~0xFFF; // page size = 4096byte in sst25vfxx_page_write()
83 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 1); in sst25vfxx_page_write()
89 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 4); in sst25vfxx_page_write()
94 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 1); in sst25vfxx_page_write()
100 send_buffer[4] = *buffer++; in sst25vfxx_page_write()
102 need_wirte -= 2; in sst25vfxx_page_write()
103 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 6); in sst25vfxx_page_write()
112 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 3); in sst25vfxx_page_write()
117 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 1); in sst25vfxx_page_write()
122 /* RT-Thread device interface */
135 result = rt_mutex_take(&(spi_flash->lock), RT_WAITING_FOREVER); in sst25vfxx_flash_open()
142 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 1); in sst25vfxx_flash_open()
145 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 1); in sst25vfxx_flash_open()
149 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 2); in sst25vfxx_flash_open()
152 rt_mutex_release(&(spi_flash->lock)); in sst25vfxx_flash_open()
175 if (geometry == RT_NULL) return -RT_ERROR; in sst25vfxx_flash_control()
177 geometry->bytes_per_sector = spi_flash->geometry.bytes_per_sector; in sst25vfxx_flash_control()
178 geometry->sector_count = spi_flash->geometry.sector_count; in sst25vfxx_flash_control()
179 geometry->block_size = spi_flash->geometry.block_size; in sst25vfxx_flash_control()
188 uint8_t send_buffer[4]; in sst25vfxx_flash_read()
190 uint32_t offset = pos * spi_flash->geometry.bytes_per_sector; in sst25vfxx_flash_read()
193 result = rt_mutex_take(&(spi_flash->lock), RT_WAITING_FOREVER); in sst25vfxx_flash_read()
200 rt_spi_send(spi_flash->rt_spi_device, send_buffer, 1); in sst25vfxx_flash_read()
206 …rt_spi_send_then_recv(spi_flash->rt_spi_device, send_buffer, 4, buffer, size * spi_flash->geometry… in sst25vfxx_flash_read()
209 rt_mutex_release(&(spi_flash->lock)); in sst25vfxx_flash_read()
222 result = rt_mutex_take(&(spi_flash->lock), RT_WAITING_FOREVER); in sst25vfxx_flash_write()
231 (pos + i) * spi_flash->geometry.bytes_per_sector, in sst25vfxx_flash_write()
233 spi_flash->geometry.bytes_per_sector); in sst25vfxx_flash_write()
234 write_buffer += spi_flash->geometry.bytes_per_sector; in sst25vfxx_flash_write()
238 rt_mutex_release(&(spi_flash->lock)); in sst25vfxx_flash_write()
264 return -RT_ENOSYS; in sst25vfxx_init()
266 spi_flash->rt_spi_device = rt_spi_device; in sst25vfxx_init()
274 rt_spi_configure(spi_flash->rt_spi_device, &cfg); in sst25vfxx_init()
283 rt_spi_send(spi_flash->rt_spi_device, &cmd, 1); in sst25vfxx_init()
287 rt_spi_send_then_recv(spi_flash->rt_spi_device, &cmd, 1, id_recv, 3); in sst25vfxx_init()
292 … FLASH_TRACE("JEDEC Read-ID Data : %02X %02X %02X\r\n", id_recv[0], id_recv[1], id_recv[2]); in sst25vfxx_init()
293 return -RT_ENOSYS; in sst25vfxx_init()
296 spi_flash->geometry.bytes_per_sector = 4096; in sst25vfxx_init()
297 spi_flash->geometry.block_size = 4096; /* block erase: 4k */ in sst25vfxx_init()
302 spi_flash->geometry.sector_count = 64; in sst25vfxx_init()
307 spi_flash->geometry.sector_count = 128; in sst25vfxx_init()
312 spi_flash->geometry.sector_count = 256; in sst25vfxx_init()
317 spi_flash->geometry.sector_count = 512; in sst25vfxx_init()
322 spi_flash->geometry.sector_count = 1024; in sst25vfxx_init()
327 spi_flash->geometry.sector_count = 2048; in sst25vfxx_init()
332 return -RT_ENOSYS; in sst25vfxx_init()
337 rt_mutex_init(&spi_flash->lock, flash_device_name, RT_IPC_FLAG_PRIO); in sst25vfxx_init()
340 spi_flash->flash_device.type = RT_Device_Class_Block; in sst25vfxx_init()
342 spi_flash->flash_device.ops = &sst25vfxx_device_ops; in sst25vfxx_init()
344 spi_flash->flash_device.init = sst25vfxx_flash_init; in sst25vfxx_init()
345 spi_flash->flash_device.open = sst25vfxx_flash_open; in sst25vfxx_init()
346 spi_flash->flash_device.close = sst25vfxx_flash_close; in sst25vfxx_init()
347 spi_flash->flash_device.read = sst25vfxx_flash_read; in sst25vfxx_init()
348 spi_flash->flash_device.write = sst25vfxx_flash_write; in sst25vfxx_init()
349 spi_flash->flash_device.control = sst25vfxx_flash_control; in sst25vfxx_init()
352 spi_flash->flash_device.user_data = RT_NULL; in sst25vfxx_init()
354 rt_device_register(&spi_flash->flash_device, flash_device_name, in sst25vfxx_init()