aprs_decoder.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * aprs_decoder.h
  3. *
  4. * Created on: Sep 1, 2019
  5. * Author: curiousmuch
  6. */
  7. #ifndef APRS_DECODER_H_
  8. #define APRS_DECODER_H_
  9. #include <stdio.h>
  10. #include <stdint.h>
  11. //#define uint8_t unsigned int
  12. //#define uint32_t unsigned int
  13. /* Constants and Defines */
  14. #define APRS_MAX_FRAME 256
  15. /* Data Structures */
  16. typedef enum {
  17. NORMAL,
  18. FRAME_DECODED,
  19. ERROR_FCS_MISMATCH,
  20. ERROR_PACKET_FORMAT,
  21. ERROR_BUFFER_OVERFLOW
  22. } decoder_output_t;
  23. typedef enum {
  24. NONE,
  25. BUFFER_OVERFLOW,
  26. BIT_STUFFING_FAILURE,
  27. FCS_MISMATCH,
  28. } decoder_error_t;
  29. typedef enum {
  30. FLAG_SEARCH,
  31. FLAG_FOUND,
  32. FRAME_START,
  33. FRAME_BREAK,
  34. ABORT,
  35. } decoder_state_t;
  36. typedef struct {
  37. decoder_state_t decoder_state;
  38. uint8_t *frame_buffer;
  39. uint32_t frame_buffer_index;
  40. uint32_t frame_buffer_len;
  41. uint32_t frame_len;
  42. uint8_t flag_buffer;
  43. uint8_t flag_buffer_index;
  44. uint8_t byte_buffer;
  45. uint8_t byte_buffer_index;
  46. uint8_t current_nrzi_bit;
  47. uint8_t previous_nrzi_bit;
  48. uint8_t current_bit;
  49. uint8_t one_count;
  50. uint8_t skip_bit_flag;
  51. uint8_t packet_rx;
  52. } decoder_varibles_t;
  53. /* Public Functions */
  54. uint8_t get_rx_status(void);
  55. void frame_buffer_init(uint8_t *buf, uint32_t len);
  56. void aprs_decoder_init(void);
  57. void ax25_decoder_init(uint8_t *frame_buffer, uint32_t frame_len)
  58. decoder_output_t ax25_decoder_feed_bit(uint8_t nrzi_bit);
  59. #endif /* APRS_DECODER_H_ */