server.c 24 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
#include "modules/log.h"
#include "epicardium.h"

void __api_dispatch_call(uint32_t id, void*epc__apistub_buffer)
{
        switch (id) {
        case API_INTERRUPT_ENABLE:
                *((int*)epc__apistub_buffer) = epic_interrupt_enable(
                        *(api_int_id_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_INTERRUPT_DISABLE:
                *((int*)epc__apistub_buffer) = epic_interrupt_disable(
                        *(api_int_id_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_SYSTEM_EXIT:
                __epic_exit(
                        *(int*)(epc__apistub_buffer + 0)
                );
                break;
        case API_SYSTEM_EXEC:
                *((int*)epc__apistub_buffer) = __epic_exec(
                        *(char **)(epc__apistub_buffer + 0)
                );
                break;
        case API_SYSTEM_RESET:
                epic_system_reset(
                );
                break;
        case API_BATTERY_VOLTAGE:
                *((int*)epc__apistub_buffer) = epic_read_battery_voltage(
                        *(float **)(epc__apistub_buffer + 0)
                );
                break;
        case API_BATTERY_CURRENT:
                *((int*)epc__apistub_buffer) = epic_read_battery_current(
                        *(float **)(epc__apistub_buffer + 0)
                );
                break;
        case API_CHARGEIN_VOLTAGE:
                *((int*)epc__apistub_buffer) = epic_read_chargein_voltage(
                        *(float **)(epc__apistub_buffer + 0)
                );
                break;
        case API_CHARGEIN_CURRENT:
                *((int*)epc__apistub_buffer) = epic_read_chargein_current(
                        *(float **)(epc__apistub_buffer + 0)
                );
                break;
        case API_SYSTEM_VOLTAGE:
                *((int*)epc__apistub_buffer) = epic_read_system_voltage(
                        *(float **)(epc__apistub_buffer + 0)
                );
                break;
        case API_THERMISTOR_VOLTAGE:
                *((int*)epc__apistub_buffer) = epic_read_thermistor_voltage(
                        *(float **)(epc__apistub_buffer + 0)
                );
                break;
        case API_UART_WRITE_STR:
                epic_uart_write_str(
                        *(const char **)(epc__apistub_buffer + 0),
Astro's avatar
Astro committed
64
                        *(size_t*)(epc__apistub_buffer + sizeof(const char *))
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
                );
                break;
        case API_UART_READ_CHAR:
                *((int*)epc__apistub_buffer) = epic_uart_read_char(
                );
                break;
        case API_UART_READ_STR:
                *((int*)epc__apistub_buffer) = epic_uart_read_str(
                        *(char **)(epc__apistub_buffer + 0),
                        *(size_t*)(epc__apistub_buffer + sizeof(char *))
                );
                break;
        case API_BUTTONS_READ:
                *((uint8_t*)epc__apistub_buffer) = epic_buttons_read(
                        *(uint8_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_GPIO_SET_PIN_MODE:
                *((int*)epc__apistub_buffer) = epic_gpio_set_pin_mode(
                        *(uint8_t*)(epc__apistub_buffer + 0),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(uint8_t))
                );
                break;
        case API_GPIO_GET_PIN_MODE:
                *((int*)epc__apistub_buffer) = epic_gpio_get_pin_mode(
                        *(uint8_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_GPIO_WRITE_PIN:
                *((int*)epc__apistub_buffer) = epic_gpio_write_pin(
                        *(uint8_t*)(epc__apistub_buffer + 0),
                        *(_Bool*)(epc__apistub_buffer + sizeof(uint8_t))
                );
                break;
        case API_GPIO_READ_PIN:
                *((int*)epc__apistub_buffer) = epic_gpio_read_pin(
                        *(uint8_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_LEDS_SET:
                epic_leds_set(
                        *(int*)(epc__apistub_buffer + 0),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(int)),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(int) + sizeof(uint8_t)),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(int) + sizeof(uint8_t) + sizeof(uint8_t))
                );
                break;
Astro's avatar
Astro committed
112 113 114 115 116 117
        case API_LEDS_GET:
                *((int*)epc__apistub_buffer) = epic_leds_get_rgb(
                        *(int*)(epc__apistub_buffer + 0),
                        *(uint8_t **)(epc__apistub_buffer + sizeof(int))
                );
                break;
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
        case API_LEDS_SET_HSV:
                epic_leds_set_hsv(
                        *(int*)(epc__apistub_buffer + 0),
                        *(float*)(epc__apistub_buffer + sizeof(int)),
                        *(float*)(epc__apistub_buffer + sizeof(int) + sizeof(float)),
                        *(float*)(epc__apistub_buffer + sizeof(int) + sizeof(float) + sizeof(float))
                );
                break;
        case API_LEDS_SET_ALL:
                epic_leds_set_all(
                        *(uint8_t **)(epc__apistub_buffer + 0),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(uint8_t *))
                );
                break;
        case API_LEDS_SET_ALL_HSV:
                epic_leds_set_all_hsv(
                        *(float **)(epc__apistub_buffer + 0),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(float *))
                );
                break;
        case API_LEDS_PREP:
                epic_leds_prep(
                        *(int*)(epc__apistub_buffer + 0),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(int)),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(int) + sizeof(uint8_t)),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(int) + sizeof(uint8_t) + sizeof(uint8_t))
                );
                break;
        case API_LEDS_PREP_HSV:
                epic_leds_prep_hsv(
                        *(int*)(epc__apistub_buffer + 0),
                        *(float*)(epc__apistub_buffer + sizeof(int)),
                        *(float*)(epc__apistub_buffer + sizeof(int) + sizeof(float)),
                        *(float*)(epc__apistub_buffer + sizeof(int) + sizeof(float) + sizeof(float))
                );
                break;
        case API_LEDS_DIM_BOTTOM:
                epic_leds_dim_bottom(
                        *(uint8_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_LEDS_DIM_TOP:
                epic_leds_dim_top(
                        *(uint8_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_LEDS_SET_POWERSAVE:
                epic_leds_set_powersave(
                        *(_Bool*)(epc__apistub_buffer + 0)
                );
                break;
        case API_LEDS_UPDATE:
                epic_leds_update(
                );
                break;
        case API_LEDS_SET_ROCKET:
                epic_leds_set_rocket(
                        *(int*)(epc__apistub_buffer + 0),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(int))
                );
                break;
Astro's avatar
Astro committed
179 180 181 182 183
        case API_LEDS_GET_ROCKET:
                *((int*)epc__apistub_buffer) = epic_leds_get_rocket(
                        *(int*)(epc__apistub_buffer + 0)
                );
                break;
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
        case API_LEDS_SET_FLASHLIGHT:
                epic_set_flashlight(
                        *(_Bool*)(epc__apistub_buffer + 0)
                );
                break;
        case API_LEDS_SET_GAMMA_TABLE:
                epic_leds_set_gamma_table(
                        *(uint8_t*)(epc__apistub_buffer + 0),
                        *(uint8_t **)(epc__apistub_buffer + sizeof(uint8_t))
                );
                break;
        case API_LEDS_CLEAR_ALL:
                epic_leds_clear_all(
                        *(uint8_t*)(epc__apistub_buffer + 0),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(uint8_t)),
                        *(uint8_t*)(epc__apistub_buffer + sizeof(uint8_t) + sizeof(uint8_t))
                );
                break;
        case API_BME680_INIT:
                *((int*)epc__apistub_buffer) = epic_bme680_init(
                );
                break;
        case API_BME680_DEINIT:
                *((int*)epc__apistub_buffer) = epic_bme680_deinit(
                );
                break;
        case API_BME680_GET_DATA:
                *((int*)epc__apistub_buffer) = epic_bme680_read_sensors(
                        *(struct bme680_sensor_data **)(epc__apistub_buffer + 0)
                );
                break;
Arist's avatar
Arist committed
215 216 217 218 219 220 221 222 223 224
        case API_MAX86150_ENABLE:
                *((int*)epc__apistub_buffer) = epic_max86150_enable_sensor(
                        *(struct max86150_sensor_config **)(epc__apistub_buffer + 0),
                        *(size_t*)(epc__apistub_buffer + sizeof(struct max86150_sensor_config *))
                );
                break;
        case API_MAX86150_DISABLE:
                *((int*)epc__apistub_buffer) = epic_max86150_disable_sensor(
                );
                break;
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
        case API_PERSONAL_STATE_SET:
                *((int*)epc__apistub_buffer) = epic_personal_state_set(
                        *(uint8_t*)(epc__apistub_buffer + 0),
                        *(_Bool*)(epc__apistub_buffer + sizeof(uint8_t))
                );
                break;
        case API_PERSONAL_STATE_GET:
                *((int*)epc__apistub_buffer) = epic_personal_state_get(
                );
                break;
        case API_PERSONAL_STATE_IS_PERSISTENT:
                *((int*)epc__apistub_buffer) = epic_personal_state_is_persistent(
                );
                break;
        case API_STREAM_READ:
                *((int*)epc__apistub_buffer) = epic_stream_read(
                        *(int*)(epc__apistub_buffer + 0),
                        *(void **)(epc__apistub_buffer + sizeof(int)),
                        *(size_t*)(epc__apistub_buffer + sizeof(int) + sizeof(void *))
                );
                break;
        case API_BHI160_ENABLE:
                *((int*)epc__apistub_buffer) = epic_bhi160_enable_sensor(
                        *(enum bhi160_sensor_type*)(epc__apistub_buffer + 0),
                        *(struct bhi160_sensor_config **)(epc__apistub_buffer + sizeof(enum bhi160_sensor_type))
                );
                break;
        case API_BHI160_DISABLE:
                *((int*)epc__apistub_buffer) = epic_bhi160_disable_sensor(
                        *(enum bhi160_sensor_type*)(epc__apistub_buffer + 0)
                );
                break;
        case API_BHI160_DISABLE_ALL:
                epic_bhi160_disable_all_sensors(
                );
                break;
        case API_VIBRA_SET:
                epic_vibra_set(
                        *(int*)(epc__apistub_buffer + 0)
                );
                break;
        case API_VIBRA_VIBRATE:
                epic_vibra_vibrate(
                        *(int*)(epc__apistub_buffer + 0)
                );
                break;
        case API_DISP_OPEN:
                *((int*)epc__apistub_buffer) = epic_disp_open(
                );
                break;
        case API_DISP_CLOSE:
                *((int*)epc__apistub_buffer) = epic_disp_close(
                );
                break;
        case API_DISP_UPDATE:
                *((int*)epc__apistub_buffer) = epic_disp_update(
                );
                break;
        case API_DISP_PRINT:
                *((int*)epc__apistub_buffer) = epic_disp_print(
Astro's avatar
Astro committed
285 286 287 288 289
                        *(int16_t*)(epc__apistub_buffer + 0),
                        *(int16_t*)(epc__apistub_buffer + sizeof(int16_t)),
                        *(const char **)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(const char *)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(const char *) + sizeof(uint16_t))
290 291
                );
                break;
Astro's avatar
Astro committed
292 293 294
        case API_DISP_PRINT_ADV:
                *((int*)epc__apistub_buffer) = epic_disp_print_adv(
                        *(uint8_t*)(epc__apistub_buffer + 0),
Astro's avatar
Astro committed
295 296 297 298 299
                        *(int16_t*)(epc__apistub_buffer + sizeof(uint8_t)),
                        *(int16_t*)(epc__apistub_buffer + sizeof(uint8_t) + sizeof(int16_t)),
                        *(const char **)(epc__apistub_buffer + sizeof(uint8_t) + sizeof(int16_t) + sizeof(int16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(uint8_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(const char *)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(uint8_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(const char *) + sizeof(uint16_t))
Astro's avatar
Astro committed
300 301
                );
                break;
302 303 304 305 306 307 308
        case API_DISP_CLEAR:
                *((int*)epc__apistub_buffer) = epic_disp_clear(
                        *(uint16_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_DISP_PIXEL:
                *((int*)epc__apistub_buffer) = epic_disp_pixel(
Astro's avatar
Astro committed
309 310 311
                        *(int16_t*)(epc__apistub_buffer + 0),
                        *(int16_t*)(epc__apistub_buffer + sizeof(int16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t))
312 313 314 315
                );
                break;
        case API_DISP_LINE:
                *((int*)epc__apistub_buffer) = epic_disp_line(
Astro's avatar
Astro committed
316 317 318 319 320 321 322
                        *(int16_t*)(epc__apistub_buffer + 0),
                        *(int16_t*)(epc__apistub_buffer + sizeof(int16_t)),
                        *(int16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t)),
                        *(int16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t)),
                        *(enum disp_linestyle*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(uint16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(uint16_t) + sizeof(enum disp_linestyle))
323 324 325 326
                );
                break;
        case API_DISP_RECT:
                *((int*)epc__apistub_buffer) = epic_disp_rect(
Astro's avatar
Astro committed
327 328 329 330 331 332 333
                        *(int16_t*)(epc__apistub_buffer + 0),
                        *(int16_t*)(epc__apistub_buffer + sizeof(int16_t)),
                        *(int16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t)),
                        *(int16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t)),
                        *(enum disp_fillstyle*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(uint16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(int16_t) + sizeof(uint16_t) + sizeof(enum disp_fillstyle))
334 335 336 337
                );
                break;
        case API_DISP_CIRC:
                *((int*)epc__apistub_buffer) = epic_disp_circ(
Astro's avatar
Astro committed
338 339 340 341 342 343
                        *(int16_t*)(epc__apistub_buffer + 0),
                        *(int16_t*)(epc__apistub_buffer + sizeof(int16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(uint16_t)),
                        *(enum disp_fillstyle*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(uint16_t) + sizeof(uint16_t)),
                        *(uint16_t*)(epc__apistub_buffer + sizeof(int16_t) + sizeof(int16_t) + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(enum disp_fillstyle))
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
                );
                break;
        case API_DISP_FRAMEBUFFER:
                *((int*)epc__apistub_buffer) = epic_disp_framebuffer(
                        *(union disp_framebuffer **)(epc__apistub_buffer + 0)
                );
                break;
        case API_DISP_BACKLIGHT:
                *((int*)epc__apistub_buffer) = epic_disp_backlight(
                        *(uint16_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_LIGHT_SENSOR_RUN:
                *((int*)epc__apistub_buffer) = epic_light_sensor_run(
                );
                break;
        case API_LIGHT_SENSOR_GET:
                *((int*)epc__apistub_buffer) = epic_light_sensor_get(
                        *(uint16_t**)(epc__apistub_buffer + 0)
                );
                break;
        case API_LIGHT_SENSOR_STOP:
                *((int*)epc__apistub_buffer) = epic_light_sensor_stop(
                );
                break;
        case API_LIGHT_SENSOR_READ:
                *((uint16_t*)epc__apistub_buffer) = epic_light_sensor_read(
                );
                break;
        case API_FILE_OPEN:
                *((int*)epc__apistub_buffer) = epic_file_open(
                        *(const char**)(epc__apistub_buffer + 0),
                        *(const char**)(epc__apistub_buffer + sizeof(const char*))
                );
                break;
        case API_FILE_CLOSE:
                *((int*)epc__apistub_buffer) = epic_file_close(
                        *(int*)(epc__apistub_buffer + 0)
                );
                break;
        case API_FILE_READ:
                *((int*)epc__apistub_buffer) = epic_file_read(
                        *(int*)(epc__apistub_buffer + 0),
                        *(void**)(epc__apistub_buffer + sizeof(int)),
                        *(size_t*)(epc__apistub_buffer + sizeof(int) + sizeof(void*))
                );
                break;
        case API_FILE_WRITE:
                *((int*)epc__apistub_buffer) = epic_file_write(
                        *(int*)(epc__apistub_buffer + 0),
                        *(const void**)(epc__apistub_buffer + sizeof(int)),
                        *(size_t*)(epc__apistub_buffer + sizeof(int) + sizeof(const void*))
                );
                break;
        case API_FILE_FLUSH:
                *((int*)epc__apistub_buffer) = epic_file_flush(
                        *(int*)(epc__apistub_buffer + 0)
                );
                break;
        case API_FILE_SEEK:
                *((int*)epc__apistub_buffer) = epic_file_seek(
                        *(int*)(epc__apistub_buffer + 0),
                        *(long*)(epc__apistub_buffer + sizeof(int)),
                        *(int*)(epc__apistub_buffer + sizeof(int) + sizeof(long))
                );
                break;
        case API_FILE_TELL:
                *((int*)epc__apistub_buffer) = epic_file_tell(
                        *(int*)(epc__apistub_buffer + 0)
                );
                break;
        case API_FILE_STAT:
                *((int*)epc__apistub_buffer) = epic_file_stat(
                        *(const char**)(epc__apistub_buffer + 0),
                        *(struct epic_stat**)(epc__apistub_buffer + sizeof(const char*))
                );
                break;
        case API_FILE_OPENDIR:
                *((int*)epc__apistub_buffer) = epic_file_opendir(
                        *(const char**)(epc__apistub_buffer + 0)
                );
                break;
        case API_FILE_READDIR:
                *((int*)epc__apistub_buffer) = epic_file_readdir(
                        *(int*)(epc__apistub_buffer + 0),
                        *(struct epic_stat**)(epc__apistub_buffer + sizeof(int))
                );
                break;
        case API_FILE_UNLINK:
                *((int*)epc__apistub_buffer) = epic_file_unlink(
                        *(const char**)(epc__apistub_buffer + 0)
                );
                break;
        case API_FILE_RENAME:
                *((int*)epc__apistub_buffer) = epic_file_rename(
                        *(const char **)(epc__apistub_buffer + 0),
                        *(const char**)(epc__apistub_buffer + sizeof(const char *))
                );
                break;
        case API_FILE_MKDIR:
                *((int*)epc__apistub_buffer) = epic_file_mkdir(
                        *(const char **)(epc__apistub_buffer + 0)
                );
                break;
Astro's avatar
Astro committed
448 449 450 451 452 453 454 455
        case API_RTC_GET_MONOTONIC_SECONDS:
                *((uint32_t*)epc__apistub_buffer) = epic_rtc_get_monotonic_seconds(
                );
                break;
        case API_RTC_GET_MONOTONIC_MILLISECONDS:
                *((uint64_t*)epc__apistub_buffer) = epic_rtc_get_monotonic_milliseconds(
                );
                break;
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
        case API_RTC_GET_SECONDS:
                *((uint32_t*)epc__apistub_buffer) = epic_rtc_get_seconds(
                );
                break;
        case API_RTC_GET_MILLISECONDS:
                *((uint64_t*)epc__apistub_buffer) = epic_rtc_get_milliseconds(
                );
                break;
        case API_RTC_SET_MILLISECONDS:
                epic_rtc_set_milliseconds(
                        *(uint64_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_RTC_SCHEDULE_ALARM:
                *((int*)epc__apistub_buffer) = epic_rtc_schedule_alarm(
                        *(uint32_t*)(epc__apistub_buffer + 0)
                );
                break;
        case API_TRNG_READ:
                *((int*)epc__apistub_buffer) = epic_trng_read(
                        *(uint8_t **)(epc__apistub_buffer + 0),
                        *(size_t*)(epc__apistub_buffer + sizeof(uint8_t *))
                );
                break;
        case API_MAX30001_ENABLE:
                *((int*)epc__apistub_buffer) = epic_max30001_enable_sensor(
                        *(struct max30001_sensor_config **)(epc__apistub_buffer + 0)
                );
                break;
        case API_MAX30001_DISABLE:
                *((int*)epc__apistub_buffer) = epic_max30001_disable_sensor(
                );
                break;
        case API_USB_SHUTDOWN:
                *((int*)epc__apistub_buffer) = epic_usb_shutdown(
                );
                break;
        case API_USB_STORAGE:
                *((int*)epc__apistub_buffer) = epic_usb_storage(
                );
                break;
        case API_USB_CDCACM:
                *((int*)epc__apistub_buffer) = epic_usb_cdcacm(
                );
                break;
Astro's avatar
Astro committed
501 502 503 504 505 506 507
        case API_WS2812_WRITE:
                epic_ws2812_write(
                        *(uint8_t*)(epc__apistub_buffer + 0),
                        *(uint8_t **)(epc__apistub_buffer + sizeof(uint8_t)),
                        *(uint32_t*)(epc__apistub_buffer + sizeof(uint8_t) + sizeof(uint8_t *))
                );
                break;
Astro's avatar
Astro committed
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
        case API_CONFIG_GET_INTEGER:
                *((int*)epc__apistub_buffer) = epic_config_get_integer(
                        *(const char **)(epc__apistub_buffer + 0),
                        *(int **)(epc__apistub_buffer + sizeof(const char *))
                );
                break;
        case API_CONFIG_GET_BOOLEAN:
                *((int*)epc__apistub_buffer) = epic_config_get_boolean(
                        *(const char **)(epc__apistub_buffer + 0),
                        *(_Bool **)(epc__apistub_buffer + sizeof(const char *))
                );
                break;
        case API_CONFIG_GET_STRING:
                *((int*)epc__apistub_buffer) = epic_config_get_string(
                        *(const char **)(epc__apistub_buffer + 0),
                        *(char **)(epc__apistub_buffer + sizeof(const char *)),
                        *(size_t*)(epc__apistub_buffer + sizeof(const char *) + sizeof(char *))
                );
                break;
527 528 529 530 531 532
        default:
                /* TODO: Better error handling */
                LOG_ERR("api-dispatcher", "API function 0x%lx is unknown!!", id);
                break;
        }
}