OpenCores
URL https://opencores.org/ocsvn/minsoc/minsoc/trunk

Subversion Repositories minsoc

[/] [minsoc/] [branches/] [verilator/] [utils/] [contributions/] [gpio/] [sw/] [gpio.h] - Blame information for rev 139

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 40 rfajardo
#ifndef __GPIO_H__
2
 
3
#define __GPIO_H__
4
 
5
#define MIN_GPIO_BIT            0
6
#define MAX_GPIO_BIT            31
7
 
8
#define TOTAL_GPIO_BITS         ((MAX_GPIO_BIT-MIN_GPIO_BIT+1))
9
 
10
 
11
#define IN_REG_OFFSET           0x00
12
#define OUT_REG_OFFSET          0x04
13
#define OE_REG_OFFSET           0x08
14
#define INTE_REG_OFFSET         0x0C
15
#define PTRIG_REG_OFFSET        0x10
16
#define AUX_REG_OFFSET          0x14
17
#define CTRL_REG_OFFSET         0x18
18
#define INTS_REG_OFFSET         0x1C
19
#define ECLK_REG_OFFSET         0x20
20
#define NEC_REG_OFFSET          0x24
21
 
22
 
23
typedef struct vector_t_
24
{
25
        void (*vec)();
26
} vector_t;
27
 
28
typedef struct gpio_t_
29
{
30
        volatile unsigned char *base_addr;
31
        unsigned int instance_num;
32
        unsigned int io_config;
33
        vector_t vectors[TOTAL_GPIO_BITS];
34
} gpio_t;
35
 
36
typedef enum iotype_t_
37
{
38
        IO_OUTPUT = 0,
39
        IO_INPUT = 1
40
} iotype_t;
41
 
42
typedef enum edge_t_
43
{
44
        NEG_EDGE = 0,
45
        POS_EDGE = 1
46
} edge_t;
47
 
48
 
49
#define LED_0                   0x00
50
#define LED_1                   0x01
51
#define LED_2                   0x02
52
#define LED_3                   0x03
53
#define LED_4                   0x04
54
#define LED_5                   0x05
55
#define LED_6                   0x06
56
#define LED_7                   0x07
57
 
58
#define DIP_0                   0x08
59
#define DIP_1                   0x09
60
#define DIP_2                   0x0A
61
#define DIP_3                   0x0B
62
 
63
#define PUSH_EAST               0x0C
64
#define PUSH_WEST               0x0D
65
#define PUSH_NORTH              0x0E
66
#define PUSH_SOUTH              0x0F
67
 
68
 
69
void gpio_init(gpio_t *, long, unsigned long);
70
void gpio_config_bit(gpio_t *, unsigned long, iotype_t);
71
void gpio_set_bit(gpio_t *, unsigned long, unsigned long);
72
void gpio_get_bit(gpio_t *, unsigned long, unsigned long *);
73
void gpio_add_interrupt(gpio_t *, unsigned int, edge_t,void (*func)() );
74
void gpio_interrupt(gpio_t *gpio);
75
 
76
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.