OSDN Git Service

[AKC6955][v1.0] Limit frequency on tuning.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 27 Sep 2013 03:54:51 +0000 (12:54 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 27 Sep 2013 03:54:51 +0000 (12:54 +0900)
OpenI2CRadio.v1.0.X/nbproject/Makefile-genesis.properties
akc6955.c

index 3b37697..a436662 100644 (file)
@@ -1,5 +1,5 @@
 #
-#Tue Sep 24 14:03:51 JST 2013
+#Wed Sep 25 08:07:52 JST 2013
 default.languagetoolchain.dir=/opt/microchip/xc8/v1.20/bin
 com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=1c49f19f6a43b876c317e0d8d41c0854
 default.languagetoolchain.version=1.20
index f74d24c..c0e67db 100644 (file)
--- a/akc6955.c
+++ b/akc6955.c
@@ -166,33 +166,64 @@ void akc6955_set_tune(unsigned char mode_3k, unsigned int ch)
     __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();