Mercurial > public > ostc4
comparison Discovery/Src/demo.c @ 1037:2af07aa38531 GasConsumption
Merge with external development branches:
Some features have been prepared for integration: Profiles, DMA UART on Firmware part, Bluetooth discovery and messges logging for development phase. All these new function are deactivated by compile switch and may be activated using the configuration.h for testing purpose.
| author | Ideenmodellierer |
|---|---|
| date | Mon, 15 Sep 2025 21:12:44 +0200 |
| parents | 5865f0aeb438 |
| children |
comparison
equal
deleted
inserted
replaced
| 1029:e938901f6386 | 1037:2af07aa38531 |
|---|---|
| 26 #include "demo.h" | 26 #include "demo.h" |
| 27 #include "base.h" // for BUTTON_BACK, ... | 27 #include "base.h" // for BUTTON_BACK, ... |
| 28 #include "data_exchange_main.h" // for time_elapsed_ms() | 28 #include "data_exchange_main.h" // for time_elapsed_ms() |
| 29 #include "settings.h" | 29 #include "settings.h" |
| 30 #include "ostc.h" | 30 #include "ostc.h" |
| 31 #include "tInfoLogger.h" | |
| 32 #include <string.h> | |
| 31 | 33 |
| 32 #ifndef DEMOMODE | 34 #ifndef DEMOMODE |
| 33 | 35 |
| 34 /* Exported functions --------------------------------------------------------*/ | 36 /* Exported functions --------------------------------------------------------*/ |
| 35 | 37 |
| 423 /* Private functions ---------------------------------------------------------*/ | 425 /* Private functions ---------------------------------------------------------*/ |
| 424 | 426 |
| 425 | 427 |
| 426 #endif // DEMO | 428 #endif // DEMO |
| 427 | 429 |
| 430 #ifdef ENABLE_USART_RADIO /* debug function to check receiption of radio data */ | |
| 431 void demo_HandleData(void) | |
| 432 { | |
| 433 static uint8_t comStarted = 0; | |
| 434 static uint8_t text[50]; | |
| 435 static uint8_t index = 0; | |
| 436 static uint32_t startTick = 0; | |
| 437 static uint8_t firstData = 1; | |
| 438 uint8_t data = 0; | |
| 439 | |
| 440 switch(comStarted) | |
| 441 { | |
| 442 case 0: startTick = HAL_GetTick(); | |
| 443 comStarted++; | |
| 444 break; | |
| 445 case 1: if(time_elapsed_ms(startTick, HAL_GetTick()) > 5000) | |
| 446 { | |
| 447 MX_UART_RADIO_Init_DMA(); | |
| 448 UART_StartDMARxRadio(); | |
| 449 comStarted++; | |
| 450 sprintf((char*)text,"RadioStarted"); | |
| 451 InfoLogger_writeLine(text,strlen((char*)text),1); | |
| 452 } | |
| 453 break; | |
| 454 case 2: data = UART_getChar(); | |
| 455 if(data != 0) | |
| 456 { | |
| 457 if(firstData) | |
| 458 { | |
| 459 firstData = 0; | |
| 460 sprintf((char*)text,"FirstData"); | |
| 461 InfoLogger_writeLine(text,strlen((char*)text),1); | |
| 462 } | |
| 463 if((index == 50) || (data =='r') || (data =='n')) | |
| 464 { | |
| 465 if(index > 0) | |
| 466 { | |
| 467 InfoLogger_writeLine(text,index,0); | |
| 468 index = 0; | |
| 469 } | |
| 470 } | |
| 471 else | |
| 472 { | |
| 473 text[index++] = data; | |
| 474 } | |
| 475 } | |
| 476 break; | |
| 477 default: | |
| 478 break; | |
| 479 } | |
| 480 | |
| 481 | |
| 482 { | |
| 483 } | |
| 484 } | |
| 485 #endif | |
| 486 | |
| 428 | 487 |
| 429 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ | 488 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |
