OSDN Git Service

[SCHEMATIC] Modify SW/MW/LW Preamp, insert galbanic-isolator replace of common-mode...
[openi2cradio/OpenI2CRadio.git] / iodef.h
1 /*
2  * OpenI2CRADIO
3  * I/O Port defines / Main.
4  * Copyright (C) 2013-06-10 K.Ohta <whatisthis.sowhat ai gmail.com>
5  * License: GPL2+LE
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2,
10  *  or (at your option) any later version.
11  *  This library / program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  *  See the GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this library; see the file COPYING. If not, write to the
18  *  Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19  *  MA 02110-1301, USA.
20  *
21  *  As a special exception, if you link this(includeed from sdcc) library
22  *  with other files, some of which are compiled with SDCC,
23  *  to produce an executable, this library does not by itself cause
24  *  the resulting executable to be covered by the GNU General Public License.
25  *  This exception does not however invalidate any other reasons why
26  *  the executable file might be covered by the GNU General Public License.
27  */
28
29 #ifndef IODEF_H
30 #define IODEF_H
31
32 #ifdef __SDCC
33 #else
34 #include <xc.h>
35
36 #ifndef _XTAL_FREQ
37 #define _XTAL_FREQ 8000000
38 #endif
39
40 #endif
41
42
43 /*
44  * LCD(ACM1602 Type)
45  */
46 // If you use I2C-Type ACM1602, You should define, otherwise #undef.
47 #undef _USE_I2C_1602
48 #define _LCD_IF_4BIT
49
50
51 #ifdef  __cplusplus
52 extern "C" {
53 #endif
54
55 #include "iodef_i2c.h"
56
57 /*
58  * MAP OF IOPORT
59  *
60  * RE3: VPP (ICSP Programming Voltage) / MCLR, Dont use for I/O.
61  *
62  * PORTA/B/C USED basic.
63  *
64  * PORTA:
65  *        RA0 : KO0
66  *        RA1 : KO1
67  *        RA2 : KO2
68  *        RA3 : KO7
69  *        RA4 : AM LAMP('1' = On)
70  *        RA5:  FM LAMP('1) = On)
71  *        RA6-RA7 : Used for CLOCK, connect to 8MHz resonator.
72  *
73  * PORTB:
74  *        RB0 : KI0
75  *        RB1 : KI1
76  *        RB2 : KI2
77  *        RB3 : KI3
78  *        RB4 : Power Key
79  *        RB5-RB7 : FOR ICSP
80  *
81  * PORTC: 
82  *        RC0 : RF AMP SEL bit0
83  *        RC1 : LCD-Backlight
84  *        RC2 : RF AMP SEL bit1
85  *        RC3-RC4 : SCL/SDA
86  *        RC5 : Reserved
87  *        RC6-RC7 : USART
88  *
89  * In addition, usage of PARALLEL-LCD,You should use 40Pin(or greater) PIC.
90  * ON 4BIT LCD I/F:
91  *
92  * PORTD: 
93  *        RD0: LCD RS
94  *        RD1: LCD RW
95  *        RD2: LCD EN
96  *        RD3: POWER LAMP
97  *        RD4-RD7: LCD DB4-DB7
98  *
99  * PORTE:
100  *        RE0: External Power AMP
101  *        RE1: Power to Radio-Chip.
102  *        RE2: ADC(IN) to measure battery
103  *        RE3: VPP (ICSP Programming Voltage) / MCLR
104  */
105
106 #define TRIS_A_VAL   0b11000000
107 #define AN_A_VAL     0b00000000
108
109 #define TRIS_B_VAL   0b11111111 /* PORTB as INPUT.*/
110 #define AN_B_VAL     0b00000000
111
112 #define TRIS_C_VAL_O 0b10011000 /* FOR I2C-WRITE, RC7=INPUT */
113 #define TRIS_C_VAL_I  0b10011000 /* FOR I2C-WRITE, RC7=INPUT */
114 #define AN_C_VAL     0b00000000
115
116 #define TRIS_D_VAL   0b00001000 /* RD3="RTS IN" another = FOR OUTPUT, LCD(Optional) */
117 #ifdef _LCD_IF_4BIT
118  #define TRIS_D_RVAL 0b11111000 /* RD3="RTS IN" FOR INPUT*/
119 #else
120  #define TRIS_D_RVAL 0b11111111 /* RD3="RTS IN" FOR INPUT*/
121 #endif
122
123 #define TRIS_E_VAL   0b00000100 /* FOR OUTPUT, ADC, PSP=OFF */
124
125 #define _BATT_ADC 0x07
126 #define _REF_ADC 0x10
127 #define _ADC_INITF ANS7
128 #define _ADCH_INITF 0x00
129
130 #include "iodef_amp.h"
131 /*
132  * Lamp
133  */
134 #define _AM_STATLAMP  LATAbits.LATA4
135 #define _FM_STATLAMP  LATAbits.LATA5
136 #define _POW_STATLAMP LATDbits.LATD3
137
138 #include "iodef_key.h"
139 #include "iodef_lcd.h"
140
141 #ifdef  __cplusplus
142 }
143 #endif
144
145 #endif  /* IODEF_H */
146