/*
* 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
* RA1 : KO1
* RA2 : KO2
* RA3 : KO7
- * RA2-RA5 : READ
+ * RA4 : AM LAMP('1' = On)
+ * RA5: FM LAMP('1) = On)
* RA6-RA7 : Used for CLOCK, connect to 8MHz resonator.
*
* PORTB:
* RD4-RD7: LCD DB4-DB7
*
* PORTE:
- * RE0:
- * RE1:
+ * RE0: External Power AMP
+ * RE1: Power to Radio-Chip.
* RE2: ADC(IN) to measure battery
* RE3: VPP (ICSP Programming Voltage) / MCLR
*/
#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 TRIS_C_VAL_O 0b10011000 /* FOR I2C-WRITE, RC7=INPUT */
+#define TRIS_C_VAL_I 0b10011000 /* FOR I2C-WRITE, RC7=INPUT */
#define AN_C_VAL 0b00000000
-#define TRIS_D_VAL 0b00000000 /* FOR OUTPUT, LCD(Optional) */
+
+#define TRIS_D_VAL 0b00001000 /* RD3="RTS IN" another = FOR OUTPUT, LCD(Optional) */
#ifdef _LCD_IF_4BIT
- #define TRIS_D_RVAL 0xf0 /* FOR INPUT*/
+ #define TRIS_D_RVAL 0b11111000 /* RD3="RTS IN" FOR INPUT*/
#else
- #define TRIS_D_RVAL 0b11111111 /* FOR INPUT*/
+ #define TRIS_D_RVAL 0b11111111 /* RD3="RTS IN" FOR INPUT*/
#endif
+
#define TRIS_E_VAL 0b00000100 /* FOR OUTPUT, ADC, PSP=OFF */
-#define _BATT_ADC AN7
+
+#define _BATT_ADC 0x07
+#define _REF_ADC 0x10
#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
}