4 * Copyright (C) 2013-06-20 K.Ohta <whatisthis.sowhat ai gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2,
9 * or (at your option) any later version.
10 * This library / program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this library; see the file COPYING. If not, write to the
17 * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
20 * As a special exception, if you link this(includeed from sdcc) library
21 * with other files, some of which are compiled with SDCC,
22 * to produce an executable, this library does not by itself cause
23 * the resulting executable to be covered by the GNU General Public License.
24 * This exception does not however invalidate any other reasons why
25 * the executable file might be covered by the GNU General Public License.
27 #include "commondef.h"
30 #include "backlight.h"
32 unsigned char statecount;
34 void set_amfmlamp(unsigned char f)
46 void set_examp_mute(unsigned char f)
49 _PORT_MUTE = 1; // 20130709 Not Mute
56 void set_radiopower(unsigned char f)
59 _PORT_RADIOPOW = 0; // OFF
61 _PORT_RADIOPOW = 1; // ON
65 void set_powerlamp(unsigned char f)
74 #if defined(pic18f23k22) || defined(pic18f24k22) || defined(pic18f25k22) || defined(pic18f26k22) || \
75 defined(_18F23K22) || defined(_18F24K22) || defined(_18F25K22) || defined(_18F26K22)
78 * For 28Pin PIC(18F2xK22), I2C lcd using.
81 void keyin_ioinit(void)
83 /* Initialize IOPORTS*/
98 // lcd_backlightinit();
102 #if defined(pic18f23k20) || defined(pic18f24k20) || defined(pic18f25k20) || defined(pic18f26k20) || \
103 defined(_18F23K20) || defined(_18F24K20) || defined(_18F25K20) || defined(_18F26K20)
106 * For 28Pin PIC(18F2xK20), I2C lcd using.
109 void keyin_ioinit(void)
111 /* Initialize IOPORTS*/
114 ANSEL = 0x01; // Use RA0 AS ADC, Another is not used.
124 TRISC = TRIS_C_VAL_O;
125 // lcd_backlightinit();
129 #if defined(pic18f43k20) || defined(pic18f44k20) || defined(pic18f45k20) || defined(pic18f46k20) || \
130 defined(_18F43K20) || defined(_18F44K20) || defined(_18F45K20) || defined(_18F46K20)
133 * For 40Pin PIC(18F4xK20), paralell or I2C lcd using.
135 void keyin_ioinit(void)
137 /* Initialize IOPORTS*/
140 ANSEL = 0x80; // Use RA7 AS ADC, Another is not used.
150 TRISC = TRIS_C_VAL_O;
153 * You can use PORTD,RE0-RE2 extention, when using I2C lcd.
160 PORTE = 0b00000000; // Mute OK
163 INTCONbits.INT0IE = 0;
164 INTCONbits.INT0IF = 0;
165 INTCON3bits.INT1IF = 0;
166 INTCON3bits.INT2IF = 0;
167 INTCON3bits.INT1IE = 0;
168 INTCON3bits.INT2IE = 0;
170 // lcd_backlightinit();
173 void keyin_ioinit(void)
175 /* Initialize IOPORTS*/
178 // ANSEL = 0x01; // Use RA0 AS ADC, Another is not used.
188 TRISC = TRIS_C_VAL_O;
189 // lcd_backlightinit();
194 * Read IOPORTS for KEY. You should modify if you modify circuit.
196 void readkey_io(unsigned char state)
203 for(i = 0; i < 2; i++){
204 keyin_old[1].byte[i] = keyin_old[0].byte[i];
205 keyin_old[0].byte[i] = keyin_now.byte[i];
206 keyin_now.byte[i] = 0x00;
208 _KEY_SENDPORT |= _KEY_SENDPORTMASK; // Group1 DOWN.
211 _KEY_SEND_GRP1 = 0; // Group1 DOWN.
214 portvar.byte = _KEY_RECVPORT;
215 if(!_KEY_POS1MASK(portvar)) {
218 if(!_KEY_POS2MASK(portvar)) {
221 if(!_KEY_POS3MASK(portvar)) {
224 if(!_KEY_POS4MASK(portvar)) {
227 _KEY_SENDPORT |= _KEY_SENDPORTMASK; // Group1 DOWN.
230 _KEY_SEND_GRP2 = 0; // Group2 DOWN.
233 portvar.byte = _KEY_RECVPORT;
234 if(!_KEY_POS1MASK(portvar)) {
237 if(!_KEY_POS2MASK(portvar)) {
240 if(!_KEY_POS3MASK(portvar)) {
243 if(!_KEY_POS4MASK(portvar)) {
246 _KEY_SENDPORT |= _KEY_SENDPORTMASK; // Group1 DOWN.
249 _KEY_SEND_GRP3 = 0; // Group1 DOWN.
252 portvar.byte = _KEY_RECVPORT;
253 if(!_KEY_POS1MASK(portvar)) {
256 if(!_KEY_POS2MASK(portvar)) {
259 if(!_KEY_POS3MASK(portvar)) {
262 if(!_KEY_POS4MASK(portvar)) {
265 _KEY_SENDPORT |= _KEY_SENDPORTMASK; // Group1 DOWN.
268 _KEY_SEND_GRP4 = 0; // Group4 up
271 portvar.byte = _KEY_RECVPORT;
272 if(!_KEY_POS1MASK(portvar)) {
275 if(!_KEY_POS2MASK(portvar)) {
278 if(!_KEY_POS3MASK(portvar)) {
281 if(!_KEY_POS4MASK(portvar)) {
284 _KEY_SENDPORT |= _KEY_SENDPORTMASK; // Group1 DOWN.