2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

Committer:
shimniok
Date:
Wed Jan 02 18:41:52 2019 +0000
Revision:
39:465213249f71
Parent:
38:6fec81f85221
Child:
42:8d99f64f5898
display gps data via eventqueue

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:7e98bbfd102a 1 /* mbed Microcontroller Library
shimniok 0:7e98bbfd102a 2 * Copyright (c) 2018 ARM Limited
shimniok 0:7e98bbfd102a 3 * SPDX-License-Identifier: Apache-2.0
shimniok 0:7e98bbfd102a 4 */
shimniok 0:7e98bbfd102a 5
shimniok 0:7e98bbfd102a 6 #include "mbed.h"
shimniok 0:7e98bbfd102a 7 #include <stdio.h>
shimniok 0:7e98bbfd102a 8 #include <errno.h>
shimniok 16:eb28d0f64a9b 9 #include "pinouts.h"
shimniok 0:7e98bbfd102a 10 #include "stats_report.h"
shimniok 0:7e98bbfd102a 11 #include "SDBlockDevice.h"
shimniok 0:7e98bbfd102a 12 #include "FATFileSystem.h"
shimniok 35:c42e7e29c3bd 13 #include "Servo.h"
shimniok 0:7e98bbfd102a 14 #include "SimpleShell.h"
shimniok 4:de7feb458652 15 #include "Config.h"
shimniok 11:8ec858b7c6d1 16 #include "Updater.h"
shimniok 16:eb28d0f64a9b 17 #include "Ublox6.h"
shimniok 24:a7f92dfc5310 18 #include "Logger.h"
shimniok 24:a7f92dfc5310 19 #include "SystemState.h"
shimniok 37:b8259500dbd3 20 #include "Display.h"
shimniok 0:7e98bbfd102a 21
shimniok 24:a7f92dfc5310 22 ///////////////////////////////////////////////////////////////////////////////
shimniok 24:a7f92dfc5310 23 // Config
shimniok 24:a7f92dfc5310 24 Config config;
shimniok 24:a7f92dfc5310 25
shimniok 24:a7f92dfc5310 26 ///////////////////////////////////////////////////////////////////////////////
shimniok 24:a7f92dfc5310 27 // Devices
shimniok 30:ed791f1f7f7d 28 DigitalOut led1(LED1);
shimniok 30:ed791f1f7f7d 29 DigitalOut led2(LED2);
shimniok 30:ed791f1f7f7d 30 DigitalOut led3(LED3);
shimniok 30:ed791f1f7f7d 31 DigitalOut led4(LED4);
shimniok 37:b8259500dbd3 32 Display display(UART3TX, UART3RX);
shimniok 0:7e98bbfd102a 33 LocalFileSystem lfs("etc");
shimniok 24:a7f92dfc5310 34 SDBlockDevice bd(p5, p6, p7, p8); // MOSI, MISO, CLK, CS
shimniok 24:a7f92dfc5310 35 FATFileSystem ffs("log", &bd);
shimniok 24:a7f92dfc5310 36 Serial pc(USBTX, USBRX);
shimniok 20:043987d06f8d 37 RawSerial s(UART1TX, UART1RX, 38400);
shimniok 33:74c514aea0a1 38 InterruptIn lbutton(LBUTTON, PullUp); // button interrupts
shimniok 33:74c514aea0a1 39 InterruptIn cbutton(CBUTTON, PullUp);
shimniok 33:74c514aea0a1 40 InterruptIn rbutton(RBUTTON, PullUp);
shimniok 35:c42e7e29c3bd 41 Servo steer(STEERING);
shimniok 35:c42e7e29c3bd 42 Servo esc(THROTTLE);
shimniok 20:043987d06f8d 43
shimniok 24:a7f92dfc5310 44 ///////////////////////////////////////////////////////////////////////////////
shimniok 24:a7f92dfc5310 45 // Idle hook
shimniok 24:a7f92dfc5310 46 void idler() {
shimniok 24:a7f92dfc5310 47 while(1) {
shimniok 24:a7f92dfc5310 48 led1 = !led1;
shimniok 24:a7f92dfc5310 49 wait(0.1);
shimniok 24:a7f92dfc5310 50 }
shimniok 24:a7f92dfc5310 51 }
shimniok 19:0d1728091519 52
shimniok 24:a7f92dfc5310 53 ///////////////////////////////////////////////////////////////////////////////
shimniok 24:a7f92dfc5310 54 // Logging
shimniok 29:cb2f55fbfe9c 55 EventQueue logQueue(16 * EVENTS_EVENT_SIZE);
shimniok 31:20a95043adb0 56 Logger logger;
shimniok 25:b8176ebb96c6 57
shimniok 25:b8176ebb96c6 58 ///////////////////////////////////////////////////////////////////////////////
shimniok 25:b8176ebb96c6 59 // Updater
shimniok 25:b8176ebb96c6 60 Updater *u = Updater::instance();
shimniok 26:2dc31a801cc8 61 EventQueue updaterQueue(8 * EVENTS_EVENT_SIZE);
shimniok 25:b8176ebb96c6 62
shimniok 25:b8176ebb96c6 63 void updater_callback() {
shimniok 30:ed791f1f7f7d 64 SensorData d;
shimniok 30:ed791f1f7f7d 65 float dt;
shimniok 30:ed791f1f7f7d 66
shimniok 25:b8176ebb96c6 67 led1 = !led1;
shimniok 30:ed791f1f7f7d 68 d.timestamp = Kernel::get_ms_count();
shimniok 30:ed791f1f7f7d 69 d.encoder = u->encoder();
shimniok 32:eb673f6f5734 70 u->imu(d.gyro, d.accel, d.mag, dt);
shimniok 30:ed791f1f7f7d 71 logQueue.call(&logger, &Logger::log_sensors, d);
shimniok 37:b8259500dbd3 72 //lcdQueue.call ...
shimniok 25:b8176ebb96c6 73 }
shimniok 25:b8176ebb96c6 74
shimniok 24:a7f92dfc5310 75 ///////////////////////////////////////////////////////////////////////////////
shimniok 30:ed791f1f7f7d 76 // Buttons
shimniok 30:ed791f1f7f7d 77
shimniok 30:ed791f1f7f7d 78 //enum button_mask { LEFT = 0x01, CENTER = 0x02, RIGHT = 0x04 };
shimniok 30:ed791f1f7f7d 79 EventQueue buttonQueue(16 * EVENTS_EVENT_SIZE);
shimniok 33:74c514aea0a1 80 const int BUTTON_DEBOUNCE_SAMPLES = 20;
shimniok 33:74c514aea0a1 81 const int BUTTON_DEBOUNCE_THRESH = 8;
shimniok 33:74c514aea0a1 82 const int BUTTON_SAMPLE_MS = 0.005;
shimniok 30:ed791f1f7f7d 83
shimniok 30:ed791f1f7f7d 84 void button_event() {
shimniok 33:74c514aea0a1 85 int samples = 0;
shimniok 33:74c514aea0a1 86
shimniok 33:74c514aea0a1 87 // disable subsequent interrupts
shimniok 33:74c514aea0a1 88 lbutton.fall(NULL);
shimniok 33:74c514aea0a1 89
shimniok 33:74c514aea0a1 90 // sample repeatedly to debounce
shimniok 33:74c514aea0a1 91 for (int i=0; i < BUTTON_DEBOUNCE_SAMPLES; i++) {
shimniok 33:74c514aea0a1 92 if (lbutton == 0) samples++;
shimniok 33:74c514aea0a1 93 wait(BUTTON_SAMPLE_MS);
shimniok 33:74c514aea0a1 94 }
shimniok 33:74c514aea0a1 95
shimniok 33:74c514aea0a1 96 if (samples > BUTTON_DEBOUNCE_THRESH) {
shimniok 30:ed791f1f7f7d 97 if (logger.enabled()) {
shimniok 30:ed791f1f7f7d 98 logQueue.call(&logger, &Logger::stop);
shimniok 30:ed791f1f7f7d 99 led3 = 0;
shimniok 30:ed791f1f7f7d 100 } else {
shimniok 30:ed791f1f7f7d 101 logQueue.call(&logger, &Logger::start);
shimniok 30:ed791f1f7f7d 102 led3 = 1;
shimniok 30:ed791f1f7f7d 103 }
shimniok 30:ed791f1f7f7d 104 }
shimniok 33:74c514aea0a1 105
shimniok 33:74c514aea0a1 106 lbutton.fall(buttonQueue.event(button_event));
shimniok 30:ed791f1f7f7d 107 }
shimniok 30:ed791f1f7f7d 108
shimniok 30:ed791f1f7f7d 109
shimniok 30:ed791f1f7f7d 110 ///////////////////////////////////////////////////////////////////////////////
shimniok 24:a7f92dfc5310 111 // GPS
shimniok 24:a7f92dfc5310 112 Ublox6 ublox;
shimniok 24:a7f92dfc5310 113 EventQueue gpsQueue(8 * EVENTS_EVENT_SIZE);
shimniok 38:6fec81f85221 114 EventQueue lcdQueue(8 * EVENTS_EVENT_SIZE);
shimniok 23:5e61cf4a8c34 115
shimniok 23:5e61cf4a8c34 116 // Callback for gps parse data ready
shimniok 23:5e61cf4a8c34 117 void gps_callback() {
shimniok 24:a7f92dfc5310 118 GpsData d;
shimniok 24:a7f92dfc5310 119
shimniok 25:b8176ebb96c6 120 led2 = !led2;
shimniok 24:a7f92dfc5310 121 ublox.read(d.latitude, d.longitude, d.course, d.speed, d.hdop, d.svcount);
shimniok 30:ed791f1f7f7d 122 d.timestamp = Kernel::get_ms_count();
shimniok 29:cb2f55fbfe9c 123 logQueue.call(&logger, &Logger::log_gps, d);
shimniok 39:465213249f71 124 lcdQueue.call(&display, &Display::gps, d);
shimniok 23:5e61cf4a8c34 125 }
shimniok 29:cb2f55fbfe9c 126
shimniok 22:4d62bd16f037 127 // ISR for GPS serial, passes off to thread
shimniok 20:043987d06f8d 128 void gps_handler() {
shimniok 22:4d62bd16f037 129 while (s.readable()) {
shimniok 22:4d62bd16f037 130 int c = s.getc();
shimniok 22:4d62bd16f037 131 gpsQueue.call(&ublox, &Ublox6::parse, c);
shimniok 16:eb28d0f64a9b 132 }
shimniok 19:0d1728091519 133 }
shimniok 16:eb28d0f64a9b 134
shimniok 24:a7f92dfc5310 135 ///////////////////////////////////////////////////////////////////////////////
shimniok 24:a7f92dfc5310 136 // Shell
shimniok 30:ed791f1f7f7d 137 SimpleShell sh("/log");
shimniok 9:fc3575d2cbbf 138
shimniok 24:a7f92dfc5310 139 void test(int argc, char **argv) {
shimniok 35:c42e7e29c3bd 140 //printf("Hello world!\n");
shimniok 35:c42e7e29c3bd 141 char file[32];
shimniok 35:c42e7e29c3bd 142
shimniok 35:c42e7e29c3bd 143 for (int i=30; i < 40; i++) {
shimniok 35:c42e7e29c3bd 144 sprintf(file, "/log/%04d.csv", i);
shimniok 35:c42e7e29c3bd 145 printf("removing <%s>\n", file);
shimniok 35:c42e7e29c3bd 146 int stat = remove(file);
shimniok 35:c42e7e29c3bd 147 printf("return: %d\n", stat);
shimniok 35:c42e7e29c3bd 148 }
shimniok 1:7019a60fd585 149 }
shimniok 1:7019a60fd585 150
shimniok 24:a7f92dfc5310 151 void stats(int argc, char **argv) {
shimniok 24:a7f92dfc5310 152 SystemReport r(200);
shimniok 24:a7f92dfc5310 153 r.report_state();
shimniok 24:a7f92dfc5310 154 return;
shimniok 24:a7f92dfc5310 155 }
shimniok 24:a7f92dfc5310 156
shimniok 24:a7f92dfc5310 157 void read_gps(int argc, char **argv)
shimniok 18:3f8a8f6e3cc1 158 {
shimniok 18:3f8a8f6e3cc1 159 double lat=0;
shimniok 18:3f8a8f6e3cc1 160 double lon=0;
shimniok 18:3f8a8f6e3cc1 161 float course=0;
shimniok 18:3f8a8f6e3cc1 162 float speed=0;
shimniok 18:3f8a8f6e3cc1 163 float hdop=0.0;
shimniok 18:3f8a8f6e3cc1 164 int svcount=0;
shimniok 18:3f8a8f6e3cc1 165
shimniok 18:3f8a8f6e3cc1 166 ublox.read(lat, lon, course, speed, hdop, svcount);
shimniok 18:3f8a8f6e3cc1 167 printf("%3.7f %3.7f\n", lat, lon);
shimniok 18:3f8a8f6e3cc1 168 printf("hdg=%03.1f deg spd=%3.1f m/s\n", course, speed);
shimniok 18:3f8a8f6e3cc1 169 printf("%d %f\n", svcount, hdop);
shimniok 18:3f8a8f6e3cc1 170 }
shimniok 18:3f8a8f6e3cc1 171
shimniok 32:eb673f6f5734 172 void read_imu(int argc, char **argv)
shimniok 9:fc3575d2cbbf 173 {
shimniok 12:3cd91e150d9c 174 int g[3];
shimniok 32:eb673f6f5734 175 int a[3];
shimniok 32:eb673f6f5734 176 int m[3];
shimniok 13:5566df1250f1 177 float dt;
shimniok 12:3cd91e150d9c 178
shimniok 11:8ec858b7c6d1 179 Updater *u = Updater::instance();
shimniok 11:8ec858b7c6d1 180
shimniok 32:eb673f6f5734 181 u->imu(g, a, m, dt);
shimniok 32:eb673f6f5734 182
shimniok 32:eb673f6f5734 183 printf(" Gyro: %d, %d, %d\n", g[0], g[1], g[2]);
shimniok 32:eb673f6f5734 184 printf(" Accel: %d, %d, %d\n", a[0], a[1], a[2]);
shimniok 32:eb673f6f5734 185 printf(" Mag: %d, %d, %d\n", m[0], m[1], m[2]);
shimniok 32:eb673f6f5734 186 printf(" dt: %f\n", dt);
shimniok 12:3cd91e150d9c 187 }
shimniok 12:3cd91e150d9c 188
shimniok 24:a7f92dfc5310 189 void read_enc(int argc, char **argv)
shimniok 14:1dd83e626153 190 {
shimniok 14:1dd83e626153 191 Updater *u = Updater::instance();
shimniok 14:1dd83e626153 192
shimniok 14:1dd83e626153 193 printf("Encoder: %d\n", u->encoder());
shimniok 14:1dd83e626153 194 }
shimniok 14:1dd83e626153 195
shimniok 29:cb2f55fbfe9c 196 void log(int argc, char **argv)
shimniok 29:cb2f55fbfe9c 197 {
shimniok 29:cb2f55fbfe9c 198 char *usage = "usage: log [start|stop]";
shimniok 29:cb2f55fbfe9c 199
shimniok 29:cb2f55fbfe9c 200 if (argc == 1) {
shimniok 29:cb2f55fbfe9c 201 printf("logging ");
shimniok 29:cb2f55fbfe9c 202 if (logger.enabled())
shimniok 29:cb2f55fbfe9c 203 printf("enabled");
shimniok 29:cb2f55fbfe9c 204 else
shimniok 29:cb2f55fbfe9c 205 printf("disabled");
shimniok 29:cb2f55fbfe9c 206 printf("\n");
shimniok 29:cb2f55fbfe9c 207 } else if (argc == 2) {
shimniok 29:cb2f55fbfe9c 208 if (!strcmp("start", argv[1])) {
shimniok 29:cb2f55fbfe9c 209 logger.start();
shimniok 29:cb2f55fbfe9c 210 } else if (!strcmp("stop", argv[1])) {
shimniok 29:cb2f55fbfe9c 211 logger.stop();
shimniok 29:cb2f55fbfe9c 212 } else {
shimniok 29:cb2f55fbfe9c 213 puts(usage);
shimniok 29:cb2f55fbfe9c 214 }
shimniok 29:cb2f55fbfe9c 215 } else {
shimniok 29:cb2f55fbfe9c 216 puts(usage);
shimniok 29:cb2f55fbfe9c 217 }
shimniok 29:cb2f55fbfe9c 218 }
shimniok 29:cb2f55fbfe9c 219
shimniok 29:cb2f55fbfe9c 220
shimniok 24:a7f92dfc5310 221 void bridge_uart1(int argc, char **argv) {
shimniok 20:043987d06f8d 222 RawSerial s(UART1TX, UART1RX, 38400);
shimniok 20:043987d06f8d 223 while (1) {
shimniok 20:043987d06f8d 224 if (pc.readable()) s.putc(pc.getc());
shimniok 20:043987d06f8d 225 if (s.readable()) pc.putc(s.getc());
shimniok 20:043987d06f8d 226 }
shimniok 20:043987d06f8d 227 }
shimniok 20:043987d06f8d 228
shimniok 24:a7f92dfc5310 229 void reset(int argc, char **argv)
shimniok 12:3cd91e150d9c 230 {
shimniok 12:3cd91e150d9c 231 NVIC_SystemReset();
shimniok 9:fc3575d2cbbf 232 }
shimniok 9:fc3575d2cbbf 233
shimniok 24:a7f92dfc5310 234 ///////////////////////////////////////////////////////////////////////////////
shimniok 24:a7f92dfc5310 235 // MAIN
shimniok 1:7019a60fd585 236
shimniok 0:7e98bbfd102a 237 // main() runs in its own thread in the OS
shimniok 0:7e98bbfd102a 238 int main()
shimniok 11:8ec858b7c6d1 239 {
shimniok 20:043987d06f8d 240 //bridge_uart1();
shimniok 24:a7f92dfc5310 241
shimniok 25:b8176ebb96c6 242 //Kernel::attach_idle_hook(idler);
shimniok 20:043987d06f8d 243
shimniok 37:b8259500dbd3 244 display.status("Bootup...");
shimniok 0:7e98bbfd102a 245 printf("Bootup...\n");
shimniok 0:7e98bbfd102a 246 fflush(stdout);
shimniok 1:7019a60fd585 247
shimniok 35:c42e7e29c3bd 248 steer = 0.50;
shimniok 35:c42e7e29c3bd 249 esc = 0.00;
shimniok 35:c42e7e29c3bd 250
shimniok 4:de7feb458652 251 printf("Loading config...\n");
shimniok 37:b8259500dbd3 252 display.status("Loading config");
shimniok 7:1f2661b840ed 253 config.add("intercept_distance", Config::DOUBLE);
shimniok 7:1f2661b840ed 254 config.add("waypoint_threshold", Config::DOUBLE);
shimniok 7:1f2661b840ed 255 config.add("minimum_turning_radius", Config::DOUBLE);
shimniok 7:1f2661b840ed 256 config.add("wheelbase", Config::DOUBLE);
shimniok 7:1f2661b840ed 257 config.add("track_width", Config::DOUBLE);
shimniok 7:1f2661b840ed 258 config.add("tire_circumference", Config::DOUBLE);
shimniok 7:1f2661b840ed 259 config.add("encoder_stripes", Config::INT);
shimniok 7:1f2661b840ed 260 config.add("esc_brake", Config::INT);
shimniok 7:1f2661b840ed 261 config.add("esc_off", Config::INT);
shimniok 7:1f2661b840ed 262 config.add("esc_max", Config::INT);
shimniok 7:1f2661b840ed 263 config.add("turn_speed", Config::DOUBLE);
shimniok 7:1f2661b840ed 264 config.add("turn_distance", Config::DOUBLE);
shimniok 7:1f2661b840ed 265 config.add("start_speed", Config::DOUBLE);
shimniok 7:1f2661b840ed 266 config.add("cruise_speed", Config::DOUBLE);
shimniok 7:1f2661b840ed 267 config.add("speed_kp", Config::DOUBLE);
shimniok 7:1f2661b840ed 268 config.add("speed_ki", Config::DOUBLE);
shimniok 7:1f2661b840ed 269 config.add("speed_kd", Config::DOUBLE);
shimniok 7:1f2661b840ed 270 config.add("steer_center", Config::DOUBLE);
shimniok 7:1f2661b840ed 271 config.add("steer_scale", Config::DOUBLE);
shimniok 7:1f2661b840ed 272 config.add("gyro_scale", Config::DOUBLE);
shimniok 7:1f2661b840ed 273 config.add("gps_valid_speed", Config::DOUBLE);
shimniok 35:c42e7e29c3bd 274
shimniok 4:de7feb458652 275 if (config.load("/etc/2018cfg.txt")) {
shimniok 4:de7feb458652 276 printf("error loading config\n");
shimniok 37:b8259500dbd3 277 display.status("config load error");
shimniok 4:de7feb458652 278 }
shimniok 10:9fb3feb38746 279
shimniok 38:6fec81f85221 280 printf("Starting display...\n");
shimniok 39:465213249f71 281 Thread lcdThread(osPriorityNormal, 2048, 0, "lcd");
shimniok 38:6fec81f85221 282 lcdThread.start(callback(&lcdQueue, &EventQueue::dispatch_forever));
shimniok 38:6fec81f85221 283
shimniok 30:ed791f1f7f7d 284 printf("Starting buttons...\n");
shimniok 37:b8259500dbd3 285 display.status("Starting buttons");
shimniok 33:74c514aea0a1 286 lbutton.fall(buttonQueue.event(button_event));
shimniok 30:ed791f1f7f7d 287 //cbutton.rise(buttonQueue.event(button_event));
shimniok 30:ed791f1f7f7d 288 //rbutton.rise(buttonQueue.event(button_event));
shimniok 30:ed791f1f7f7d 289 Thread buttonThread(osPriorityNormal, 256, 0, "buttons");
shimniok 30:ed791f1f7f7d 290 buttonThread.start(callback(&buttonQueue, &EventQueue::dispatch_forever));
shimniok 30:ed791f1f7f7d 291
shimniok 24:a7f92dfc5310 292 printf("Starting updater...\n");
shimniok 37:b8259500dbd3 293 display.status("Starting updater");
shimniok 25:b8176ebb96c6 294 u->attach(updater_callback);
shimniok 24:a7f92dfc5310 295 Thread updaterThread(osPriorityRealtime, 512, 0, "updater");
shimniok 26:2dc31a801cc8 296 updaterQueue.call_every(20, u, &Updater::update);
shimniok 26:2dc31a801cc8 297 updaterThread.start(callback(&updaterQueue, &EventQueue::dispatch_forever));
shimniok 24:a7f92dfc5310 298
shimniok 24:a7f92dfc5310 299 printf("Starting gps...\n");
shimniok 37:b8259500dbd3 300 display.status("Starting gps");
shimniok 29:cb2f55fbfe9c 301 Thread gpsThread(osPriorityHigh, 2048, 0, "gps");
shimniok 24:a7f92dfc5310 302 gpsThread.start(callback(&gpsQueue, &EventQueue::dispatch_forever));
shimniok 24:a7f92dfc5310 303 ublox.subscribe(gps_callback);
shimniok 24:a7f92dfc5310 304 s.attach(gps_handler);
shimniok 24:a7f92dfc5310 305
shimniok 37:b8259500dbd3 306 printf("Starting logging...\n");
shimniok 37:b8259500dbd3 307 display.status("Starting logging");
shimniok 29:cb2f55fbfe9c 308 Thread logThread(osPriorityNormal, 2048, 0, "log");
shimniok 24:a7f92dfc5310 309 logThread.start(callback(&logQueue, &EventQueue::dispatch_forever));
shimniok 24:a7f92dfc5310 310
shimniok 13:5566df1250f1 311 printf("Starting shell...\n");
shimniok 37:b8259500dbd3 312 display.status("Starting shell");
shimniok 30:ed791f1f7f7d 313 sh.command(test, "test");
shimniok 32:eb673f6f5734 314 sh.command(read_imu, "imu");
shimniok 30:ed791f1f7f7d 315 sh.command(read_enc, "enc");
shimniok 30:ed791f1f7f7d 316 sh.command(read_gps, "gps");
shimniok 30:ed791f1f7f7d 317 sh.command(reset, "reset");
shimniok 30:ed791f1f7f7d 318 sh.command(stats, "stats");
shimniok 30:ed791f1f7f7d 319 sh.command(log, "log");
shimniok 37:b8259500dbd3 320
shimniok 37:b8259500dbd3 321 display.status("DataBus 2018");
shimniok 24:a7f92dfc5310 322 sh.run();
shimniok 22:4d62bd16f037 323
shimniok 0:7e98bbfd102a 324 while (true) {
shimniok 0:7e98bbfd102a 325 // Blink LED and wait 0.5 seconds
shimniok 0:7e98bbfd102a 326 led1 = !led1;
shimniok 0:7e98bbfd102a 327 wait(0.5f);
shimniok 0:7e98bbfd102a 328 }
shimniok 0:7e98bbfd102a 329 }