OSDN Git Service

[SCHEMATIC] Modify SW/MW/LW Preamp, insert galbanic-isolator replace of common-mode...
[openi2cradio/OpenI2CRadio.git] / akc6955.h
1 /*
2  * OpenI2CRADIO
3  * RADIO CHIP AKC6955 Handler(Header)
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 AKC6955_H
30 #define AKC6955_H
31
32 #include "i2c_io.h"
33
34 #ifdef  __cplusplus
35 extern "C" {
36 #endif
37
38 #define AKC6955_ADDRESS 0x20
39
40 /*
41  * Register definisions.
42  */
43 #define AKC6955_POWER  0
44 #define AKC6955_BAND   1
45 #define AKC6955_CH_HI  2
46 #define AKC6955_CH_LO  3
47 #define AKC6955_UCH_ST 4
48 #define AKC6955_UCH_EN 5
49 #define AKC6955_VOLUME 6
50 #define AKC6955_STEREO 7
51 #define AKC6955_THRESH 8
52 #define AKC6955_ENABLE 9
53 #define AKC6955_FM_SEEKSTEP 10
54 #define AKC6955_SPACE  11
55 #define AKC6955_ADCEN 12
56 #define AKC6955_PRE 13
57 // 14-19 = RESERVE
58
59 // Read only registers
60 #define AKC6955_RCH_HI   20
61 #define AKC6955_RCH_LO   21
62 #define AKC6955_CNR_AM   22
63 #define AKC6955_CNR_FM   23
64 #define AKC6955_PGALEVEL 24
65 #define AKC6955_VBAT     25
66 #define AKC6955_FDNUM    26
67 #define AKC6955_RSSI     27
68
69 /*
70  * BAND DEFINES
71  */
72
73     enum {
74         AKC6955_BAND_LW = 0, // 150~285KHz, 3KHz order
75         AKC6955_BAND_MW1,    // 520~1710KHz, 5KHz order
76         AKC6955_BAND_MW2,    // 522~1620KHz, 9KHz order
77         AKC6955_BAND_MW3,    // 520~1710KHz, 10KHz order
78
79         AKC6955_BAND_SW1,    // 4700~10000KHz, 5KHz order
80         AKC6955_BAND_SW2,    // 3200~4100KHz, 5KHz order
81         AKC6955_BAND_SW3,    // 4700~5600KHz, 5KHz order
82         AKC6955_BAND_SW4,    // 5700~6400KHz, 5KHz order
83
84         AKC6955_BAND_SW5,    // 6800~7600KHz, 5KHz order
85         AKC6955_BAND_SW6,    // 9200~10000KHz, 5KHz order
86         AKC6955_BAND_SW7,    // 11400~12200KHz, 5KHz order
87         AKC6955_BAND_SW8,    // 13500~14300KHz, 5KHz order
88
89         AKC6955_BAND_SW9,    // 15000~15900KHz, 5KHz order
90         AKC6955_BAND_SW10,   // 17400~17900KHz, 5KHz order
91         AKC6955_BAND_SW11,   // 18900~19700KHz, 5KHz order
92         AKC6955_BAND_SW12,   // 21400~21900KHz, 5KHz order
93
94         AKC6955_BAND_SW13,   // 11400~17900KHz, 5KHz order
95         AKC6955_BAND_AMUSER, // User Setting
96         AKC6955_BAND_MW4,    // 520~1730KHz, 5KHz order
97         AKC6955_BAND_AMEND
98     };
99
100
101     enum {
102         AKC6955_BAND_FM1 = 0, // 87.0~108.0MHz
103         AKC6955_BAND_FM2,     // 76.0~108.0MHz
104         AKC6955_BAND_FM3,     // 70.0~93.0MHz
105         AKC6955_BAND_FM4,     // 76.0~90.0MHz
106         AKC6955_BAND_FM5,     // 64.0~88.0MHz
107         AKC6955_BAND_TV1,     // 56.25~91.75MHz
108         AKC6955_BAND_TV2,     // 174.75~222.25MHz
109         AKC6955_BAND_FMUSER,  // User Setting
110         AKC6955_BAND_FMEND
111     };
112 /*
113  * Band defines
114  */
115 typedef struct {
116     unsigned int start;
117     unsigned int end;
118 } banddesc;
119 // MCU Clock = 8MHz
120
121 #define _AKC6955_WAIT_62_5MS()     idle_time_62_5ms()
122 // Wait 12.5ms
123 #define _AKC6955_WAIT_12_5MS()     idle_time_ms(13)
124 // Wait 125.0ms
125 #define _AKC6955_WAIT_125_0MS()   idle_time_ms(125)
126
127
128 #ifdef __SDCC
129      // Wait 62.5ms
130 //#define _AKC6955_WAIT_62_5MS()     delay1ktcy(500)
131 // Wait 12.5ms
132 //#define _AKC6955_WAIT_12_5MS()     delay1ktcy(100)
133 // Wait 125.0ms
134 //#define _AKC6955_WAIT_125_0MS()     delay10ktcy(100)
135 // Wait 50us
136 #define _AKC6955_WAIT_12_5uS()     delay10tcy(40)
137 #else
138 #ifndef _XTAL_FREQ
139 #define _XTAL_FREQ 8000000
140 #endif
141
142 //#define _AKC6955_WAIT_62_5MS()     __delay_ms(63)
143 // Wait 12.5ms
144 //#define _AKC6955_WAIT_12_5MS()     __delay_ms(13)
145 // Wait 125.0ms
146 //#define _AKC6955_WAIT_125_0MS()    idle_time_ms(125)
147 //#define _AKC6955_WAIT_125_0MS()    {_delay_ms(63); _deyal_ms(62);}
148 // Wait 50us
149 #define _AKC6955_WAIT_12_5uS()     __delay_us(13)
150 #endif
151
152 extern unsigned char akc6955_readcmd(unsigned char reg);
153 extern void akc6955_writecmd(unsigned char reg,unsigned char data);
154 extern unsigned char akc6955_getband(void);
155 extern unsigned char akc6955_get_amband(void);
156 extern unsigned char akc6955_get_fmband(void);
157 extern void akc6955_chg_fm(unsigned char fm, unsigned int freq);
158 extern unsigned char akc6955_get_fm(void);
159 extern unsigned char akc6955_get_band(void);
160      
161 extern void akc6955_set_amband(unsigned char band);
162 extern void akc6955_set_fmband(unsigned char band);
163
164      
165 extern void akc6955_set_power(unsigned char on);
166 extern void akc6955_do_tune(void);
167 extern unsigned char akc6955_tune(void);
168 extern void akc6955_set_tune(unsigned char mode_3k, unsigned int ch);
169
170 extern void akc6955_mode3k(unsigned char flag);
171 extern unsigned char akc6955_get_mode3k(void);
172
173 extern void akc6955_do_scan(unsigned char up);
174 extern void akc6955_abort_scan(void);
175 extern unsigned char akc6955_chk_donescan(void);
176
177 extern unsigned int akc6955_get_channel(void);
178 extern unsigned int akc6955_get_freq(void);
179 extern void akc6955_set_freq(unsigned int freq);
180 extern unsigned char akc6955_get_cnr(void);
181 extern void akc6955_set_userband(unsigned char start, unsigned char stop, unsigned int ch, unsigned char mode3k);
182
183 extern int akc6955_read_level(void);
184 extern void akc6955_up_freq(unsigned int step);
185 extern void akc6955_down_freq(unsigned int step);
186 extern int akc6955_get_diff(void);
187
188 extern void akc6955_setvolume(unsigned char level);
189 extern void akc6955_setvolumemode(unsigned char flag);
190 extern unsigned char akc6955_getvolumemode(void);
191 extern unsigned char akc6955_getvolume(void);
192 extern unsigned char akc6955_get_prevolume(void);
193 extern void akc6955_set_prevolume(unsigned char level);
194
195 extern void akc6955_setphase(unsigned char flag);
196 extern void akc6955_setline(unsigned char flag);
197 extern void akc6955_set_stereomode(unsigned char mode);
198 extern unsigned char akc6955_get_stereo(void);
199 extern void akc6955_set_scanrate_fm(unsigned char rate);
200 extern unsigned char akc6955_get_scanrate_fm(void);
201 extern unsigned int akc6955_get_battery(void);
202 extern void akc6955_set_lowboost(unsigned char flag);
203 extern void akc6955_set_thresh_fmstereo(unsigned char a);
204 extern void akc6955_set_thresh_fmcnr(unsigned char a);
205 extern void akc6955_set_thresh_amcnr(unsigned char a);
206 extern void akc6955_set_thresh_width(unsigned char a);
207 extern void akc6955_set_fmbandwidth(unsigned char bw);
208 extern unsigned char akc6955_get_fmbandwidth(void);
209
210
211
212
213
214 #ifdef  __cplusplus
215 }
216 #endif
217
218 #endif  /* AKC6955_H */
219