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
Diff: JroDDS.cpp
- Revision:
- 4:de495ce256b8
- Parent:
- 3:f0e6c145b075
diff -r f0e6c145b075 -r de495ce256b8 JroDDS.cpp
--- 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
