This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static bool flash_busy(void) { | |
uint8_t cmd = CMD_RDSR; | |
uint8_t data; | |
spi_tx(config, &cmd, 1, &data , 1, 0); | |
return data & STAT_BSY; | |
} | |
int flash_erase_block(uint32_t address, block_erase_t mode) { | |
uint8_t cmd_buffer[4]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline uint8_t spi_send(SPI_TypeDef* SPI, uint8_t data) { | |
SPI->DR = data; | |
while (!(SPI->SR & SPI_FLAG_TXE)); | |
while (!(SPI->SR & SPI_FLAG_RXNE)); | |
return SPI->DR; | |
} |