Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of jro by
Revision 4:de495ce256b8, committed 2015-02-10
- Comitter:
- miguelcordero191
- Date:
- Tue Feb 10 14:28:42 2015 +0000
- Parent:
- 3:f0e6c145b075
- Child:
- 5:6500be930b36
- Commit message:
- Some features were added to library
Changed in this revision
--- a/JroDDS.cpp Thu Feb 05 21:31:37 2015 +0000
+++ b/JroDDS.cpp Tue Feb 10 14:28:42 2015 +0000
@@ -108,7 +108,7 @@
int DDS::__writeDataAndVerify(char addr, char ndata, const char* wr_spi_data, SerialDriver *screen){
- bool success;
+ int success;
char* rd_spi_data;
this->__writeData(addr, ndata, wr_spi_data);
@@ -209,6 +209,9 @@
wait_ms(1);
*dds_mreset = 0;
wait_ms(1);
+
+ this->rf_enabled = false;
+
return 0;
}
@@ -370,6 +373,14 @@
return rd_data;
}
+
+int DDS::isRFEnabled(){
+
+ if (this->rf_enabled)
+ return 1;
+
+ return 0;
+ }
int DDS::wrMode(char mode){
@@ -435,9 +446,8 @@
this->rf_enabled = true;
this->__writeDataAndVerify(0x08, 2, this->amplitudeI);
- this->__writeDataAndVerify(0x09, 2, this->amplitudeQ);
-
- return 1;
+ return this->__writeDataAndVerify(0x09, 2, this->amplitudeQ);
+
}
int DDS::disableRF(){
@@ -445,9 +455,8 @@
this->rf_enabled = false;
this->__writeDataAndVerify(0x08, 2, "\x00\x00");
- this->__writeDataAndVerify(0x09, 2, "\x00\x00");
+ return this->__writeDataAndVerify(0x09, 2, "\x00\x00");
- return 1;
}
int DDS::defaultSettings(SerialDriver *screen){
@@ -458,13 +467,14 @@
}
this->wrMultiplier(1, 0.0);
- this->wrAmplitudeI("\x0F\xC0", 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)
-
+ this->wrPhase2("\x20\x00"); //180 grados <> 0x20 0x00 <> 180/360*(2**14)
+ this->disableRF();
+
if (!(screen == NULL)){
screen->putc(0x37);
screen->putc(0x31);
@@ -562,7 +572,7 @@
break;
case DDS_CMD_READ | DDS_CMD_ENABLE_RF:
- if (rf_enabled == 1)
+ if (this->isRFEnabled() == 1)
tx_msg = "\x01";
else
tx_msg = "\x00";
@@ -676,8 +686,15 @@
this->wrAmplitudeI(amplitudeI);
this->wrAmplitudeQ(amplitudeQ);
this->__writeDataAndVerify(0x25, 1, ampl_ramp_rate);
- sts = this->__writeDataAndVerify(0x26, 2, qdac, screen);
+ this->__writeDataAndVerify(0x26, 2, qdac, screen);
+
+ sts = this->enableRF();
return sts;
- }
\ No newline at end of file
+ }
+
+bool DDS::wasInitialized(){
+
+ return this->isConfig;
+}
\ No newline at end of file
--- a/JroDDS.h Thu Feb 05 21:31:37 2015 +0000
+++ b/JroDDS.h Tue Feb 10 14:28:42 2015 +0000
@@ -1,3 +1,6 @@
+#ifndef JRO_DDS
+#define JRO_DDS
+
#include "mbed.h"
#include "SerialDriver.h"
@@ -72,6 +75,7 @@
char* rdFrequency2();
char* rdAmplitudeI();
char* rdAmplitudeQ();
+ int isRFEnabled();
int wrMode(char mode);
int wrMultiplier(char multiplier, float clock);
int wrPhase1(char* phase, SerialDriver *screen=NULL);
@@ -87,5 +91,8 @@
char* getCmdAnswer();
unsigned long getCmdAnswerLen();
int setAllDevice(char* payload, SerialDriver *screen=NULL);
+ bool wasInitialized();
-};
\ No newline at end of file
+};
+
+#endif
\ No newline at end of file
--- a/JroIpdata.cpp Thu Feb 05 21:31:37 2015 +0000
+++ b/JroIpdata.cpp Tue Feb 10 14:28:42 2015 +0000
@@ -89,7 +89,7 @@
return 1;
}
-char* IpData::encode(unsigned short cmd, char* payload, unsigned long len_payload){
+char* IpData::encode(unsigned short cmd, const char* payload, unsigned long len_payload){
int head_size= strlen(HEADER);
char xor_wr;
@@ -220,13 +220,28 @@
return NULL;
return this->payload;
- }
+}
char* IpData::getTxData(){
return this->tx_buff;
- }
+}
+
unsigned long IpData::getTxDataLen(){
return this->len_tx_buffer;
- }
\ No newline at end of file
+}
+
+char* IpData::getNIData(unsigned short cmd){
+
+ char tx_data[5];
+
+ strcpy(tx_data, NI_PAYLOAD);
+
+ return this->encode(cmd, tx_data, NI_LEN);
+}
+
+unsigned long IpData::getNIDataLen(){
+
+ return this->len_tx_buffer;
+}
\ No newline at end of file
--- a/JroIpdata.h Thu Feb 05 21:31:37 2015 +0000
+++ b/JroIpdata.h Tue Feb 10 14:28:42 2015 +0000
@@ -1,9 +1,15 @@
+#ifndef JRO_IPDATA
+#define JRO_IPDATA
+
#include "mbed.h"
#define HEADER "$JRO$"
#define ID_CLASS 2
#define ID_DEV 1
+#define NI_PAYLOAD "NI"
+#define NI_LEN 2
+
/*
IP DATA STRUCTURE
@@ -62,7 +68,7 @@
IpData(char* tx_buffer);
char id;
- char* encode( unsigned short cmd, char* payload, unsigned long len_payload);
+ char* encode( unsigned short cmd, const char* payload, unsigned long len_payload);
int decode(char* buffer, unsigned long len_buffer);
char getIdClass();
char getIdDevice();
@@ -71,7 +77,8 @@
char* getPayload();
char* getTxData();
unsigned long getTxDataLen();
-
+ char* getNIData(unsigned short cmd=0x0);
+ unsigned long getNIDataLen();
+};
-};
-
\ No newline at end of file
+#endif
\ No newline at end of file
