-
Notifications
You must be signed in to change notification settings - Fork 0
/
hcl_gpio_rpi.c
79 lines (71 loc) · 3.33 KB
/
hcl_gpio_rpi.c
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//==============================================================================
//
// hcl_gpio_rpi.c - Seiko Epson Hardware Control Library
//
// This layer of indirection is added to allow the sample code to call
// generic functions to work on multiple hardware platforms. This is the
// Raspberry Pi specific implementation for GPIO
//
//
// THE SOFTWARE IS RELEASED INTO THE PUBLIC DOMAIN.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// NONINFRINGEMENT, SECURITY, SATISFACTORY QUALITY, AND FITNESS FOR A
// PARTICULAR PURPOSE. IN NO EVENT SHALL EPSON BE LIABLE FOR ANY LOSS, DAMAGE
// OR CLAIM, ARISING FROM OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF THE
// SOFTWARE.
//
//==============================================================================
#include <stdint.h>
#include <wiringPi.h>
#include "hcl.h"
#include "hcl_gpio.h"
/*****************************************************************************
** Function name: gpioInit
** Description: Initialize the RPI GPIO Interface.
** Delay for RESET incase it was asserted
** Parameters: None
** Return value: OK or NG
** Note: This function assumes seInit() has been called first to
** initialise the wiringPI Library
*****************************************************************************/
int gpioInit(void) {
pinMode(EPSON_RESET, OUTPUT);
pinMode(EPSON_CS, OUTPUT);
pinMode(EPSON_DRDY, INPUT);
pullUpDnControl(EPSON_DRDY, PUD_DOWN);
// Force outputs to inactive state
gpioSet(EPSON_RESET); // RESET pin HIGH
gpioSet(EPSON_CS); // CS pin HIGH
printf("...delay for GPIO pins...");
seDelayMS(3000); // incase of RESET
return OK;
}
/*****************************************************************************
** Function name: gpioRelease
** Description: Release the RPI GPIO Interface.
** Parameters: None
** Return value: OK
*****************************************************************************/
int gpioRelease(void) { return OK; }
/*****************************************************************************
** Function name: gpioSet
** Description: Set the RPI GPIO pin level HIGH.
** Parameters: uint8_t pin
** Return value: None
*****************************************************************************/
void gpioSet(uint8_t pin) { digitalWrite(pin, HIGH); }
/*****************************************************************************
** Function name: gpioClr
** Description: Set the RPI GPIO pin level LOW.
** Parameters: uint8_t pin
** Return value: None
*****************************************************************************/
void gpioClr(uint8_t pin) { digitalWrite(pin, LOW); }
/*****************************************************************************
** Function name: gpioGetPinLevel
** Description: Get the RPI GPIO pin level.
** Parameters: uint8_t pin
** Return value: uint8_t level (1 or 0)
*****************************************************************************/
uint8_t gpioGetPinLevel(uint8_t pin) { return (digitalRead(pin)); }