-
Notifications
You must be signed in to change notification settings - Fork 2
/
gpio-fpga.h
62 lines (52 loc) · 1.94 KB
/
gpio-fpga.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
59
60
61
62
/************************************************************************
* This is the header file for a GPIO driver which is
* implemented in an FPGA.
*
* The GPIO hardware is the IP given by XILINX (AXI GPIO)
* The hardware is controlled by a collection of registers
* implemented in the FPGA.
*
* To use the GPIO hardware, writes and reads to these registers must
* take place at the correct times
*
* The locations of these registers in memory are offsets of the GPIO base
* address.
*
************************************************************************/
/************************************************************************
* Author: Mitchell Orsucci
*
* This software is offered freely by Digilent Inc.
*
* Creation Date: July 24, 2017
*
*
************************************************************************/
#ifndef GPIO_FPGA_H
#define GPIO_FPGA_H
#include <stdint.h>
typedef uint8_t byte;
typedef void * GPIO;
/**********************HARDWARE REGISTER OFFSETS************************/
#define CHANNEL_1_DATA 0x00
#define CHANNEL_1_DIRECTION 0x04
#define CHANNEL_2_DATA 0x08
#define CHANNEL_2_DIRECTION 0x0C
/************************OPERATIONAL MASKS****************************/
#define INPUT 1
#define OUTPUT 0
#define HIGH 1
#define LOW 0
#define CHANNEL_MAX_SIZE 32
#define CHANNEL_MIN_SIZE 1
/**************************HELPFUL MACROS****************************/
/**************************FUNC DEFITIONS****************************/
GPIO GPIO_init(uint8_t uioNum, uint8_t mapNum);
int8_t setPinMode(GPIO vm, uint8_t channel, int8_t pinNum, int8_t direction);
int8_t digitalWrite(GPIO vm, uint8_t channel, int8_t pinNum, int8_t value);
int8_t digitalRead(GPIO vm, uint8_t channel, int8_t pinNum);
int8_t setChannelValue(GPIO vm, uint32_t valMask, int8_t channel);
uint32_t readChannelValue(GPIO vm, int8_t channel);
int8_t setChannelDirection(GPIO vm, uint32_t dirMask, int8_t channel);
uint8_t GPIO_Close(GPIO vm);
#endif