#ifndef AKC6955_H
#define AKC6955_H
+#include "i2c_io.h"
+
#ifdef __cplusplus
extern "C" {
#endif
#define AKC6955_CH_HI 2
#define AKC6955_CH_LO 3
#define AKC6955_UCH_ST 4
-#define AKC6955_UCS_EN 5
+#define AKC6955_UCH_EN 5
#define AKC6955_VOLUME 6
#define AKC6955_STEREO 7
#define AKC6955_THRESH 8
#define AKC6955_ENABLE 9
-// 10 = RESERVE
+#define AKC6955_FM_SEEKSTEP 10
#define AKC6955_SPACE 11
-// 12 = RESERVE
+#define AKC6955_ADCEN 12
#define AKC6955_PRE 13
// 14-19 = RESERVE
AKC6955_BAND_SW13, // 11400~17900KHz, 5KHz order
AKC6955_BAND_AMUSER, // User Setting
AKC6955_BAND_MW4, // 520~1730KHz, 5KHz order
+ AKC6955_BAND_AMEND
};
AKC6955_BAND_TV1, // 56.25~91.75MHz
AKC6955_BAND_TV2, // 174.75~222.25MHz
AKC6955_BAND_FMUSER, // User Setting
+ AKC6955_BAND_FMEND
};
-
/*
- * Resister definitions
+ * Band defines
*/
- typedef union{
- unsigned char byte;
- struct {
- unsigned power_on :1;
- unsigned fm_en :1;
- unsigned tune :1;
- unsigned seek :1;
- unsigned seekdir :1;
- unsigned mute :1;
- unsigned reserve :2;
- };
- } AKC6955_Reg0;
-
+typedef struct {
+ unsigned int start;
+ unsigned int end;
+} banddesc;
// MCU Clock = 8MHz
-// Wait 62.5ms
-#define _AKC6955_WAIT_62_5MS() delay1ktcy(500)
+
+#define _AKC6955_WAIT_62_5MS() idle_time_62_5ms()
+// Wait 12.5ms
+#define _AKC6955_WAIT_12_5MS() idle_time_ms(13)
+// Wait 125.0ms
+#define _AKC6955_WAIT_125_0MS() idle_time_ms(125)
+
+
+#ifdef __SDCC
+ // Wait 62.5ms
+//#define _AKC6955_WAIT_62_5MS() delay1ktcy(500)
// Wait 12.5ms
-#define _AKC6955_WAIT_12_5MS() delay1ktcy(100)
+//#define _AKC6955_WAIT_12_5MS() delay1ktcy(100)
+// Wait 125.0ms
+//#define _AKC6955_WAIT_125_0MS() delay10ktcy(100)
// Wait 50us
#define _AKC6955_WAIT_12_5uS() delay10tcy(40)
+#else
+#ifndef _XTAL_FREQ
+#define _XTAL_FREQ 8000000
+#endif
+//#define _AKC6955_WAIT_62_5MS() __delay_ms(63)
+// Wait 12.5ms
+//#define _AKC6955_WAIT_12_5MS() __delay_ms(13)
+// Wait 125.0ms
+//#define _AKC6955_WAIT_125_0MS() idle_time_ms(125)
+//#define _AKC6955_WAIT_125_0MS() {_delay_ms(63); _deyal_ms(62);}
+// Wait 50us
+#define _AKC6955_WAIT_12_5uS() __delay_us(13)
+#endif
-extern void akc6955_writecmd(unsigned char reg, unsigned char data);
extern unsigned char akc6955_readcmd(unsigned char reg);
-extern void akc6955_chg_fm(unsigned char fm);
+extern void akc6955_writecmd(unsigned char reg,unsigned char data);
+extern unsigned char akc6955_getband(void);
+extern unsigned char akc6955_get_amband(void);
+extern unsigned char akc6955_get_fmband(void);
+extern void akc6955_chg_fm(unsigned char fm, unsigned int freq);
+extern unsigned char akc6955_get_fm(void);
+extern unsigned char akc6955_get_band(void);
extern void akc6955_set_amband(unsigned char band);
extern void akc6955_set_fmband(unsigned char band);
-extern unsigned char akc6955_get_amband(void);
-extern unsigned char akc6955_get_fmband(void);
extern void akc6955_set_power(unsigned char on);
extern void akc6955_do_tune(void);
extern unsigned char akc6955_tune(void);
-
-extern unsigned int akc6955_mode3k(unsigned char flag);
extern void akc6955_set_tune(unsigned char mode_3k, unsigned int ch);
-extern void akc6955_do_scan(unsigned char up);
+extern void akc6955_mode3k(unsigned char flag);
+extern unsigned char akc6955_get_mode3k(void);
+
+extern void akc6955_do_scan(unsigned char up);
+extern void akc6955_abort_scan(void);
extern unsigned char akc6955_chk_donescan(void);
+
+extern unsigned int akc6955_get_channel(void);
extern unsigned int akc6955_get_freq(void);
extern void akc6955_set_freq(unsigned int freq);
extern unsigned char akc6955_get_cnr(void);
+extern void akc6955_set_userband(unsigned char start, unsigned char stop, unsigned int ch, unsigned char mode3k);
extern int akc6955_read_level(void);
-extern unsigned int akc6955_up_freq(unsigned int step);
-extern unsigned int akc6955_down_freq(unsigned int step);
+extern void akc6955_up_freq(unsigned int step);
+extern void akc6955_down_freq(unsigned int step);
+extern int akc6955_get_diff(void);
+
+extern void akc6955_setvolume(unsigned char level);
+extern void akc6955_setvolumemode(unsigned char flag);
+extern unsigned char akc6955_getvolumemode(void);
+extern unsigned char akc6955_getvolume(void);
+extern unsigned char akc6955_get_prevolume(void);
+extern void akc6955_set_prevolume(unsigned char level);
+
+extern void akc6955_setphase(unsigned char flag);
+extern void akc6955_setline(unsigned char flag);
+extern void akc6955_set_stereomode(unsigned char mode);
+extern unsigned char akc6955_get_stereo(void);
+extern void akc6955_set_scanrate_fm(unsigned char rate);
+extern unsigned char akc6955_get_scanrate_fm(void);
+extern unsigned int akc6955_get_battery(void);
+extern void akc6955_set_lowboost(unsigned char flag);
+extern void akc6955_set_thresh_fmstereo(unsigned char a);
+extern void akc6955_set_thresh_fmcnr(unsigned char a);
+extern void akc6955_set_thresh_amcnr(unsigned char a);
+extern void akc6955_set_thresh_width(unsigned char a);
+extern void akc6955_set_fmbandwidth(unsigned char bw);
+extern unsigned char akc6955_get_fmbandwidth(void);
+
+
+
-
#ifdef __cplusplus
}