Source code for the Trusted Boot Module.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
tbm-mcu/include/spi_flash.h

23 lines
680 B

#pragma once
/* Read commands */
#define CMD_READ_ARRAY_SLOW 0x03
#define CMD_READ_ID 0x9f
/* Write commands */
#define CMD_PAGE_PROGRAM 0x02
#define CMD_WRITE_DISABLE 0x04
#define CMD_WRITE_ENABLE 0x06
/* Erase commands */
#define CMD_ERASE_4K 0x20
#define CMD_ERASE_32K 0x52
#define CMD_ERASE_64K 0xD8
#define CMD_ERASE_CHIP 0x60
void init_spi(void);
void spi_send_cmd(uint32_t dev, const char *cmd, size_t cmd_len,
char *data, size_t data_len);
void spi_flash_read(uint32_t dev, uint32_t addr, char *data, size_t len);
void spi_flash_write(uint32_t dev, uint32_t addr, char *data, size_t len);
void spi_flash_erase(uint32_t dev, uint32_t addr, size_t len);