-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspi.h
51 lines (40 loc) · 1.3 KB
/
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
#ifndef _SPI_H_
#define _SPI_H_
/**
@breif SPI control
@author Stephan Ruloff
@date 13.03.2014
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; in version 2 only
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdint.h>
#include <unistd.h>
#define MAXPATHNAME 16
//#define TRANSFER_LEN 3
#define TRANSFER_DELAY 5
#define TRANSFER_SPEED 1000000
#define TRANSFER_BPW 8
#define SPI_WRITE_CMD 0x40
#define SPI_READ_CMD 0x41
typedef struct {
int mFd;
int mMode;
int mBitsPerWord;
int mMaxSpeed; // max speed [Hz]
int mDevice; // Device ID (Chip-Select)
} Spi;
Spi* SpiCreate(int device);
uint8_t SpiTransfer(Spi* s, uint8_t* txBuffer, uint8_t* rxBuffer, size_t lenBuffer);
void SpiDestroy(Spi* s);
#endif