#include "commondef.h"
#include "menu.h"
-void akc6955_writecmd(unsigned char reg, unsigned char data)
-{
-#ifdef __SDCC
- i2c_open(I2C_MASTER, I2C_SLEW_ON, 5);
- I2C_START();
- i2c_writechar(0x20);
- i2c_writechar(reg);
- i2c_writechar(data);
- I2C_STOP();
- i2c_close();
- delay100tcy(2);
-#else
- OpenI2C(MASTER, SLEW_OFF);
- StartI2C();
- WriteI2C(0x20);
- //delay1ktcy(8);
- WriteI2C(reg);
- //delay1ktcy(8);
- WriteI2C(data);
- //delay1ktcy(8);
- StopI2C();
- // delay1ktcy(8);
- CloseI2C();
-// CLOSEASMASTER();
-#endif // i2c_idle();
-}
-
-unsigned char akc6955_readcmd(unsigned char reg)
-{
- unsigned char c;
- // OPENASMASTER();
-#ifdef __SDCC
- i2c_open(I2C_MASTER, I2C_SLEW_ON, 5);
-#else
- OpenI2C(MASTER, SLEW_OFF);
-#endif
-#ifdef __SDCC
- I2C_START();
- i2c_writechar(0x20);
- i2c_writechar(reg);
- I2C_STOP();
- delay100tcy(2);
- I2C_START();
- i2c_writechar(0x21);
- c = i2c_readchar();
- I2C_ACK();
- I2C_STOP();
- i2c_close();
-#else
- StartI2C();
- WriteI2C(0x20);
- // delay1ktcy(8);
- WriteI2C(reg);
- // delay1ktcy(8);
- StopI2C();
- __delay_us(13);
- StartI2C();
- WriteI2C(0x21);
- // delay1ktcy(8);
- c = ReadI2C();
- AckI2C();
- StopI2C();
- // delay1ktcy(8);
- CloseI2C();
-#endif
- // CLOSEASMASTER();
-
- return c;
-}
void akc6955_chg_fm(unsigned char f, unsigned int freq)
{
b.b6 = 0;
if(f != 0){
b.b6 = 1;
- akc6955_set_fmband(fmband);
+ akc6955_set_fmband(setup.fmband);
akc6955_writecmd(AKC6955_POWER, b.byte);
akc6955_set_freq(freq);
return;
}
akc6955_writecmd(AKC6955_POWER, b.byte);
- akc6955_set_amband(amband);
+ akc6955_set_amband(setup.amband);
akc6955_set_freq(freq);
}
void akc6955_mode3k(unsigned char flag)
{
__bitops_t b;
+ b.byte = akc6955_readcmd(AKC6955_CH_LO);
+ akc6955_writecmd(AKC6955_CH_LO, b.byte);
+
b.byte = akc6955_readcmd(AKC6955_CH_HI);
b.b5 = 0;
if(flag != 0){
}
akc6955_writecmd(AKC6955_CH_HI, b.byte);
akc6955_do_tune();
- _AKC6955_WAIT_62_5MS();
}
void akc6955_set_tune(unsigned char mode_3k, unsigned int ch)
void akc6955_do_scan(unsigned char up)
{
__bitops_t b;
- // akc6955_do_tune();
+
+ //20130823 Need wait for scan/tune completed w/o SDCC 3.3.x.
+#ifndef __SDCC
+ while(akc6955_chk_donescan() == 0)
+ {
+ idle_time_ms(5);
+ }
+#endif
b.byte = akc6955_readcmd(AKC6955_POWER);
b.b3 = 0;
b.b4 = 0;
- b.b5 = 0;
+// 20130823 : Is this collect?
+#ifdef __SDCC
+ b.b5 = 0;
akc6955_writecmd(AKC6955_POWER, b.byte);
+ idle_time_ms(35);
+#endif
+
b.b5 = 1; // Tune 0->1.
- idle_time_35ms();
akc6955_writecmd(AKC6955_POWER, b.byte);
- idle_time_35ms();
+ idle_time_ms(35);
+
+ b.b4 = 1;
if(up != 0) {
b.b3= 1;
}
- b.b4 = 1;
akc6955_writecmd(AKC6955_POWER, b.byte); // Raise seek bit to '1'.
+ idle_time_ms(35);
}
void akc6955_abort_scan(void)
akc6955_get_fmband(band);
// band &= 7;
if(band == AKC6955_BAND_FMUSER){
- start = fm_usrbands[fm_userbandnum].start * 32;
- stop = fm_usrbands[fm_userbandnum].stop * 32;
+ start = setup.fm_usrbands[setup.fm_userbandnum].start * 32;
+ stop = setup.fm_usrbands[setup.fm_userbandnum].stop * 32;
} else {
start = fmbands[band].start;
stop = fmbands[band].end;
akc6955_get_amband(band);
// if(band >= AKC6955_BAND_AMEND) band = AKC6955_BAND_AMEND - 1;
if(band == AKC6955_BAND_AMUSER){
- start = am_usrbands[am_userbandnum].start * 32;
- stop = am_usrbands[am_userbandnum].stop * 32;
+ start = setup.am_usrbands[setup.am_userbandnum].start * 32;
+ stop = setup.am_usrbands[setup.am_userbandnum].stop * 32;
} else {
start = ambands[band].start;
stop = ambands[band].end;
freq = akc6955_get_channel();
freq += step;
- mode3k.byte = akc6955_readcmd(AKC6955_CNR_AM);
- akc6955_set_tune(mode3k.b7, freq);
+// mode3k.byte = akc6955_readcmd(AKC6955_CNR_AM);
+// akc6955_set_tune(mode3k.b7, freq);
+ akc6955_set_tune(setup.am_mode3k, freq);
}
freq = akc6955_get_channel();
if(freq <= step) return;
freq -= step;
- mode3k.byte = akc6955_readcmd(AKC6955_CNR_AM);
- akc6955_set_tune(mode3k.b7, freq);
+// mode3k.byte = akc6955_readcmd(AKC6955_CNR_AM);
+// akc6955_set_tune(mode3k.b7, freq);
+ akc6955_set_tune(setup.am_mode3k, freq);
}
void akc6955_setvolumemode(unsigned char flag)
{
unsigned char b;
a = a & 0x03;
- threshold_fmstereo = a;
+ setup.threshold_fmstereo = a;
b = akc6955_readcmd(AKC6955_THRESH) & 0xfc;
akc6955_writecmd(AKC6955_THRESH, a | b);
}
{
unsigned char b;
a = a & 0x03;
- threshold_width = a;
+ setup.threshold_width = a;
a = a << 2; // << 2
b = akc6955_readcmd(AKC6955_THRESH) & 0xf3;;
akc6955_writecmd(AKC6955_THRESH, a | b);
{
unsigned char b;
a = a & 0x03;
- threshold_amcnr = a;
+ setup.threshold_amcnr = a;
a = a << 4; // << 4
b = akc6955_readcmd(AKC6955_THRESH) & 0xcf;
akc6955_writecmd(AKC6955_THRESH, a | b);
{
unsigned char b;
a = a & 0x03;
- threshold_fmcnr = a;
+ setup.threshold_fmcnr = a;
a = a << 6; // << 4
b = akc6955_readcmd(AKC6955_THRESH) & 0x3f;
akc6955_writecmd(AKC6955_THRESH, a | b);