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.
For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Diff: examples/drvdiag/main.cpp
- Revision:
- 33:c3ec596a29c2
- Parent:
- 21:a8023e5e97be
diff -r 97d248e81e7f -r c3ec596a29c2 examples/drvdiag/main.cpp
--- a/examples/drvdiag/main.cpp Wed Oct 26 16:47:55 2016 +0300
+++ b/examples/drvdiag/main.cpp Mon Nov 07 16:27:12 2016 +0200
@@ -53,6 +53,7 @@
#include "config.h"
Serial pc(SERIAL_TX, SERIAL_RX);
+Serial test(D8, D2);
vector<string> cmdbuffer;
class commands
@@ -65,11 +66,13 @@
void (*fktPtr)(void);
};
+
// *INDENT-OFF*
const vector<commands> cmdlist = {
{"nop" , 0, [](){ }},
+ /*
{"echo",commands::VAR, [](){ for(auto i = begin(cmdbuffer) + 1, e = end(cmdbuffer); i!=e; ++i)
- printf("%s ", i->c_str()); printf("\r\n");}},
+ printf("%s ", i->c_str()); printf("\r\n");}},*/
{"help", 0 , [](){ for(auto command : cmdlist)
pc.printf("%s ",command.cmd_str.c_str()); }},
@@ -159,12 +162,100 @@
{"xlfr16", 0, [](){adxl362diag.fifo_read_u16(); }},
{"xlfrs", 0, [](){adxl362diag.fifo_scan(); }},
{"xlintinit",0,[](){adxl362diag.intinit();}},
- {"xlawake",0,[](){adxl362diag.checkawake();}
- },
+ {"xlawake",0,[](){adxl362diag.checkawake();}},
+#endif
+
+
+// UART
+ {"uart" , 0, [](){test.putc('\n');}},
+ {"uartecho" , 1, [](){test.printf(cmdbuffer[1].c_str());}},
+ {"uartlisten",0 , [](){
+ char buff[100] = {0};
+ size_t readPosition = 0;
+
+ // read from console until newline
+ while(1) {
+ buff[readPosition] = test.getc();
+ if(buff[readPosition] == '\n' || buff[readPosition] == '\r') {
+ buff[readPosition] = ' ';
+ break;
+ }
+ readPosition++;
+ }
+ readPosition++;
+ buff[readPosition] = '\0';
+ //create std::string from char buffer
+
+ pc.printf("%s",buff);}},
+
+#ifdef AD7124_PRESENT
+ {"adrst" , 0, [](){ad7124diag.reset();}},
+ {"adrd" , 1, [](){ad7124diag.read_reg();}},
+ {"adrdd" , 0, [](){ad7124diag.read_data();}},
+ {"adrdv" , 0, [](){ad7124diag.read_volt();}},
+ {"adwr" , 2, [](){ad7124diag.write_reg();}},
+ {"adsetup",0,[]() {ad7124diag.setup();pc.printf("setup done\r\n");ad7124diag.mvpInit();pc.printf("init done\r\n");}}
+
#endif
+#ifdef CN0398_PRESENT
+ {"cnrst" , 0, [](){cn0398diag.reset();}},
+ {"cnrd" , 1, [](){cn0398diag.read_reg();}},
+ /*{"cnrdd" , 0, [](){ad7124diag.read_data();}},
+ {"cnrdv" , 0, [](){ad7124diag.read_volt();}},*/
+ {"cnwr" , 2, [](){cn0398diag.write_reg();}},
+ {"cnsetup",0,[]() {cn0398diag.init();pc.printf("init done\r\n");}},
+ {"cnled0",1,[]() {cn0398diag.toggle_output(1,strtol(cmdbuffer[1].c_str(), NULL, 16)); pc.printf("LED1 toggled"); }},
+ {"cnled1",1,[]() {cn0398diag.toggle_output(2,strtol(cmdbuffer[1].c_str(), NULL, 16));pc.printf("LED2 toggled");}},
+ {"cnoffp",0,[]() {cn0398diag.offsetph();pc.printf("OffsetVoltage measured");}},
+ {"cnpcal0",1,[]() {cn0398diag.calibp(0);pc.printf("calibration point 0");}},
+ {"cnpcal1",1,[]() {cn0398diag.calibp(1);pc.printf("calibration point 1");}},
+ {"cnreadp",0,[]() {cn0398diag.readp();pc.printf("calibration point 1");}},
+ {"cnreadm",0,[]() {cn0398diag.readm();pc.printf("calibration point 1");}},
+ {"cnreadt",0,[]() {cn0398diag.readt();pc.printf("Temperature Read");}},
+
+
+
+
+#endif
+
+#ifdef CN0397_PRESENT
+ {"cnrst" , 0, [](){cn0397diag.reset();}},
+ /* {"cnrd" , 1, [](){cn0397diag.read_reg();}},
+ {"cnwr" , 2, [](){cn0397diag.write_reg();}},*/
+ {"cnsetup",0,[]() {cn0397diag.init();pc.printf("init done\r\n");}},
+ {"cnread",0,[]() {cn0397diag.read();pc.printf("calibration point 1");}},
+#endif
+
+#ifdef CN0396_PRESENT
+ {"cntrst" , 0, [](){pc.printf("reset temp sensor \r\n");cn0396diag.dut.temp.reset();}},
+ {"cntrds" , 0, [](){pc.printf("temp status: %x \r\n",cn0396diag.dut.temp.read_status());}},
+ {"cntrdt" , 0, [](){pc.printf("temp val: %x \r\n",cn0396diag.dut.temp.read_temp());}},
+ {"cntrdc" , 0, [](){pc.printf("temp val: %x \r\n",cn0396diag.dut.temp.read_config());}},
+ {"cntwcf" , 1, [](){pc.printf("wrote config: %x \r\n",strtol(cmdbuffer[1].c_str(), NULL, 16));
+ cn0396diag.dut.temp.write_config(strtol(cmdbuffer[1].c_str(), NULL, 16));}},
+ {"cnardi" , 0, [](){pc.printf("adid : %x \r\n",cn0396diag.dut.ad.get_register_value(3,1,true));}},
+
+ {"rdwrr" , 1, [](){pc.printf("aa");ad5270diag.write_RDAC();}},
+ {"rdrdr" , 0, [](){ad5270diag.read_RDAC();}},
+ {"rdwrcmd" , 2, [](){ad5270diag.write_cmd();}},
+ {"rdsetz" , 0, [](){ad5270diag.set_HiZ();}},
+ {"rd50en", 0, [](){ad5270diag.enable_50TP_programming();}},
+ {"rd50ds", 0, [](){ad5270diag.disable_50TP_programming();}},
+ {"rd50st", 0, [](){ad5270diag.store_50TP();}},
+ {"rd50a" , 0, [](){ad5270diag.read_50TP_last_address();}},
+ {"rd50m" , 1, [](){ad5270diag.read_50TP_memory();}},
+ {"rdwrc" , 1, [](){ad5270diag.write_ctrl_reg();}},
+ {"rdrdc" , 0, [](){ad5270diag.read_ctrl_reg();}},
+ {"rdrst" , 0, [](){ad5270diag.reset_RDAC();}},
+ {"rdchm" , 1, [](){ad5270diag.change_mode();}},
+ {"rdwrw" , 1, [](){ad5270diag.write_wiper_reg();}},
+ {"rdrdw" , 0, [](){ad5270diag.read_wiper_reg();}},
+
+
+#endif
};
// *INDENT-ON*
@@ -223,6 +314,8 @@
int main()
{
+ pc.baud(115200);
+ test.baud(76800);
// ad7791.frequency(100000);
pc.printf("\r\n#### DrvDiag ####\r\n");
CN0357 - Toxic gas measurement
CN0216 - Weight Scale