Firmware SDK
twr_spi.h
1 #ifndef _TWR_SPI_H
2 #define _TWR_SPI_H
3 
4 #include <twr_common.h>
5 
9 
11 
12 typedef enum
13 {
16 
19 
22 
25 
28 
31 
34 
37 
39 
41 
42 typedef enum
43 {
46 
49 
52 
55 
57 
59 
60 typedef enum
61 {
64 
66 
70 
72 
75 
77 
82 
83 void twr_spi_set_timing(uint16_t cs_delay, uint16_t delay, uint16_t cs_quit);
84 
87 
89 
92 
94 
97 
98 void twr_spi_set_manual_cs_control(bool manual_cs_control);
99 
102 
104 
108 
109 bool twr_spi_is_ready(void);
110 
115 
116 bool twr_spi_transfer(const void *source, void *destination, size_t length);
117 
124 
125 bool twr_spi_async_transfer(const void *source, void *destination, size_t length, void (*event_handler)(twr_spi_event_t event, void *event_param), void (*event_param));
126 
128 
129 #endif // _TWR_SPI_H
twr_spi_event_t
SPI event.
Definition: twr_spi.h:60
SPI communication speed is 500 kHz.
Definition: twr_spi.h:21
SPI event is completed.
Definition: twr_spi.h:63
SPI mode of operation is 2 (CPOL = 1, CPHA = 0)
Definition: twr_spi.h:51
void twr_spi_init(twr_spi_speed_t speed, twr_spi_mode_t mode)
Initialize SPI channel.
Definition: twr_spi.c:64
SPI communication speed is 8 MHz.
Definition: twr_spi.h:33
twr_spi_mode_t
SPI mode of operation.
Definition: twr_spi.h:42
SPI communication speed is 16 MHz.
Definition: twr_spi.h:36
bool twr_spi_transfer(const void *source, void *destination, size_t length)
Execute SPI transfer.
Definition: twr_spi.c:192
twr_spi_speed_t
SPI communication speed.
Definition: twr_spi.h:12
SPI communication speed is 1 MHz.
Definition: twr_spi.h:24
SPI communication speed is 4 MHz.
Definition: twr_spi.h:30
SPI communication speed is 2 MHz.
Definition: twr_spi.h:27
SPI mode of operation is 3 (CPOL = 1, CPHA = 1)
Definition: twr_spi.h:54
SPI communication speed is 125 kHz.
Definition: twr_spi.h:15
SPI mode of operation is 0 (CPOL = 0, CPHA = 0)
Definition: twr_spi.h:45
SPI mode of operation is 1 (CPOL = 0, CPHA = 1)
Definition: twr_spi.h:48
void twr_spi_set_mode(twr_spi_mode_t mode)
Set SPI mode of operation.
Definition: twr_spi.c:155
void twr_spi_set_manual_cs_control(bool manual_cs_control)
Enable manual control of CS pin.
Definition: twr_spi.c:182
SPI communication speed is 250 kHz.
Definition: twr_spi.h:18
bool twr_spi_is_ready(void)
Check if is ready for transfer.
Definition: twr_spi.c:187
bool twr_spi_async_transfer(const void *source, void *destination, size_t length, void(*event_handler)(twr_spi_event_t event, void *event_param), void(*event_param))
Execute async SPI transfer.
Definition: twr_spi.c:267
void twr_spi_set_timing(uint16_t cs_delay, uint16_t delay, uint16_t cs_quit)
Set SPI timing.
Definition: twr_spi.c:141
twr_spi_mode_t twr_spi_get_mode(void)
Get SPI mode of operation.
Definition: twr_spi.c:177
void twr_spi_set_speed(twr_spi_speed_t speed)
Set SPI communication speed.
Definition: twr_spi.c:119
twr_spi_speed_t twr_spi_get_speed(void)
Get SPI communication speed.
Definition: twr_spi.c:150