For robots and stuff

Dependents:   Base Station

Revision:
2:c42a035d71ed
Parent:
1:05a48c038381
--- a/CC1101/CC1101.cpp	Sun Dec 28 06:28:42 2014 +0000
+++ b/CC1101/CC1101.cpp	Wed Dec 31 22:16:01 2014 +0000
@@ -11,7 +11,7 @@
 {  };
 
 CC1101::CC1101(PinName mosi, PinName miso, PinName clk, PinName csn, PinName tx_led, PinName rx_led, PinName interpt, unsigned int xosc) :
-    Radio(_tx_led, _rx_led),
+    Radio(tx_led, rx_led),
     _crystal_freq(xosc)
 {
     setup_spi(mosi, miso, clk);
@@ -72,6 +72,11 @@
 }
 */
 
+void CC1101::isr_receive(void)
+{
+    // do nothing
+}
+
 
 // Configuration method that is called from the constructors
 void CC1101::setup_chip()
@@ -124,8 +129,8 @@
     _modem.sync_mode = SYNC_HIGH_ALLOW_TWO;
     _modem.preamble_bytes = PREAM_FOUR;
 
-    _send_count = 1;
-    _receive_count = 0;
+    //_send_count = 1;
+    //_receive_count = 0;
 
     // the values assigned here are used for the frequency synthesizer control
     assign_if_freq(_316KHZ_);
@@ -152,8 +157,14 @@
         fprintf(fp, "FATAL ERROR: CC1101 Version Error\n");
         fclose(fp);
 #endif
-        // send message over serial port and kill mbed
-        error(
+
+        // flip the error led ON
+        _err_led = !_err_led;
+        
+        _has_error = true;
+
+        // send message over serial port
+        std::printf(
             "[FATAL ERROR]\r\n"
             "  Wrong version number returned from chip's 'VERSION' register (Addr: 0x%02X)\r\n"
             "\r\n"
@@ -168,7 +179,7 @@
 }
 
 
-void powerUp(void)
+void CC1101::powerUp(void)
 {
 #if DEBUG_MODE > 0
     std::printf("[CC1101 RADIO TRANSCEIVER INITILIZATION]\r\n");
@@ -945,7 +956,7 @@
             std::printf("  LQI:  %u\r\n", _lqi);
 #endif
 
-            if (_p_count%5 == 0) {
+            if (_p_count++%5 == 0) {
                 //calibrate the frequency synthesizer
                 calibrate();
             }
@@ -955,7 +966,7 @@
             return 1;
 
         } else {
-            *length = size;
+            *length = rx_size;
         }
     }