serial_service.h 841 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #define SERIAL_SVC_DATA_LEN_MAX (248)
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef enum {
  9. SerialServiceEventTypeDataReceived,
  10. SerialServiceEventTypeDataSent,
  11. } SerialServiceEventType;
  12. typedef struct {
  13. uint8_t* buffer;
  14. uint16_t size;
  15. } SerialServiceData;
  16. typedef struct {
  17. SerialServiceEventType event;
  18. SerialServiceData data;
  19. } SerialServiceEvent;
  20. typedef uint16_t(*SerialServiceEventCallback)(SerialServiceEvent event, void* context);
  21. void serial_svc_start();
  22. void serial_svc_set_callbacks(uint16_t buff_size, SerialServiceEventCallback callback, void* context);
  23. void serial_svc_notify_buffer_is_empty();
  24. void serial_svc_stop();
  25. bool serial_svc_is_started();
  26. bool serial_svc_update_tx(uint8_t* data, uint8_t data_len);
  27. #ifdef __cplusplus
  28. }
  29. #endif