49 #define BLS_CODE_PROGRAM 0x02
50 #define BLS_CODE_READ 0x03
51 #define BLS_CODE_READ_STATUS 0x05
52 #define BLS_CODE_WRITE_ENABLE 0x06
53 #define BLS_CODE_SECTOR_ERASE 0x20
54 #define BLS_CODE_MDID 0x90
56 #define BLS_CODE_PD 0xB9
57 #define BLS_CODE_RPD 0xAB
61 #define BLS_CODE_ERASE_4K 0x20
62 #define BLS_CODE_ERASE_32K 0x52
63 #define BLS_CODE_ERASE_64K 0xD8
64 #define BLS_CODE_ERASE_ALL 0xC7
68 #define BLS_STATUS_SRWD_BM 0x80
69 #define BLS_STATUS_BP_BM 0x0C
70 #define BLS_STATUS_WEL_BM 0x02
71 #define BLS_STATUS_WIP_BM 0x01
73 #define BLS_STATUS_BIT_BUSY 0x01
76 #define BLS_DEVICE_ID_W25X20CL 0x11
77 #define BLS_DEVICE_ID_W25X40CL 0x12
78 #define BLS_DEVICE_ID_MX25R8035F 0x14
79 #define BLS_DEVICE_ID_MX25R1635F 0x15
81 #define BLS_WINBOND_MID 0xEF
82 #define BLS_MACRONIX_MID 0xC2
84 #define BLS_PROGRAM_PAGE_SIZE 256
85 #define BLS_ERASE_SECTOR_SIZE 4096
87 #define VERIFY_PART_ERROR -1
88 #define VERIFY_PART_POWERED_DOWN 0
89 #define VERIFY_PART_OK 1
97 ti_lib_gpio_pin_write(BOARD_FLASH_CS, 0);
106 ti_lib_gpio_pin_write(BOARD_FLASH_CS, 1);
165 uint8_t rbuf[2] = { 0, 0 };
174 return VERIFY_PART_ERROR;
181 return VERIFY_PART_ERROR;
184 if((rbuf[0] != BLS_WINBOND_MID && rbuf[0] != BLS_MACRONIX_MID) ||
185 (rbuf[1] != BLS_DEVICE_ID_W25X20CL && rbuf[1] != BLS_DEVICE_ID_W25X40CL
186 && rbuf[1] != BLS_DEVICE_ID_MX25R8035F
187 && rbuf[1] != BLS_DEVICE_ID_MX25R1635F)) {
188 return VERIFY_PART_POWERED_DOWN;
190 return VERIFY_PART_OK;
242 success =
wait_ready() ==
true ?
true :
false;
276 ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_FLASH_CS);
284 return verify_part() == VERIFY_PART_OK ?
true :
false;
312 wbuf[1] = (offset >> 16) & 0xff;
313 wbuf[2] = (offset >> 8) & 0xff;
314 wbuf[3] = offset & 0xff;
350 ilen = BLS_PROGRAM_PAGE_SIZE - (offset % BLS_PROGRAM_PAGE_SIZE);
356 wbuf[1] = (offset >> 16) & 0xff;
357 wbuf[2] = (offset >> 8) & 0xff;
358 wbuf[3] = offset & 0xff;
398 size_t i, numsectors;
399 size_t endoffset = offset + length - 1;
401 offset = (offset / BLS_ERASE_SECTOR_SIZE) * BLS_ERASE_SECTOR_SIZE;
402 numsectors = (endoffset - offset + BLS_ERASE_SECTOR_SIZE - 1) / BLS_ERASE_SECTOR_SIZE;
406 for(i = 0; i < numsectors; i++) {
418 wbuf[1] = (offset >> 16) & 0xff;
419 wbuf[2] = (offset >> 8) & 0xff;
420 wbuf[3] = offset & 0xff;
431 offset += BLS_ERASE_SECTOR_SIZE;
bool ext_flash_test(void)
Test the flash (power on self-test)
#define BLS_CODE_READ_STATUS
Read Status Register.
#define BLS_CODE_MDID
Manufacturer Device ID.
bool ext_flash_read(size_t offset, size_t length, uint8_t *buf)
Read storage content.
Header file with macros which rename TI CC26xxware functions.
Header file for the Sensortag/LaunchPad SPI Driver.
#define BLS_CODE_PROGRAM
Page Program.
static bool wait_ready(void)
Wait till previous erase/program operation completes.
static bool write_enable(void)
Enable write.
static void power_down(void)
Put the device in power save mode.
static void select_on_bus(void)
Clear external flash CSN line.
bool ext_flash_open()
Initialize storage driver.
void ext_flash_init()
Initialise the external flash.
static bool power_standby(void)
Take device out of power save mode and prepare it for normal operation.
void board_spi_close()
Close the SPI interface.
static uint8_t verify_part(void)
Verify the flash part.
bool board_spi_write(const uint8_t *buf, size_t len)
Write to an SPI device.
Header file for the Sensortag/LaunchPad External Flash Driver.
static void deselect(void)
Set external flash CSN line.
#define BLS_CODE_SECTOR_ERASE
Sector Erase.
#define BLS_CODE_PD
Power down.
bool board_spi_read(uint8_t *buf, size_t len)
Read from an SPI device.
void board_spi_open(uint32_t bit_rate, uint32_t clk_pin)
Initialize the SPI interface.
void board_spi_flush()
Clear data from the SPI interface.
bool ext_flash_erase(size_t offset, size_t length)
Erase storage sectors corresponding to the range.
#define BLS_STATUS_BIT_BUSY
Busy bit of the status register.
bool ext_flash_write(size_t offset, size_t length, const uint8_t *buf)
Write to storage sectors.
#define BLS_CODE_READ
Read Data.
void ext_flash_close()
Close the storage driver.
#define BLS_CODE_RPD
Release Power-Down.
#define BLS_CODE_WRITE_ENABLE
Write Enable.