Go to the source code of this file.
Functions | |
int | Sppi0SetMode (uint8_t ix, uint8_t mode) |
Set mode for a given device at SPI0. | |
void | Sppi0SetSpeed (uint8_t ix, uint32_t rate) |
Set transfer rate for a given device at SPI0. | |
void | Sppi0Enable (uint8_t ix) |
Enable the serial peripheral interface 0. | |
void | Sppi0ChipReset (uint8_t ix, uint8_t hi) |
Set or clear a configured reset line for a given device. | |
void | Sppi0ChipSelect (uint8_t ix, uint8_t hi) |
Set or clear a configured chip select for a given device. | |
void | Sppi0SelectDevice (uint8_t ix) |
Select the device at a given chip select. | |
void | Sppi0DeselectDevice (uint8_t ix) |
Deselect the device at a given chip select. | |
void | Sppi0NegSelectDevice (uint8_t ix) |
Select the device at a given negated chip select. | |
void | Sppi0NegDeselectDevice (uint8_t ix) |
Deselect the device at a given negated chip select. | |
uint8_t | Sppi0Byte (uint8_t data) |
Exchange a byte with the currently selected SPI device. | |
void | Sppi0Transact (CONST void *wdata, void *rdata, size_t len) |
Exchange a specified number of bytes with the currently selected SPI device. |
Set mode for a given device at SPI0.
This is typically the first call in order to use the device. It will not directly enable the SPI hardware. This is done when selecting the device.
The transfer rate is set to the lowest possible value and can be adjusted by calling Sppi0SetSpeed().
ix | The device index, starting at 0. |
mode | The mode to set.
|
Definition at line 76 of file sppif0.c.
References _BV, and SPPI0_MAX_DEVICES.
Set transfer rate for a given device at SPI0.
ix | The device index, starting at 0. |
rate | Transfer rate in bits per second. |
Definition at line 99 of file sppif0.c.
References _BV, and NutGetCpuClock().
void Sppi0Enable | ( | uint8_t | ix | ) |
Enable the serial peripheral interface 0.
Enables SPI with the parameters previously set by Sppi0SetMode() and Sppi0SetSpeed().
ix | The device index, starting at 0. The routine will not check if this is valid. |
Set or clear a configured reset line for a given device.
Reset lines must be configured when building the system libraries. This routine silently ignores them, if not configured.
ix | The device index, starting at 0. |
hi | If 0, the reset line is driven low. Otherwise the line is driven high. |
Set or clear a configured chip select for a given device.
Chip selects must be configured when building the system libraries. This routine silently ignores selects, if they are not configured.
ix | The device index, starting at 0. Same as the chip select number. |
hi | If 0, the chip select is driven low. Otherwise the line is driven high. |
void Sppi0SelectDevice | ( | uint8_t | ix | ) |
Select the device at a given chip select.
Enables the serial peripheral interface with the parameters previously set for the given device by Sppi0SetMode() and Sppi0SetSpeed(). Then the configured chip select line is driven high.
ix | The device index, starting at 0. The routine will not check if this is a valid number. |
Definition at line 297 of file sppif0.c.
References Sppi0ChipSelect(), and Sppi0Enable().
void Sppi0DeselectDevice | ( | uint8_t | ix | ) |
Deselect the device at a given chip select.
The configured chip select line will be driven low.
ix | The device index, starting at 0. The routine will not check if this is a valid number. |
Definition at line 311 of file sppif0.c.
References Sppi0ChipSelect().
void Sppi0NegSelectDevice | ( | uint8_t | ix | ) |
Select the device at a given negated chip select.
Enables the serial peripheral interface with the parameters previously set for the given device by Sppi0SetMode() and Sppi0SetSpeed(). Then the configured chip select line is driven low.
ix | The device index, starting at 0. The routine will not check if this is a valid number. |
Definition at line 327 of file sppif0.c.
References Sppi0ChipSelect(), and Sppi0Enable().
void Sppi0NegDeselectDevice | ( | uint8_t | ix | ) |
Deselect the device at a given negated chip select.
The configured chip select line will be driven high.
ix | The device index, starting at 0. The routine will not check if this is a valid number. |
Definition at line 341 of file sppif0.c.
References Sppi0ChipSelect().
Exchange a byte with the currently selected SPI device.
data | Byte to transmit. |
Definition at line 353 of file sppif0.c.
References inb, loop_until_bit_is_set, and outb.
Referenced by Sppi0Transact().
void Sppi0Transact | ( | CONST void * | wdata, |
void * | rdata, | ||
size_t | len | ||
) |
Exchange a specified number of bytes with the currently selected SPI device.
It is assumed, that the serial peripheral interface has been properly initialized by calling Sppi0SetMode() and optionally Sppi0SetSpeed().
Further it is assumed, that the chip select (if there is one) had been enabled by a previous call to Sppi0SelectDevice() or Sppi0NegSelectDevice().
wdata | Pointer to the data to transmit. |
rdata | Pointer to a buffer that receives the data from the device. Can be set to NULL for transmit only. May also point to the tranmit buffer, in which case the transmitted bytes are replaced by the bytes received. |
Definition at line 377 of file sppif0.c.
References CONST, and Sppi0Byte().