uart_write.c 928 B

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