/* * EP9302 Digital library * Copyright (C) 2010 Andrea Milazzo aka Mancausoft * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #define DATA_PAGE 0x80840000 #define SYSCON_PAGE 0x80930000 #define SYSCON_UNLOCK 0x00C0 #define UNLOCK_VAL 0xAA #define DEVICECFG 0x80 //Registers #define PADR 0x0 #define PBDR 0x04 #define PCDR 0x08 #define PDDR 0x0C #define PADDR 0x10 #define PBDDR 0x14 #define PCDDR 0x18 #define PDDDR 0x1C #define PEDR 0x20 #define PEDDR 0x24 #define PFDR 0x30 #define PFDDR 0x34 #define PGDR 0x38 #define PGDDR 0x3C #define PHDR 0x40 #define PHDDR 0x44 #define MAX_PORT_USED 5 #define MAX_CONN 4 #define MAX_PIN 7 int init_ports(); void close_ports(int devmem); int set_port_bit (uint8_t nport, bool value, uint8_t pos); int get_port_bit (uint8_t nport, bool* value, uint8_t pos); int set_port_dir_bit (uint8_t nport, bool value, uint8_t pos); int get_port_dir_bit (uint8_t nport, bool* value, uint8_t pos); int set_port_dir(uint8_t nport, uint8_t value); int get_port_dir(uint8_t nport, uint8_t* value); int set_port (uint8_t nport, uint8_t value); int get_port (uint8_t nport, uint8_t* value); inline void set_bit(bool src, volatile uint8_t *dst, uint8_t bit); inline void get_bit(volatile uint8_t src, bool *dst, uint8_t bit);