/* * aprs_decoder.h * * Created on: Sep 1, 2019 * Author: curiousmuch */ #ifndef APRS_DECODER_H_ #define APRS_DECODER_H_ #include #include //#define uint8_t unsigned int //#define uint32_t unsigned int /* Constants and Defines */ #define APRS_MAX_FRAME 256 /* Data Structures */ typedef enum { NORMAL, FRAME_DECODED, ERROR_FCS_MISMATCH, ERROR_PACKET_FORMAT, ERROR_BUFFER_OVERFLOW } decoder_output_t; typedef enum { NONE, BUFFER_OVERFLOW, BIT_STUFFING_FAILURE, FCS_MISMATCH, } decoder_error_t; typedef enum { FLAG_SEARCH, FLAG_FOUND, FRAME_START, FRAME_BREAK, ABORT, } decoder_state_t; typedef struct { decoder_state_t decoder_state; uint8_t *frame_buffer; uint32_t frame_buffer_index; uint32_t frame_buffer_len; uint32_t frame_len; uint8_t flag_buffer; uint8_t flag_buffer_index; uint8_t byte_buffer; uint8_t byte_buffer_index; uint8_t current_nrzi_bit; uint8_t previous_nrzi_bit; uint8_t current_bit; uint8_t one_count; uint8_t skip_bit_flag; uint8_t packet_rx; } decoder_varibles_t; /* Public Functions */ void ax25_decoder_init(uint8_t *frame_buffer, uint32_t frame_len); void ax25_decoder_reset(void); uint8_t ax25_decoder_get_cs(void); uint32_t ax25_decoder_get_frame_len(void); uint8_t * ax25_decoder_get_frame(void); decoder_output_t ax25_decoder_feed_bit(uint8_t nrzi_bit); #endif /* APRS_DECODER_H_ */