3.2 Polling Operation Mode Functions
The SPI Transfer Elementary Function
The function spi() is the elementary function that handles the SPI interface in polling mode. It sends a byte and stores the received one. Note that this function does not control the level of the chip select line. spi() is called from tx_spi() and rx_spi(). The function tx_spi() writes a byte on SPI and rx_spi() receives the byte.
Prototype:
char spi(uint8_t data);
The Read Status Register Function
The functions dataflash_read_status_register() and eeprom_read_status_register() perform an RDSR access. They return the access status value.
Prototype:
uint8_t dataflash_read_status_register(void);
uint8_t eeprom_read_status_register(void);
The Single Byte Write Command
The function send_cmd() sends the single byte op_codes, such as WREN,WRDI, etc. The serial memory must be ready before performing the access.
Prototype:
void send_cmd(uint8_t opcode)
The Write Status Register Function
This function performs the RDSR access. It sends op_codes OP_EWSR: Enable Write Status Register and OP_WRSR: Write Status Register and then sends the data to be written to the status register.
Prototype:
void dataflash_write_status_register(uint8_t byte);