firmware/io_cfg.h
author cpresser@slime-ws
Sat, 26 Jul 2008 14:22:38 +0200
changeset 25 96f051df5d60
parent 23 dc247e80ef26
permissions -rw-r--r--
added eeprom code
     1 /*
     2  * Project Frontplatte
     3  *
     4  * io_cfg.h  -  Pinmappings and naming
     5  *
     6  * This file is released under the GNU General Public License. Refer
     7  * to the COPYING file distributed with this package.
     8  *
     9  * (c) 2007 Carsten Presser cpresser AT fsing.uni-sb.de
    10  */
    11 
    12 #ifndef IO_CFG_H
    13 #define IO_CFG_H
    14 
    15 #define FW_VERSION					0x05
    16 
    17 /** U S B ***********************************************************/
    18 #define usb_bus_sense       	1
    19 #define self_power          	1
    20 
    21 
    22 /** P O R T A  P I N S *********************************************/
    23 // PortA is not used yet...
    24 
    25 
    26 /** P O R T B  P I N S *********************************************/
    27 //								RB0 & RB1 -> I2C (MSSP-Module)
    28 #define PIN_IR					PORTBbits.RB2
    29 #define PIN_POWER				LATBbits.LATB3
    30 #define PIN_I2C_INT				PORTBbits.RB4
    31 //								RB5 has no connection
    32 //								RB6 & RB7 -> ISCP
    33 
    34 #define DDR_I2C_SCL				DDRBbits.RB1
    35 #define DDR_I2C_SDA				DDRBbits.RB0
    36 #define DDR_IR					DDRBbits.RB2
    37 #define DDR_I2C_INT				DDRBbits.RB4
    38 
    39 #define	mInitPortB				TRISB = 0x00; LATB = 0xFF; 
    40 
    41 
    42 /** P O R T C  P I N S *********************************************/
    43 #define PIN_BOOT_SW				PORTCbits.RC0
    44 #define DDR_BOOT_SW				DDRCbits.RC0
    45 
    46 #define DDR_PWM1				DDRCbits.RC1
    47 #define DDR_PWM2				DDRCbits.RC2
    48 //								RC3 -> not implemented in hardware
    49 //								RC4 & RC5 -> USB
    50 //								RC6 has no connection
    51 //								RC7 has no connection
    52 
    53 
    54 /** P O R T D  &  P O R T E   P I N S  ( D I S P L A Y ) ************/
    55 // control pins.
    56 #define	D_WR			LATEbits.LATE0
    57 #define	D_RD			LATEbits.LATE1
    58 #define	D_CD			LATEbits.LATE2
    59 
    60 #define	mLcdInitCtrl()			D_WR = 1; D_RD = 1; D_CD = 0; TRISE = 0x00;
    61 
    62 #define mLcdDataDirIn()			TRISD=0xFF
    63 #define mLcdDataDirOut() 		TRISD=0x00
    64 #define mLcdWriteData(a)		PORTD=(a)		
    65 #define mLcdReadData()			PORTD		
    66 
    67 
    68 /** S O M E   F L A G S *********************************************/
    69 #define FLAG_I2C			0x20
    70 #define FLAG_COUNTER		0x10
    71 #define FLAG_POWER			0x08
    72 #define FLAG_ALARM			0x04
    73 #define FLAG_IR				0x02
    74 #define FLAG_KEY			0x01
    75 #define FLAG_CLEAR			0x00
    76 
    77 #define MODE_MANAGED		0x01
    78 #define MODE_UNMANAGED		0x00
    79 
    80 
    81 /** I 2 C - A D D R E S S *******************************************/
    82 #define	pcf8583				0xA0
    83 #define pcf8574A_1			0x40
    84 #define	pcf8574A_2			0x42
    85 
    86 /** P C F 8 5 8 3   R E G I S T E R *********************************/
    87 #define CLK_CTRL			0x00
    88 #define CLK_HUNDRSEC		0x01
    89 #define CLK_SEC				0x02
    90 #define CLK_MIN				0x03
    91 #define CLK_HOURS			0x04
    92 #define CLK_YEARDAY			0x05
    93 #define CLK_WEEKDMON		0x06
    94 #define CLK_TIMER			0x07
    95 #define CLK_ALARM_CTRL		0x08
    96 
    97 
    98 /** C O M M U N I C A T I O N ***************************************/
    99 // address
   100 #define CMD_HD_SYNC		0x00
   101 #define CMD_HD_COMMAND	0x01
   102 #define CMD_HD_LENGTH	0x02
   103 #define CMD_DATA_START	0x04
   104 
   105 // sync words
   106 #define CMD_SYNC_SEND	0xAA
   107 #define CMD_SYNC_RECV	0x55
   108 
   109 // commands
   110 #define CMD_SYS_SYNC	0x00
   111 #define CMD_SYS_ACK		0x01		
   112 #define CMD_SYS_NACK	0x02
   113 #define CMD_SYS_NIMP	0xFF
   114 #define CMD_SYS_IR		0x10
   115 
   116 #define CMD_GET_VERSION				0x01
   117 
   118 #define CMD_DISP_CLEAR_SCREEN		0x10
   119 #define CMD_DISP_SET_ROW_DATA   	0x14
   120 #define CMD_DISP_SET_ADDRESS		0x16
   121 
   122 #define CMD_WRITE_EEPROM			0x20
   123 #define CMD_READ_EEPROM				0x21
   124 
   125 #define CMD_READ_CLOCK				0x40
   126 #define CMD_WRITE_CLOCK				0x41
   127 #define CMD_SET_PWM1				0x45
   128 #define CMD_SET_PWM2				0x46
   129 
   130 #define CMD_SET_MODE_MANAGED		0x70
   131 #define CMD_SET_MODE_UNMANAGED		0x71
   132 
   133 #define CMD_BOOT					0x80
   134 
   135 // rc5 keymap
   136 #define RC5_KEY_UP					0x20
   137 #define RC5_KEY_DOWN				0x21
   138 #define RC5_KEY_LEFT				0x11
   139 #define RC5_KEY_RIGHT				0x10
   140 #define RC5_KEY_OK					0x0E
   141 #define RC5_KEY_MENU				0x12
   142 #define RC5_KEY_BACK				0x22
   143 #define RC5_KEY_RED					0x37
   144 #define RC5_KEY_GREEN				0x36
   145 #define RC5_KEY_YELLOW				0x32
   146 #define RC5_KEY_BLUE				0x34
   147 #define RC5_KEY_POWER				0x0C
   148 
   149 #define RC5_FRONT_ADDRESS			0x20
   150 
   151 
   152 /** E E P R O M   L O C A T I O N S *********************************/
   153 #define EE_ADDR_DISPLAY				0x00
   154 #define EE_ADDR_FEATURES			0x01
   155 
   156 #define EE_ADDR_RC5KEY00			0x10
   157 #define EE_ADDR_RC5KEY01			0x11
   158 #define EE_ADDR_RC5KEY02			0x12
   159 #define EE_ADDR_RC5KEY03			0x13
   160 #define EE_ADDR_RC5KEY04			0x14
   161 #define EE_ADDR_RC5KEY05			0x15
   162 #define EE_ADDR_RC5KEY06			0x16
   163 #define EE_ADDR_RC5KEY07			0x17
   164 #define EE_ADDR_RC5KEY08			0x18
   165 #define EE_ADDR_RC5KEY09 			0x19
   166 #define EE_ADDR_RC5KEY10			0x1a
   167 #define EE_ADDR_RC5KEY11			0x1b
   168 #define EE_ADDR_RC5KEY12			0x1c
   169 #define EE_ADDR_RC5KEY13			0x1d
   170 #define EE_ADDR_RC5KEY14			0x1e
   171 #define EE_ADDR_RC5KEY15			0x1f
   172 
   173 
   174 /** P R O G R A M   L O C A T I O N *********************************/
   175 #define BOOTLOAD_START		0x000686		// taken from bootload.asm
   176 
   177 #endif //IO_CFG_H