firmware/io_cfg.h
changeset 2 2f55e5dd591d
child 11 4c5712778d27
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/firmware/io_cfg.h	Tue Jan 29 22:31:52 2008 +0100
     1.3 @@ -0,0 +1,153 @@
     1.4 +/*
     1.5 + * Project Frontplatte
     1.6 + *
     1.7 + * io_cfg.h  -  Pinmappings and naming
     1.8 + *
     1.9 + * This file is released under the GNU General Public License. Refer
    1.10 + * to the COPYING file distributed with this package.
    1.11 + *
    1.12 + * (c) 2007 Carsten Presser cpresser AT fsing.uni-sb.de
    1.13 + */
    1.14 +
    1.15 +#ifndef IO_CFG_H
    1.16 +#define IO_CFG_H
    1.17 +
    1.18 +#define FW_VERSION					0x04
    1.19 +
    1.20 +/** U S B ***********************************************************/
    1.21 +#define usb_bus_sense       	1
    1.22 +#define self_power          	1
    1.23 +
    1.24 +
    1.25 +/** P O R T A  P I N S *********************************************/
    1.26 +// PortA is not used yet...
    1.27 +
    1.28 +
    1.29 +/** P O R T B  P I N S *********************************************/
    1.30 +//								RB0 & RB1 -> I2C (MSSP-Module)
    1.31 +#define PIN_IR					PORTBbits.RB2
    1.32 +#define PIN_POWER				LATBbits.LATB3
    1.33 +#define PIN_I2C_INT				PORTBbits.RB4
    1.34 +//								RB5 has no connection
    1.35 +//								RB6 & RB7 -> ISCP
    1.36 +
    1.37 +#define DDR_I2C_SCL				DDRBbits.RB1
    1.38 +#define DDR_I2C_SDA				DDRBbits.RB0
    1.39 +#define DDR_IR					DDRBbits.RB2
    1.40 +#define DDR_I2C_INT				DDRBbits.RB4
    1.41 +
    1.42 +#define	mInitPortB				TRISB = 0x00; LATB = 0xFF; 
    1.43 +
    1.44 +
    1.45 +/** P O R T C  P I N S *********************************************/
    1.46 +#define PIN_BOOT_SW				PORTCbits.RC0
    1.47 +#define DDR_BOOT_SW				DDRCbits.RC0
    1.48 +
    1.49 +#define DDR_PWM1				DDRCbits.RC1
    1.50 +#define DDR_PWM2				DDRCbits.RC2
    1.51 +//								RC3 -> not implemented in hardware
    1.52 +//								RC4 & RC5 -> USB
    1.53 +//								RC6 has no connection
    1.54 +//								RC7 has no connection
    1.55 +
    1.56 +
    1.57 +/** P O R T D  &  P O R T E   P I N S  ( D I S P L A Y ) ************/
    1.58 +// control pins.
    1.59 +#define	D_WR			LATEbits.LATE0
    1.60 +#define	D_RD			LATEbits.LATE1
    1.61 +#define	D_CD			LATEbits.LATE2
    1.62 +
    1.63 +#define	mLcdInitCtrl()			D_WR = 1; D_RD = 1; D_CD = 0; TRISE = 0x00;
    1.64 +
    1.65 +#define mLcdDataDirIn()			TRISD=0xFF
    1.66 +#define mLcdDataDirOut() 		TRISD=0x00
    1.67 +#define mLcdWriteData(a)		PORTD=(a)		
    1.68 +#define mLcdReadData()			PORTD		
    1.69 +
    1.70 +
    1.71 +/** S O M E   F L A G S *********************************************/
    1.72 +#define FLAG_I2C			0x20
    1.73 +#define FLAG_COUNTER		0x10
    1.74 +#define FLAG_POWER			0x08
    1.75 +#define FLAG_ALARM			0x04
    1.76 +#define FLAG_IR				0x02
    1.77 +#define FLAG_KEY			0x01
    1.78 +#define FLAG_CLEAR			0x00
    1.79 +
    1.80 +#define MODE_MANAGED		0x01
    1.81 +#define MODE_UNMANAGED		0x00
    1.82 +
    1.83 +
    1.84 +/** I 2 C - A D D R E S S *******************************************/
    1.85 +#define	pcf8583				0xA0
    1.86 +#define pcf8574A_1			0x40
    1.87 +#define	pcf8574A_2			0x42
    1.88 +
    1.89 +/** P C F 8 5 8 3   R E G I S T E R *********************************/
    1.90 +#define CLK_CTRL			0x00
    1.91 +#define CLK_HUNDRSEC		0x01
    1.92 +#define CLK_SEC				0x02
    1.93 +#define CLK_MIN				0x03
    1.94 +#define CLK_HOURS			0x04
    1.95 +#define CLK_YEARDAY			0x05
    1.96 +#define CLK_WEEKDMON		0x06
    1.97 +#define CLK_TIMER			0x07
    1.98 +#define CLK_ALARM_CTRL		0x08
    1.99 +
   1.100 +
   1.101 +/** C O M M U N I C A T I O N ***************************************/
   1.102 +// address
   1.103 +#define CMD_HD_SYNC		0x00
   1.104 +#define CMD_HD_COMMAND	0x01
   1.105 +#define CMD_HD_LENGTH	0x02
   1.106 +#define CMD_DATA_START	0x04
   1.107 +
   1.108 +// sync words
   1.109 +#define CMD_SYNC_SEND	0xAA
   1.110 +#define CMD_SYNC_RECV	0x55
   1.111 +
   1.112 +// commands
   1.113 +#define CMD_SYS_SYNC	0x00
   1.114 +#define CMD_SYS_ACK		0x01
   1.115 +#define CMD_SYS_NACK	0x02
   1.116 +#define CMD_SYS_NIMP	0xFF
   1.117 +#define CMD_SYS_IR		0x10
   1.118 +
   1.119 +#define CMD_GET_VERSION				0x01
   1.120 +
   1.121 +#define CMD_DISP_CLEAR_SCREEN		0x10
   1.122 +#define CMD_DISP_SET_ROW_DATA   	0x14
   1.123 +#define CMD_DISP_SET_ADDRESS		0x16
   1.124 +
   1.125 +#define CMD_READ_CLOCK				0x40
   1.126 +#define CMD_WRITE_CLOCK				0x41
   1.127 +#define CMD_SET_PWM1				0x45
   1.128 +#define CMD_SET_PWM2				0x46
   1.129 +
   1.130 +#define CMD_SET_MODE_MANAGED		0x70
   1.131 +#define CMD_SET_MODE_UNMANAGED		0x71
   1.132 +
   1.133 +#define CMD_BOOT					0x80
   1.134 +
   1.135 +// rc5 keymap
   1.136 +#define RC5_KEY_UP					0x20
   1.137 +#define RC5_KEY_DOWN				0x21
   1.138 +#define RC5_KEY_LEFT				0x11
   1.139 +#define RC5_KEY_RIGHT				0x10
   1.140 +#define RC5_KEY_OK					0x0E
   1.141 +#define RC5_KEY_MENU				0x12
   1.142 +#define RC5_KEY_BACK				0x22
   1.143 +#define RC5_KEY_RED					0x37
   1.144 +#define RC5_KEY_GREEN				0x36
   1.145 +#define RC5_KEY_YELLOW				0x32
   1.146 +#define RC5_KEY_BLUE				0x34
   1.147 +#define RC5_KEY_POWER				0x0C
   1.148 +
   1.149 +#define RC5_FRONT_ADDRESS			0x55
   1.150 +
   1.151 +
   1.152 +
   1.153 +/** P R O G R A M   L O C A T I O N *********************************/
   1.154 +#define BOOTLOAD_START		0x000686		// taken from bootload.asm
   1.155 +
   1.156 +#endif //IO_CFG_H