A collection of Analog Devices drivers for the mbed platform

For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all

Committer:
Adrian Suciu
Date:
Tue May 17 14:21:17 2016 +0300
Revision:
19:fb92949e59c9
Parent:
17:b8356808e8ad
Child:
21:a8023e5e97be
Added ADXL362 driver & reference project

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Adrian Suciu 8:6e96c6b3c83f 1 /**
Adrian Suciu 8:6e96c6b3c83f 2 * @file main.cpp
Adrian Suciu 8:6e96c6b3c83f 3 * @brief Main file of the driver diag tool
Adrian Suciu 8:6e96c6b3c83f 4 * @author Analog Devices Inc.
Adrian Suciu 8:6e96c6b3c83f 5 *
Adrian Suciu 8:6e96c6b3c83f 6 * For support please go to:
Adrian Suciu 8:6e96c6b3c83f 7 * Github: https://github.com/analogdevicesinc/mbed-adi
Adrian Suciu 8:6e96c6b3c83f 8 * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
Adrian Suciu 8:6e96c6b3c83f 9 * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Adrian Suciu 8:6e96c6b3c83f 10
Adrian Suciu 8:6e96c6b3c83f 11 ********************************************************************************
Adrian Suciu 8:6e96c6b3c83f 12 * Copyright 2016(c) Analog Devices, Inc.
Adrian Suciu 8:6e96c6b3c83f 13 *
Adrian Suciu 8:6e96c6b3c83f 14 * All rights reserved.
Adrian Suciu 8:6e96c6b3c83f 15 *
Adrian Suciu 8:6e96c6b3c83f 16 * Redistribution and use in source and binary forms, with or without
Adrian Suciu 8:6e96c6b3c83f 17 * modification, are permitted provided that the following conditions are met:
Adrian Suciu 8:6e96c6b3c83f 18 * - Redistributions of source code must retain the above copyright
Adrian Suciu 8:6e96c6b3c83f 19 * notice, this list of conditions and the following disclaimer.
Adrian Suciu 8:6e96c6b3c83f 20 * - Redistributions in binary form must reproduce the above copyright
Adrian Suciu 8:6e96c6b3c83f 21 * notice, this list of conditions and the following disclaimer in
Adrian Suciu 8:6e96c6b3c83f 22 * the documentation and/or other materials provided with the
Adrian Suciu 8:6e96c6b3c83f 23 * distribution.
Adrian Suciu 8:6e96c6b3c83f 24 * - Neither the name of Analog Devices, Inc. nor the names of its
Adrian Suciu 8:6e96c6b3c83f 25 * contributors may be used to endorse or promote products derived
Adrian Suciu 8:6e96c6b3c83f 26 * from this software without specific prior written permission.
Adrian Suciu 8:6e96c6b3c83f 27 * - The use of this software may or may not infringe the patent rights
Adrian Suciu 8:6e96c6b3c83f 28 * of one or more patent holders. This license does not release you
Adrian Suciu 8:6e96c6b3c83f 29 * from the requirement that you obtain separate licenses from these
Adrian Suciu 8:6e96c6b3c83f 30 * patent holders to use this software.
Adrian Suciu 8:6e96c6b3c83f 31 * - Use of the software either in source or binary form, must be run
Adrian Suciu 8:6e96c6b3c83f 32 * on or directly connected to an Analog Devices Inc. component.
Adrian Suciu 8:6e96c6b3c83f 33 *
Adrian Suciu 8:6e96c6b3c83f 34 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
Adrian Suciu 8:6e96c6b3c83f 35 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
Adrian Suciu 8:6e96c6b3c83f 36 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Adrian Suciu 8:6e96c6b3c83f 37 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
Adrian Suciu 8:6e96c6b3c83f 38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Adrian Suciu 8:6e96c6b3c83f 39 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
Adrian Suciu 8:6e96c6b3c83f 40 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Adrian Suciu 8:6e96c6b3c83f 41 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Adrian Suciu 8:6e96c6b3c83f 42 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Adrian Suciu 8:6e96c6b3c83f 43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Adrian Suciu 8:6e96c6b3c83f 44 *
Adrian Suciu 8:6e96c6b3c83f 45 ********************************************************************************/
Adrian Suciu 8:6e96c6b3c83f 46
Adrian Suciu 7:b62398a1d17a 47 #include "mbed.h"
Adrian Suciu 7:b62398a1d17a 48 #include "stdio.h"
Adrian Suciu 7:b62398a1d17a 49 #include <iostream>
Adrian Suciu 7:b62398a1d17a 50 #include <string>
Adrian Suciu 7:b62398a1d17a 51 #include <vector>
Adrian Suciu 7:b62398a1d17a 52
Adrian Suciu 7:b62398a1d17a 53 #include "config.h"
Adrian Suciu 7:b62398a1d17a 54
Adrian Suciu 7:b62398a1d17a 55 Serial pc(SERIAL_TX, SERIAL_RX);
Adrian Suciu 7:b62398a1d17a 56 vector<string> cmdbuffer;
Adrian Suciu 7:b62398a1d17a 57
Adrian Suciu 19:fb92949e59c9 58 static const uint16_t INACT_VAL = 50;
Adrian Suciu 19:fb92949e59c9 59 static const uint16_t INACT_TIMER = 25 * 10;
Adrian Suciu 19:fb92949e59c9 60 static const uint16_t ACT_VAL = 50;
Adrian Suciu 19:fb92949e59c9 61 static const uint8_t ACT_TIMER = 100;
Adrian Suciu 19:fb92949e59c9 62 static const uint16_t SCAN_SENSOR_TIME = 500;
Adrian Suciu 19:fb92949e59c9 63
Adrian Suciu 7:b62398a1d17a 64 class commands
Adrian Suciu 7:b62398a1d17a 65 {
Adrian Suciu 7:b62398a1d17a 66 public:
Adrian Suciu 7:b62398a1d17a 67 commands(string str, int p, void (*h)() ) : cmd_str(str), nr_of_param(p), fktPtr(h) { }
Adrian Suciu 7:b62398a1d17a 68 const static int VAR = -1; // variable number of params
Adrian Suciu 7:b62398a1d17a 69 string cmd_str;
Adrian Suciu 7:b62398a1d17a 70 int nr_of_param;
Adrian Suciu 7:b62398a1d17a 71 void (*fktPtr)(void);
Adrian Suciu 7:b62398a1d17a 72 };
Adrian Suciu 7:b62398a1d17a 73
Adrian Suciu 7:b62398a1d17a 74 // *INDENT-OFF*
Adrian Suciu 8:6e96c6b3c83f 75 const vector<commands> cmdlist = {
Adrian Suciu 7:b62398a1d17a 76 {"nop" , 0, [](){ }},
Adrian Suciu 7:b62398a1d17a 77 {"echo",commands::VAR, [](){ for(auto i = begin(cmdbuffer) + 1, e = end(cmdbuffer); i!=e; ++i)
Adrian Suciu 7:b62398a1d17a 78 printf("%s ", i->c_str()); printf("\r\n");}},
Adrian Suciu 7:b62398a1d17a 79
Adrian Suciu 7:b62398a1d17a 80 {"help", 0 , [](){ for(auto command : cmdlist)
Adrian Suciu 7:b62398a1d17a 81 pc.printf("%s ",command.cmd_str.c_str()); }},
Adrian Suciu 7:b62398a1d17a 82 /* #### SPI ####*/
Adrian Suciu 7:b62398a1d17a 83 #ifdef SPI_LOW_LEVEL
Adrian Suciu 7:b62398a1d17a 84 {"csa", 0, [](){ spibus.format(8, 3);CSA_pin = !CSA_pin; wait_us(2);
Adrian Suciu 7:b62398a1d17a 85 pc.printf("CS ADC pin set %s", ((CSA_pin.read()) ? "high" : "low") ); }},
Adrian Suciu 7:b62398a1d17a 86 {"csr", 0, [](){ spibus.format(8, 1);CSR_pin = !CSR_pin; wait_us(2);
Adrian Suciu 7:b62398a1d17a 87 pc.printf("CS RDAC pin set %s", ((CSR_pin.read()) ? "high" : "low") );} },
Adrian Suciu 7:b62398a1d17a 88 {"spi", 1, [](){ uint8_t spibyte = strtol(cmdbuffer[1].c_str(), NULL, 16);
Adrian Suciu 7:b62398a1d17a 89 pc.printf("writing 0x%x to SPI", spibyte);
Adrian Suciu 7:b62398a1d17a 90 pc.printf("\r\nreturned: 0x%x ", spibus.write(spibyte)); }},
Adrian Suciu 7:b62398a1d17a 91 #endif
Adrian Suciu 13:66c8e4ce4ff1 92
Adrian Suciu 13:66c8e4ce4ff1 93 #ifdef AD7791_PRESENT
Adrian Suciu 13:66c8e4ce4ff1 94 {"adrst", 0, [](){ad7791diag.reset();}},
Adrian Suciu 13:66c8e4ce4ff1 95 {"adwrm", 1, [](){ad7791diag.write_mode();}},
Adrian Suciu 13:66c8e4ce4ff1 96 {"adrdm", 0, [](){ad7791diag.read_mode();}},
Adrian Suciu 13:66c8e4ce4ff1 97 {"adwrf", 1, [](){ad7791diag.write_filter();}},
Adrian Suciu 13:66c8e4ce4ff1 98 {"adrdf", 0, [](){ad7791diag.read_filter();}},
Adrian Suciu 13:66c8e4ce4ff1 99 {"adrdd", 0, [](){ad7791diag.read_data();}},
Adrian Suciu 13:66c8e4ce4ff1 100 {"adrds", 0, [](){ad7791diag.read_status();}},
Adrian Suciu 13:66c8e4ce4ff1 101 {"adread32", 0, [](){ad7791diag.read();}},
Adrian Suciu 13:66c8e4ce4ff1 102 {"adread", 0, [](){ad7791diag.read_u16();}},
Adrian Suciu 13:66c8e4ce4ff1 103 {"adreadv", 0, [](){ad7791diag.read_voltage();}},
Adrian Suciu 13:66c8e4ce4ff1 104 {"adsetc", 1, [](){ad7791diag.set_continous_mode();}},
Adrian Suciu 13:66c8e4ce4ff1 105 {"adsetref", 1, [](){ad7791diag.set_reference_voltage();}},
Adrian Suciu 13:66c8e4ce4ff1 106 {"adsetch", 1, [](){ad7791diag.set_channel();}},
Adrian Suciu 13:66c8e4ce4ff1 107 #endif
Adrian Suciu 13:66c8e4ce4ff1 108
Adrian Suciu 13:66c8e4ce4ff1 109 #ifdef CN0216_PRESENT
Adrian Suciu 13:66c8e4ce4ff1 110 {"cninit" , 1, [](){cn0216diag.init();}},
Adrian Suciu 13:66c8e4ce4ff1 111 {"cncal" , 1, [](){cn0216diag.calibrate();}},
Adrian Suciu 13:66c8e4ce4ff1 112 {"cnrdw" , 0, [](){cn0216diag.read_weight();}},
Adrian Suciu 13:66c8e4ce4ff1 113 #endif
Adrian Suciu 7:b62398a1d17a 114
Adrian Suciu 7:b62398a1d17a 115 #ifdef AD7790_PRESENT
Adrian Suciu 7:b62398a1d17a 116 {"adrst", 0, [](){ad7790diag.reset();}},
Adrian Suciu 7:b62398a1d17a 117 {"adwrm", 1, [](){ad7790diag.write_mode();}},
Adrian Suciu 7:b62398a1d17a 118 {"adrdm", 0, [](){ad7790diag.read_mode();}},
Adrian Suciu 7:b62398a1d17a 119 {"adwrf", 1, [](){ad7790diag.write_filter();}},
Adrian Suciu 7:b62398a1d17a 120 {"adrdf", 0, [](){ad7790diag.read_filter();}},
Adrian Suciu 7:b62398a1d17a 121 {"adrdd", 0, [](){ad7790diag.read_data();}},
Adrian Suciu 7:b62398a1d17a 122 {"adrds", 0, [](){ad7790diag.read_status();}},
Adrian Suciu 7:b62398a1d17a 123 {"adread", 0, [](){ad7790diag.read_u16();}},
Adrian Suciu 7:b62398a1d17a 124 {"adreadv", 0, [](){ad7790diag.read_voltage();}},
Adrian Suciu 7:b62398a1d17a 125 {"adsetc", 1, [](){ad7790diag.set_continous_mode();}},
Adrian Suciu 7:b62398a1d17a 126 {"adsetref", 1, [](){ad7790diag.set_reference_voltage();}},
Adrian Suciu 7:b62398a1d17a 127 {"adsetch", 1, [](){ad7790diag.set_channel();}},
Adrian Suciu 7:b62398a1d17a 128 #endif
Adrian Suciu 7:b62398a1d17a 129
Adrian Suciu 7:b62398a1d17a 130 #ifdef AD5270_PRESENT
Adrian Suciu 7:b62398a1d17a 131 {"rdwrr" , 1, [](){ad5270diag.write_RDAC();}},
Adrian Suciu 7:b62398a1d17a 132 {"rdrdr" , 0, [](){ad5270diag.read_RDAC();}},
Adrian Suciu 7:b62398a1d17a 133 {"rdwrcmd" , 2, [](){ad5270diag.write_cmd();}},
Adrian Suciu 7:b62398a1d17a 134 {"rdsetz" , 0, [](){ad5270diag.set_HiZ();}},
Adrian Suciu 7:b62398a1d17a 135 {"rd50en", 0, [](){ad5270diag.enable_50TP_programming();}},
Adrian Suciu 7:b62398a1d17a 136 {"rd50ds", 0, [](){ad5270diag.disable_50TP_programming();}},
Adrian Suciu 7:b62398a1d17a 137 {"rd50st", 0, [](){ad5270diag.store_50TP();}},
Adrian Suciu 7:b62398a1d17a 138 {"rd50a" , 0, [](){ad5270diag.read_50TP_last_address();}},
Adrian Suciu 7:b62398a1d17a 139 {"rd50m" , 1, [](){ad5270diag.read_50TP_memory();}},
Adrian Suciu 7:b62398a1d17a 140 {"rdwrc" , 1, [](){ad5270diag.write_ctrl_reg();}},
Adrian Suciu 7:b62398a1d17a 141 {"rdrdc" , 0, [](){ad5270diag.read_ctrl_reg();}},
Adrian Suciu 7:b62398a1d17a 142 {"rdrst" , 0, [](){ad5270diag.reset_RDAC();}},
Adrian Suciu 7:b62398a1d17a 143 {"rdchm" , 1, [](){ad5270diag.change_mode();}},
Adrian Suciu 7:b62398a1d17a 144 {"rdwrw" , 1, [](){ad5270diag.write_wiper_reg();}},
Adrian Suciu 7:b62398a1d17a 145 {"rdrdw" , 0, [](){ad5270diag.read_wiper_reg();}},
Adrian Suciu 7:b62398a1d17a 146 #endif
Adrian Suciu 7:b62398a1d17a 147
Adrian Suciu 7:b62398a1d17a 148 #ifdef CN0357_PRESENT
Adrian Suciu 7:b62398a1d17a 149 {"cnwrdac" , 1, [](){cn0357diag.set_RDAC();}},
Adrian Suciu 7:b62398a1d17a 150 {"cnrppm" , 0, [](){cn0357diag.read_ppm();}},
Adrian Suciu 7:b62398a1d17a 151 {"cnparam" , 2, [](){cn0357diag.set_sensor_param();}}
Adrian Suciu 7:b62398a1d17a 152 #endif
Adrian Suciu 7:b62398a1d17a 153
Adrian Suciu 19:fb92949e59c9 154 #ifdef ADXL362_PRESENT
Adrian Suciu 19:fb92949e59c9 155 {"xlrst" , 0, [](){adxl362diag.reset();}},
Adrian Suciu 19:fb92949e59c9 156 {"xlscan" , 0, [](){adxl362diag.scan();}},
Adrian Suciu 19:fb92949e59c9 157 {"xlwr" , 2, [](){adxl362diag.write_reg();}},
Adrian Suciu 19:fb92949e59c9 158 {"xlrd" , 1, [](){adxl362diag.read_reg();}},
Adrian Suciu 19:fb92949e59c9 159 {"xlstat", 0 , [](){adxl362diag.read_status();}},
Adrian Suciu 19:fb92949e59c9 160 {"xlctl", 1 , [](){adxl362diag.write_ctl(); }},
Adrian Suciu 19:fb92949e59c9 161 {"xlftl", 1 , [](){adxl362diag.write_ftl(); }},
Adrian Suciu 19:fb92949e59c9 162
Adrian Suciu 19:fb92949e59c9 163 {"xlfrn", 0, [](){adxl362diag.fifo_read_nr_of_entries(); }},
Adrian Suciu 19:fb92949e59c9 164 {"xlfset", 2, [](){adxl362diag.fifo_setup(); }},
Adrian Suciu 19:fb92949e59c9 165 {"xlfr16", 0, [](){adxl362diag.fifo_read_u16(); }},
Adrian Suciu 19:fb92949e59c9 166 {"xlfrs", 0, [](){adxl362diag.fifo_scan(); }},
Adrian Suciu 19:fb92949e59c9 167 {"xlintinit",0,[](){
Adrian Suciu 19:fb92949e59c9 168 adxl362.reset();
Adrian Suciu 19:fb92949e59c9 169 pc.printf("adxl362 reset\r\n");
Adrian Suciu 19:fb92949e59c9 170 wait_ms(500);
Adrian Suciu 19:fb92949e59c9 171 adxl362.set_activity_threshold(ACT_VAL);
Adrian Suciu 19:fb92949e59c9 172 adxl362.set_activity_time(ACT_TIMER / 10);
Adrian Suciu 19:fb92949e59c9 173
Adrian Suciu 19:fb92949e59c9 174 adxl362.set_inactivity_threshold(INACT_VAL);
Adrian Suciu 19:fb92949e59c9 175 adxl362.set_inactivity_time(INACT_TIMER);
Adrian Suciu 19:fb92949e59c9 176 adxl362.set_act_inact_ctl_reg(0x3f);
Adrian Suciu 19:fb92949e59c9 177
Adrian Suciu 19:fb92949e59c9 178 pc.printf("adxl362 set activity/inactivity\r\n");
Adrian Suciu 19:fb92949e59c9 179
Adrian Suciu 19:fb92949e59c9 180 adxl362.disable_interrupt2();
Adrian Suciu 19:fb92949e59c9 181 adxl362.set_interrupt2_pin(D2,0x40,&rising_adxl362,&falling_adxl362);
Adrian Suciu 19:fb92949e59c9 182 extern bool awake;
Adrian Suciu 19:fb92949e59c9 183 awake = true;
Adrian Suciu 19:fb92949e59c9 184
Adrian Suciu 19:fb92949e59c9 185 pc.printf("adxl362 set interrupt\r\n");
Adrian Suciu 19:fb92949e59c9 186 adxl362.enable_interrupt2();
Adrian Suciu 19:fb92949e59c9 187 adxl362.set_mode(ADXL362::MEASUREMENT);
Adrian Suciu 19:fb92949e59c9 188 pc.printf("adxl362 measurement started\r\n");
Adrian Suciu 19:fb92949e59c9 189
Adrian Suciu 19:fb92949e59c9 190 }},
Adrian Suciu 19:fb92949e59c9 191 {
Adrian Suciu 19:fb92949e59c9 192 "xlawake",0,[](){
Adrian Suciu 19:fb92949e59c9 193 extern bool awake;
Adrian Suciu 19:fb92949e59c9 194 if(awake) pc.printf("awaken");
Adrian Suciu 19:fb92949e59c9 195 else pc.printf("asleep");
Adrian Suciu 19:fb92949e59c9 196 }
Adrian Suciu 19:fb92949e59c9 197 },
Adrian Suciu 19:fb92949e59c9 198
Adrian Suciu 19:fb92949e59c9 199
Adrian Suciu 19:fb92949e59c9 200 #endif
Adrian Suciu 19:fb92949e59c9 201
Adrian Suciu 7:b62398a1d17a 202 };
Adrian Suciu 7:b62398a1d17a 203 // *INDENT-ON*
Adrian Suciu 7:b62398a1d17a 204
Adrian Suciu 7:b62398a1d17a 205
Adrian Suciu 7:b62398a1d17a 206
Adrian Suciu 7:b62398a1d17a 207 void read_from_console()
Adrian Suciu 7:b62398a1d17a 208 {
Adrian Suciu 7:b62398a1d17a 209 char buffer[100] = {0};
Adrian Suciu 7:b62398a1d17a 210 size_t readPosition = 0;
Adrian Suciu 7:b62398a1d17a 211
Adrian Suciu 7:b62398a1d17a 212 // read from console until newline
Adrian Suciu 7:b62398a1d17a 213 while(1) {
Adrian Suciu 7:b62398a1d17a 214 buffer[readPosition] = pc.getc();
Adrian Suciu 7:b62398a1d17a 215 if(buffer[readPosition] == '\n' || buffer[readPosition] == '\r') {
Adrian Suciu 7:b62398a1d17a 216 buffer[readPosition] = ' ';
Adrian Suciu 7:b62398a1d17a 217 break;
Adrian Suciu 7:b62398a1d17a 218 }
Adrian Suciu 7:b62398a1d17a 219 readPosition++;
Adrian Suciu 7:b62398a1d17a 220 }
Adrian Suciu 7:b62398a1d17a 221 readPosition++;
Adrian Suciu 7:b62398a1d17a 222 buffer[readPosition] = '\0';
Adrian Suciu 7:b62398a1d17a 223 //create std::string from char buffer
Adrian Suciu 7:b62398a1d17a 224 string s(buffer);
Adrian Suciu 7:b62398a1d17a 225
Adrian Suciu 7:b62398a1d17a 226 // create std::vector of std:string, each string contains parameter
Adrian Suciu 7:b62398a1d17a 227 size_t pos = 0;
Adrian Suciu 7:b62398a1d17a 228 string delimiter = " ";
Adrian Suciu 7:b62398a1d17a 229 string token;
Adrian Suciu 7:b62398a1d17a 230 while ((pos = s.find(delimiter)) != std::string::npos) {
Adrian Suciu 7:b62398a1d17a 231 token = s.substr(0, pos);
Adrian Suciu 7:b62398a1d17a 232 cmdbuffer.push_back(token);
Adrian Suciu 7:b62398a1d17a 233 s.erase(0, pos + delimiter.length());
Adrian Suciu 7:b62398a1d17a 234 }
Adrian Suciu 7:b62398a1d17a 235
Adrian Suciu 7:b62398a1d17a 236 }
Adrian Suciu 7:b62398a1d17a 237
Adrian Suciu 7:b62398a1d17a 238 void run_command()
Adrian Suciu 7:b62398a1d17a 239 {
Adrian Suciu 7:b62398a1d17a 240 for(auto i : cmdlist) {
Adrian Suciu 7:b62398a1d17a 241 if(i.cmd_str == cmdbuffer[0]) {
Adrian Suciu 7:b62398a1d17a 242 if(static_cast<int>(cmdbuffer.size()) - 1 == i.nr_of_param || i.nr_of_param == commands::VAR) {
Adrian Suciu 7:b62398a1d17a 243 pc.printf("RX> ");
Adrian Suciu 7:b62398a1d17a 244 i.fktPtr();
Adrian Suciu 7:b62398a1d17a 245 } else {
Adrian Suciu 7:b62398a1d17a 246 pc.printf("RX> ");
Adrian Suciu 7:b62398a1d17a 247 pc.printf("Command %s expects %d parameters, found %d", i.cmd_str.c_str(), i.nr_of_param, cmdbuffer.size() - 1);
Adrian Suciu 7:b62398a1d17a 248 }
Adrian Suciu 7:b62398a1d17a 249 return;
Adrian Suciu 7:b62398a1d17a 250 }
Adrian Suciu 7:b62398a1d17a 251 }
Adrian Suciu 7:b62398a1d17a 252 pc.printf("RX> ");
Adrian Suciu 7:b62398a1d17a 253 pc.printf("Command %s not found", cmdbuffer[0].c_str());
Adrian Suciu 7:b62398a1d17a 254
Adrian Suciu 7:b62398a1d17a 255 }
Adrian Suciu 7:b62398a1d17a 256
Adrian Suciu 7:b62398a1d17a 257 int main()
Adrian Suciu 7:b62398a1d17a 258
Adrian Suciu 13:66c8e4ce4ff1 259 {
Adrian Suciu 19:fb92949e59c9 260 // ad7791.frequency(100000);
Adrian Suciu 7:b62398a1d17a 261 pc.printf("\r\n#### DrvDiag ####\r\n");
Adrian Suciu 13:66c8e4ce4ff1 262
Adrian Suciu 7:b62398a1d17a 263 while(1) {
Adrian Suciu 7:b62398a1d17a 264 pc.printf("\r\nTX> ");
Adrian Suciu 7:b62398a1d17a 265 read_from_console();
Adrian Suciu 7:b62398a1d17a 266 run_command();
Adrian Suciu 7:b62398a1d17a 267 cmdbuffer.clear();
Adrian Suciu 7:b62398a1d17a 268 }
Adrian Suciu 7:b62398a1d17a 269
Adrian Suciu 7:b62398a1d17a 270 }
Adrian Suciu 7:b62398a1d17a 271