spi
1.0
AVR mega series spi library
Toggle main menu visibility
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 0x00
62
#endif
63
64
#ifndef SPI_DDR
76
#define SPI_DDR DDRB
77
#endif
78
79
#ifndef SPI_PORT
91
#define SPI_PORT PORTB
92
#endif
93
94
#ifndef SPI_MOSI
104
#define SPI_MOSI PINB5
105
#endif
106
107
#ifndef SPI_MISO
117
#define SPI_MISO PINB6
118
#endif
119
120
#ifndef SPI_SCK
130
#define SPI_SCK PINB7
131
#endif
132
133
#ifndef SPI_MULTISLAVE
143
// #define SPI_MULTISLAVE
144
#endif
145
146
#ifndef SPI_MULTISLAVE
147
#ifndef SPI_SS
148
158
#define SPI_SS PINB4
159
160
#ifndef SPI_ENABLE_MASTER_ABORT
172
#define SPI_ENABLE_MASTER_ABORT
173
#endif
174
#endif
175
#endif
176
177
#ifndef SPI_SPIE
187
// #define SPI_SPIE
188
#endif
189
190
#include <avr/io.h>
191
#include "
../../common/enums/SPI_enums.h
"
192
193
SPI_Status
spi_init
(
SPI_Direction
direction,
SPI_Polarity
setup,
SPI_Phase
sample);
194
void
spi_disable
(
void
);
195
196
#ifndef SPI_MULTISLAVE
197
void
spi_select
(
SPI_Select
mode);
198
#else
199
void
spi_select
(
unsigned
char
node,
SPI_Select
mode);
200
#endif
201
202
#ifndef SPI_SPIE
203
unsigned
char
spi_transfer
(
unsigned
char
data);
204
#endif
205
206
#endif
/* SPI_H_ */
SPI_enums.h
Enumerations for SPI interface configurations and status.
SPI_Status
enum SPI_Status_t SPI_Status
Alias for enum SPI_Status_t representing SPI communication status codes.
Definition
SPI_enums.h:110
SPI_Direction
enum SPI_Direction_t SPI_Direction
Alias for enum SPI_Direction_t representing SPI bit order options.
Definition
SPI_enums.h:41
SPI_Select
enum SPI_Select_t SPI_Select
Alias for enum SPI_Select_t representing SPI enable states.
Definition
SPI_enums.h:86
SPI_Phase
enum SPI_Edge_t SPI_Phase
Alias for enum SPI_Edge_t representing the clock phase edge.
Definition
SPI_enums.h:67
SPI_Polarity
enum SPI_Edge_t SPI_Polarity
Alias for enum SPI_Edge_t representing the clock polarity edge.
Definition
SPI_enums.h:62
spi_transfer
unsigned char spi_transfer(unsigned char data)
Transfer a single byte of data over the SPI bus.
Definition
spi.c:160
spi_disable
void spi_disable(void)
Disable the SPI hardware interface and reset related pins.
Definition
spi.c:113
spi_init
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
spi_select
void spi_select(SPI_Select mode)
Control the SPI Slave Select (SS) pin to enable or disable the SPI slave device.
Definition
spi.c:138
avr
spi
spi.h
Generated by
1.17.0