aprs_encoder.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * aprs_encoder.h
  3. *
  4. * Created on: Oct 22, 2019
  5. * Author: curiousmuch
  6. */
  7. #ifndef APRS_ENCODER_H_
  8. #define APRS_ENCODER_H_
  9. #include <stdint.h>
  10. /* Data Structures */
  11. typedef struct {
  12. uint8_t *frame; // frame buffer ptr
  13. uint32_t frame_len; // frame buffer len
  14. uint32_t index; // current buffer index
  15. uint8_t bit_index; // current bit index
  16. uint8_t one_count; // stores the number of "1s" for NRZI
  17. uint8_t cur_bit; // current raw bit being processed
  18. uint8_t prev_bit; // previous raw bit
  19. uint8_t nrzi_bit; // nrzi-bit to be sent
  20. uint32_t byte; // current raw byte being processed
  21. uint8_t flag_count; // number of flags "0x7E" sent
  22. ax25_enc_status_t status; // status of the encoding process
  23. ax25_enc_state_t state; // state of the encoding state machine
  24. } ax25_enc_var_t;
  25. typedef struct {
  26. uint8_t tx_delay;
  27. uint8_t tx_tail;
  28. } ax25_enc_param_t;
  29. typedef enum {
  30. NOCONFIG = 0,
  31. STOP,
  32. READY,
  33. ERROR,
  34. } ax25_enc_status_t;
  35. typedef enum {
  36. PREAMBLE = 0,
  37. FRAME,
  38. TAIL,
  39. DONE
  40. } ax25_enc_state_t;
  41. /* Public Functions*/
  42. void ax25_encoder_init(uint8_t tx_delay , uint8_t tx_delay);
  43. ax25_enc_status_t ax25_encoder_encode(uint8_t *frame, int32_t frame_len);
  44. uint8_t ax25_encoder_get_bit(void);
  45. ax25_enc_state_t ax25_encoder_get_status(void);
  46. #endif /* COMPONENTS_APRS_INCLUDE_APRS_ENCODER_H_ */