[Build] Seems to work well building with XC8, excepts SCAN function(why?).
void akc6955_do_scan(unsigned char up)
{
__bitops_t b;
- // akc6955_do_tune();
b.byte = akc6955_readcmd(AKC6955_POWER);
b.b3 = 0;
b.b4 = 0;
b.b5 = 0;
akc6955_writecmd(AKC6955_POWER, b.byte);
b.b5 = 1; // Tune 0->1.
- idle_time_35ms();
+ idle_time_ms(10);
akc6955_writecmd(AKC6955_POWER, b.byte);
- idle_time_35ms();
+ idle_time_ms(10);
+ b.b4 = 1;
if(up != 0) {
b.b3= 1;
}
- b.b4 = 1;
akc6955_writecmd(AKC6955_POWER, b.byte); // Raise seek bit to '1'.
+ idle_time_ms(35);
}
void akc6955_abort_scan(void)
"5: Cancel", "f: (Exit) Help",
};
-const char *mainmenu_helpstr[14] = {
+const char *mainmenu_helpstr[16] = {
"Help", "F=exit any=continue",
"0: Setup", "1: Band",
"3: Freq", ""
"7: Power Off", "8: Volume",
"9: Width", "a: AM/FM",
"b: Cancel","c: Set user",
- "d: Input user","f: (Exit) Help"
+ "d: Input user","f: (Exit) Help",
};
const char *numeric_helpstr[10] = {
StartI2C();
while (SSPCON2bits.SEN);
WriteI2C(addr);
+ while(SSPCON2bits.SEN);
WriteI2C(reg);
+ while(SSPCON2bits.SEN);
WriteI2C(data);
StopI2C();
while (SSPCON2bits.PEN);
while(SSPCON2bits.SEN);
WriteI2C(addr);
// delay1ktcy(8);
+ while(SSPCON2bits.SEN);
WriteI2C(reg);
// delay1ktcy(8);
StopI2C();
/* Pre-scaler: 1/2, PSA=1(ON), TOSE=0, T0CS=0(INTERNAL), T08BIT=0(16bit), TMR0ON=1(START) */
/* 1Tick = 1/1000 ms*/
T0CON = 0b00001000; // 1/2
+// T0CON = 0b00001010; // 1/8
OSCCONbits.IDLEN = 1;
INTCONbits.TMR0IF = 0;
+ INTCONbits.TMR0IE = 1;
+// TMR0L = initial & 0xff;
// TMR0H = initial >> 8; // Write order : L->H
TMR0H = initial >> 8; // Write order : H->L
TMR0L = initial & 0xff;
if(ms == 0) return;
upper = (ms & 0xffc0) >> 6;
-// tim = ms * 8 - ms / 16 - ms / 8;
tim = (ms & 0x3f) * 1000; //
tim = (65535 - tim) + 1; // tim = 65536 - tim;
while(upper > 0) {
/*
* OpenI2CRADIO
- * I/O Port defines.
+ * I/O Port defines / Main.
* Copyright (C) 2013-06-10 K.Ohta <whatisthis.sowhat ai gmail.com>
* License: GPL2+LE
*
#ifndef IODEF_H
#define IODEF_H
+
#ifdef __SDCC
#else
#include <xc.h>
+
+#ifndef _XTAL_FREQ
#define _XTAL_FREQ 8000000
#endif
-#ifdef __cplusplus
-extern "C" {
+
#endif
+
/*
* LCD(ACM1602 Type)
*/
#undef _USE_I2C_1602
#define _LCD_IF_4BIT
-/*
- * Machine depended flags
- */
-#if defined(__SDCC)
-#if defined(pic18f23k22) || defined(pic18f24k22) || defined(pic18f25k22) || defined(pic18f26k22)
-#define _I2C_IO_TWO_MSSPS
-#define _PIO_HAS_THREE
-#endif
-
-#if defined(pic18f23k20) || defined(pic18f24k20) || defined(pic18f25k20) || defined(pic18f26k20)
-#define _I2C_IO_ONE_MSSP
-#define _PIO_HAS_THREE
-#endif
-
-#if defined(pic18f43k20) || defined(pic18f44k20) || defined(pic18f45k20) || defined(pic18f46k20)
-#define _I2C_IO_ONE_MSSP
-#define _PIO_HAS_FIVE
-#endif
-#else // __XC
-#if defined(_18F23K22) || defined(_18F24K22) || defined(_18F25K22) || defined(_18F26K22)
-#define _I2C_IO_TWO_MSSPS
-#define _PIO_HAS_THREE
-#endif
-
-#if defined(_18F23K20) || defined(_18F24K20) || defined(_18F25K20) || defined(_18F26K20)
-#define _I2C_IO_ONE_MSSP
-#define _PIO_HAS_THREE
+#ifdef __cplusplus
+extern "C" {
#endif
-#if defined(_18F43K20) || defined(_18F44K20) || defined(_18F45K20) || defined(_18F46K20)
-#define _I2C_IO_ONE_MSSP
-#define _PIO_HAS_FIVE
-#endif
-#endif
+#include "iodef_i2c.h"
/*
* MAP OF IOPORT
#define TRIS_A_VAL 0b11000000
#define AN_A_VAL 0b00000000
+
#define TRIS_B_VAL 0b11111111 /* PORTB as INPUT.*/
#define AN_B_VAL 0b00000000
+
#define TRIS_C_VAL_O 0b00011000 /* FOR I2C-WRITE */
#define TRIS_C_VAL_I 0b00011000 /* FOR I2C-WRITE */
#define AN_C_VAL 0b00000000
+
#define TRIS_D_VAL 0b00000000 /* FOR OUTPUT, LCD(Optional) */
#ifdef _LCD_IF_4BIT
- #define TRIS_D_RVAL 0xf0 /* FOR INPUT*/
+ #define TRIS_D_RVAL 0b11110000 /* FOR INPUT*/
#else
#define TRIS_D_RVAL 0b11111111 /* FOR INPUT*/
#endif
+
#define TRIS_E_VAL 0b00000100 /* FOR OUTPUT, ADC, PSP=OFF */
+
#define _BATT_ADC AN7
#define _ADC_INITF ANS7
#define _ADCH_INITF 0x00
-#define _PORT_MUTE LATEbits.LATE0
-#define _PORT_RADIOPOW LATEbits.LATE1
-//#ifdef __SDCC
-#define _LCD_BACKLIGHT LATC
-#define _LCD_BACKLIGHT_BIT b1
-#define _LCD_BACKLIGHT_TRIS TRISC
-//#else
-//#define _LCD_BACKLIGHT _PORTC_RC2_MASK
-//#endif // __SDCC
-
-#define _LCD_PORT LATC
+#include "iodef_amp.h"
/*
- * RF Preamp
+ * Lamp
*/
- enum {
- RFAMP_OFF = 0,
- RFAMP_FM = 1,
- RFAMP_MWLW = 2,
- RFAMP_SW = 1
- /* 3 = Reserve*/
- };
-#define _RFAMP_SEL_B0 LATCbits.LATC0
-#define _RFAMP_SEL_B1 LATCbits.LATC2
-
#define _AM_STATLAMP LATAbits.LATA4
#define _FM_STATLAMP LATAbits.LATA5
#define _POW_STATLAMP LATDbits.LATD3
-
-#define _KEY_SENDPORT LATA
-#define _KEY_RECVPORT PORTB
-#define _KEY_GRP1MASK 0x01
-#define _KEY_GRP2MASK 0x02
-#define _KEY_GRP3MASK 0x04
-#define _KEY_GRP4MASK 0x08
-#define _KEY_SENDPORTMASK (_KEY_GRP1MASK | _KEY_GRP2MASK | _KEY_GRP3MASK | _KEY_GRP4MASK)
-#define _KEY_SEND_GRP1 LATAbits.LATA0
-#define _KEY_SEND_GRP2 LATAbits.LATA1
-#define _KEY_SEND_GRP3 LATAbits.LATA2
-#define _KEY_SEND_GRP4 LATAbits.LATA3
-#define _KEY_POS1MASK(p) p.b0
-#define _KEY_POS2MASK(p) p.b1
-#define _KEY_POS3MASK(p) p.b2
-#define _KEY_POS4MASK(p) p.b3
-
-typedef union {
- struct {
- unsigned BIT0A:1;
- unsigned BIT1A:1;
- unsigned BIT2A:1;
- unsigned BIT3A:1;
-
- unsigned BIT0B:1;
- unsigned BIT1B:1;
- unsigned BIT2B:1;
- unsigned BIT3B:1;
-
- unsigned BIT0C:1;
- unsigned BIT1C:1;
- unsigned BIT2C:1;
- unsigned BIT3C:1;
-
- unsigned BIT0D:1;
- unsigned BIT1D:1;
- unsigned BIT2D:1;
- unsigned BIT3D:1;
-
- };
- unsigned char byte[2];
-} keyin_defs;
-
-enum {
- charcode_null = 0,
- charcode_1,
- charcode_2,
- charcode_3,
- charcode_4,
- charcode_5,
- charcode_6,
- charcode_7,
- charcode_8,
- charcode_9,
- charcode_a,
- charcode_b,
- charcode_c,
- charcode_d,
- charcode_e,
- charcode_f,
- charcode_0,
- // Special keys was removed.
-};
-
-/*
- * LCD Control: Default register values, You should re-define in iodef.h if you need.
- */
-
-
-#ifdef _LCD_IF_4BIT
-/*
- * 4bit Interface, Used Below:
- * PORTD: RD0 : RS
- * RD1 : RW
- * RD2 : EN
- * RD4-RD7: DATA(4-7).
- */
-#ifndef _LCDPORT_DATA
-#define _LCDPORT_DATA PORTD
-#define _LCDPORT_TRIS_DATA TRISD
-#define _LCDPORT_LATCH_DATA LATD
-#define _LCDPORT_BUSYMASK 0b10000000
-#define _LCDPORT_READMASK TRIS_D_RVAL
-#define _LCDPORT_DATA_SHIFT 4
-#endif
-
-#ifndef _LCDPORT_CONT
-#define _LCDPORT_CONT PORTD
-#define _LCDPORT_TRIS_CONT TRISD
-#define _LCDPORT_CONT_LATCH LATD
-#define _LCDPORT_CONT_RSbit b0
-#define _LCDPORT_CONT_RWbit b1
-#define _LCDPORT_CONT_ENbit b2
-#define _LCDPORT_CONT_BLbit b3
-#define _LCDPORT_CONT_RS LATDbits.LATD0
-#define _LCDPORT_CONT_RW LATDbits.LATD1
-#define _LCDPORT_CONT_EN LATDbits.LATD2
-#endif
-
-#else
-/*
- * 8bit Interface, Used Below:
- * PORTE: RE0 : RS
- * RE1 : RW
- * RE2 : EN
- * PORTD: RD0-RD7: DATA(0-7).
- */
-// 8bit I/F
- #ifndef _LCDPORT_DATA
-#define _LCDPORT_DATA PORTD
-#define _LCDPORT_TRIS_DATA TRISD
-#define _LCDPORT_LATCH_DATA LATD
-#define _LCDPORT_BUSYMASK 0b10000000
-#define _LCDPORT_READMASK TRIS_D_RVAL
- #endif
-
- #ifndef _LCDPORT_CONT
-#define _LCDPORT_CONT PORTE
-#define _LCDPORT_TRIS_CONT TRISE
-#define _LCDPORT_CONT_RSbit 0
-#define _LCDPORT_CONT_RWbit 1
-#define _LCDPORT_CONT_ENbit 2
-#define _LCDPORT_CONT_RS _PORTE_RE0
-#define _LCDPORT_CONT_RW _PORTE_RE1
-#define _LCDPORT_CONT_EN _PORTE_RE2
-#define _LCDPORT_CONT_LATCH LATE
- #endif
-#endif
+#include "iodef_key.h"
+#include "iodef_lcd.h"
#ifdef __cplusplus
}
--- /dev/null
+/*
+ * OpenI2CRADIO
+ * I/O Port defines / External AMP.
+ * Copyright (C) 2013-08-22 K.Ohta <whatisthis.sowhat ai gmail.com>
+ * License: GPL2+LE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ * This library / program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; see the file COPYING. If not, write to the
+ * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * As a special exception, if you link this(includeed from sdcc) library
+ * with other files, some of which are compiled with SDCC,
+ * to produce an executable, this library does not by itself cause
+ * the resulting executable to be covered by the GNU General Public License.
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ */
+
+#ifndef IODEF_AMP_H
+#define IODEF_AMP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define _PORT_MUTE LATEbits.LATE0
+#define _PORT_RADIOPOW LATEbits.LATE1
+//#ifdef __SDCC
+
+/*
+ * RF Preamp
+ */
+#define _RFAMP_SEL_B0 LATCbits.LATC0
+#define _RFAMP_SEL_B1 LATCbits.LATC2
+
+enum {
+ RFAMP_OFF = 0,
+ RFAMP_FM = 0,
+ RFAMP_MWLW = 2,
+ RFAMP_SW = 1
+ /* 3 = Reserve*/
+};
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IODEF_AMP_H */
+
--- /dev/null
+/*
+ * OpenI2CRADIO
+ * I/O Port defines / I2C.
+ * Copyright (C) 2013-08-22 K.Ohta <whatisthis.sowhat ai gmail.com>
+ * License: GPL2+LE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ * This library / program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; see the file COPYING. If not, write to the
+ * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * As a special exception, if you link this(includeed from sdcc) library
+ * with other files, some of which are compiled with SDCC,
+ * to produce an executable, this library does not by itself cause
+ * the resulting executable to be covered by the GNU General Public License.
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ */
+
+#ifndef IODEF_I2C_H
+#define IODEF_I2C_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Machine depended flags
+ */
+#if defined(__SDCC)
+#if defined(pic18f23k22) || defined(pic18f24k22) || defined(pic18f25k22) || defined(pic18f26k22)
+#define _I2C_IO_TWO_MSSPS
+#define _PIO_HAS_THREE
+#endif
+
+#if defined(pic18f23k20) || defined(pic18f24k20) || defined(pic18f25k20) || defined(pic18f26k20)
+#define _I2C_IO_ONE_MSSP
+#define _PIO_HAS_THREE
+#endif
+
+#if defined(pic18f43k20) || defined(pic18f44k20) || defined(pic18f45k20) || defined(pic18f46k20)
+#define _I2C_IO_ONE_MSSP
+#define _PIO_HAS_FIVE
+#endif
+#else // __XC
+
+#if defined(_18F23K22) || defined(_18F24K22) || defined(_18F25K22) || defined(_18F26K22)
+#define _I2C_IO_TWO_MSSPS
+#define _PIO_HAS_THREE
+#endif
+
+#if defined(_18F23K20) || defined(_18F24K20) || defined(_18F25K20) || defined(_18F26K20)
+#define _I2C_IO_ONE_MSSP
+#define _PIO_HAS_THREE
+#endif
+
+#if defined(_18F43K20) || defined(_18F44K20) || defined(_18F45K20) || defined(_18F46K20)
+#define _I2C_IO_ONE_MSSP
+#define _PIO_HAS_FIVE
+#endif
+#endif
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IODEF_I2C_H */
+
--- /dev/null
+/*
+ * OpenI2CRADIO
+ * I/O Port defines / KEYBOARD.
+ * Copyright (C) 2013-08-22 K.Ohta <whatisthis.sowhat ai gmail.com>
+ * License: GPL2+LE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ * This library / program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; see the file COPYING. If not, write to the
+ * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * As a special exception, if you link this(includeed from sdcc) library
+ * with other files, some of which are compiled with SDCC,
+ * to produce an executable, this library does not by itself cause
+ * the resulting executable to be covered by the GNU General Public License.
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ */
+
+#ifndef IODEF_KEY_H
+#define IODEF_KEY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define _KEY_SENDPORT LATA
+#define _KEY_RECVPORT PORTB
+#define _KEY_GRP1MASK 0x01
+#define _KEY_GRP2MASK 0x02
+#define _KEY_GRP3MASK 0x04
+#define _KEY_GRP4MASK 0x08
+#define _KEY_SENDPORTMASK (_KEY_GRP1MASK | _KEY_GRP2MASK | _KEY_GRP3MASK | _KEY_GRP4MASK)
+#define _KEY_SEND_GRP1 LATAbits.LATA0
+#define _KEY_SEND_GRP2 LATAbits.LATA1
+#define _KEY_SEND_GRP3 LATAbits.LATA2
+#define _KEY_SEND_GRP4 LATAbits.LATA3
+#define _KEY_POS1MASK(p) p.b0
+#define _KEY_POS2MASK(p) p.b1
+#define _KEY_POS3MASK(p) p.b2
+#define _KEY_POS4MASK(p) p.b3
+
+typedef union {
+ struct {
+ unsigned BIT0A:1;
+ unsigned BIT1A:1;
+ unsigned BIT2A:1;
+ unsigned BIT3A:1;
+
+ unsigned BIT0B:1;
+ unsigned BIT1B:1;
+ unsigned BIT2B:1;
+ unsigned BIT3B:1;
+
+ unsigned BIT0C:1;
+ unsigned BIT1C:1;
+ unsigned BIT2C:1;
+ unsigned BIT3C:1;
+
+ unsigned BIT0D:1;
+ unsigned BIT1D:1;
+ unsigned BIT2D:1;
+ unsigned BIT3D:1;
+
+ };
+ unsigned char byte[2];
+} keyin_defs;
+
+enum {
+ charcode_null = 0,
+ charcode_1,
+ charcode_2,
+ charcode_3,
+ charcode_4,
+ charcode_5,
+ charcode_6,
+ charcode_7,
+ charcode_8,
+ charcode_9,
+ charcode_a,
+ charcode_b,
+ charcode_c,
+ charcode_d,
+ charcode_e,
+ charcode_f,
+ charcode_0,
+ // Special keys was removed.
+};
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IODEF_KEY_H */
+
--- /dev/null
+/*
+ * OpenI2CRADIO
+ * I/O Port defines / LCD.
+ * Copyright (C) 2013-08-22 K.Ohta <whatisthis.sowhat ai gmail.com>
+ * License: GPL2+LE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ * This library / program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; see the file COPYING. If not, write to the
+ * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * As a special exception, if you link this(includeed from sdcc) library
+ * with other files, some of which are compiled with SDCC,
+ * to produce an executable, this library does not by itself cause
+ * the resulting executable to be covered by the GNU General Public License.
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ */
+
+#ifndef IODEF_LCD_H
+#define IODEF_LCD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define _LCD_BACKLIGHT LATC
+#define _LCD_BACKLIGHT_BIT b1
+#define _LCD_BACKLIGHT_TRIS TRISC
+//#else
+//#define _LCD_BACKLIGHT _PORTC_RC2_MASK
+//#endif // __SDCC
+
+#define _LCD_PORT LATC
+
+/*
+ * LCD Control: Default register values, You should re-define in iodef.h if you need.
+ */
+
+#ifdef _LCD_IF_4BIT
+/*
+ * 4bit Interface, Used Below:
+ * PORTD: RD0 : RS
+ * RD1 : RW
+ * RD2 : EN
+ * RD4-RD7: DATA(4-7).
+ */
+#ifndef _LCDPORT_DATA
+#define _LCDPORT_DATA PORTD
+#define _LCDPORT_TRIS_DATA TRISD
+#define _LCDPORT_LATCH_DATA LATD
+#define _LCDPORT_BUSYMASK 0b10000000
+#define _LCDPORT_READMASK TRIS_D_RVAL
+#define _LCDPORT_DATA_SHIFT 4
+#endif
+
+#ifndef _LCDPORT_CONT
+#define _LCDPORT_CONT PORTD
+#define _LCDPORT_TRIS_CONT TRISD
+#define _LCDPORT_CONT_LATCH LATD
+#define _LCDPORT_CONT_RSbit b0
+#define _LCDPORT_CONT_RWbit b1
+#define _LCDPORT_CONT_ENbit b2
+#define _LCDPORT_CONT_BLbit b3
+#define _LCDPORT_CONT_RS LATDbits.LATD0
+#define _LCDPORT_CONT_RW LATDbits.LATD1
+#define _LCDPORT_CONT_EN LATDbits.LATD2
+#endif
+
+#else
+/*
+ * 8bit Interface, Used Below:
+ * PORTE: RE0 : RS
+ * RE1 : RW
+ * RE2 : EN
+ * PORTD: RD0-RD7: DATA(0-7).
+ */
+// 8bit I/F
+ #ifndef _LCDPORT_DATA
+#define _LCDPORT_DATA PORTD
+#define _LCDPORT_TRIS_DATA TRISD
+#define _LCDPORT_LATCH_DATA LATD
+#define _LCDPORT_BUSYMASK 0b10000000
+#define _LCDPORT_READMASK TRIS_D_RVAL
+ #endif
+
+ #ifndef _LCDPORT_CONT
+#define _LCDPORT_CONT PORTE
+#define _LCDPORT_TRIS_CONT TRISE
+#define _LCDPORT_CONT_RSbit 0
+#define _LCDPORT_CONT_RWbit 1
+#define _LCDPORT_CONT_ENbit 2
+#define _LCDPORT_CONT_RS _PORTE_RE0
+#define _LCDPORT_CONT_RW _PORTE_RE1
+#define _LCDPORT_CONT_EN _PORTE_RE2
+#define _LCDPORT_CONT_LATCH LATE
+ #endif
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IODEF_LCD_H */
+
T0CONbits.TMR0ON = 0;
// Clear interrupt flag
- INTCONbits.TMR0IF = 0;
+// INTCONbits.TMR0IF = 0;
INTCONbits.TMR0IE = 0;;
return;
if(INTCONbits.RBIF) RBIF_handler();
if(PIR2bits.EEIF) EEPROM_handler();
if(PIR2bits.TMR3IF) TMR3_Handler();
- if(INTCONbits.TMR0IF) TMR0_handler();
+ // if(INTCONbits.TMR0IF) TMR0_handler();
if(INTCON3bits.INT1IF) EXINT_Handler();
if(INTCON3bits.INT2IF) EXINT_Handler();
if(PIR1bits.ADIF) INADC_handler();
lvcount = 0;
}
/* Main routine*/
- c = pollkeys(pollkeybuf, 19, 1); // 23*19=437ms
+// c = pollkeys(pollkeybuf, 19, 1); // 23*19=437ms
+ c = pollkey_single_timeout(41, 1); // 23*41 = 943ms
p = 0;
- while(c > 0) {
+// while(c > 0) {
+ if(c != charcode_null) {
ClrWdt();
if(dispf == 0) {
acm1602_resume(LCD_I2CADDR);
dispf = 0xff;
}
- setfreq_updown(pollkeybuf[p]);
- c--;
- p++;
+ setfreq_updown(c);
+
+// setfreq_updown(pollkeybuf[p]);
+ // c--;
+ // p++;
}
// _LOCATE(0,0);
pbutton = chk_powerbutton(); // 48ms
acm1602_suspend(LCD_I2CADDR);
dispf = 0;
}
+ idle_time_ms(9); // Pad 9ms, 1Loop = 1000ms.
ClrWdt();
} while(1);
}
printstr("LOW");
}
_HOME();
- c = pollkeys(pollkeybuf, 5, 1);
- p = 0;
- while(c > 0) {
- switch(pollkeybuf[p]) {
+// c = pollkeys(pollkeybuf, 5, 1);
+ // p = 0;
+ c = pollkey_single_timeout(22, 1); // 506ms
+ switch(c) {
case charcode_6:
setup.volume++;
if(setup.volume > 63) setup.volume = 63;
default:
break;
}
- c--;
- p++;
+ if(setup.volume < 24){
+ set_examp_mute(1);
+ } else {
+ set_examp_mute(0);
}
- if(setup.volume < 24){
- set_examp_mute(1);
- } else {
- set_examp_mute(0);
- }
- akc6955_setvolume(setup.volume);
+ akc6955_setvolume(setup.volume);
// _HOME();
} while(1);
}
+
void scan_start(void)
{
unsigned char c;
unsigned char cc;
+ unsigned char n;
_CLS();
scanflag = 0;
- c = 0;
do {
do {
- c = pollkeys(pollkeybuf, 20, 0); // 23*20 = 460ms
+// c = pollkeys(pollkeybuf, 20, 0); // 23*20 = 460ms
+ n = pollkeys(pollkeybuf, 19, 1);
update_status();
// _HOME();
// _LOCATE(0,0);
printstr("Scan A/4/6");
print_freq(1);
_HOME();
- } while(c == 0);
-
+ } while(n == 0);
+ c = pollkeybuf[0];
// New Scan
- switch(pollkeybuf[0]){
+ switch(c){
case charcode_6:
scanflag = 0xff;
akc6955_do_scan(0xff);
void main_menu(void)
{
unsigned char c;
- unsigned char p;
- unsigned char n;
unsigned int val;
_CLS();
printstr("Menu:F=HELP");
_LOCATE(0,1);
printstr("B=CANCEL");
- do {
- n = pollkeys(pollkeybuf, 5, 1);
- } while(n == 0);
- p = 0;
- c = pollkeybuf[0];
+ c = pollkey_single(); // 1012ms
if(c == charcode_1){
// Band
setband_direct();
#
-#Wed Aug 14 04:05:32 JST 2013
+#Thu Aug 22 13:56:50 JST 2013
default.languagetoolchain.dir=/usr/local/bin
default.br-unifei-rmaalmeida-toolchainSDCC-SDCCtoolchain.md5=b67cce1ad75b450308d7806e430931b3
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=1c49f19f6a43b876c317e0d8d41c0854
<itemPath>helps.h</itemPath>
<itemPath>menu_memoryfreq.c</itemPath>
<itemPath>menu_memoryfreq.h</itemPath>
+ <itemPath>iodef_lcd.h</itemPath>
+ <itemPath>iodef_i2c.h</itemPath>
+ <itemPath>iodef_key.h</itemPath>
+ <itemPath>iodef_amp.h</itemPath>
</logicalFolder>
<sourceRootList>
<Elem>/usr/local/share/sdcc/lib/src/pic16/libc</Elem>
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
<makeCustomizationNormalizeHexFile>true</makeCustomizationNormalizeHexFile>
</makeCustomizationType>
+ <HI-TECH-COMP>
+ </HI-TECH-COMP>
+ <HI-TECH-LINK>
+ </HI-TECH-LINK>
<PICkit3PlatformTool>
<property key="AutoSelectMemRanges" value="auto"/>
<property key="Freeze Peripherals" value="true"/>
<property key="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="3.25"/>
</PICkit3PlatformTool>
+ <XC8-config-global>
+ </XC8-config-global>
+ <item path="akc6955.c" ex="false" overriding="false">
+ <sdcc>
+ </sdcc>
+ </item>
+ <item path="idle.c" ex="false" overriding="false">
+ <sdcc>
+ </sdcc>
+ </item>
<sdcc>
<property key="V-show-commands-compiler" value="true"/>
<property key="Werror" value="false"/>
_LOCATE(startx + d - i, starty);
_CURSOR_ON();
- do {
- n = pollkeys(pollkeybuf, 60, 1);
- } while(n == 0);
- c = pollkeybuf[0];
-
+ c = pollkey_single();
if(c == charcode_0){
val = subst_numeric(val, i, 0);
i--;
for(i = 0; i < 9; i++) {
idle_time_ms(2); // 2ms
readkey_io(i);
- ClrWdt();
+// ClrWdt();
}
readkey_compare();
return pop_keyinfifo();
unsigned int lifetime = 0;
unsigned int penalty = 0;
unsigned char c;
+ unsigned char i;
do {
idle_time_ms(5); // 5ms.
c = readkey(); //18ms
ClrWdt();
- if(c != charcode_null) {
- push_keyinfifo(c);
- do {
- ClrWdt();
- c = pop_keyinfifo();
- if(c == charcode_null) {
- break;
- }
- if(c != cold) {
- p[count++] = c;
- cold = c;
+ if(c != charcode_null){
+ if(cold != c) {
+ p[count++] = c;
+ cold = c;
+ count++;
+ if(repeat == 0) {
+ break;
}
- } while(count < 32);
- penalty = 0;
- } else {
+ penalty = 0;
+ }
+ } else {
penalty++;
- if((limit > 3) && (penalty > (limit >> 2))){
+ if(penalty > 4){
penalty = 0;
cold = charcode_null;
}
if(limit != 0) lifetime++;
if(lifetime > limit) break;
} while(count < 32);
- if(repeat != 0) cold = charcode_null;
+ p[count] = charcode_null;
return count;
}
unsigned int penalty = 0;
unsigned char c;
- cold = charcode_null;
+// cold = charcode_null;
do {
- idle_time_ms(5); // 0.125 * 4 * 20 = 10ms.
+ idle_time_ms(5); // 5ms.
c = readkey(); // 2 * 9 = 18ms
ClrWdt();
if(c != charcode_null) {
}
}
penalty++;
- if(penalty > 20) cold = charcode_null;
+ if(penalty > 65) cold = charcode_null; // About 1500ms
} while(1);
}
+unsigned char pollkey_single_timeout(unsigned int limit, unsigned char repeat)
+{
+ unsigned char c;
+ unsigned int ticks = 0;
+
+
+// cold = charcode_null;
+ do {
+ idle_time_ms(5); // 5ms.
+ c = readkey(); // 2 * 9 = 18ms
+ ClrWdt();
+ ticks++;
+ if(c != charcode_null) {
+ if(repeat != 0){
+ cold = c;
+ break;
+ } else {
+ if(cold != c) {
+ cold = c;
+ break;
+ }
+ }
+ }
+ if(limit != 0) {
+ ticks++;
+ if(ticks > limit) {
+ cold = charcode_null;
+ return charcode_null;
+ }
+ }
+ } while(1);
+
+ /*
+ * Set Deadzone.
+ */
+ if(limit == 0) {
+// if(ticks >= (limit >> 1)) cold = charcode_null;
+ while(ticks <= limit) {
+ idle_time_ms(5 + 18);
+ ticks++;
+ }
+ }
+ return c;
+}
/*
* Notes:
* Initialize sequence:
extern unsigned char readkey(void);
extern unsigned char pollkeys(unsigned char *p, unsigned int limit, unsigned char repeat);
extern unsigned char pollkey_single(void);
+extern unsigned char pollkey_single_timeout(unsigned int limit, unsigned char repeat);
#ifdef __cplusplus
}