serial_service.h 900 B

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