Kamil Cukrowski / Mbed 2 deprecated STM32_Button_Interrupt_dla_taty

Dependencies:   mbed DS18B20 TextLCD

Committer:
KamilCuk
Date:
Thu Feb 13 16:27:38 2020 +0000
Revision:
0:55c37ea095b0
Child:
1:f8a4796e766e
Working version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KamilCuk 0:55c37ea095b0 1 #include "mbed.h"
KamilCuk 0:55c37ea095b0 2 #include "TextLCD.h"
KamilCuk 0:55c37ea095b0 3 #include <atomic_flag.h>
KamilCuk 0:55c37ea095b0 4 #include <string>
KamilCuk 0:55c37ea095b0 5 #include <cstdio>
KamilCuk 0:55c37ea095b0 6 #include <cassert>
KamilCuk 0:55c37ea095b0 7 #include <cstdarg>
KamilCuk 0:55c37ea095b0 8 #include <DS1820.h>
KamilCuk 0:55c37ea095b0 9 #include <DebounceIn.h>
KamilCuk 0:55c37ea095b0 10 #include <limits>
KamilCuk 0:55c37ea095b0 11 #include <flash.h>
KamilCuk 0:55c37ea095b0 12 #include <cassert>
KamilCuk 0:55c37ea095b0 13
KamilCuk 0:55c37ea095b0 14 static DigitalOut led_on_board(PC_13);
KamilCuk 0:55c37ea095b0 15
KamilCuk 0:55c37ea095b0 16 /* str --------------------------------------------- */
KamilCuk 0:55c37ea095b0 17
KamilCuk 0:55c37ea095b0 18 void str_remove(char *str, const char *reject) {
KamilCuk 0:55c37ea095b0 19 while (1) {
KamilCuk 0:55c37ea095b0 20 const size_t s = strcspn(str, reject);
KamilCuk 0:55c37ea095b0 21 str += s;
KamilCuk 0:55c37ea095b0 22 if (str[0] == '\0') {
KamilCuk 0:55c37ea095b0 23 break;
KamilCuk 0:55c37ea095b0 24 }
KamilCuk 0:55c37ea095b0 25 memmove(str, str + 1, strlen(str + 1) + 1);
KamilCuk 0:55c37ea095b0 26 }
KamilCuk 0:55c37ea095b0 27 }
KamilCuk 0:55c37ea095b0 28
KamilCuk 0:55c37ea095b0 29 void str_pad_suffix(char *str, size_t len, char c) {
KamilCuk 0:55c37ea095b0 30 if (strlen(str) < len) {
KamilCuk 0:55c37ea095b0 31 memset(str + strlen(str), c, len - strlen(str));
KamilCuk 0:55c37ea095b0 32 }
KamilCuk 0:55c37ea095b0 33 str[len] = '\0';
KamilCuk 0:55c37ea095b0 34 }
KamilCuk 0:55c37ea095b0 35
KamilCuk 0:55c37ea095b0 36 char *str_filename(const char *file) {
KamilCuk 0:55c37ea095b0 37 return (char*)(strrchr(file, '/') ? strrchr(file, '/') + 1 : file);
KamilCuk 0:55c37ea095b0 38 }
KamilCuk 0:55c37ea095b0 39
KamilCuk 0:55c37ea095b0 40 /* lcd ------------------------------------------------- */
KamilCuk 0:55c37ea095b0 41
KamilCuk 0:55c37ea095b0 42 static TextLCD& lcd() {
KamilCuk 0:55c37ea095b0 43 static TextLCD lcd(PB_15, PA_10, PB_3, PB_4, PB_5, PB_6, TextLCD::LCD16x2); // rs, e, d4-d7
KamilCuk 0:55c37ea095b0 44 // static TextLCD lcd(PA_0, PA_1, PA_2, PA_3, PA_4, PA_5, TextLCD::LCD16x2); // rs, e, d4-d7
KamilCuk 0:55c37ea095b0 45 return lcd;
KamilCuk 0:55c37ea095b0 46 }
KamilCuk 0:55c37ea095b0 47
KamilCuk 0:55c37ea095b0 48 void lcd_cls() {
KamilCuk 0:55c37ea095b0 49 lcd().cls();
KamilCuk 0:55c37ea095b0 50 }
KamilCuk 0:55c37ea095b0 51
KamilCuk 0:55c37ea095b0 52 void lcd_vprintln(const char *fmt, va_list va) {
KamilCuk 0:55c37ea095b0 53 char buf[20] = {0};
KamilCuk 0:55c37ea095b0 54 const size_t len = vsnprintf(buf, sizeof(buf), fmt, va);
KamilCuk 0:55c37ea095b0 55 str_remove(buf, "\r\n");
KamilCuk 0:55c37ea095b0 56 str_pad_suffix(buf, 16, ' ');
KamilCuk 0:55c37ea095b0 57 lcd().printf(buf);
KamilCuk 0:55c37ea095b0 58 }
KamilCuk 0:55c37ea095b0 59
KamilCuk 0:55c37ea095b0 60 __attribute__((__format__(__printf__, 1, 2)))
KamilCuk 0:55c37ea095b0 61 void lcd_println(const char *fmt, ...) {
KamilCuk 0:55c37ea095b0 62 va_list va;
KamilCuk 0:55c37ea095b0 63 va_start(va, fmt);
KamilCuk 0:55c37ea095b0 64 lcd_vprintln(fmt, va);
KamilCuk 0:55c37ea095b0 65 va_end(va);
KamilCuk 0:55c37ea095b0 66 }
KamilCuk 0:55c37ea095b0 67
KamilCuk 0:55c37ea095b0 68 extern "C" {
KamilCuk 0:55c37ea095b0 69 void d(const char *fmt, ...) {
KamilCuk 0:55c37ea095b0 70 va_list va;
KamilCuk 0:55c37ea095b0 71 va_start(va, fmt);
KamilCuk 0:55c37ea095b0 72 lcd_vprintln(fmt, va);
KamilCuk 0:55c37ea095b0 73 va_end(va);
KamilCuk 0:55c37ea095b0 74 wait(1);
KamilCuk 0:55c37ea095b0 75 }
KamilCuk 0:55c37ea095b0 76 }
KamilCuk 0:55c37ea095b0 77
KamilCuk 0:55c37ea095b0 78 /* system --------------------------------------------- */
KamilCuk 0:55c37ea095b0 79
KamilCuk 0:55c37ea095b0 80 extern "C" void abort() {
KamilCuk 0:55c37ea095b0 81 for (int i = 0; i < 20 * 5; ++i) {
KamilCuk 0:55c37ea095b0 82 led_on_board = !led_on_board;
KamilCuk 0:55c37ea095b0 83 wait(0.05);
KamilCuk 0:55c37ea095b0 84 }
KamilCuk 0:55c37ea095b0 85 NVIC_SystemReset();
KamilCuk 0:55c37ea095b0 86 }
KamilCuk 0:55c37ea095b0 87
KamilCuk 0:55c37ea095b0 88 extern "C" void __assert_func(const char *file, int line, const char *func, const char *failedexpr) {
KamilCuk 0:55c37ea095b0 89 lcd_println("ASSERT %d", line);
KamilCuk 0:55c37ea095b0 90 lcd_println("%s", str_filename(file));
KamilCuk 0:55c37ea095b0 91 abort();
KamilCuk 0:55c37ea095b0 92 }
KamilCuk 0:55c37ea095b0 93
KamilCuk 0:55c37ea095b0 94
KamilCuk 0:55c37ea095b0 95 /* ds18b20 --------------------------------------------- */
KamilCuk 0:55c37ea095b0 96
KamilCuk 0:55c37ea095b0 97 /**
KamilCuk 0:55c37ea095b0 98 * @return
KamilCuk 0:55c37ea095b0 99 * 0 - no errors ('temp' contains the temperature measured)
KamilCuk 0:55c37ea095b0 100 * 1 - sensor not present ('temp' is not updated)
KamilCuk 0:55c37ea095b0 101 * 2 - CRC error ('temp' is not updated)
KamilCuk 0:55c37ea095b0 102 */
KamilCuk 0:55c37ea095b0 103 static int ds18b20_temp(float& temperature_f_C) {
KamilCuk 0:55c37ea095b0 104 static DS1820 probe('B', PB_1);
KamilCuk 0:55c37ea095b0 105 static Timer t;
KamilCuk 0:55c37ea095b0 106 static bool running = false;
KamilCuk 0:55c37ea095b0 107
KamilCuk 0:55c37ea095b0 108 // start the conversion if not running
KamilCuk 0:55c37ea095b0 109 if (running == false) {
KamilCuk 0:55c37ea095b0 110 running = true;
KamilCuk 0:55c37ea095b0 111 probe.startConversion();
KamilCuk 0:55c37ea095b0 112 t.start();
KamilCuk 0:55c37ea095b0 113 }
KamilCuk 0:55c37ea095b0 114
KamilCuk 0:55c37ea095b0 115 // wait for conversion end
KamilCuk 0:55c37ea095b0 116 const unsigned ms = t.read_ms();
KamilCuk 0:55c37ea095b0 117 const unsigned conversion_time_ms = 800;
KamilCuk 0:55c37ea095b0 118 if (ms < conversion_time_ms) {
KamilCuk 0:55c37ea095b0 119 wait((conversion_time_ms - ms) / 1000.0);
KamilCuk 0:55c37ea095b0 120 }
KamilCuk 0:55c37ea095b0 121
KamilCuk 0:55c37ea095b0 122 // read temperature from buffer
KamilCuk 0:55c37ea095b0 123 temperature_f_C = -1000;
KamilCuk 0:55c37ea095b0 124 const uint8_t err = probe.read(temperature_f_C);
KamilCuk 0:55c37ea095b0 125
KamilCuk 0:55c37ea095b0 126 // restart new conversion
KamilCuk 0:55c37ea095b0 127 probe.startConversion();
KamilCuk 0:55c37ea095b0 128 t.reset();
KamilCuk 0:55c37ea095b0 129
KamilCuk 0:55c37ea095b0 130 return err;
KamilCuk 0:55c37ea095b0 131 }
KamilCuk 0:55c37ea095b0 132
KamilCuk 0:55c37ea095b0 133 /* output -------------------------------------------- */
KamilCuk 0:55c37ea095b0 134
KamilCuk 0:55c37ea095b0 135 static DigitalOut output(PC_14);
KamilCuk 0:55c37ea095b0 136
KamilCuk 0:55c37ea095b0 137 /* state --------------------------------------------- */
KamilCuk 0:55c37ea095b0 138
KamilCuk 0:55c37ea095b0 139 struct state {
KamilCuk 0:55c37ea095b0 140 volatile int high; // in Celcius
KamilCuk 0:55c37ea095b0 141 volatile int low; // in Celcius
KamilCuk 0:55c37ea095b0 142 volatile bool inverted;
KamilCuk 0:55c37ea095b0 143
KamilCuk 0:55c37ea095b0 144 state() : high(30), low(20) {}
KamilCuk 0:55c37ea095b0 145
KamilCuk 0:55c37ea095b0 146 struct data {
KamilCuk 0:55c37ea095b0 147 static const int data_version = 0x11;
KamilCuk 0:55c37ea095b0 148 int version;
KamilCuk 0:55c37ea095b0 149 int high;
KamilCuk 0:55c37ea095b0 150 int low;
KamilCuk 0:55c37ea095b0 151 bool inverted : 1;
KamilCuk 0:55c37ea095b0 152 bool current : 1;
KamilCuk 0:55c37ea095b0 153 data() : version(data_version) {}
KamilCuk 0:55c37ea095b0 154 data(const state& s, const DigitalOut& o) :
KamilCuk 0:55c37ea095b0 155 version(data_version),
KamilCuk 0:55c37ea095b0 156 high(s.high),
KamilCuk 0:55c37ea095b0 157 low(s.low),
KamilCuk 0:55c37ea095b0 158 inverted(s.inverted),
KamilCuk 0:55c37ea095b0 159 current(output)
KamilCuk 0:55c37ea095b0 160 {}
KamilCuk 0:55c37ea095b0 161 void put(state& s, DigitalOut& o) {
KamilCuk 0:55c37ea095b0 162 s.high = high;
KamilCuk 0:55c37ea095b0 163 s.low = low;
KamilCuk 0:55c37ea095b0 164 s.inverted = inverted;
KamilCuk 0:55c37ea095b0 165 o = current;
KamilCuk 0:55c37ea095b0 166 }
KamilCuk 0:55c37ea095b0 167 };
KamilCuk 0:55c37ea095b0 168
KamilCuk 0:55c37ea095b0 169 static bool _low_high_valid(int high, int low) {
KamilCuk 0:55c37ea095b0 170 return -99 < high && high < 99 &&
KamilCuk 0:55c37ea095b0 171 -99 < low && low < 99 &&
KamilCuk 0:55c37ea095b0 172 low < high &&
KamilCuk 0:55c37ea095b0 173 low != high;
KamilCuk 0:55c37ea095b0 174 }
KamilCuk 0:55c37ea095b0 175
KamilCuk 0:55c37ea095b0 176 void save() {
KamilCuk 0:55c37ea095b0 177 const struct data d(*this, output);
KamilCuk 0:55c37ea095b0 178 flash::write(d);
KamilCuk 0:55c37ea095b0 179 }
KamilCuk 0:55c37ea095b0 180
KamilCuk 0:55c37ea095b0 181 void restore() {
KamilCuk 0:55c37ea095b0 182 struct data d;
KamilCuk 0:55c37ea095b0 183 const int e = flash::read(d);
KamilCuk 0:55c37ea095b0 184 if (e) {
KamilCuk 0:55c37ea095b0 185 lcd_println("New flash %d", e);
KamilCuk 0:55c37ea095b0 186 wait(1);
KamilCuk 0:55c37ea095b0 187 return;
KamilCuk 0:55c37ea095b0 188 }
KamilCuk 0:55c37ea095b0 189 if (!_low_high_valid(d.high, d.low)) {
KamilCuk 0:55c37ea095b0 190 lcd_println("Invalid flash vals");
KamilCuk 0:55c37ea095b0 191 lcd_println("%d %d", d.high, d.low);
KamilCuk 0:55c37ea095b0 192 wait(1);
KamilCuk 0:55c37ea095b0 193 return;
KamilCuk 0:55c37ea095b0 194 }
KamilCuk 0:55c37ea095b0 195 lcd_println("Flash load %d %d", d.high, d.low);
KamilCuk 0:55c37ea095b0 196 wait(1);
KamilCuk 0:55c37ea095b0 197 d.put(*this, output);
KamilCuk 0:55c37ea095b0 198 }
KamilCuk 0:55c37ea095b0 199
KamilCuk 0:55c37ea095b0 200 void high_inc() { _inc_it(high, low); }
KamilCuk 0:55c37ea095b0 201 void high_dec() { _dec_it(high, low); }
KamilCuk 0:55c37ea095b0 202 void low_inc() { _inc_it(low, high); }
KamilCuk 0:55c37ea095b0 203 void low_dec() { _dec_it(low, high); }
KamilCuk 0:55c37ea095b0 204 void invert_invert() {
KamilCuk 0:55c37ea095b0 205 inverted = !inverted;
KamilCuk 0:55c37ea095b0 206 save();
KamilCuk 0:55c37ea095b0 207 }
KamilCuk 0:55c37ea095b0 208
KamilCuk 0:55c37ea095b0 209 private:
KamilCuk 0:55c37ea095b0 210 void _inc_it(volatile int &val, volatile int &other) {
KamilCuk 0:55c37ea095b0 211 if (val + 1 == other) return;
KamilCuk 0:55c37ea095b0 212 if (val >= 99) return;
KamilCuk 0:55c37ea095b0 213 val++;
KamilCuk 0:55c37ea095b0 214 save();
KamilCuk 0:55c37ea095b0 215 }
KamilCuk 0:55c37ea095b0 216 void _dec_it(volatile int &val, volatile int &other) {
KamilCuk 0:55c37ea095b0 217 if (val - 1 == other) return;
KamilCuk 0:55c37ea095b0 218 if (val <= -99) return;
KamilCuk 0:55c37ea095b0 219 val--;
KamilCuk 0:55c37ea095b0 220 save();
KamilCuk 0:55c37ea095b0 221 }
KamilCuk 0:55c37ea095b0 222 };
KamilCuk 0:55c37ea095b0 223
KamilCuk 0:55c37ea095b0 224 static state state;
KamilCuk 0:55c37ea095b0 225
KamilCuk 0:55c37ea095b0 226
KamilCuk 0:55c37ea095b0 227 /* buttons -------------------------------------------- */
KamilCuk 0:55c37ea095b0 228
KamilCuk 0:55c37ea095b0 229 static DebounceIn button_h_inc(PA_6, PullDown);
KamilCuk 0:55c37ea095b0 230 static DebounceIn button_h_dec(PA_5, PullDown);
KamilCuk 0:55c37ea095b0 231 static DebounceIn button_l_inc(PA_4, PullDown);
KamilCuk 0:55c37ea095b0 232 static DebounceIn button_l_dec(PA_3, PullDown);
KamilCuk 0:55c37ea095b0 233 static DebounceIn button_inv(PA_2, PullDown);
KamilCuk 0:55c37ea095b0 234 static DebounceIn button_refresh(PA_1, PullDown);
KamilCuk 0:55c37ea095b0 235
KamilCuk 0:55c37ea095b0 236 static void button_h_inc_pressed() { state.high_inc(); }
KamilCuk 0:55c37ea095b0 237 static void button_h_dec_pressed() { state.high_dec(); }
KamilCuk 0:55c37ea095b0 238 static void button_l_inc_pressed() { state.low_inc(); }
KamilCuk 0:55c37ea095b0 239 static void button_l_dec_pressed() { state.low_dec(); }
KamilCuk 0:55c37ea095b0 240 static void button_inv_pressed() {
KamilCuk 0:55c37ea095b0 241 output = !output;
KamilCuk 0:55c37ea095b0 242 state.invert_invert();
KamilCuk 0:55c37ea095b0 243 }
KamilCuk 0:55c37ea095b0 244
KamilCuk 0:55c37ea095b0 245 static void button_init() {
KamilCuk 0:55c37ea095b0 246 const unsigned debounce_timeout_us = 200 * 1000;
KamilCuk 0:55c37ea095b0 247 button_h_inc.fall(button_h_inc_pressed, debounce_timeout_us);
KamilCuk 0:55c37ea095b0 248 button_h_dec.fall(button_h_dec_pressed, debounce_timeout_us);
KamilCuk 0:55c37ea095b0 249 button_l_inc.fall(button_l_inc_pressed, debounce_timeout_us);
KamilCuk 0:55c37ea095b0 250 button_l_dec.fall(button_l_dec_pressed, debounce_timeout_us);
KamilCuk 0:55c37ea095b0 251 button_inv.fall(button_inv_pressed, debounce_timeout_us * 2);
KamilCuk 0:55c37ea095b0 252 }
KamilCuk 0:55c37ea095b0 253
KamilCuk 0:55c37ea095b0 254
KamilCuk 0:55c37ea095b0 255 static void button_check() {
KamilCuk 0:55c37ea095b0 256 while(1) {
KamilCuk 0:55c37ea095b0 257 DebounceIn *arr[6] = {
KamilCuk 0:55c37ea095b0 258 &button_h_inc,
KamilCuk 0:55c37ea095b0 259 &button_h_dec,
KamilCuk 0:55c37ea095b0 260 &button_l_inc,
KamilCuk 0:55c37ea095b0 261 &button_l_dec,
KamilCuk 0:55c37ea095b0 262 &button_inv,
KamilCuk 0:55c37ea095b0 263 &button_refresh
KamilCuk 0:55c37ea095b0 264 };
KamilCuk 0:55c37ea095b0 265 lcd_println("%d %d %d %d %d %d\n",
KamilCuk 0:55c37ea095b0 266 arr[0]->read(),
KamilCuk 0:55c37ea095b0 267 arr[1]->read(),
KamilCuk 0:55c37ea095b0 268 arr[2]->read(),
KamilCuk 0:55c37ea095b0 269 arr[3]->read(),
KamilCuk 0:55c37ea095b0 270 arr[4]->read(),
KamilCuk 0:55c37ea095b0 271 arr[5]->read());
KamilCuk 0:55c37ea095b0 272 lcd_println("");
KamilCuk 0:55c37ea095b0 273 }
KamilCuk 0:55c37ea095b0 274 }
KamilCuk 0:55c37ea095b0 275
KamilCuk 0:55c37ea095b0 276 /* main --------------------------- */
KamilCuk 0:55c37ea095b0 277
KamilCuk 0:55c37ea095b0 278 static void setup() {
KamilCuk 0:55c37ea095b0 279 // wait for voltage stability
KamilCuk 0:55c37ea095b0 280 wait(1);
KamilCuk 0:55c37ea095b0 281 // some info
KamilCuk 0:55c37ea095b0 282 lcd_cls();
KamilCuk 0:55c37ea095b0 283 lcd_println("Hello!");
KamilCuk 0:55c37ea095b0 284 lcd_println("clock=%ld", SystemCoreClock);
KamilCuk 0:55c37ea095b0 285 wait(1);
KamilCuk 0:55c37ea095b0 286 lcd_cls();
KamilCuk 0:55c37ea095b0 287 state.restore();
KamilCuk 0:55c37ea095b0 288 button_init();
KamilCuk 0:55c37ea095b0 289 }
KamilCuk 0:55c37ea095b0 290
KamilCuk 0:55c37ea095b0 291 static void loop() {
KamilCuk 0:55c37ea095b0 292 static bool alive;
KamilCuk 0:55c37ea095b0 293 alive = !alive;
KamilCuk 0:55c37ea095b0 294
KamilCuk 0:55c37ea095b0 295 float temperature_f_C = 0;
KamilCuk 0:55c37ea095b0 296 const int ds18b20_err = ds18b20_temp(temperature_f_C);
KamilCuk 0:55c37ea095b0 297
KamilCuk 0:55c37ea095b0 298 lcd_cls();
KamilCuk 0:55c37ea095b0 299
KamilCuk 0:55c37ea095b0 300 char temperature_s[8] = "ERROR";
KamilCuk 0:55c37ea095b0 301 if (ds18b20_err == 0) {
KamilCuk 0:55c37ea095b0 302 const int temperature_dC = temperature_f_C * 10;
KamilCuk 0:55c37ea095b0 303 const int temperature_C = temperature_f_C;
KamilCuk 0:55c37ea095b0 304
KamilCuk 0:55c37ea095b0 305 if (temperature_C < -100 || temperature_C > 100) {
KamilCuk 0:55c37ea095b0 306 snprintf(temperature_s, sizeof(temperature_s), "INVAL");
KamilCuk 0:55c37ea095b0 307 } else {
KamilCuk 0:55c37ea095b0 308
KamilCuk 0:55c37ea095b0 309 if (!output ^ state.inverted) {
KamilCuk 0:55c37ea095b0 310 if (temperature_C > state.high) {
KamilCuk 0:55c37ea095b0 311 output = 1 ^ state.inverted;
KamilCuk 0:55c37ea095b0 312 }
KamilCuk 0:55c37ea095b0 313 } else {
KamilCuk 0:55c37ea095b0 314 if (temperature_C < state.low) {
KamilCuk 0:55c37ea095b0 315 output = 0 ^ state.inverted;
KamilCuk 0:55c37ea095b0 316 }
KamilCuk 0:55c37ea095b0 317 }
KamilCuk 0:55c37ea095b0 318
KamilCuk 0:55c37ea095b0 319 snprintf(temperature_s, sizeof(temperature_s), "%3d.%d'C", temperature_C, temperature_dC % 10);
KamilCuk 0:55c37ea095b0 320 }
KamilCuk 0:55c37ea095b0 321 }
KamilCuk 0:55c37ea095b0 322
KamilCuk 0:55c37ea095b0 323 led_on_board = output;
KamilCuk 0:55c37ea095b0 324
KamilCuk 0:55c37ea095b0 325 lcd_println("%-7s %3s %3s",
KamilCuk 0:55c37ea095b0 326 temperature_s,
KamilCuk 0:55c37ea095b0 327 state.inverted ? "INV" : "NOR",
KamilCuk 0:55c37ea095b0 328 output ? "ON" : "OFF"
KamilCuk 0:55c37ea095b0 329 );
KamilCuk 0:55c37ea095b0 330 lcd_println("H=%2d'C L=%2d'C %c%c",
KamilCuk 0:55c37ea095b0 331 state.high,
KamilCuk 0:55c37ea095b0 332 state.low,
KamilCuk 0:55c37ea095b0 333 !alive ? '\xff' : ' ',
KamilCuk 0:55c37ea095b0 334 alive ? '\xff' : ' '
KamilCuk 0:55c37ea095b0 335 );
KamilCuk 0:55c37ea095b0 336 }
KamilCuk 0:55c37ea095b0 337
KamilCuk 0:55c37ea095b0 338 int main() {
KamilCuk 0:55c37ea095b0 339 setup();
KamilCuk 0:55c37ea095b0 340 while (1) {
KamilCuk 0:55c37ea095b0 341 loop();
KamilCuk 0:55c37ea095b0 342 }
KamilCuk 0:55c37ea095b0 343 return 0;
KamilCuk 0:55c37ea095b0 344 }