-
Notifications
You must be signed in to change notification settings - Fork 0
/
SPI.h
58 lines (43 loc) · 864 Bytes
/
SPI.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
53
54
55
56
57
58
/*
* Author: Klusjesman
*/
#ifndef __SPI_H__
#define __SPI_H__
#include <stdio.h>
#include "DigitalPin.h"
/* SPI ports and pins configuration */
#define SPI_PORT_MOSI PORTB //PB3 = MOSI
#define SPI_PIN_MOSI 3
#define SPI_DDR_MOSI DDRB
#define SPI_PORT_MISO PORTB //PB4 = MISO
#define SPI_PIN_MISO 4
#define SPI_DDR_MISO DDRB
#define SPI_PORT_SCK PORTB //PB5 = SCK
#define SPI_PIN_SCK 5
#define SPI_DDR_SCK DDRB
class SPI
{
//variables
public:
protected:
private:
DigitalPin *ssPin;
//functions
public:
SPI(DigitalPin *ssPin);
~SPI();
void init();
void waitMiso();
void select();
void deselect();
uint8_t write(uint8_t value);
uint8_t read();
void attachInterrupt();
void detachInterrupt();
protected:
private:
SPI();
SPI( const SPI &c );
SPI& operator=( const SPI &c );
}; //SPI
#endif //__SPI_H__