4 * Copyright (C) 2013-06-10 K.Ohta <whatisthis.sowhat ai gmail.com>
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.
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,
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.
39 // If you use I2C-Type ACM1602, You should define, otherwise #undef.
44 * Machine depended flags
46 #if defined(pic18f23k22) || defined(pic18f24k22) || defined(pic18f25k22) || defined(pic18f26k22)
47 #define _I2C_IO_TWO_MSSPS
48 #define _PIO_HAS_THREE
51 #if defined(pic18f23k20) || defined(pic18f24k20) || defined(pic18f25k20) || defined(pic18f26k20)
52 #define _I2C_IO_ONE_MSSP
53 #define _PIO_HAS_THREE
56 #if defined(pic18f43k20) || defined(pic18f44k20) || defined(pic18f45k20) || defined(pic18f46k20)
57 #define _I2C_IO_ONE_MSSP
65 * RE3: VPP (ICSP Programming Voltage) / MCLR, Dont use for I/O.
67 * PORTA/B/C USED basic.
69 * PORTA: RA0 : ADC(IN) to measure battery .
72 * RA6-RA7 : Used for CLOCK, connect to 8MHz resonator.
74 * PORTB: RB0 : Light Out
88 * In addition, usage of PARALLEL-LCD,You should use 40Pin(or greater) PIC.
95 * RD4-RD7 : LCD DATA(DB4-DB7)
97 * PORTD: RE0: FM AMP SW(OUT)
100 * RE3: VPP (ICSP Programming Voltage) / MCLR
103 * PORTD: RD0-RD7 : LCD DATA(DB0-DB7)
107 * RE3: VPP (ICSP Programming Voltage) / MCLR
110 #define TRIS_A_VAL 0b11111101
111 #define AN_A_VAL 0b00000001
112 #define TRIS_B_VAL 0b11111110
113 #define AN_B_VAL 0b00000000
114 #define TRIS_C_VAL_O 0b11000000 /* FOR I2C-WRITE */
115 #define TRIS_C_VAL_I 0b11011000 /* FOR I2C-WRITE */
116 #define AN_C_VAL 0b00000000
118 #define TRIS_D_VAL 0b00000000 /* FOR OUTPUT, LCD(Optional) */
120 #define TRIS_D_RVAL 0b11110000 /* FOR INPUT*/
122 #define TRIS_D_RVAL 0b11111111 /* FOR INPUT*/
124 #define TRIS_E_VAL 0b00000000 /* FOR OUTPUT, LCD(Optional), PSP=OFF */
161 unsigned char byte[3];
185 charcode_s3, // Reserve
189 * LCD Control: Default register values, You should re-define in iodef.h if you need.
207 * 4bit Interface, Used Below:
211 * RD4-RD7: DATA(4-7).
213 #ifndef _LCDPORT_DATA
214 #define _LCDPORT_DATA PORTD
215 #define _LCDPORT_TRIS_DATA TRISD
216 #define _LCDPORT_LATCH_DATA LATD
217 #define _LCDPORT_BUSYMASK 0b10000000
218 #define _LCDPORT_READMASK TRIS_D_RVAL
219 #define _LCDPORT_DATA_SHIFT 4
222 #ifndef _LCDPORT_CONT
223 #define _LCDPORT_CONT PORTD
224 #define _LCDPORT_TRIS_CONT TRISD
225 #define _LCDPORT_CONT_LATCH LATD
226 #define _LCDPORT_CONT_RSbit b0
227 #define _LCDPORT_CONT_RWbit b1
228 #define _LCDPORT_CONT_ENbit b2
229 #define _LCDPORT_CONT_RS _PORTD_RD0
230 #define _LCDPORT_CONT_RW _PORTD_RD1
231 #define _LCDPORT_CONT_EN _PORTD_RD2
236 * 8bit Interface, Used Below:
240 * PORTD: RD0-RD7: DATA(0-7).
243 #ifndef _LCDPORT_DATA
244 #define _LCDPORT_DATA PORTD
245 #define _LCDPORT_TRIS_DATA TRISD
246 #define _LCDPORT_LATCH_DATA LATD
247 #define _LCDPORT_BUSYMASK 0b10000000
248 #define _LCDPORT_READMASK TRIS_D_RVAL
251 #ifndef _LCDPORT_CONT
252 #define _LCDPORT_CONT PORTE
253 #define _LCDPORT_TRIS_CONT TRISE
254 #define _LCDPORT_CONT_RSbit 0
255 #define _LCDPORT_CONT_RWbit 1
256 #define _LCDPORT_CONT_ENbit 2
257 #define _LCDPORT_CONT_RS _PORTE_RE0
258 #define _LCDPORT_CONT_RW _PORTE_RE1
259 #define _LCDPORT_CONT_EN _PORTE_RE2
260 #define _LCDPORT_CONT_LATCH LATE