OSDN Git Service

[Tuner] Re-order functions.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 11 Jun 2013 03:03:55 +0000 (12:03 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 11 Jun 2013 03:03:55 +0000 (12:03 +0900)
akc6955.c

index 97c29eb..94ba118 100644 (file)
--- a/akc6955.c
+++ b/akc6955.c
@@ -94,14 +94,26 @@ void akc6955_do_tune(void)
     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
@@ -113,8 +125,9 @@ unsigned int akc6955_set_tune(unsigned char mode_3k, unsigned int ch)
         // 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 {
@@ -124,12 +137,15 @@ unsigned int akc6955_set_tune(unsigned char mode_3k, unsigned int ch)
     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;
@@ -186,9 +202,8 @@ unsigned int akc6955_get_freq(void)
 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
@@ -206,16 +221,6 @@ void akc6955_set_freq(unsigned int freq)
     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)
 {
@@ -264,10 +269,6 @@ unsigned int akc6955_up_freq(unsigned int step)
     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();
 }
 
@@ -279,9 +280,5 @@ unsigned int akc6955_down_freq(unsigned int step)
     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();
 }