OSDN Git Service

[Doc] GITLOG to v1.0beta1.1.
[openi2cradio/OpenI2CRadio.git] / akc6955.c
index 170027b..181cea9 100644 (file)
--- a/akc6955.c
+++ b/akc6955.c
 #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)
 {
@@ -118,13 +49,13 @@ 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);
 
 }
@@ -359,8 +290,8 @@ void akc6955_set_freq(unsigned int freq)
         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;
@@ -371,8 +302,8 @@ void akc6955_set_freq(unsigned int freq)
         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;
@@ -624,7 +555,7 @@ void akc6955_set_thresh_fmstereo(unsigned char a)
 {
     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);
 }
@@ -633,7 +564,7 @@ void akc6955_set_thresh_width(unsigned char a)
 {
     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);
@@ -643,7 +574,7 @@ void akc6955_set_thresh_amcnr(unsigned char a)
 {
     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);
@@ -653,7 +584,7 @@ void akc6955_set_thresh_fmcnr(unsigned char a)
 {
     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);