OSDN Git Service

[LCD] Fix click-noise of LCD=ON.
[openi2cradio/OpenI2CRadio.git] / iodef.h
diff --git a/iodef.h b/iodef.h
index b5ab19e..2aecfa1 100644 (file)
--- a/iodef.h
+++ b/iodef.h
@@ -1,6 +1,6 @@
 /*
  * 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 __cplusplus
-extern "C" {
-#endif
+#ifdef __SDCC
+#else
+#include <xc.h>
 
-/*
- * Machine depended flags
- */
-#if defined(__18F23K22) || defined(__18F24K22) || defined(__18F25K22) || defined(__18F26K22)
-#define _I2C_IO_TWO_MSSPS
-#define _PIO_HAS_THREE
+#ifndef _XTAL_FREQ
+#define _XTAL_FREQ 8000000
 #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
 
 /*
  * LCD(ACM1602 Type)
  */
 // If you use I2C-Type ACM1602, You should define, otherwise #undef.
 #undef _USE_I2C_1602
+#define _LCD_IF_4BIT
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "iodef_i2c.h"
 
 /*
  * MAP OF IOPORT
- * PORTA/B/C USED.
- * PORTA: RA2-RA5 : READ
- *        RA1 : SLOT D(OUT)
- *        RA0 : ADC(IN)
- *        RA6-RA7 : CLOCK
- * PORTB: RB4-RB5 : RESERVED
- *        RB6-RB7 : FOR ICSP
- *        RB3 : DEL / BAND
- *        RB2 : FUNC
- *        RB1 : Light
- *        RB0 : Light Out
- * PORTC  RC0 : LED
- *        RC1 : SLOT A
- *        RC2 : SLOT B
- *        RC5 : SLOT C
+ *
+ * RE3: VPP (ICSP Programming Voltage) / MCLR, Dont use for I/O.
+ *
+ * PORTA/B/C USED basic.
+ *
+ * PORTA:
+ *        RA0 : KO0
+ *        RA1 : KO1
+ *        RA2 : KO2
+ *        RA3 : KO7
+ *        RA4 : AM LAMP('1' = On)
+ *        RA5:  FM LAMP('1) = On)
+ *        RA6-RA7 : Used for CLOCK, connect to 8MHz resonator.
+ *
+ * PORTB:
+ *        RB0 : KI0
+ *        RB1 : KI1
+ *        RB2 : KI2
+ *        RB3 : KI3
+ *        RB4 : Power Key
+ *        RB5-RB7 : FOR ICSP
+ *
+ * PORTC: 
+ *        RC0 : RF AMP SEL bit0
+ *        RC1 : LCD-Backlight
+ *        RC2 : RF AMP SEL bit1
  *        RC3-RC4 : SCL/SDA
+ *        RC5 : Reserved
  *        RC6-RC7 : USART
+ *
  * In addition, usage of PARALLEL-LCD,You should use 40Pin(or greater) PIC.
- * PORTD: RD0-RD7 : LCD DATA(DB0-DB7)
- * PORTE: RE0: LCD RS
- *        RE1: LCD RW
- *        RE2: LCD EN
- *        RE3: VPP (ICSP Programing Voltage) / MCLR
+ * ON 4BIT LCD I/F:
+ *
+ * PORTD: 
+ *        RD0: LCD RS
+ *        RD1: LCD RW
+ *        RD2: LCD EN
+ *        RD3: POWER LAMP
+ *        RD4-RD7: LCD DB4-DB7
+ *
+ * PORTE:
+ *        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 0b11111101
-#define AN_A_VAL 0b00000001
-#define TRIS_B_VAL 0b11111110
-#define AN_B_VAL 0b00000000
-#define TRIS_C_VAL_O 0b11000000 /* FOR I2C-WRITE */
-#define TRIS_C_VAL_I 0b11011000 /* FOR I2C-WRITE */
-#define AN_C_VAL 0b00000000
-
-#define TRIS_D_VAL 0b00000000 /* FOR OUTPUT, LCD(Optional) */
-#define TRIS_E_VAL 0b00000000 /* FOR OUTPUT, LCD(Optional), PSP=OFF */
-
-
-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;
-
-    /*
-     * special keys
-     */
-    unsigned BIT0F:1;
-    unsigned BIT1F:1;
-    unsigned BIT2F:1;
-    unsigned BIT3F:1;
-    unsigned :1;
-    unsigned :1;
-    unsigned :1;
-    unsigned :1;
-    };
-    unsigned char byte[3];
-} 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,
-    charcode_s0, // RB1
-    charcode_s1, // RB2
-    charcode_s2, // RB3
-    charcode_s3, // Reserve
-};
+#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 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 0x07
+#define _REF_ADC 0x10
+#define _ADC_INITF ANS7
+#define _ADCH_INITF 0x00
+
+#include "iodef_amp.h"
 /*
- * LCD Control: Default register values, You should re-define in iodef.h if you need.
+ * Lamp
  */
-#ifndef _LCDPORT_DATA
-#define _LCDPORT_DATA PORTD
-#define _LCDPORT_TRIS_DATA TRISD
-#define _LCDPORT_LATCH_DATA LATD
-#endif
+#define _AM_STATLAMP  LATAbits.LATA4
+#define _FM_STATLAMP  LATAbits.LATA5
+#define _POW_STATLAMP LATDbits.LATD3
 
-#ifndef _LCDPORT_CONT
-#define _LCDPORT_CONT PORTE
-#define _LCDPORT_TRIS_CONT TRISE
-#define _LCDPORT_CONT_RS _PORTE_RE0
-#define _LCDPORT_CONT_RW _PORTE_RE1
-#define _LCDPORT_CONT_EN _PORTE_RE2
-#define _LCDPORT_CONT_LATCH LATE
-#endif
+#include "iodef_key.h"
+#include "iodef_lcd.h"
 
 #ifdef __cplusplus
 }