@CHIP-RTOS C Library V2.06 - SPI API
spi_init_hw
Init the SPI Interface (hardware interface) void spi_init_hw ( unsigned int mode, unsigned int div ); Parameters
mode
- Combine the following defines with a bitwise OR to select the operation mode
SPI mode:
set on of these: SPI_MODE0, SPI_MODE1, SPI_MODE2 or SPI_MODE3
Open-Drain-Mode:
select SPI_OPEN_DRAIN for open-drain-mode,
else output mode is used
Autodrive:
select SPI_AUTODRIVE to autodrive SLVSEL chipselect pin,
works only together with SPI_ALTERNATE_IO
else do not drive SLVSEL pin
Invert chipselect:
select SPI_INVERT_CS to invert SLVSEL chipselect pin (active high),
else do not invert SLVSEL pin (active low)
Shift count:
select the shift count with these defines:
SPI_SHIFT1, SPI_SHIFT2, SPI_SHIFT3, SPI_SHIFT4,
SPI_SHIFT5, SPI_SHIFT6, SPI_SHIFT7, SPI_SHIFT8
Swap SDI and SDO:
select SPI_ALTERNATE_IO to swap SDI and SDO pins
div
- SPI speed clock divider (valid values: 0-65535)
The SPI clock frequency is calculated with the formula:
SPI freq = CPU freq / (divider*2+2)
Return Value
- -- none --.
Comments
- A Wired-OR mode is provided which allows multiple masters to collide on the bus
without risk of damage. In this mode, an external pull-up resistor is required
on the Master Out Slave In (MOSI) and Master In Slave Out (MISO) pins.
Generally, pull-ups are recommended on all of the external SPI signals to ensure
they are held in a valid state, even when the SPI interface is disabled.
See Also
RTOS API
- This library function invokes a RTOS software interrupt.
Refer to this RTOS API function's
documentation
for more details.
Supported since or modified in @CHIP-RTOS version-
SC12 | SC13 | SC11 | SC1x3 |
-
n/a | n/a | n/a | V0.90 |
Supported by @CHIP-RTOS C Library since version
This API List
List of C Libraries
@CHIP-RTOS Main Index
End of document
|