rcc 1.0
RCC - RGB LED Color Cube Documentation
Loading...
Searching...
No Matches
spi.h
Go to the documentation of this file.
1
19
20#ifndef SPI_H_
21#define SPI_H_
22
23 #ifndef SPI2X_ENABLE
33 //#define SPI2X_ENABLE
34
35 #ifdef _DOXYGEN_ // Used for documentation, can be ignored
36 #define SPI2X_ENABLE
37 #endif
38 #endif
39
40 #ifndef SPI_CLOCK
61 #define SPI_CLOCK SPI_PRESC_DIV4_gc
62 #endif
63
64 #ifndef SPI_PORTMUX
86 #define SPI_PORTMUX PORTMUX_SPI0_DEFAULT_gc
87
88 #ifdef _DOXYGEN_ // Used for documentation, can be ignored
89 #define SPI_PORTMUX PORTMUX_SPI0_DEFAULT_gc
90 #endif
91 #endif
92
93 #ifndef SPI_PORT
107 #define SPI_PORT PORTA
108 #endif
109
110 #ifndef SPI_MOSI
120 #define SPI_MOSI PIN1_bm
121 #endif
122
123 #ifndef SPI_MISO
133 #define SPI_MISO SET_PIN(2, _bm)
134
135 #ifndef SPI_MISO_PINCTRL
145 #define SPI_MISO_PINCTRL SET_PIN(2, CTRL)
146 #endif
147 #endif
148
149 #ifndef SPI_SCK
159 #define SPI_SCK PIN3_bm
160 #endif
161
162 #ifndef SPI_SS
163 #define SPI_SS SET_PIN(4, _bm)
164
165 #ifndef SPI_ENABLE_MASTER_ABORT
178 #define SPI_ENABLE_MASTER_ABORT
179
180 #ifndef SPI_SS_PINCTRL
190 #define SPI_SS_PINCTRL SET_PIN(4, CTRL)
191 #endif
192 #endif
193 #endif
194
195 #ifndef SPI_SPIE
205 // #define SPI_SPIE
206 #endif
207
208 #include <avr/io.h>
211
212 SPI_Status spi_init(SPI_Direction direction, SPI_Polarity setup, SPI_Phase sample);
213 void spi_disable(void);
214 void spi_select(SPI_Select mode);
215
216 #ifndef SPI_SPIE
217 unsigned char spi_transfer(unsigned char data);
218 #endif
219
220#endif /* SPI_H_ */
Macro definitions for port operations.
Enumerations for SPI interface configurations and status.
enum SPI_Status_t SPI_Status
Alias for enum SPI_Status_t representing SPI communication status codes.
Definition SPI_enums.h:110
enum SPI_Direction_t SPI_Direction
Alias for enum SPI_Direction_t representing SPI bit order options.
Definition SPI_enums.h:41
enum SPI_Select_t SPI_Select
Alias for enum SPI_Select_t representing SPI enable states.
Definition SPI_enums.h:86
enum SPI_Edge_t SPI_Phase
Alias for enum SPI_Edge_t representing the clock phase edge.
Definition SPI_enums.h:67
enum SPI_Edge_t SPI_Polarity
Alias for enum SPI_Edge_t representing the clock polarity edge.
Definition SPI_enums.h:62
unsigned char spi_transfer(unsigned char data)
Transfer a single byte of data over the SPI bus.
Definition spi.c:157
void spi_disable(void)
Disable the SPI hardware interface and reset related pins.
Definition spi.c:106
SPI_Status spi_init(SPI_Direction direction, SPI_Polarity setup, SPI_Phase sample)
Initialize the SPI hardware interface in master mode with specified configuration.
Definition spi.c:48
void spi_select(SPI_Select mode)
Control the SPI Slave Select (SS) pin to enable or disable the SPI slave device.
Definition spi.c:136