-
Notifications
You must be signed in to change notification settings - Fork 0
/
grovepi.h
39 lines (35 loc) · 834 Bytes
/
grovepi.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
#ifndef GROVEPI_H
#define GROVEPI_H
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
extern int fd;
extern char *fileName;
extern int address;
extern unsigned char w_buf[5],r_buf[32];
extern unsigned long reg_addr;
#define dRead_cmd 1
#define dWrite_cmd 2
#define aRead_cmd 3
#define aWrite_cmd 4
#define pMode_cmd 5
//Initialize
int init(void);
//Write a register
int write_block(char cmd,char v1,char v2,char v3);
//Read 1 byte of data
char read_byte(void);
char read_block(void);
void pi_sleep(int);
int analogRead(int pin);
int digitalWrite(int pin,int value);
int pinMode(int pin,int mode);
int digitalRead(int pin);
int analogWrite(int pin,int value);
#endif /*GROVEPI_H */