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.

  1. 1.The port directions are configured as the following:
    1. 1.1.Outputs: PA3/SCK, PA1/MOSI, PA4/SS
    2. 1.2.Inputs: PA2/MISO.
  2. 2.The SPI interface is configured as a master by configuring the CTRLA register.
  3. 3.For SPI clock speed, the clock prescaler used is DIV4 and clock speed is doubled using the CLK2X bit in CTRLA register.
  4. 4.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.
  5. 5.The slave select line is configured high.