46 #ifndef IO_PORT_DEFS_H
47 #define IO_PORT_DEFS_H
50 #define IOPORT_ID_NA 0xff //Port not available (use 0xff = erased flash)
51 #define UCPORT_ID_NA 0xff //UCPort not available (use 0xff = erased flash)
52 #define UCPORT_INDEX_NA 0xff //UCPort Index not available (use 0xff = erased flash)
53 #define BITADR_NA 0xffff //Bit Address not available (use 0xffff = erased flash)
56 #if defined(__PIC24FJ256GB206__) || defined(__PIC24FJ256GB208__) || defined(__PIC24FJ256GB210__)
57 #define CNPD1_ADR 0x0056
58 #define CNPU6_ADR 0x0078
59 #elif defined(__PIC24FJ128GB106__) || defined(__PIC24FJ128GB108__) || defined(__PIC24FJ128GB110__)
60 #define CNPD1_ADR 0x0054
61 #define CNPU6_ADR 0x0076
77 #define PCFG_NA_TYPE 0xff // Port Not available (use 0xff = erased flash)
83 #define PCFG_IN_FL_PULLUP 0x80 // Pull-up enabled Flag (can be ORed with other PCFG_DIN_xxx defines)
84 #define PCFG_IN_FL_PULLDOWN 0x40 // Pull-down enabled Flag (can be ORed with other PCFG_DIN_xxx defines)
87 #define PCFG_ADC_TYPE 0x01 // ADC Input - ##### TYPE #####
88 #define PTYPE_ADC 0x0100
89 #define PCFG_ADC_PULLUP PCFG_IN_FL_PULLUP // Pull-up enabled
90 #define PCFG_ADC_PULLDOWN PCFG_IN_FL_PULLDOWN // Pull-down enabled
91 #define PCFG_ADC_2V5_10BIT 0x00 // 10-bit ADC port, using external 2.5V reference
92 #define PCFG_ADC_3V3_10BIT 0x01 // 10-bit ADC port, using internal 3.3V Avcc as reference
93 #define PCFG_ADC_2V5_12BIT 0x10 // 12-bit ADC port, using external 2.5V reference
94 #define PCFG_ADC_3V3_12BIT 0x11 // 12-bit ADC port, using internal 3.3V Avcc as reference
96 #define PCFG_DIN_TYPE 0x02 // Digital input - ##### TYPE #####
97 #define PTYPE_DIN 0x0200 // Digital input - ##### TYPE #####
98 #define PCFG_DIN_PULLUP PCFG_IN_FL_PULLUP // Pull-up enabled
99 #define PCFG_DIN_PULLDOWN PCFG_IN_FL_PULLDOWN // Pull-down enabled
100 #define PCFG_DIN_3V3_IN 0x00 // 3V3 Digital input
101 #define PCFG_DIN_5V_IN 0x01 // 5V Digital input
105 #define PCFG_UART_RX_TYPE 0x03 // UART Input - ##### TYPE #####
106 #define PTYPE_UART_IN 0x0300
107 #define PCFG_UART_PULLUP PCFG_IN_FL_PULLUP // Pull-up enabled
108 #define PCFG_UART_PULLDOWN PCFG_IN_FL_PULLDOWN // Pull-down enabled
110 #define PCFG_UART_NUMER_1 0x00 // UART 1
111 #define PCFG_UART_NUMER_2 0x01 // UART 2
112 #define PCFG_UART_NUMER_3 0x02 // UART 3
113 #define PCFG_UART_NUMER_4 0x03 // UART 4
114 #define PCFG_UART_NUMER_5 0x04 // UART 5
115 #define PCFG_UART_NUMER_6 0x05 // UART 6
116 #define PCFG_UART_NUMER_7 0x06 // UART 7
117 #define PCFG_UART_NUMER_8 0x07 // UART 8
121 #define PCFG_USART_RX_TYPE 0x04 // USART Input - ##### TYPE #####
122 #define PTYPE_USART_RX 0x0400
123 #define PCFG_USART_PULLUP PCFG_IN_FL_PULLUP // Pull-up enabled
124 #define PCFG_USART_PULLDOWN PCFG_IN_FL_PULLDOWN // Pull-down enabled
126 #define PCFG_USART_NUMER_1 0x00 // USART 1
127 #define PCFG_USART_NUMER_2 0x01 // USART 2
128 #define PCFG_USART_NUMER_3 0x02 // USART 3
129 #define PCFG_USART_NUMER_4 0x03 // USART 4
130 #define PCFG_USART_NUMER_5 0x04 // USART 5
131 #define PCFG_USART_NUMER_6 0x05 // USART 6
132 #define PCFG_USART_NUMER_7 0x06 // USART 7
133 #define PCFG_USART_NUMER_8 0x07 // USART 8
137 #define PCFG_SPI_SDI_TYPE 0x05 // SPI Data Input - ##### TYPE #####
138 #define PTYPE_SPI_SDI 0x0500
139 #define PCFG_SPI_SS_TYPE 0x06 // SPI Slave Select Input - ##### TYPE #####
140 #define PTYPE_SPI_SS 0x0600
141 #define PCFG_SPI_PULLUP PCFG_IN_FL_PULLUP // Pull-up enabled
142 #define PCFG_SPI_PULLDOWN PCFG_IN_FL_PULLDOWN // Pull-down enabled
144 #define PCFG_SPI_NUMBER_1 0x00 // SPI 1
145 #define PCFG_SPI_NUMBER_2 0x01 // SPI 2
146 #define PCFG_SPI_NUMBER_3 0x02 // SPI 3
147 #define PCFG_SPI_NUMBER_4 0x03 // SPI 4
148 #define PCFG_SPI_NUMBER_5 0x04 // SPI 5
149 #define PCFG_SPI_NUMBER_6 0x05 // SPI 6
150 #define PCFG_SPI_NUMBER_7 0x06 // SPI 7
151 #define PCFG_SPI_NUMBER_8 0x07 // SPI 8
159 #define PCFG_OUT_FL_OPEN_COLL 0x80 // Open Collector enabled Flag (can be ORed with other PCFG_xxx defines)
162 #define PCFG_AOUT_TYPE 0x81 // Analog Output - ##### TYPE #####
163 #define PTYPE_AOUT 0x8100
164 #define PCFG_AOUT_3V3 0x00 // 3V3 Digital output
165 #define PCFG_AOUT_3V3_OC 0x01 // 3V3 Open Collector output. NOT 5V tolerant
166 #define PCFG_AOUT_5V 0x02 // 5V Digital output (push-pull)
167 #define PCFG_AOUT_5V_OC 0x03 // 5V tolerant Open Collector output
169 #define PCFG_DOUT_TYPE 0x82 // Digital Out - ##### TYPE #####
170 #define PTYPE_DOUT 0x8200
171 #define PCFG_DOUT_3V3 0x00 // 3V3 Digital output
172 #define PCFG_DOUT_3V3_OC 0x01 // 3V3 Open Collector output. NOT 5V tolerant
173 #define PCFG_DOUT_5V 0x02 // 5V Digital output (push-pull)
174 #define PCFG_DOUT_5V_OC 0x03 // 5V tolerant Open Collector output
176 #define PCFG_PWM_TYPE 0x83 // PWM Output - ##### TYPE #####
177 #define PTYPE_PWM 0x8300
178 #define PCFG_PWM_3V3_10BIT 0x00 // 3V3 Digital output, 10 bit
179 #define PCFG_PWM_3V3_OC_10BIT 0x01 // 3V3 Open COllector output, 10 bit. NOT 5V tolerant
180 #define PCFG_PWM_5V_10BIT 0x02 // 5V Digital output (push-pull), 10 bit
181 #define PCFG_PWM_5V_OC_10BIT 0x03 // 5V tolerant Open Collector output, 10 bit
182 #define PCFG_PWM_3V3_12BIT 0x10 // 3V3 Digital output, 12 bit
183 #define PCFG_PWM_3V3_OC_12BIT 0x11 // 3V3 Open COllector output, 12 bit. NOT 5V tolerant
184 #define PCFG_PWM_5V_12BIT 0x12 // 5V Digital output (push-pull), 12 bit
185 #define PCFG_PWM_5V_OC_12BIT 0x13 // 5V tolerant Open Collector output, 12 bit
187 #define PCFG_VREFOUT_TYPE 0x84 // High impedance Reference output, for all PICs looked at this is RB10 pin - ##### TYPE #####
188 #define PTYPE_VREFOUT 0x8400
189 #define PCFG_VREFOUT_xxx 0x00 // Reference voltage is set to ?V
193 #define PCFG_UART_OUT_TYPE 0x85 // UART Output - ##### TYPE #####
194 #define PTYPE_UART_OUT 0x8500
199 #define PCFG_USART_OUT_TYPE 0x86 // USART Output - ##### TYPE #####
200 #define PTYPE_USART_OUT 0x8600
205 #define PCFG_SPI_SDO_TYPE 0x87 // SPI Data Output - ##### TYPE #####
206 #define PTYPE_SPI_SDO 0x8700
207 #define PCFG_SPI_CLK_TYPE 0x88 // SPI Clock Output - ##### TYPE #####
208 #define PTYPE_SPI_CLK 0x8800
213 #define PCFG_I2C_SDA_TYPE 0x89 // I2C Serial Data - ##### TYPE #####
214 #define PTYPE_I2C_SDA 0x8900
215 #define PCFG_I2C_SCL_TYPE 0x8A // I2C Serial Clock - ##### TYPE #####
216 #define PTYPE_I2C_SCL 0x8A00
218 #define PCFG_I2C_NUMBER_1 0x00 // I2C 1
219 #define PCFG_I2C_NUMBER_2 0x01 // I2C 2
220 #define PCFG_I2C_NUMBER_3 0x02 // I2C 3
221 #define PCFG_I2C_NUMBER_4 0x03 // I2C 4
222 #define PCFG_I2C_NUMBER_5 0x04 // I2C 5
223 #define PCFG_I2C_NUMBER_6 0x05 // I2C 6
224 #define PCFG_I2C_NUMBER_7 0x06 // I2C 7
225 #define PCFG_I2C_NUMBER_8 0x07 // I2C s8
228 extern const WORD TRIS_PORTID_BITADR_MAP[];
230 extern const BYTE PORTID_UCPORT_MAP[];
233 #define getUcPortNumber() ((sizeof(CFG_BLOCK_UC66_PORT) - sizeof(((CFG_BLOCK_UC66_PORT*)0)->reserve)) / sizeof(UCPORT_CONFIG))
234 #define UC_PORT_NUMBER ((sizeof(CFG_BLOCK_UC66_PORT) - sizeof(((CFG_BLOCK_UC66_PORT*)0)->reserve)) / sizeof(UCPORT_CONFIG))
242 #define GET_UCPORT_INDEX(ele) (offsetof(CFG_BLOCK_UC66_PORT, ele) / sizeof(UCPORT_CONFIG))
248 UCPORT_ID_A0 = 0, UCPORT_ID_A1, UCPORT_ID_A2, UCPORT_ID_A3, UCPORT_ID_A4, UCPORT_ID_A5, UCPORT_ID_A6, UCPORT_ID_A7,
249 UCPORT_ID_A8, UCPORT_ID_A9, UCPORT_ID_A10, UCPORT_ID_A11, UCPORT_ID_A12, UCPORT_ID_A13, UCPORT_ID_A14, UCPORT_ID_A15,
251 UCPORT_ID_B0 = 16, UCPORT_ID_B1, UCPORT_ID_B2, UCPORT_ID_B3, UCPORT_ID_B4, UCPORT_ID_B5, UCPORT_ID_B6, UCPORT_ID_B7,
252 UCPORT_ID_B8, UCPORT_ID_B9, UCPORT_ID_B10, UCPORT_ID_B11, UCPORT_ID_B12, UCPORT_ID_B13, UCPORT_ID_B14, UCPORT_ID_B15,
254 UCPORT_ID_C0 = 32, UCPORT_ID_C1, UCPORT_ID_C2, UCPORT_ID_C3, UCPORT_ID_C4, UCPORT_ID_C5, UCPORT_ID_C6, UCPORT_ID_C7,
255 UCPORT_ID_C8, UCPORT_ID_C9, UCPORT_ID_C10, UCPORT_ID_C11, UCPORT_ID_C12, UCPORT_ID_C13, UCPORT_ID_C14, UCPORT_ID_C15,
257 UCPORT_ID_D0 = 48, UCPORT_ID_D1, UCPORT_ID_D2, UCPORT_ID_D3, UCPORT_ID_D4, UCPORT_ID_D5, UCPORT_ID_D6, UCPORT_ID_D7,
258 UCPORT_ID_D8, UCPORT_ID_D9, UCPORT_ID_D10, UCPORT_ID_D11, UCPORT_ID_D12, UCPORT_ID_D13, UCPORT_ID_D14, UCPORT_ID_D15,
260 UCPORT_ID_E0 = 64, UCPORT_ID_E1, UCPORT_ID_E2, UCPORT_ID_E3, UCPORT_ID_E4, UCPORT_ID_E5, UCPORT_ID_E6, UCPORT_ID_E7,
261 UCPORT_ID_E8, UCPORT_ID_E9, UCPORT_ID_E10, UCPORT_ID_E11, UCPORT_ID_E12, UCPORT_ID_E13, UCPORT_ID_E14, UCPORT_ID_E15,
263 UCPORT_ID_F0 = 80, UCPORT_ID_F1, UCPORT_ID_F2, UCPORT_ID_F3, UCPORT_ID_F4, UCPORT_ID_F5, UCPORT_ID_F6, UCPORT_ID_F7,
264 UCPORT_ID_F8, UCPORT_ID_F9, UCPORT_ID_F10, UCPORT_ID_F11, UCPORT_ID_F12, UCPORT_ID_F13, UCPORT_ID_F14, UCPORT_ID_F15,
266 UCPORT_ID_G0 = 96, UCPORT_ID_G1, UCPORT_ID_G2, UCPORT_ID_G3, UCPORT_ID_G4, UCPORT_ID_G5, UCPORT_ID_G6, UCPORT_ID_G7,
267 UCPORT_ID_G8, UCPORT_ID_G9, UCPORT_ID_G10, UCPORT_ID_G11, UCPORT_ID_G12, UCPORT_ID_G13, UCPORT_ID_G14, UCPORT_ID_G15,
270 #define UCPORT_ID_MAX UCPORT_ID_G15
280 unsigned char bFill : 6;
281 unsigned char bPulldown : 1;
282 unsigned char bPullup : 1;
294 unsigned char bFill : 6;
295 unsigned char bOpenCollector : 1;
296 unsigned char bDefault : 1;
326 typedef struct __attribute__((__packed__))
352 typedef struct __attribute__((__packed__))
406 typedef struct __attribute__((__packed__))
457 #define UCPORT_PROP_NA_VAL 0xffffffff
458 #define UCPORT_PROP_NA 0x80000000
459 #define UCPORT_PROP_DIG_IN 0x00000001
460 #define UCPORT_PROP_DIG_OUT 0x00000002
461 #define UCPORT_PROP_ANALOG_IN 0x00000004
462 #define UCPORT_PROP_OPEN_COL 0x00000008
463 #define UCPORT_PROP_RP 0x00000010
464 #define UCPORT_PROP_RPI 0x00000020
465 #define UCPORT_PROP_PULLUP 0x00000040
466 #define UCPORT_PROP_PULLDOWN 0x00000080
467 #define UCPORT_PROP_5V 0x00000100
468 #define UCPORT_PROP_SDA 0x00000200
469 #define UCPORT_PROP_SCL 0x00000400
470 #define UCPORT_PROP_INT 0x00000800
480 typedef struct __attribute__((__packed__))
486 typedef struct __attribute__((__packed__))
523 typedef struct __attribute__((__packed__))
577 typedef struct __attribute__((__packed__))