uart_write.c 820 B

123456789101112131415161718192021222324252627282930313233
  1. #include "flipper.h"
  2. #include <string.h>
  3. #include "log.h"
  4. void application_uart_write(void* p) {
  5. // Red led for showing progress
  6. GpioPin led = {.pin = GPIO_PIN_8, .port = GPIOA};
  7. pinMode(led, GpioModeOpenDrain);
  8. // get_default_log open "tty" record
  9. FuriRecordSubscriber* log = get_default_log();
  10. // create buffer
  11. const char test_string[] = "test\n";
  12. furi_write(log, test_string, strlen(test_string));
  13. // for example, create counter and show its value
  14. uint8_t counter = 0;
  15. while(1) {
  16. // continously write it to UART
  17. printf("counter: %d\n", counter);
  18. counter++;
  19. // flash at every send
  20. digitalWrite(led, LOW);
  21. delay(50);
  22. digitalWrite(led, HIGH);
  23. // delay with overall perion of 1s
  24. delay(950);
  25. }
  26. }