Spim#

group bsp_spim

Control the SPIM peripheral.

Author

Alexandre Abadie alexandre.abadie@inria.fr

Copyright

Inria, 2024-present

Defines

DB_SPIM_FREQ_125K#

SPIM frequency register values (must be left shifted by 6)

125 kHz

DB_SPIM_FREQ_250K#

250 kHz

DB_SPIM_FREQ_500K#

500 kHz

DB_SPIM_FREQ_1M#

1 MHz

DB_SPIM_FREQ_2M#

2 MHz

DB_SPIM_FREQ_4M#

4 MHz

DB_SPIM_FREQ_8M#

8 MHz

DB_SPIM_FREQ_16M#

16 MHz

DB_SPIM_FREQ_32M#

32 MHz

Typedefs

typedef uint8_t spim_t#

SPIM peripheral index.

Enums

enum db_spim_mode_t#

SPIM mode.

Values:

enumerator DB_SPIM_MODE_0#

CPOL = 0 (Active High), CPHA = 0 (Leading)

enumerator DB_SPIM_MODE_1#

CPOL = 0 (Active High), CPHA = 1 (Trailing)

enumerator DB_SPIM_MODE_2#

CPOL = 1 (Active Low), CPHA = 0 (Leading)

enumerator DB_SPIM_MODE_3#

CPOL = 1 (Active Low), CPHA = 1 (Trailing)

Functions

void db_spim_init(spim_t spim, const db_spim_conf_t *conf)#

Initialize the SPIM peripheral.

Parameters:
  • spim[in] SPIM reference used

  • conf[in] Pointer to configuration struct

void db_spim_begin(spim_t spim, const gpio_t *cs, db_spim_mode_t mode, uint32_t freq)#

Begin transmission on SPIM.

Parameters:
  • spim[in] SPIM reference used

  • cs[in] Pointer to the chip select pin

  • mode[in] SPI mode

  • freq[in] SPI clock frequency

void db_spim_end(spim_t spim, const gpio_t *cs)#

End transmission on SPIM.

Parameters:
  • spim[in] SPIM reference used

  • cs[in] Pointer to the chip select pin

void db_spim_send(spim_t spim, const void *bytes, size_t len)#

Send bytes over SPI.

Parameters:
  • spim[in] SPIM reference used

  • bytes[in] Pointer to the input bytes

  • len[in] Length of the bytes to send

void db_spim_receive(spim_t spim, const void *bytes, size_t len)#

Receive bytes over SPI.

Parameters:
  • spim[in] SPIM reference used

  • bytes[in] Pointer to the output bytes

  • len[in] Length of the bytes to receive

struct db_spim_conf_t#

SPIM pin configuration.

Public Members

const gpio_t *mosi#

Master Out Slave In.

const gpio_t *miso#

Master In Slave Out.

const gpio_t *sck#

Clock.