====== SPI ====== Different variants exist. Usually SPI refers to the Motorola Serial Peripheral Interface. Other variants are the Texas Instruments Serial protocol (SSP) and the National Instruments Microwire. ===== Protocol ===== Most significant bit first ===== Modes ===== There are 4 Modes. Defied by the two settings "clock polarity" CPOL and "clock phase" CPHA. "clock polarity" CPOL = 0: - Clock line is low when idle. "clock polarity" CPOL = 1: - Clock line is high when idle. "clock phase" CPHA = 0: - first data bit is output on /CS activating (going low). - data bits change when clock goes to idle level. - data bits are read when clock comes from idle level. "clock phase" CPHA = 1: - first data bit starts on first edge after /CS activates. - data bits change when clock comes from idle level. - data bits are read when clock goes to idle level. ^ mode ^ CPOL ^ CPHA ^ write bit ^ read bit ^ | 0 | 0 | 0 | clock goes low, and when /CS activates | clock goes high | | 1 | 0 | 1 | clock goes high | clock goes low | | 2 | 1 | 0 | clock goes high, and when /CS activates | clock goes low | | 3 | 1 | 1 | clock goes low | clock goes high | ===== API ===== The part "signal_name" in the described functions will be replaced by the name of the signal. E.g. if your signal is called "audio" then the API function "signal_name_transfer" will become "audio_transfer". void signal_name_transfer(const uint8_t *data_send, const uint8_t *data_receive, const uint32_t length ) Will send "length" bytes from the buffer "data_send" out on MOSI and will receive the same amount of bytes from MISO into the buffer "data_receive".