aprs_encoder.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 enum {
  12. NOCONFIG = 0,
  13. STOP,
  14. READY,
  15. ERROR,
  16. } ax25_enc_status_t;
  17. typedef struct {
  18. uint8_t tx_delay;
  19. uint8_t tx_tail;
  20. } ax25_enc_param_t;
  21. typedef enum {
  22. PREAMBLE = 0,
  23. FRAME,
  24. TAIL,
  25. DONE
  26. } ax25_enc_state_t;
  27. typedef struct {
  28. uint8_t *frame; // frame buffer ptr
  29. uint32_t frame_len; // frame buffer len
  30. uint32_t index; // current buffer index
  31. uint8_t bit_index; // current bit index
  32. uint8_t one_count; // stores the number of "1s" for NRZI
  33. uint8_t cur_bit; // current raw bit being processed
  34. uint8_t prev_bit; // previous raw bit
  35. uint8_t nrzi_bit; // nrzi-bit to be sent
  36. uint32_t byte; // current raw byte being processed
  37. uint8_t flag_count; // number of flags "0x7E" sent
  38. ax25_enc_status_t status; // status of the encoding process
  39. ax25_enc_state_t state; // state of the encoding state machine
  40. } ax25_enc_var_t;
  41. /* Public Functions*/
  42. void ax25_encoder_init(uint8_t tx_delay, uint8_t tx_tail);
  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_status_t ax25_encoder_get_status(void);
  46. #endif /* COMPONENTS_APRS_INCLUDE_APRS_ENCODER_H_ */