picofuse

spi.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "deviceio.h"
23 #include "gpio.h"
24 #include <stdbool.h>
25 #include <stdint.h>
26 
28 // TYPES
29 
34 typedef enum {
36  0,
38  1,
40  2,
42  3,
44 
56 typedef struct {
59  uint8_t bits_per_word;
61 
63 // LIFECYCLE
64 
82 hw_deviceio_t *hw_spi_init_default(uint32_t baud_rate,
83  const hw_spi_config_t *config);
84 
100 hw_deviceio_t *hw_spi_init(uint8_t index, hw_gpio_t *sck_pin,
101  hw_gpio_t *tx_pin, hw_gpio_t *rx_pin,
102  hw_gpio_t *cs_pin, uint32_t baud_rate,
103  const hw_spi_config_t *config);
104 
119 hw_deviceio_t *hw_spi_init_device(const char *device, uint32_t baud_rate,
120  const hw_spi_config_t *config);
121 
124 // PROPERTIES
126 
139 uint8_t hw_spi_count(void);
140 
hw_deviceio_t * hw_spi_init_device(const char *device, uint32_t baud_rate, const hw_spi_config_t *config)
Initialize an SPI interface from a platform-specific device path.
bool cs_active_low
True when chip-select is active low.
Definition: spi.h:57
CPOL = 1, CPHA = 0 (clock idles high; sample on falling edge)
Definition: spi.h:39
struct hw_deviceio_t hw_deviceio_t
Opaque device I/O handle.
Definition: deviceio.h:48
uint8_t hw_spi_count(void)
Get the total number of available SPI adapters.
struct hw_gpio_t hw_gpio_t
GPIO logical pin structure.
Definition: gpio.h:50
GPIO (General Purpose Input/Output) interface.
CPOL = 0, CPHA = 0 (clock idles low; sample on rising edge)
Definition: spi.h:35
uint8_t bits_per_word
SPI frame size in bits.
Definition: spi.h:59
hw_deviceio_t * hw_spi_init_default(uint32_t baud_rate, const hw_spi_config_t *config)
Initialize an SPI interface using the platform default adapter and pins.
SPI initialization configuration.
Definition: spi.h:56
Abstract device I/O interface.
hw_spi_mode_t mode
SPI mode selection.
Definition: spi.h:58
CPOL = 0, CPHA = 1 (clock idles low; sample on falling edge)
Definition: spi.h:37
CPOL = 1, CPHA = 1 (clock idles high; sample on rising edge)
Definition: spi.h:41
hw_spi_mode_t
SPI mode selection.
Definition: spi.h:34
hw_deviceio_t * hw_spi_init(uint8_t index, hw_gpio_t *sck_pin, hw_gpio_t *tx_pin, hw_gpio_t *rx_pin, hw_gpio_t *cs_pin, uint32_t baud_rate, const hw_spi_config_t *config)
Initialize an SPI interface with a specific adapter and pins.