Contiki 2.5
Files | Macros | Functions
Master SPI Bus Manager

Files

file  mspi-mgr.h
 
    Master SPI Bus Manager definitions

 

Macros

#define MAX_SPI_DEVICES   7
 

Functions

void add_to_spi_mgr (uint8_t cs, uint8_t mode, uint16_t baud)
 This function add a device to the SPI device table and calculates the specific checksum. More...
 
void change_spi_mode (spi_dev new_config)
 This function changes the SPI configuration. More...
 

Detailed Description

The various SPI devices are all connected to the SPI Bus (SCK, MOSI/SDA, MISO/SDI) and only separated by the Chip Select. With a high probability, not every SPI Device will use the same SPI Bus configuration (SPI Mode), so you would have to change (or to check) the SPI mode whenever accessing another SPI device. But in higher software layers you are not interested in such details like SPI Mode. Therefore the SPI Bus Manager was implemented, to separate the low level hardware and register level from higher software layers. The SPI Bus Manager holds all devices, which are connected to the SPI Bus. With a checksum he can decide, if the SPI configuration has to change. So in some cases these reconfiguration can be avoid.

Note
If you know what you are doing, it is possible to disable the SPI Bus Manager by setting MSPI_BUS_MANAGER in the mspi-drv.h to 0.

Macro Definition Documentation

#define MAX_SPI_DEVICES   7

Defines the maximum number of SPI devices

Note
In our case we have 7 (2³-1) possible SPI devices, because we are using 3 I/O pins and a BCD-to-decimal encoder for the chip select.

Definition at line 64 of file mspi-mgr.h.

Function Documentation

void add_to_spi_mgr ( uint8_t  cs,
uint8_t  mode,
uint16_t  baud 
)

This function add a device to the SPI device table and calculates the specific checksum.

Parameters
csChip Select: Device ID
modeSelect the (M)SPI mode (MSPI_MODE_0 ... MSPI_MODE_3)
baudThe MSPI BAUD rate. Sometimes it is necessary to reduce the SCK. Use MSPI_BAUD_MAX in common case.

Definition at line 106 of file mspi-drv.c.

Referenced by mspi_init().

void change_spi_mode ( spi_dev  new_config)

This function changes the SPI configuration.

Parameters
spi_devThe specified entry of the SPI Device Table

Definition at line 112 of file mspi-drv.c.

Referenced by mspi_chip_select().