Definitions of spi_driver functions.
Definition in file spi_driver.c.
#include "spi_driver.h"
Go to the source code of this file.
Functions | |
void | SPI_PinInit (uint32_t port, uint32_t pin, enum directionIO direction) |
Initializes a given pin as either an input or output. More... | |
void | SPI_PinClear (uint32_t port, uint32_t pin) |
Clears a given pin on a port to LOW. More... | |
void | SPI_PinSet (uint32_t port, uint32_t pin) |
Sets a given pin on a port to HIGH. More... | |
uint32_t | SPI_PinRead (uint32_t port, uint32_t pin) |
Reads the voltage on a given pin. More... | |
void | SPI_ConfigureSingleSPIIOs () |
Configure the IOs for SPI bit banging usage. 4 pins are needed: CSb, SCK, MOSI, MISO. More... | |
void | SPI_ReturnToSingleSPIIOs () |
Returns MISO and MOSI pins to their standard SPI state as an input and output. More... | |
void | SPI_ConfigureDualSPIIOsInput () |
Configures SPIO IOs for dual input. This changes the MOSI pin from an output to an input so that the slave can drive both SI and SO. More... | |
void | SPI_ConfigureQuadSPIIOsInput () |
Configures SPIO IOs for quad input. This changes the MOSI, WPb, and HOLDb pins to inputs so that the slave can drive all 4 IOs. More... | |
void | SPI_ConfigureDualSPIIOsOutput () |
Configures SPIO IOs for dual output. This changes the MISO pin from an input to an output so that the master can drive both SI and SO. More... | |
void | SPI_ConfigureQuadSPIIOsOutput () |
Configures SPIO IOs for quad output. This changes the MISO pin to an output so that the master can drive all 4 IOs. More... | |
void | SPI_Delay (uint32_t delayTime) |
Performs a delayTime number of NOPs. More... | |
void | SPI_ClockTick () |
Toggles the clock: current_state->high->low. More... | |
void | SPI_SendBit (uint8_t transmittedBit) |
Sends a single bit along MOSI while toggling the clock. More... | |
void | SPI_SendByte (uint8_t transmittedByte) |
Sends a byte along MOSI. More... | |
void | SPI_DualSendByte (uint8_t transmittedByte) |
Sends a byte along both MOSI and MISO. More... | |
void | SPI_QuadSendByte (uint8_t transmittedByte) |
Sends a byte along MISO, MOSI, WPb, and HOLDb. More... | |
uint8_t | SPI_ReceiveByte () |
Receives a byte along MISO and returns the value received. More... | |
uint8_t | SPI_DualReceiveByte () |
Receives a byte along both MOSI and MISO and returns the value received. More... | |
uint8_t | SPI_QuadReceiveByte () |
Receives a byte along MOSI, MISO, HOLDb, and WPb and returns the value received. More... | |
void | SPI_Exchange (uint8_t *txBuffer, uint32_t txNumBytes, uint8_t *rxBuffer, uint32_t rxNumBytes, uint32_t dummyNumBytes) |
Sends and receives bytes based on the function parameters. MISO and MOSI fill their standard SPI roles. More... | |
void | SPI_DualExchange (uint8_t standardSPINumBytes, uint8_t *txBuffer, uint32_t txNumBytes, uint8_t *rxBuffer, uint32_t rxNumBytes, uint32_t dummyNumBytes) |
Sends and receives bytes based on the function parameters. MOSI is used for the opcode and address, then MISO or MOSI are switched for transmission and receiving such that data is transmitted from/to the flash device along both lines. Their state will then be reverted to original SPI functionality. More... | |
void | SPI_QuadExchange (uint8_t standardSPINumBytes, uint8_t *txBuffer, uint32_t txNumBytes, uint8_t *rxBuffer, uint32_t rxNumBytes, uint32_t dummyNumBytes) |
Sends and receives bytes based on the function parameters. MOSI can used for the opcode and address, then MISO, MOSI, HOLDb, WPb are switched for transmission and receiving such that data is transmitted from/to the flash device along all 4 lines. Their state will then be reverted to original SPI functionality. More... | |
void | SPI_Trigger () |
Triggers a falling edge on the SPI_TRIGGER_PORT/PIN output. More... | |
void | SPI_JEDECReset () |
Performs a JEDEC reset on the SPI device. More... | |
void SPI_ClockTick | ( | ) |
Toggles the clock: current_state->high->low.
void |
Definition at line 149 of file spi_driver.c.
void SPI_ConfigureDualSPIIOsInput | ( | ) |
Configures SPIO IOs for dual input. This changes the MOSI pin from an output to an input so that the slave can drive both SI and SO.
void |
Definition at line 101 of file spi_driver.c.
void SPI_ConfigureDualSPIIOsOutput | ( | ) |
Configures SPIO IOs for dual output. This changes the MISO pin from an input to an output so that the master can drive both SI and SO.
void |
Definition at line 121 of file spi_driver.c.
void SPI_ConfigureQuadSPIIOsInput | ( | ) |
Configures SPIO IOs for quad input. This changes the MOSI, WPb, and HOLDb pins to inputs so that the slave can drive all 4 IOs.
void |
Definition at line 108 of file spi_driver.c.
void SPI_ConfigureQuadSPIIOsOutput | ( | ) |
Configures SPIO IOs for quad output. This changes the MISO pin to an output so that the master can drive all 4 IOs.
void |
Definition at line 128 of file spi_driver.c.
void SPI_ConfigureSingleSPIIOs | ( | ) |
Configure the IOs for SPI bit banging usage. 4 pins are needed: CSb, SCK, MOSI, MISO.
void |
Definition at line 61 of file spi_driver.c.
void SPI_Delay | ( | uint32_t | delayTime | ) |
Performs a delayTime number of NOPs.
delayTime | The number of NOPs to be run. |
void |
Definition at line 140 of file spi_driver.c.
void SPI_DualExchange | ( | uint8_t | standardSPINumBytes, |
uint8_t * | txBuffer, | ||
uint32_t | txNumBytes, | ||
uint8_t * | rxBuffer, | ||
uint32_t | rxNumBytes, | ||
uint32_t | dummyNumBytes | ||
) |
Sends and receives bytes based on the function parameters. MOSI is used for the opcode and address, then MISO or MOSI are switched for transmission and receiving such that data is transmitted from/to the flash device along both lines. Their state will then be reverted to original SPI functionality.
standardSPINumBytes | The number of bytes to be sent in standard single SPI mode. Note: Dummy bytes will be sent in standard single SPI mode. |
*txBuffer | A pointer to the tx byte array to be transmitted. Should have tx_bytes elements. |
txNumBytes | The total number of bytes to be transmitted including those in standard SPI. |
*rxBuffer | A pointer to the rx byte array where received data will be stored. Should have rx_bytes elements. |
rxNumBytes | The number of bytes to be received. |
dummyNumBytes | The number of dummy bytes to be sent. |
void |
Definition at line 355 of file spi_driver.c.
uint8_t SPI_DualReceiveByte | ( | ) |
Receives a byte along both MOSI and MISO and returns the value received.
uint8_t | The byte received in Little Endian format. |
Definition at line 268 of file spi_driver.c.
void SPI_DualSendByte | ( | uint8_t | transmittedByte | ) |
Sends a byte along both MOSI and MISO.
transmittedByte | Byte to be sent. |
void |
Definition at line 180 of file spi_driver.c.
void SPI_Exchange | ( | uint8_t * | txBuffer, |
uint32_t | txNumBytes, | ||
uint8_t * | rxBuffer, | ||
uint32_t | rxNumBytes, | ||
uint32_t | dummyNumBytes | ||
) |
Sends and receives bytes based on the function parameters. MISO and MOSI fill their standard SPI roles.
*txBuffer | A pointer to the tx byte array to be transmitted. Should have tx_bytes elements. |
txNumBytes | The number of bytes to be transmitted. |
*rxBuffer | A pointer to the rx byte array where received data will be stored. Should have rx_bytes elements. |
rxNumBytes | The number of bytes to be received. |
dummyNumBytes | The number of dummy bytes to be sent. |
void |
Definition at line 325 of file spi_driver.c.
void SPI_JEDECReset | ( | ) |
Performs a JEDEC reset on the SPI device.
void |
Definition at line 492 of file spi_driver.c.
void SPI_PinClear | ( | uint32_t | port, |
uint32_t | pin | ||
) |
Clears a given pin on a port to LOW.
port | The port number. |
pin | The pin number. |
void |
Definition at line 47 of file spi_driver.c.
void SPI_PinInit | ( | uint32_t | port, |
uint32_t | pin, | ||
enum directionIO | direction | ||
) |
Initializes a given pin as either an input or output.
port | The port number. The type must be redefined based on the GPIO driver being used. |
pin | The pin number. |
direction | INPUT or OUTPUT. See the directionIO enum type. |
void |
Definition at line 43 of file spi_driver.c.
uint32_t SPI_PinRead | ( | uint32_t | port, |
uint32_t | pin | ||
) |
Reads the voltage on a given pin.
port | The port number. |
pin | The pin number. |
32-bit | word, 0 = LOW, 1 = HIGH. |
Definition at line 56 of file spi_driver.c.
void SPI_PinSet | ( | uint32_t | port, |
uint32_t | pin | ||
) |
Sets a given pin on a port to HIGH.
port | The port number. |
pin | The pin number. |
void |
Definition at line 51 of file spi_driver.c.
void SPI_QuadExchange | ( | uint8_t | standardSPINumBytes, |
uint8_t * | txBuffer, | ||
uint32_t | txNumBytes, | ||
uint8_t * | rxBuffer, | ||
uint32_t | rxNumBytes, | ||
uint32_t | dummyNumBytes | ||
) |
Sends and receives bytes based on the function parameters. MOSI can used for the opcode and address, then MISO, MOSI, HOLDb, WPb are switched for transmission and receiving such that data is transmitted from/to the flash device along all 4 lines. Their state will then be reverted to original SPI functionality.
standardSPINumBytes | The number of bytes to be sent in standard single SPI mode. Note: Dummy bytes will be sent in standard single SPI mode based on the input parameters. |
*txBuffer | A pointer to the tx byte array to be transmitted. Should have tx_bytes elements. |
txNumBytes | The total number of bytes to be transmitted including those in standard SPI. |
*rxBuffer | A pointer to the rx byte array where received data will be stored. Should have rx_bytes elements. |
rxNumBytes | The number of bytes to be received. |
dummyNumBytes | The number of dummy bytes to be sent. |
void |
Definition at line 406 of file spi_driver.c.
uint8_t SPI_QuadReceiveByte | ( | ) |
Receives a byte along MOSI, MISO, HOLDb, and WPb and returns the value received.
uint8_t | The byte received in Little Endian format. |
Definition at line 292 of file spi_driver.c.
void SPI_QuadSendByte | ( | uint8_t | transmittedByte | ) |
Sends a byte along MISO, MOSI, WPb, and HOLDb.
transmittedByte | Byte to be sent. |
void |
Definition at line 211 of file spi_driver.c.
uint8_t SPI_ReceiveByte | ( | ) |
Receives a byte along MISO and returns the value received.
uint8_t | The byte received in Little Endian format. |
Definition at line 251 of file spi_driver.c.
void SPI_ReturnToSingleSPIIOs | ( | ) |
Returns MISO and MOSI pins to their standard SPI state as an input and output.
void |
Definition at line 85 of file spi_driver.c.
void SPI_SendBit | ( | uint8_t | transmittedBit | ) |
Sends a single bit along MOSI while toggling the clock.
transmittedBit | Bit to be sent, either 1 or 0. |
void |
Definition at line 157 of file spi_driver.c.
void SPI_SendByte | ( | uint8_t | transmittedByte | ) |
Sends a byte along MOSI.
transmittedByte | Byte to be sent. |
void |
Definition at line 170 of file spi_driver.c.
void SPI_Trigger | ( | ) |
Triggers a falling edge on the SPI_TRIGGER_PORT/PIN output.
void |
Definition at line 485 of file spi_driver.c.