CTS-SAT-1-OBC-Firmware
|
Go to the source code of this file.
Macros | |
#define | FLASH_NUMBER_OF_FLASH_DEVICES 8 |
#define | FLASH_CHIP_SIZE_BYTES 134217728 |
#define | FLASH_CHIP_PAGES_PER_BLOCK 64 |
#define | FLASH_MAX_BYTES_PER_PAGE 2048 |
Enumerations | |
enum | FLASH_error_enum_t { FLASH_ERR_OK = 0 , FLASH_ERR_SPI_TRANSMIT_FAILED = -3 , FLASH_ERR_SPI_RECEIVE_FAILED = -4 , FLASH_ERR_DEVICE_BUSY_TIMEOUT = -6 , FLASH_ERR_UNKNOWN = -7 , FLASH_ERR_STATUS_REG_ERROR = -8 , FLASH_ERR_SPI_TRANSMIT_TIMEOUT = -10 , FLASH_ERR_SPI_RECEIVE_TIMEOUT = -11 } |
Functions | |
void | FLASH_activate_chip_select (uint8_t chip_number) |
Activates the chip select for the given flash module number. | |
void | FLASH_deactivate_chip_select () |
Deactivates the chip select for all lines. | |
FLASH_error_enum_t | FLASH_unblock_block_lock (SPI_HandleTypeDef *hspi, uint8_t chip_number, uint8_t *buf) |
Unblocks all blocked blocks of memory on the NAND flash memory module. | |
FLASH_error_enum_t | FLASH_read_status_register (SPI_HandleTypeDef *hspi, uint8_t chip_number, uint8_t *buf) |
Read Status Register and store the values in given buffer. | |
FLASH_error_enum_t | FLASH_read_block_lock_register (SPI_HandleTypeDef *hspi, uint8_t chip_number, uint8_t *buf) |
Read Block Lock Register and store the values in given buffer. | |
FLASH_error_enum_t | FLASH_write_enable (SPI_HandleTypeDef *hspi, uint8_t chip_number) |
Sends Write Enable Command. | |
FLASH_error_enum_t | FLASH_write_disable (SPI_HandleTypeDef *hspi, uint8_t chip_number) |
Sends Write Disable Command. | |
FLASH_error_enum_t | FLASH_erase (SPI_HandleTypeDef *hspi, uint8_t chip_number, lfs_block_t page) |
Sends Block Erase Command. | |
FLASH_error_enum_t | FLASH_write_data (SPI_HandleTypeDef *hspi, uint8_t chip_number, lfs_block_t page, uint8_t *packet_buffer, lfs_size_t packet_buffer_len) |
Sends Page Program Command. | |
FLASH_error_enum_t | FLASH_read_data (SPI_HandleTypeDef *hspi, uint8_t chip_number, lfs_block_t page, uint8_t *rx_buffer, lfs_size_t rx_buffer_len) |
Sends Page Read Command. | |
FLASH_error_enum_t | FLASH_is_reachable (SPI_HandleTypeDef *hspi, uint8_t chip_number) |
Checks if the FLASH chip is reachable by checking it's ID. | |
FLASH_error_enum_t | FLASH_reset (SPI_HandleTypeDef *hspi, uint8_t chip_number) |
Resets the NAND flash memory module. | |
Variables | |
static const uint8_t | FLASH_FEAT_BLOCK_LOCK = 0xA0 |
static const uint8_t | FLASH_FEAT_CONFIG = 0xB0 |
static const uint8_t | FLASH_FEAT_STATUS = 0xC0 |
static const uint8_t | FLASH_FEAT_DIE_SELECT = 0xD0 |
static const uint8_t | FLASH_CMD_PAGE_READ = 0x13 |
static const uint8_t | FLASH_CMD_READ_FROM_CACHE = 0x03 |
static const uint8_t | FLASH_CMD_PROGRAM_LOAD = 0x02 |
static const uint8_t | FLASH_CMD_PROGRAM_EXEC = 0x10 |
static const uint8_t | FLASH_CMD_BLOCK_ERASE = 0xD8 |
static const uint8_t | FLASH_CMD_WRITE_ENABLE = 0x06 |
static const uint8_t | FLASH_CMD_WRITE_DISABLE = 0x04 |
static const uint8_t | FLASH_CMD_GET_FEATURES = 0x0F |
static const uint8_t | FLASH_CMD_SET_FEATURES = 0x1F |
static const uint8_t | FLASH_CMD_READ_ID = 0x9F |
static const uint8_t | FLASH_CMD_RESET = 0xFF |
static const uint8_t | FLASH_SR1_WRITE_IN_PROGRESS_MASK = (1 << 0) |
static const uint8_t | FLASH_SR1_WRITE_ENABLE_LATCH_MASK = (1 << 1) |
static const uint8_t | FLASH_SR1_PROGRAMMING_ERROR_MASK = (1 << 3) |
static const uint8_t | FLASH_SR1_ERASE_ERROR_MASK = (1 << 2) |
#define FLASH_CHIP_PAGES_PER_BLOCK 64 |
#define FLASH_CHIP_SIZE_BYTES 134217728 |
#define FLASH_MAX_BYTES_PER_PAGE 2048 |
#define FLASH_NUMBER_OF_FLASH_DEVICES 8 |
enum FLASH_error_enum_t |
void FLASH_activate_chip_select | ( | uint8_t | chip_number | ) |
Activates the chip select for the given flash module number.
chip_number | - Index of the chip select line to activate |
Activates the chip select for the given chip number by setting the corresponding GPIO pins LOW. Deactivates all other chip selects by setting their corresponding GPIO pins HIGH.
void FLASH_deactivate_chip_select | ( | ) |
Deactivates the chip select for all lines.
FLASH_error_enum_t FLASH_erase | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number, | ||
lfs_block_t | page ) |
Sends Block Erase Command.
hspi | - Pointer to the SPI HAL handle |
chip_number | - the chip select number to activate |
page | - page number to erase the block the page is contained in |
FLASH_error_enum_t FLASH_is_reachable | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number ) |
Checks if the FLASH chip is reachable by checking it's ID.
hspi | - Pointer to the SPI HAL handle |
chip_number | - The chip select number to activate |
FLASH_ERR_OK | (0) on success, <0 on failure (from the FLASH_error_enum_t enum) |
FLASH_error_enum_t FLASH_read_block_lock_register | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number, | ||
uint8_t * | buf ) |
Read Block Lock Register and store the values in given buffer.
hspi | - Pointer to the SPI HAL handle |
chip_number | - the chip select number to activate |
buf | - Pointer to a buffer to store Block Lock Register value. Length: 1 byte. |
FLASH_error_enum_t FLASH_read_data | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number, | ||
lfs_block_t | page, | ||
uint8_t * | rx_buffer, | ||
lfs_size_t | rx_buffer_len ) |
Sends Page Read Command.
hspi | - Pointer to the SPI HAL handle |
chip_number | - The chip select number to activate |
page | - page number to be read |
rx_buffer | - A buffer where the read data will be stored |
rx_buffer_len | - Integer that indicates the capacity of rx_buffer |
FLASH_error_enum_t FLASH_read_status_register | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number, | ||
uint8_t * | buf ) |
Read Status Register and store the values in given buffer.
hspi | - Pointer to the SPI HAL handle |
chip_number | - the chip select number to activate |
buf | - Pointer to a buffer to store SR1 value. Length: 1 byte. |
FLASH_error_enum_t FLASH_reset | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number ) |
Resets the NAND flash memory module.
hspi | - Pointer to the SPI HAL handle |
chip_number | - The chip select number to activate |
FLASH_error_enum_t FLASH_unblock_block_lock | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number, | ||
uint8_t * | buf ) |
Unblocks all blocked blocks of memory on the NAND flash memory module.
hspi | - Pointer to the SPI HAL handle |
chip_number | - the chip select number to activate |
buf | - Pointer to a buffer to store the new Block Lock Register value. Length: 1 byte. |
FLASH_error_enum_t FLASH_write_data | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number, | ||
lfs_block_t | page, | ||
uint8_t * | packet_buffer, | ||
lfs_size_t | packet_buffer_len ) |
Sends Page Program Command.
hspi | - Pointer to the SPI HAL handle |
chip_number | - the chip select number to activate |
page | - page number the data is to be written to |
packet_buffer | - Pointer to buffer containing data to write |
packet_buffer_len | - integer that indicates the size of the data to write |
FLASH_error_enum_t FLASH_write_disable | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number ) |
Sends Write Disable Command.
hspi | - Pointer to the SPI HAL handle |
chip_number | - the chip select number to activate |
FLASH_error_enum_t FLASH_write_enable | ( | SPI_HandleTypeDef * | hspi, |
uint8_t | chip_number ) |
Sends Write Enable Command.
hspi | - Pointer to the SPI HAL handle |
chip_number | - the chip select number to activate |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |