Serial Peripheral Interface Reusable Driver v1.1
This project implements SPI reusable driver that can be adapted to various microcontrollers.
Loading...
Searching...
No Matches
spi_cfg.c File Reference

This module contains the implementation for the Serial Peripheral Interface (SPI). More...

#include "spi_cfg.h"
Include dependency graph for spi_cfg.c:

Functions

const SpiConfig_t *const SPI_ConfigGet (void)
 
size_t SPI_configSizeGet (void)
 

Variables

const SpiConfig_t SpiConfig []
 

Detailed Description

This module contains the implementation for the Serial Peripheral Interface (SPI).

Author
Jose Luis Figueroa.
Version
1.1
Date
2025-03-11

Function Documentation

◆ SPI_ConfigGet()

const SpiConfig_t *const SPI_ConfigGet ( void )

Description: This function is used to initialize the SPI based on the configuration table defined in spi_cfg module.

PRE-CONDITION: configuration table needs to be populated (sizeof > 0).
POST-CONDITION: A constant pointer to the first member of the configuration table will be returned.

Returns
A pointer to the configuration table.

Example:

size_t configSize = DIO_configSizeGet();
SPI_Init(SpiConfig, configSize);
size_t DIO_configSizeGet(void)
Definition dio_cfg.c:134
const SpiConfig_t SpiConfig[]
Definition spi_cfg.c:41
const SpiConfig_t *const SPI_ConfigGet(void)
Definition spi_cfg.c:89
Definition spi_cfg.h:135
See also
SPI_configGet
SPI_configSizeGet
SPI_Init
SPI_Transfer
SPI_RegisterWrite
SPI_RegisterRead
SPI_CallbackRegister

◆ SPI_configSizeGet()

size_t SPI_configSizeGet ( void )

Description: This function is used to get the size of the configuration table.

PRE-CONDITION: configuration table needs to be populated (sizeof > 0)

POST-CONDITION: The size of the configuration table will be returned.

Returns
The size of the configuration table.

Example:

size_t configSize = DIO_configSizeGet();
SPI_Init(SpiConfig, configSize);
See also
SPI_configGet
SPI_configSizeGet
SPI_Init
SPI_Transfer
SPI_RegisterWrite
SPI_RegisterRead
SPI_CallbackRegister

Variable Documentation

◆ SpiConfig

const SpiConfig_t SpiConfig[]
Initial value:
=
{
}
@ SPI_FPCLK4
Definition spi_cfg.h:74
@ SPI_MASTER
Definition spi_cfg.h:64
@ SPI_SOFTWARE_NSS
Definition spi_cfg.h:93
@ SPI_CHANNEL1
Definition spi_cfg.h:38
@ SPI_8BITS
Definition spi_cfg.h:125
@ SPI_MSB
Definition spi_cfg.h:105
@ SPI_FULL_DUPLEX
Definition spi_cfg.h:115
@ SPI_MODE3
Definition spi_cfg.h:53

The following array contains the configuration data for each Serial Peripheral Interface. Each row represent a single SPI configuration. Each column is representing a member of the SpiConfig_t structure. This table is read in by SPI_Init, where each channel is then set up based on this table. The SPI_CHANNELS_NUMBER constant should be agreed with the number of row.