OSDN Git Service

[IO] Add PIC18F4xK20 with parallel LCD, PIC18F2xK20 with I2C LCD.
[openi2cradio/OpenI2CRadio.git] / iodef.h
1 /*
2  * OpenI2CRADIO
3  * I/O Port defines.
4  * Copyright (C) 2013-06-10 K.Ohta <whatisthis.sowhat ai gmail.com>
5  * License: GPL2+LE
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2,
10  *  or (at your option) any later version.
11  *  This library / program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  *  See the GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this library; see the file COPYING. If not, write to the
18  *  Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19  *  MA 02110-1301, USA.
20  *
21  *  As a special exception, if you link this(includeed from sdcc) library
22  *  with other files, some of which are compiled with SDCC,
23  *  to produce an executable, this library does not by itself cause
24  *  the resulting executable to be covered by the GNU General Public License.
25  *  This exception does not however invalidate any other reasons why
26  *  the executable file might be covered by the GNU General Public License.
27  */
28
29 #ifndef IODEF_H
30 #define IODEF_H
31
32 #ifdef  __cplusplus
33 extern "C" {
34 #endif
35
36 /*
37  * Machine depended flags
38  */
39 #if defined(__18F23K22) || defined(__18F24K22) || defined(__18F25K22) || defined(__18F26K22)
40 #define _I2C_IO_TWO_MSSPS
41 #define _PIO_HAS_THREE
42 #endif
43
44 #if defined(__18F23K20) || defined(__18F24K20) || defined(__18F25K20) || defined(__18F26K20)
45 #define _I2C_IO_ONE_MSSP
46 #define _PIO_HAS_THREE
47 #endif
48
49 #if defined(__18F43K20) || defined(__18F44K20) || defined(__18F45K20) || defined(__18F46K20)
50 #define _I2C_IO_ONE_MSSP
51 #define _PIO_HAS_FIVE
52 #endif
53
54 /*
55  * LCD(ACM1602 Type)
56  */
57 // If you use I2C-Type ACM1602, You should define, otherwise #undef.
58 #undef _USE_I2C_1602
59
60 /*
61  * MAP OF IOPORT
62  * PORTA/B/C USED.
63  * PORTA: RA2-RA5 : READ
64  *        RA1 : SLOT D(OUT)
65  *        RA0 : ADC(IN)
66  *        RA6-RA7 : CLOCK
67  * PORTB: RB4-RB5 : RESERVED
68  *        RB6-RB7 : FOR ICSP
69  *        RB3 : DEL / BAND
70  *        RB2 : FUNC
71  *        RB1 : Light
72  *        RB0 : Light Out
73  * PORTC  RC0 : LED
74  *        RC1 : SLOT A
75  *        RC2 : SLOT B
76  *        RC5 : SLOT C
77  *        RC3-RC4 : SCL/SDA
78  *        RC6-RC7 : USART
79  * In addition, usage of PARALLEL-LCD,You should use 40Pin(or greater) PIC.
80  * PORTD: RD0-RD7 : LCD DATA(DB0-DB7)
81  * PORTE: RE0: LCD RS
82  *        RE1: LCD RW
83  *        RE2: LCD EN
84  *        RE3: VPP (ICSP Programing Voltage) / MCLR
85  */
86
87 #define TRIS_A_VAL 0b11111101
88 #define AN_A_VAL 0b00000001
89 #define TRIS_B_VAL 0b11111110
90 #define AN_B_VAL 0b00000000
91 #define TRIS_C_VAL_O 0b11000000 /* FOR I2C-WRITE */
92 #define TRIS_C_VAL_I 0b11011000 /* FOR I2C-WRITE */
93 #define AN_C_VAL 0b00000000
94
95 #define TRIS_D_VAL 0b00000000 /* FOR OUTPUT, LCD(Optional) */
96 #define TRIS_E_VAL 0b00000000 /* FOR OUTPUT, LCD(Optional), PSP=OFF */
97
98
99 typedef  union {
100     struct {
101     unsigned BIT0A:1;
102     unsigned BIT1A:1;
103     unsigned BIT2A:1;
104     unsigned BIT3A:1;
105
106     unsigned BIT0B:1;
107     unsigned BIT1B:1;
108     unsigned BIT2B:1;
109     unsigned BIT3B:1;
110
111     unsigned BIT0C:1;
112     unsigned BIT1C:1;
113     unsigned BIT2C:1;
114     unsigned BIT3C:1;
115
116     unsigned BIT0D:1;
117     unsigned BIT1D:1;
118     unsigned BIT2D:1;
119     unsigned BIT3D:1;
120
121     /*
122      * special keys
123      */
124     unsigned BIT0F:1;
125     unsigned BIT1F:1;
126     unsigned BIT2F:1;
127     unsigned BIT3F:1;
128     unsigned :1;
129     unsigned :1;
130     unsigned :1;
131     unsigned :1;
132     };
133     unsigned char byte[3];
134 } keyin_defs;
135
136 enum {
137     charcode_null = 0,
138     charcode_1,
139     charcode_2,
140     charcode_3,
141     charcode_4,
142     charcode_5,
143     charcode_6,
144     charcode_7,
145     charcode_8,
146     charcode_9,
147     charcode_a,
148     charcode_b,
149     charcode_c,
150     charcode_d,
151     charcode_e,
152     charcode_f,
153     charcode_0,
154     charcode_s0, // RB1
155     charcode_s1, // RB2
156     charcode_s2, // RB3
157     charcode_s3, // Reserve
158 };
159
160 /*
161  * LCD Control: Default register values, You should re-define in iodef.h if you need.
162  */
163 #ifndef _LCDPORT_DATA
164 #define _LCDPORT_DATA PORTD
165 #define _LCDPORT_TRIS_DATA TRISD
166 #define _LCDPORT_LATCH_DATA LATD
167 #endif
168
169 #ifndef _LCDPORT_CONT
170 #define _LCDPORT_CONT PORTE
171 #define _LCDPORT_TRIS_CONT TRISE
172 #define _LCDPORT_CONT_RS _PORTE_RE0
173 #define _LCDPORT_CONT_RW _PORTE_RE1
174 #define _LCDPORT_CONT_EN _PORTE_RE2
175 #define _LCDPORT_CONT_LATCH LATE
176 #endif
177
178 #ifdef  __cplusplus
179 }
180 #endif
181
182 #endif  /* IODEF_H */
183