akc6955_writecmd(AKC6955_POWER, b);
}
-unsigned int akc6955_set_tune(unsigned char mode_3k, unsigned int ch)
+unsigned char akc6955_tune(void)
+{
+ unsigned char b;
+ b = akc6955_readcmd(AKC6955_RCH_HI) & 0x20;
+ if(b == 0x00) {
+ return 0;
+ } else {
+ return 0xff;
+ }
+}
+
+
+void akc6955_set_tune(unsigned char mode_3k, unsigned int ch)
{
unsigned char band;
unsigned char fm;
unsigned char b;
unsigned int i;
- i = ch & 0x1fff;
+ i = ch;
fm = akc6955_readcmd(AKC6955_POWER) & 0x40;
if(fm == 0){
// AM
// BAND=AM && MW2
i = (i / 3) * 3;
}
- if(i < 0) i = 0;
if(i > 0x1fff) i = 0x1fff;
+ //i = ch & 0x1fff;
+
if(mode_3k == 0){
b = ((i >> 8) & 0x1f) | 0x40; // 32.768KHz clock
} else {
b = i & 0xff;
akc6955_writecmd(AKC6955_CH_LO, b);
akc6955_do_tune();
+ do{
+ // Use software-delay, but recommands hardware-delay ;-(
+ delay1ktcy(100); // Wait 100000 cycles = 12.5ms
+ } while(akc6955_tune() == 0);
}
void akc6955_do_scan(unsigned char up)
{
unsigned char b;
- unsigned char m;
akc6955_do_tune();
b = akc6955_readcmd(AKC6955_POWER);
b &= 0xe3;
void akc6955_set_freq(unsigned int freq)
{
unsigned int ch;
- unsigned char b;
unsigned char fm;
- unsigned char mode3k;
+ unsigned char mode3k = 0;
fm = akc6955_readcmd(AKC6955_POWER) & 0x40;
if(fm != 0) { // FM
akc6955_set_tune(mode3k, ch);
}
-unsigned char akc6955_tune(void)
-{
- unsigned char b;
- b = akc6955_readcmd(AKC6955_RCH_HI) & 0x20;
- if(b == 0x00) {
- return 0;
- } else {
- return 0xff;
- }
-}
unsigned char akc6955_get_cnr(void)
{
freq = akc6955_get_freq();
freq += step;
akc6955_set_freq(freq);
- do{
- // Use software-delay, but recommands hardware-delay ;-(
- delay1ktcy(100); // Wait 100000 cycles = 12.5ms
- } while(akc6955_tune() == 0);
return akc6955_get_freq();
}
if(freq <= step) return freq;
freq -= step;
akc6955_set_freq(freq);
- do{
- // Use software-delay, but recommands hardware-delay ;-(
- delay1ktcy(100); // Wait 100000 cycles = 12.5ms
- } while(akc6955_tune() == 0);
return akc6955_get_freq();
}