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 
54  TWR_SPI_MODE_3 = 3
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_speed_t
SPI communication speed.
Definition: twr_spi.h:13
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
twr_spi_speed_t twr_spi_get_speed(void)
Get SPI communication speed.
Definition: twr_spi.c:150
twr_spi_mode_t
SPI mode of operation.
Definition: twr_spi.h:43
void twr_spi_set_manual_cs_control(bool manual_cs_control)
Enable manual control of CS pin.
Definition: twr_spi.c:182
bool twr_spi_transfer(const void *source, void *destination, size_t length)
Execute SPI transfer.
Definition: twr_spi.c:192
void twr_spi_set_speed(twr_spi_speed_t speed)
Set SPI communication speed.
Definition: twr_spi.c:119
void twr_spi_set_mode(twr_spi_mode_t mode)
Set SPI mode of operation.
Definition: twr_spi.c:155
twr_spi_mode_t twr_spi_get_mode(void)
Get SPI mode of operation.
Definition: twr_spi.c:177
void twr_spi_init(twr_spi_speed_t speed, twr_spi_mode_t mode)
Initialize SPI channel.
Definition: twr_spi.c:64
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_event_t
SPI event.
Definition: twr_spi.h:61
@ TWR_SPI_SPEED_16_MHZ
SPI communication speed is 16 MHz.
Definition: twr_spi.h:36
@ TWR_SPI_SPEED_125_KHZ
SPI communication speed is 125 kHz.
Definition: twr_spi.h:15
@ TWR_SPI_SPEED_8_MHZ
SPI communication speed is 8 MHz.
Definition: twr_spi.h:33
@ TWR_SPI_SPEED_250_KHZ
SPI communication speed is 250 kHz.
Definition: twr_spi.h:18
@ TWR_SPI_SPEED_500_KHZ
SPI communication speed is 500 kHz.
Definition: twr_spi.h:21
@ TWR_SPI_SPEED_4_MHZ
SPI communication speed is 4 MHz.
Definition: twr_spi.h:30
@ TWR_SPI_SPEED_2_MHZ
SPI communication speed is 2 MHz.
Definition: twr_spi.h:27
@ TWR_SPI_SPEED_1_MHZ
SPI communication speed is 1 MHz.
Definition: twr_spi.h:24
@ TWR_SPI_MODE_2
SPI mode of operation is 2 (CPOL = 1, CPHA = 0)
Definition: twr_spi.h:51
@ TWR_SPI_MODE_1
SPI mode of operation is 1 (CPOL = 0, CPHA = 1)
Definition: twr_spi.h:48
@ TWR_SPI_MODE_0
SPI mode of operation is 0 (CPOL = 0, CPHA = 0)
Definition: twr_spi.h:45
@ TWR_SPI_MODE_3
SPI mode of operation is 3 (CPOL = 1, CPHA = 1)
Definition: twr_spi.h:54
@ TWR_SPI_EVENT_DONE
SPI event is completed.
Definition: twr_spi.h:63