Firmware for the controller of the JRO Radar Controller.

Dependencies:   CR2 EthernetInterface FreescaleIAP I2CLCD SerialDriver jro k64f_EthLink mbed-rtos mbed

Fork of JRO_DDSv2 by Miguel Urco

Files at this revision

API Documentation at this revision

Comitter:
joaquinbvw
Date:
Mon Mar 14 19:39:14 2016 +0000
Parent:
4:3883bfcdfb63
Child:
6:20e6ba387783
Commit message:
CR2 first attempt.

Changed in this revision

AD9854.lib Show diff for this revision Revisions of this file
CR2.lib Show annotated file Show diff for this revision Revisions of this file
FreescaleIAP.lib Show annotated file Show diff for this revision Revisions of this file
jro.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
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/AD9854.lib	Tue Feb 24 20:14:16 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/miguelcordero191/code/AD9854/#156a9e15919e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CR2.lib	Mon Mar 14 19:39:14 2016 +0000
@@ -0,0 +1,1 @@
+CR2#e3f3fe2e689b
--- a/FreescaleIAP.lib	Tue Feb 24 20:14:16 2015 +0000
+++ b/FreescaleIAP.lib	Mon Mar 14 19:39:14 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Sissors/code/FreescaleIAP/#186db0d96fcf
+http://mbed.org/users/Sissors/code/FreescaleIAP/#6749f7702fa5
--- a/jro.lib	Tue Feb 24 20:14:16 2015 +0000
+++ b/jro.lib	Mon Mar 14 19:39:14 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/miguelcordero191/code/jro/#6500be930b36
+http://developer.mbed.org/users/miguelcordero191/code/jro/#aa70d2640f18
--- a/main.cpp	Tue Feb 24 20:14:16 2015 +0000
+++ b/main.cpp	Mon Mar 14 19:39:14 2016 +0000
@@ -15,7 +15,7 @@
 #include "EthUtils.h"
 #include "JroIpdata.h"
 #include "JroSIR.h"
-#include "AD9854.h"
+#include "CR2.h"
 
 #define mbed_reset        NVIC_SystemReset
 
@@ -27,15 +27,15 @@
 Thread *ser_thread_ptr;
 Thread *eth_thread_ptr;
 Thread *lcd_thread_ptr;
-Mutex dds_mutex;
+Mutex cr2_mutex;
 Mutex eth_mutex;
 Mutex lcd_mutex;
 
 //SERIAL
 #define SERIAL_BAUDRATE     1000000
-const char* UART_MSG_OK = "DDS Successful";
-const char* UART_MSG_KO = "DDS Unsuccessful";
-const char* UART_MSG_NC = "DDS Not connected";
+const char* UART_MSG_OK = "CR2 Successful";
+const char* UART_MSG_KO = "CR2 Unsuccessful";
+const char* UART_MSG_NC = "CR2 Not connected";
 
 Serial screen(USBTX, USBRX);
 SerialDriver uart(D1, D0);
@@ -45,15 +45,15 @@
 I2C i2c_device(I2C_SDA, I2C_SCL);
 I2CLCD lcd(i2c_device, 0x78, LCD20x2);
 
-//const char LCD_WELCOME[]    =   "  JICAMARCA - DDS   ";
+//const char LCD_WELCOME[]    =   "  JICAMARCA - CR2   ";
 const char LCD_IP_INI[]     =   "IP : checking...    ";
 const char LCD_IP_NC[]      =   "IP : Not connected  ";
 //const char LCD_IP_NI[]      =   "IP : Not initialized";
 
-const char LCD_DAC_INI[]    =   "DAC: checking...    ";
-const char LCD_DAC_NC[]     =   "DAC: Not detected   ";
-const char LCD_DAC_ENA[]    =   "     RF Enabled     ";
-const char LCD_DAC_DIS[]    =   "     RF Disabled    ";
+const char LCD_CR2_INI[]    =   "CR2: checking...    ";
+const char LCD_CR2_NC[]     =   "CR2: Not detected   ";
+const char LCD_CR2_ENA[]    =   "     Outputs Enabled     ";
+const char LCD_CR2_DIS[]    =   "     Otuputs Disabled    ";
 
 //ETHERNET
 #define ECHO_SERVER_PORT   2000
@@ -65,17 +65,17 @@
 EthernetInterface eth;
 TCPSocketServer server;
 
-//DDS
+//CR2
 SPI spi_device(D11, D12, D13);
 
-DigitalOut    dds_mreset(D4);
-DigitalOut    dds_outramp(D5);
-DigitalOut    dds_sp_mode(D6);
-DigitalOut    dds_cs(D7);
-DigitalOut    dds_io_reset(D9);
-DigitalInOut  dds_updclk(D10);
+DigitalOut    cr2_mreset(D4);
+DigitalOut    cr2_outramp(D5);
+DigitalOut    cr2_sp_mode(D6);
+DigitalOut    cr2_cs(D7);
+DigitalOut    cr2_io_reset(D9);
+DigitalInOut  cr2_updclk(D10);
 
-DDS dds_device(&spi_device, &dds_mreset, &dds_outramp, &dds_sp_mode, &dds_cs, &dds_io_reset, &dds_updclk);
+CR2 cr2_device(&spi_device, &cr2_mreset, &cr2_outramp, &cr2_sp_mode, &cr2_cs, &cr2_io_reset, &cr2_updclk);
 
 //LEDS
 DigitalOut LedR(LED1);          
@@ -157,20 +157,20 @@
             Thread::wait(10);
         }
         lcd.printf("Serial command received", 0, 1);
-        //******************** DDS NOT INITIALIZED *******************
-        if (!dds_device.wasInitialized()){
+        //******************** CR2 NOT INITIALIZED *******************
+        if (!cr2_device.wasInitialized()){
             for (int i=0; i<strlen(UART_MSG_NC); i++){   
                 uart.putc(UART_MSG_NC[i]);
             }
             continue;
         }
-        //Lock dds_device before execute any command
-        dds_mutex.lock();
+        //Lock cr2_device before execute any command
+        cr2_mutex.lock();
         
         //********************* SUCCESSFUL DATA **********************
-        if (n == 40)   
-            if (dds_device.setAllDevice(rx_buffer) == 1)
-                successful = true;
+        //if (n == 40)   
+            //if (cr2_device.setAllDevice(rx_buffer) == 1)
+                //successful = true;
         
         //******************** REPLY UART*****************************
         if (successful)      
@@ -180,7 +180,7 @@
         else
             uart.printf(UART_MSG_KO);
         
-        dds_mutex.unlock();
+        cr2_mutex.unlock();
         
     }
     
@@ -251,8 +251,8 @@
             continue;
         }
         lcd.printf("Eth command received", 0, 1);
-        //******************** DDS NOT INITIALIZED *******************
-        if (!dds_device.wasInitialized()){
+        //******************** CR2 NOT INITIALIZED *******************
+        if (!cr2_device.wasInitialized()){
             client.send(ipData.getNIData(ipData.getCmd()), ipData.getNIDataLen());
             client.close();
             continue;
@@ -283,18 +283,19 @@
             }
         }
         
-        //Lock dds_device before execute any command
-        dds_mutex.lock();
+        //Lock cr2_device before execute any command
+        cr2_mutex.lock();
         
         // ********** OTHER COMMANDS
-        dds_device.setCommand(ipData.getCmd(), ipData.getPayload(), ipData.getPayloadLen());
-        ipData.encode(ipData.getCmd(), dds_device.getCmdAnswer(), dds_device.getCmdAnswerLen());
+        cr2_device.writeBlock(ipData.getPayloadLen(),ipData.getPayload());
+        //cr2_device.setCommand(ipData.getCmd(), ipData.getPayload(), ipData.getPayloadLen());
+        ipData.encode(ipData.getCmd(), cr2_device.getCmdAnswer(), cr2_device.getCmdAnswerLen());
         
         client.send(ipData.getTxData(), ipData.getTxDataLen());
         Thread::wait(10);
         client.close();
         
-        dds_mutex.unlock();
+        cr2_mutex.unlock();
     }
 }
 
@@ -303,7 +304,7 @@
     char c=0;
     char lcd_status[2]="\xF7";
     
-    lcd.printf(LCD_DAC_INI, 0, 0);
+    lcd.printf(LCD_CR2_INI, 0, 0);
     lcd.printf(LCD_IP_INI, 0, 1);
     Thread::wait(2000);
     
@@ -315,16 +316,16 @@
         }
         */
         
-        if (dds_device.wasInitialized()){
+        if (cr2_device.wasInitialized()){
             
             //RF ENABLED OR DISABLED
             if (c==1){
-                if(dds_device.isRFEnabled()){
-                    lcd.printf(LCD_DAC_ENA, 0, 0);
-                }
-                else{
-                    lcd.printf(LCD_DAC_DIS, 0, 0);
-                }
+                //if(cr2_device.isRFEnabled()){
+                    //lcd.printf(LCD_CR2_ENA, 0, 0);
+                //}
+                //else{
+                    lcd.printf(LCD_CR2_DIS, 0, 0);
+                //}
                 lcd_status[0] = 0x01;
                 lcd.printf(lcd_status, 19, 0);
             
@@ -332,17 +333,17 @@
             //FREQUENCY
             if (c==3){
                 char tmp[21];
-                sprintf(tmp, "Fout = %7.5f*Clk", dds_device.getFreqFactor1());
+                sprintf(tmp, "Fout = %7.5f*Clk", cr2_device.getFreqFactor1());
                 lcd.printf(tmp, 0, 0);
             }
             if (c==5){
                 char tmp[21];
-                sprintf(tmp, "Modulation = %s", dds_device.getModeStr() );
+                sprintf(tmp, "Modulation = %s", cr2_device.getModeStr() );
                 lcd.printf(tmp, 0, 0);
             }
         }
         else{
-            lcd.printf(LCD_DAC_NC, 0, 0);
+            lcd.printf(LCD_CR2_NC, 0, 0);
             lcd_status[0] = lcd_status[0] ^ 0xFF;
             lcd.printf(lcd_status, 19, 0);
         }
@@ -398,7 +399,7 @@
     screen.putc(0x32);
     
     while(true){
-        if (dds_device.init())
+        if (cr2_device.init())
             break;
             
         LedR = !LedR;
@@ -417,7 +418,7 @@
     */
     LedR = 1;
     
-    dds_device.defaultSettings();
+    //cr2_device.defaultSettings();
     LedR = 0;
     /*
     screen.putc(0x33);
@@ -428,12 +429,12 @@
     //int c=0;
     while(true){
         
-        if (dds_device.isRFEnabled()){
-            LedR = 0;
-        }
-        else{
+        //if (cr2_device.isRFEnabled()){
+            //LedR = 0;
+        //}
+        //else{
             LedR = 1;
-        }
+        //}
         
         if (wasIPResetPressed()){
             eraseIpConfig();
--- a/mbed-rtos.lib	Tue Feb 24 20:14:16 2015 +0000
+++ b/mbed-rtos.lib	Mon Mar 14 19:39:14 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#444020d511f5
+http://mbed.org/users/mbed_official/code/mbed-rtos/#dfc27975e193
--- a/mbed.bld	Tue Feb 24 20:14:16 2015 +0000
+++ b/mbed.bld	Mon Mar 14 19:39:14 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb
\ No newline at end of file