www.beck-ipc.com

@CHIP-RTOS C Library - SPI API


spi_slave_init

Init the SPI Slave Interface (hardware interface)

void spi_slave_init ( unsigned int mode );

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
Invert chipselect:
    select SPI_INVERT_CS to invert SLVSEL chipselect pin (active high),
    else do not invert SLVSEL pin (active low)
Swap SDI and SDO:
    select SPI_ALTERNATE_IO to swap SDI and SDO pins

Return Value

-- none --

Comments

To use the SPI slave interface the user has to install an interrupt service routine for the SPI interrupt. An interrupt occurs when the SLVSEL pin transitions from active to inactive.

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.

On SC1x3/SC2x (RTOS version >=1.13, CLIB version >=2.10) there's also a version of this function which uses dynamic linking instead of a software interrupt, which reduces the function's overhead and thus speeds up your application. This function's name is spi_slave_init_dyn. You should however not use this function directly. Instead you should add the define SPI_DYN_LINK to your program before including the CLIB's header file(s):
#define SPI_DYN_LINK
#include <clib.h>

This will map the original function's name to the dynamic linking version. This way you can also easily switch existing programs to dynamic linking.

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3SC2x
    n/an/an/aV0.90V1.00

Supported by @CHIP-RTOS C Library since version

    CLIB
    V2.01

This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document