source: EP9302-digital/digital.h

Last change on this file was 1, checked in by mancausoft, 13 years ago

Added Library to read and write digital for arm9 EP9302

File size: 1.9 KB
Line 
1/*
2 *  EP9302 Digital library
3 *  Copyright (C) 2010  Andrea Milazzo aka Mancausoft
4 *
5 *  This program is free software: you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation, either version 3 of the License, or
8 *  (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#define DATA_PAGE               0x80840000
20#define SYSCON_PAGE     0x80930000
21
22#define SYSCON_UNLOCK     0x00C0
23#define UNLOCK_VAL        0xAA
24#define DEVICECFG         0x80
25
26//Registers
27#define PADR  0x0
28#define PBDR  0x04
29#define PCDR  0x08
30#define PDDR  0x0C
31#define PADDR 0x10
32#define PBDDR 0x14
33#define PCDDR 0x18
34#define PDDDR 0x1C
35#define PEDR  0x20
36#define PEDDR 0x24
37#define PFDR  0x30
38#define PFDDR 0x34
39#define PGDR  0x38
40#define PGDDR 0x3C
41#define PHDR  0x40
42#define PHDDR 0x44
43
44
45#define MAX_PORT_USED 5
46#define MAX_CONN 4
47#define MAX_PIN 7
48
49int init_ports();
50void close_ports(int devmem);
51
52int set_port_bit (uint8_t nport, bool value, uint8_t pos);
53int get_port_bit (uint8_t nport, bool* value, uint8_t pos);
54int set_port_dir_bit (uint8_t nport, bool value, uint8_t pos);
55int get_port_dir_bit (uint8_t nport, bool* value, uint8_t pos);
56int set_port_dir(uint8_t nport, uint8_t value);
57int get_port_dir(uint8_t nport, uint8_t* value);
58int set_port (uint8_t nport, uint8_t value);
59int get_port (uint8_t nport, uint8_t* value);
60
61inline void set_bit(bool src, volatile uint8_t *dst, uint8_t bit);
62inline void get_bit(volatile uint8_t src, bool *dst, uint8_t bit);
63
64
Note: See TracBrowser for help on using the repository browser.