-
Notifications
You must be signed in to change notification settings - Fork 0
/
SPI_BitBang.h
52 lines (43 loc) · 883 Bytes
/
SPI_BitBang.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
Author: Vincent Gijsen
*/
#ifndef SPI_BITBANG_H
#define SPI_BITBANG_H
/*
#define MODE0 0
#define MODE1 1
#define MODE2 2
#define MODE3 3
#define SLOW 0
#define FAST 1
*/
class SPI_BitBang{
public:
enum DataRate{
SLOW,
FAST
};
enum DataMode{
MODE0,
MODE1,
};
void begin(void);
SPI_BitBang(GPIO_TypeDef * pClk, GPIO_TypeDef * pMosi, GPIO_TypeDef * pMiso, const uint8_t clk, const uint8_t mosi, const uint8_t miso);
//uint8_t transfer(unsigned char data);
void setDataMode(DataMode mode);
void setDataRate(DataRate rate);
uint8_t read(uint8_t data);
void write(uint8_t data);
uint8_t transfer(uint8_t data);
private:
GPIO_TypeDef *_pClk;
GPIO_TypeDef *_pMiso;
GPIO_TypeDef *_pMosi;
uint8_t _clk;
uint8_t _mosi ;
uint8_t _miso ;
uint8_t _delay ;
DataRate _rate;
DataMode _mode;
};
#endif /* SPI_BITBANG_H*/