__bitops_t b;
unsigned int i = ch;
unsigned char comp;
+ unsigned int start;
+ unsigned int stop;
+ unsigned int q;
do { // Wait for before completed
comp = akc6955_chk_donescan();
idle_time_35ms();
} while(comp == 0x00);
+
f.byte = akc6955_readcmd(AKC6955_POWER);
band = 0;
- if(!f.b6){
- akc6955_get_amband(band);
- }
-
- if(band == AKC6955_BAND_MW2){
- // BAND=AM && MW2
- i = ch / 3; // On MW2, Channnel must be multiple of 3.
- i = i * 3; // i = (i/3) * 3
+ if(!f.b6){ // AM
+ akc6955_get_amband(band);
+ if(band == AKC6955_BAND_MW2){
+ // BAND=AM && MW2
+ i = ch / 3; // On MW2, Channnel must be multiple of 3.
+ i = i * 3; // i = (i/3) * 3
+ mode_3k = 0xff;
+ q = 3;
+ } else if(mode_3k != 0) {
+ q = 3;
+ } else {
+ q = 5;
+ }
+
+ if(band == AKC6955_BAND_AMUSER) {
+ start = setup.am_usrbands[setup.am_userbandnum].start * 32;
+ stop = setup.am_usrbands[setup.am_userbandnum].stop * 32;
+ } else {
+ start = ambands[band].start / q;
+ stop = ambands[band].end / q;
+ }
+ } else {
+ akc6955_get_fmband(band);
+ if(band == AKC6955_BAND_FMUSER) {
+ start = setup.fm_usrbands[setup.fm_userbandnum].start * 32;
+ stop = setup.fm_usrbands[setup.fm_userbandnum].stop * 32;
+ } else {
+ start = ((fmbands[band].start - 3000) * 4) / 10;
+ stop = ((fmbands[band].end - 3000) * 4) / 10;
+ }
}
+
if(i > 0x1fff) i = 0x1fff;
- //i = ch & 0x1fff;
+ if(i > stop) i = stop;
+ if(i < start) i = start;
b.byte = i & 0xff;
akc6955_writecmd(AKC6955_CH_LO, b.byte);
b.byte = i >> 8;
b.b6 = 1;
- if(mode_3k != 0){
+ if((setup.fm == 0) && (mode_3k != 0)){
b.b5 = 1; // Mode 3K ON
+ } else {
+ b.b5 = 0;
}
+
akc6955_writecmd(AKC6955_CH_HI, b.byte);
akc6955_do_tune();