OSDN Git Service

[SCHEMATIC] Modify SW/MW/LW Preamp, insert galbanic-isolator replace of common-mode...
[openi2cradio/OpenI2CRadio.git] / iodef.h
diff --git a/iodef.h b/iodef.h
index 4f4c485..c63f1e1 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" {
+#ifdef __SDCC
+#else
+#include <xc.h>
+
+#ifndef _XTAL_FREQ
+#define _XTAL_FREQ 8000000
 #endif
 
+#endif
+
+
 /*
  * LCD(ACM1602 Type)
  */
@@ -40,24 +47,12 @@ extern "C" {
 #undef _USE_I2C_1602
 #define _LCD_IF_4BIT
 
-/*
- * Machine depended flags
- */
-#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
+#ifdef __cplusplus
+extern "C" {
 #endif
 
+#include "iodef_i2c.h"
 
 /*
  * MAP OF IOPORT
@@ -66,179 +61,82 @@ extern "C" {
  *
  * PORTA/B/C USED basic.
  *
- * PORTA: RA0 : ADC(IN) to measure battery .
- *        RA1 : SLOT D(OUT)
- *        RA2-RA5 : READ
+ * 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 : Light Out
- *        RB1 : Light
- *        RB2 : FUNC
- *        RB3 : DEL / BAND
- *        RB4-RB5 : RESERVED
- *        RB6-RB7 : FOR ICSP
+ * PORTB:
+ *        RB0 : KI0
+ *        RB1 : KI1
+ *        RB2 : KI2
+ *        RB3 : KI3
+ *        RB4 : Power Key
+ *        RB5-RB7 : FOR ICSP
  *
- * PORTC: RC0 : LED
- *        RC1 : SLOT A
- *        RC2 : SLOT B
+ * PORTC: 
+ *        RC0 : RF AMP SEL bit0
+ *        RC1 : LCD-Backlight
+ *        RC2 : RF AMP SEL bit1
  *        RC3-RC4 : SCL/SDA
- *        RC5 : SLOT C
+ *        RC5 : Reserved
  *        RC6-RC7 : USART
  *
  * In addition, usage of PARALLEL-LCD,You should use 40Pin(or greater) PIC.
  * ON 4BIT LCD I/F:
  *
- * PORTD: RD0: LCD RS
+ * PORTD: 
+ *        RD0: LCD RS
  *        RD1: LCD RW
  *        RD2: LCD EN
- *        RD3: RESERVED.
- *        RD4-RD7 : LCD DATA(DB4-DB7)
+ *        RD3: POWER LAMP
+ *        RD4-RD7: LCD DB4-DB7
  *
- * PORTD: RE0: FM AMP SW(OUT)
- *        RE1: MW AMP SW(OUT)
- *        RE2: SW AMP SW(OUT)
- *        RE3: VPP (ICSP Programming Voltage) / MCLR
- *
- * ON 8BIT LCD I/F:
- * PORTD: RD0-RD7 : LCD DATA(DB0-DB7)
- * PORTE: RE0: LCD RS
- *        RE1: LCD RW
- *        RE2: LCD EN
+ * 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 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 0b11000000 /* FOR I2C-WRITE */
-#define TRIS_C_VAL_I 0b11011000 /* 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 0b11110000 /* 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   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
-};
 
-/*
- * 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
- #endif
-
- #ifndef _LCDPORT_CONT
-#define _LCDPORT_CONT PORTD
-#define _LCDPORT_TRIS_CONT TRISD
-#define _LCDPORT_CONT_RS _PORTD_RD0
-#define _LCDPORT_CONT_RW _PORTD_RD1
-#define _LCDPORT_CONT_EN _PORTD_RD2
-#define _LCDPORT_CONT_LATCH LATD
- #endif
+#define TRIS_E_VAL   0b00000100 /* FOR OUTPUT, ADC, PSP=OFF */
 
-#else
+#define _BATT_ADC 0x07
+#define _REF_ADC 0x10
+#define _ADC_INITF ANS7
+#define _ADCH_INITF 0x00
+
+#include "iodef_amp.h"
 /*
- * 8bit Interface, Used Below:
- * PORTE: RE0 : RS
- *        RE1 : RW
- *        RE2 : EN
- * PORTD: RD0-RD7: DATA(0-7).
+ * Lamp
  */
-// 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_RS _PORTE_RE0
-#define _LCDPORT_CONT_RW _PORTE_RE1
-#define _LCDPORT_CONT_EN _PORTE_RE2
-#define _LCDPORT_CONT_LATCH LATE
- #endif
-#endif
+#define _AM_STATLAMP  LATAbits.LATA4
+#define _FM_STATLAMP  LATAbits.LATA5
+#define _POW_STATLAMP LATDbits.LATD3
+
+#include "iodef_key.h"
+#include "iodef_lcd.h"
 
 #ifdef __cplusplus
 }