Skip to content

Instantly share code, notes, and snippets.

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];
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;
}