3.1 Initialization of the SPI Interface
The function dataflash_init(), initializes SPI in the DataFlash driver.
The function eeprom_init(), initializes SPI in the EEPROM driver.
- The port directions are configured as
the following:
- Outputs: PA3/SCK, PA1/MOSI, PA4/SS
- Inputs: PA2/MISO.
- The SPI interface is configured as a master by configuring the CTRLA register.
- For SPI clock speed, the clock prescaler used is DIV4 and clock speed is doubled using the CLK2X bit in CTRLA register.
- SPI Transfer mode is selected as mode 0 and slave select is disabled by configuring the SSD bit high. By configuring the SSD bit high, #SS does not disable Master mode.
- The slave select line is configured high.