RoboCup Base Station

Dependencies:   mbed mbed-rtos Wireless Drivers

Files at this revision

API Documentation at this revision

Comitter:
jjones646
Date:
Wed Dec 31 22:16:17 2014 +0000
Parent:
3:c3114df544e8
Commit message:
adding dummy cc1101 support

Changed in this revision

BaseStation.h Show annotated file Show diff for this revision Revisions of this file
Wireless-Drivers.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BaseStation.h	Wed Dec 31 09:32:08 2014 +0000
+++ b/BaseStation.h	Wed Dec 31 22:16:17 2014 +0000
@@ -3,6 +3,7 @@
 
 #include "mbed.h"
 #include "rtos.h"
+#include "CC1101.h"
 
 // 7-Segment pins
 #define RJ_7_SEG_BIT_3_PIN  p17
@@ -25,6 +26,10 @@
 #define RJ_SECONDARY_RADIO_LED_ERR    p26
 #define RJ_SECONDARY_RADIO_LEDS       RJ_SECONDARY_RADIO_LED_TX, RJ_SECONDARY_RADIO_LED_RX, RJ_SECONDARY_RADIO_LED_ERR
 
+// Primary Radio Control Pins
+#define RJ_PRIMARY_RADIO_CS_PIN     p11
+#define RJ_PRIMARY_RADIO_INT_PIN    p12
+
 // RGB Status LED
 #define RJ_RGB_LED_RED_PIN      p23
 #define RJ_RGB_LED_GREEN_PIN    p21
@@ -32,6 +37,12 @@
 #define RJ_RGB_LED_ANNODE       p27
 #define RJ_RGB_LED_PINS         RJ_RGB_LED_RED_PIN, RJ_RGB_LED_GREEN_PIN, RJ_RGB_LED_BLUE_PIN
 
+// SPI Bus lines
+#define RJ_SPI_MOSI_PIN     p5
+#define RJ_SPI_MISO_PIN     p6
+#define RJ_SPI_SCK_PIN      p7
+#define RJ_SPI_PINS         RJ_SPI_MOSI_PIN, RJ_SPI_MISO_PIN, RJ_SPI_SCK_PIN
+
 #define R   0
 #define G   1
 #define B   2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Wireless-Drivers.lib	Wed Dec 31 22:16:17 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/jjones646/code/Wireless-Drivers/#c42a035d71ed
--- a/main.cpp	Wed Dec 31 09:32:08 2014 +0000
+++ b/main.cpp	Wed Dec 31 22:16:17 2014 +0000
@@ -2,6 +2,8 @@
 
 #include "BaseStation.h"
 
+uint8_t channel;
+
 // Function for writing a number to the 7-segment display
 void writeSegment(uint8_t val, DigitalOut& latch)
 {
@@ -25,9 +27,8 @@
     // Decimal point initialized to OFF
     DigitalOut decimal( RJ_7_SEG_DOT_PIN, 1 );
 
-    uint8_t channel = 8;
+    channel = 8;
     writeSegment(channel, latch);
-    channel = 0;    // start from 0 once the main task's look begins
 
     // wait to be signaled before beginning
     osSignalWait(0x01, osWaitForever);
@@ -40,8 +41,8 @@
 
     while(1) {  // loop forever
         // send numerical value to 7-segment & hold for a while
-        writeSegment(channel++, latch);
-        channel = (channel > 9) ? 0 : channel; // reset value if too high
+        writeSegment(channel, latch);
+        // channel = (channel > 9) ? 0 : channel; // reset value if too high
         Thread::wait(1000);
     }
 }
@@ -95,34 +96,45 @@
             r2_led[i] = 1;
         }
     }
-/*    
-    // turn off all radio status LEDs
-    for (int i=0; i<3; i++) {
-        r1_led[i] = 1;
-        r2_led[i] = 1;
-        Thread::wait(50);
-    }
-*/
+
     // give power to all colors of the RGB LED and turn off decimal point
     rgb_pwr = 1;
 
+    // 915MHz band radio object
+    CC1101 cc1101(
+        RJ_SPI_PINS,
+        RJ_PRIMARY_RADIO_CS_PIN,
+        RJ_PRIMARY_RADIO_LED_TX,
+        RJ_PRIMARY_RADIO_LED_RX,
+        RJ_PRIMARY_RADIO_INT_PIN
+    );
+
+    // set pointer for base class calls
+    Radio *radio_p = &cc1101;
+
+    channel = radio_p->channel();
     // tell the segment thread to begin its task
     thread_seg_task.signal_set(0x01);
 
-    // fade the RGB LED up to green and half power
+    uint8_t color;
+    if (radio_p->hasError()) {
+        color = 0;
+    } else {
+        color = 1;
+    }
+
+    // fade the RGB LED up to the right status color at half power
     for (float i=1.0; i>0.5; i-=0.01) {
-        rgb_led[G] = i;
+        rgb_led[color] = i;
         Thread::wait(20);
     }
 
-    // at led_intensity[3] = { 0, 0, 0 };
-    srand(time(NULL));
+
 
     // loop forever ====================
     while(1) {
-        uint8_t color = rand()%2;
 
-        // rgb_led[color] = (rand()%1000)/1000;
+        //
 
         // delay
         Thread::wait(300);