-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgpio.h
More file actions
55 lines (49 loc) · 1.66 KB
/
gpio.h
File metadata and controls
55 lines (49 loc) · 1.66 KB
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
/***********************************************
课程:暑期训练营
作者:lc
*********************************************/
#ifndef _GPIO_H_
#define _GPIO_H_
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include<sys/types.h>
#include<sys/stat.h>
#define ERROR (-1)
#define en1 38
#define en2 40
#define en3 13
#define en4 14
#define ECHO 11
#define TRIG 12
#define whole 20000000
#define low 3000000
#define mid 7000000
#define hig 15000000
using namespace std;
class motor
{
private:
int configureGPIO(int gpio,const char *in_out);//伽利略二代pwm端口和gpio的端口初始化时不一样的,具体看GPIO映像图;
int enablePWM(int pwm_io);
int setpwm_period(int period_val);//伽利略2代,所有PWM共享周期通道
int initPWM(int pwm_io);
public:
int setpwm_duty(int pwm_io,int duty_val);
int writeGPIO(int gpio,int value);
int pwm(int pwm_io,int duty);
void initgpio(void);
void line(void);
void back(void);
void right(void);
void left(void);
void stop(void);
int initGPIO_in(int IO,int dir);
int openGPIO(int gpio);
int closeGPIO(int fd);
int readGPIO(int gpio,int fd);
int initGPIO(int IO);
};
#endif