Joaquin Verastegui / jro

Dependents:   JRO_CR2 frdm_test

Fork of jro by Miguel Urco

Files at this revision

API Documentation at this revision

Comitter:
miguelcordero191
Date:
Thu Feb 05 21:31:37 2015 +0000
Parent:
2:3d8d52e9751c
Child:
4:de495ce256b8
Commit message:
jroEthernet and jroSerial modules were deleted

Changed in this revision

JroDDS.cpp Show annotated file Show diff for this revision Revisions of this file
JroDDS.h Show annotated file Show diff for this revision Revisions of this file
JroEthernet.cpp Show diff for this revision Revisions of this file
JroEthernet.h Show diff for this revision Revisions of this file
JroSerial.cpp Show diff for this revision Revisions of this file
JroSerial.h Show diff for this revision Revisions of this file
--- a/JroDDS.cpp	Thu Feb 05 19:01:42 2015 +0000
+++ b/JroDDS.cpp	Thu Feb 05 21:31:37 2015 +0000
@@ -451,19 +451,24 @@
     }
        
 int DDS::defaultSettings(SerialDriver *screen){
-    screen->putc(0x37);
-    screen->putc(0x30);
+    
+    if (!(screen == NULL)){
+        screen->putc(0x37);
+        screen->putc(0x30);
+    }
     
     this->wrMultiplier(1, 0.0);
-    this->wrAmplitudeI("\x0A\x5B", screen);                        //0xFC0 produces best SFDR than 0xFFF
+    this->wrAmplitudeI("\x0F\xC0", screen);                        //0xFC0 produces best SFDR than 0xFFF
     this->wrAmplitudeQ("\x0F\xC0");                        //0xFC0 produces best SFDR than 0xFFF    
     this->wrFrequency1("\x00\x00\x00\x00\x00\x00");        // 49.92 <> 0x3f 0xe5 0xc9 0x1d 0x14 0xe3 <> 49.92/clock*(2**48) \x3f\xe5\xc9\x1d\x14\xe3
     this->wrFrequency2("\x00\x00\x00\x00\x00\x00");
     this->wrPhase1("\x00\x00");                            //0 grados
     this->wrPhase2("\x20\x00");                    //180 grados <> 0x20 0x00 <> 180/360*(2**14)
 
-    screen->putc(0x37);
-    screen->putc(0x31);
+    if (!(screen == NULL)){
+        screen->putc(0x37);
+        screen->putc(0x31);
+    }
     
     return this->wrMode(4);                                //BPSK mode
     
@@ -494,11 +499,11 @@
     
     switch ( cmd )
       {
-        case CMD_RESET:
+        case DDS_CMD_RESET:
             success = this->init();
             break;
             
-        case CMD_ENABLE_RF:
+        case DDS_CMD_ENABLE_RF:
             if (payload_len == 1){
                 if (payload[0] == 0)
                     success = this->disableRF();
@@ -507,56 +512,56 @@
             }
             break;
             
-        case CMD_MULTIPLIER:
+        case DDS_CMD_MULTIPLIER:
             if (payload_len == 3){
                 unsigned short clock = payload[1]*256 + payload[2];
                 success = this->wrMultiplier(payload[0], (float)clock);
             }
             break;
             
-        case CMD_MODE:
+        case DDS_CMD_MODE:
             if (payload_len == 1){
                 success = this->wrMode(payload[0]);
             }
             break;
             
-        case CMD_FREQUENCY1:
+        case DDS_CMD_FREQUENCY1:
             if (payload_len == 6){
                 success = this->wrFrequency1(payload);
             }
             break;
             
-        case CMD_FREQUENCY2:
+        case DDS_CMD_FREQUENCY2:
             if (payload_len == 6){
                 success = this->wrFrequency2(payload);
             }
             break;
             
-        case CMD_PHASE1:
+        case DDS_CMD_PHASE1:
             if (payload_len == 2){
                 success = this->wrPhase1(payload);
             }
             break;
             
-        case CMD_PHASE2:
+        case DDS_CMD_PHASE2:
             if (payload_len == 2){
                 success = this->wrPhase2(payload);
             }
             break;
 
-        case CMD_AMPLITUDEI:
+        case DDS_CMD_AMPLITUDEI:
             if (payload_len == 2){
                 success = this->wrAmplitudeI(payload);
             }
             break;
 
-        case CMD_AMPLITUDEQ:
+        case DDS_CMD_AMPLITUDEQ:
             if (payload_len == 2){
                 success = this->wrAmplitudeQ(payload);
             }
             break;
 
-        case CMD_READ | CMD_ENABLE_RF:
+        case DDS_CMD_READ | DDS_CMD_ENABLE_RF:
             if (rf_enabled == 1)
                 tx_msg = "\x01";
             else
@@ -566,42 +571,42 @@
             
             break;
             
-        case CMD_READ | CMD_MULTIPLIER:
+        case DDS_CMD_READ | DDS_CMD_MULTIPLIER:
             tx_msg = this->rdMultiplier();
             tx_msg_len = 3;
             break;
             
-        case CMD_READ | CMD_MODE:
+        case DDS_CMD_READ | DDS_CMD_MODE:
             tx_msg = this->rdMode();
             tx_msg_len = 1;
             break;
             
-        case CMD_READ | CMD_FREQUENCY1:
+        case DDS_CMD_READ | DDS_CMD_FREQUENCY1:
             tx_msg = this->rdFrequency1();
             tx_msg_len = 6;
             break;
             
-        case CMD_READ | CMD_FREQUENCY2:
+        case DDS_CMD_READ | DDS_CMD_FREQUENCY2:
             tx_msg = this->rdFrequency2();
             tx_msg_len = 6;
             break;
             
-        case CMD_READ | CMD_PHASE1:
+        case DDS_CMD_READ | DDS_CMD_PHASE1:
             tx_msg = this->rdPhase1();
             tx_msg_len = 2;
             break;
             
-        case CMD_READ | CMD_PHASE2:
+        case DDS_CMD_READ | DDS_CMD_PHASE2:
             tx_msg = this->rdPhase2();
             tx_msg_len = 2;
             break;
 
-        case CMD_READ | CMD_AMPLITUDEI:
+        case DDS_CMD_READ | DDS_CMD_AMPLITUDEI:
             tx_msg = this->rdAmplitudeI();
             tx_msg_len = 2;
             break;
 
-        case CMD_READ | CMD_AMPLITUDEQ:
+        case DDS_CMD_READ | DDS_CMD_AMPLITUDEQ:
             tx_msg = this->rdAmplitudeQ();
             tx_msg_len = 2;
             break;
--- a/JroDDS.h	Thu Feb 05 19:01:42 2015 +0000
+++ b/JroDDS.h	Thu Feb 05 21:31:37 2015 +0000
@@ -5,18 +5,17 @@
 #define SPI_MODE 0
 #define SPI_FREQ 10000
 
-#define CMD_RESET       0X01
-#define CMD_ENABLE_RF   0x02
-#define CMD_MULTIPLIER  0X10
-#define CMD_MODE        0x11
-#define CMD_FREQUENCY1  0X12
-#define CMD_FREQUENCY2  0x13
-#define CMD_PHASE1      0X14
-#define CMD_PHASE2      0x15
-#define CMD_AMPLITUDEI  0X16
-#define CMD_AMPLITUDEQ  0x17
-#define CMD_READ        0x8000
-#define CMD_CHANGE_IP   0x40
+#define DDS_CMD_RESET       0X10
+#define DDS_CMD_ENABLE_RF   0x11
+#define DDS_CMD_MULTIPLIER  0X12
+#define DDS_CMD_MODE        0x13
+#define DDS_CMD_FREQUENCY1  0X14
+#define DDS_CMD_FREQUENCY2  0x15
+#define DDS_CMD_PHASE1      0X16
+#define DDS_CMD_PHASE2      0x17
+#define DDS_CMD_AMPLITUDEI  0X18
+#define DDS_CMD_AMPLITUDEQ  0x19
+#define DDS_CMD_READ        0x8000
 
 class DDS{
     private:
--- a/JroEthernet.cpp	Thu Feb 05 19:01:42 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-#include "JroEthernet.h"
-
-JroEthernet::JroEthernet(EthernetInterface *eth_)
-{
-    this->eth = eth_;
-}
-
-int JroEthernet::init(char *ip, char *mask, char *gateway)
-{               
-    int status = -1;
-    // ETHERNET
-    //screen->putc(0x36);
-    //screen->putc(0x30);
-    
-    //status = this->eth->init();
-    status = this->eth->init(ip, mask, gateway);
-    //__screen.printf("\r\nIP Address is %s %d\r\n", eth.getIPAddress(), status);
-    this->eth->setName(DEVICE_NAME);
-    //screen->putc(0x36);
-    //screen->putc(0x31);
-    
-    while(true){
-        
-        status = this->eth->connect(5000);
-        if (status == 0)
-            break;
-        Thread::wait(500);
-        status = this->eth->disconnect();
-    }
-    
-    //screen->putc(0x36);
-    //screen->putc(0x32);
-    
-    return 1;
-}
-
-int JroEthernet::changeIp(char *ip, char *mask, char *gateway)
-{
-    return this->eth->setNewAddr(ip, mask, gateway);
-    //screen.printf("\r\nIP Address is %s %d\r\n", eth.getIPAddress(), status);
-}
-
-int JroEthernet::openTCPServer(TCPSocketServer *server, int server_port)
-{
-    server->bind(server_port);
-    server->listen(1);
-    
-    this->server = server;
-    this->rx_buffer = rx_buffer;
-    
-    return 1;
-}
-
-int JroEthernet::read(char* rx_buffer)
-{
-    TCPSocketConnection client;
-    int n, totalSize=0;
-    
-    this->server->accept(client);
-    
-    client.set_blocking(false, 1500); // Timeout after (1.5)s
-    
-    //__screen.printf("Connection from: %s\r\n", client.get_address());
-    
-    while (true) {
-        n = client.receive(rx_buffer, sizeof(rx_buffer));
-        if (n <= 0) break;
-        totalSize += n;
-        Thread::wait(200);
-    }
-    
-    this->client = &client;
-    
-    if (totalSize > 5)
-        return 1;
-        
-    return 0;
-}
-
-int JroEthernet::sendResponse(char *tx_buffer, int buffer_size)
-{
-    this->client->send(tx_buffer, buffer_size);
-    
-    return 1;
-}
-
-int JroEthernet::closeClient()
-{
-    this->client->close();
-    
-    return 1;
-    
-}
\ No newline at end of file
--- a/JroEthernet.h	Thu Feb 05 19:01:42 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#include "mbed.h"
-#include "rtos.h"
-#include "EthernetInterface.h"
-
-#include "SerialDriver.h"
-
-#define DEVICE_NAME      "DDSv2"
-
-class JroEthernet{
-
-    private:
-        
-        EthernetInterface *eth;
-        TCPSocketServer *server;
-        TCPSocketConnection *client;
-        unsigned char* rx_buffer;
-        //SerialDriver *screen;
-        
-    public:
-        
-        JroEthernet(EthernetInterface *eth_);
-        int init(char *ip, char *mask, char *gateway);
-        int changeIp(char *ip, char *mask, char *gateway);
-        int openTCPServer(TCPSocketServer *server, int server_port);
-        int read(char* rx_buffer);
-        int sendResponse(char *tx_buffer, int buffer_size);
-        int closeClient();
-        
-};
--- a/JroSerial.cpp	Thu Feb 05 19:01:42 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-#include "JroSerial.h"
-
-JroSerial::JroSerial(PinName tx, PinName rx, SerialDriver *screen) : SerialDriver(tx,rx)
-{
-    //;
-    this->device_irqn = UART3_RX_TX_IRQn;
-    this->screen = screen;
-    // attach the interrupts
-}
-
-int JroSerial::Init(int baudrate)
-{
-    this->baud(baudrate);
-    //this->screen->baud(baudrate);
-    
-    //attach(this, &JroSerial::Rx_interrupt, RxIrq);
-    //NVIC_DisableIRQ(this->device_irqn);
-    //disableRxInterrupt();
-    
-    return 1;
-}
-
-
-// This function is called when a character goes into the RX buffer.
-
-void JroSerial::Rx_interrupt() {
-    
-    disableRxInterrupt();
-    //NVIC_DisableIRQ(this->device_irqn);
-    //uart.attach(NULL, Serial::RxIrq);
-    //uint32_t IRR3 = UART3->IIR;
-    //UART_3_RBR = K64F_UART3->RBR;
-    
-    //ser_thread_ptr->signal_set(0x01);
-    //this->rx_sem.release();
-    return;
-}
-int JroSerial::ReadData(char* rx_buffer)
-{
-    int tmp;
-    unsigned short i=0;
-    unsigned short time_counter=0;
-    
-    //NVIC_EnableIRQ(this->device_irqn);
-    //enableRxInterrupt();
-    this->screen->putc(0x34);
-    this->screen->putc(0x31);
-    //this->rx_sem.wait();
-    this->screen->putc(0x34);
-    this->screen->putc(0x32);
-    while(true){
-        /*
-        if(this->readable()==0){
-            time_counter++;
-            if (time_counter > 3)
-                break;
-            Thread::wait(300);
-            continue;
-        }
-        */
-        
-        tmp = this->getc(200);
-        if (tmp == -1)
-            break;
-        
-        rx_buffer[i] = (unsigned char) tmp;
-        
-        //Don't delete the next line screen.putc();
-        this->screen->putc(0x34);
-        this->screen->putc(0x33);
-        this->screen->putc(rx_buffer[i]);
-        
-        i++;
-        time_counter = 0;
-    }
-    
-    this->putc(i);
-    
-    this->screen->putc(0x34);
-    this->screen->putc(0x34);
-    
-    if (i==0x28){
-        this->putc(0x37);
-        this->putc(0x37);
-    }
-    this->putc(0x10);
-    this->putc(0x13);
-    
-    return i;
-}
\ No newline at end of file
--- a/JroSerial.h	Thu Feb 05 19:01:42 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#include "mbed.h"
-#include "rtos.h"
-#include "SerialDriver.h"
-
-class JroSerial: public SerialDriver
-{
-
-    private:
-        
-        SerialDriver *screen;
-        char* rx_buffer;
-        
-        //Semaphore rx_sem;
-        //Semaphore tx_sem;
-    protected:
-        inline void disableTxInterrupt()   {    serial_irq_set(&_serial, (SerialIrq)TxIrq, 0);    }
-        inline void enableTxInterrupt()    {    serial_irq_set(&_serial, (SerialIrq)TxIrq, 1);    }
-        
-        inline void disableRxInterrupt()   {    serial_irq_set(&_serial, (SerialIrq)RxIrq, 0);    }
-        inline void enableRxInterrupt()    {    serial_irq_set(&_serial, (SerialIrq)RxIrq, 1);    } 
-    
-    public:
-        
-        IRQn device_irqn;
-        
-        JroSerial(PinName tx, PinName rx, SerialDriver *screen);
-        int Init(int baudrate);
-        int ReadData(char* rx_buffer);
-        void Rx_interrupt();
-};