gnss.h
93 lines
| 1.7 KiB
| text/x-c
|
CLexer
|
r132 | /* | ||
* gnss.h | ||||
* | ||||
|
r175 | * Created on: Dec 29, 2014 | ||
* Author: aras | ||||
|
r132 | */ | ||
|
r175 | #ifndef LIBTE_GNSS_H_ | ||
#define LIBTE_GNSS_H_ | ||||
|
r132 | |||
|
r175 | #include "te_structs.h" | ||
|
r132 | |||
|
r203 | //pin ports to GNSS | ||
#define PPS 2 /*!< PE4 AVR <> 2 Arduino */ | ||||
#define ENB 5 /*!< PE3 AVR <> 5 Arduino */ | ||||
#define RX0_GNSS RX0 | ||||
#define TX0_GNSS TX0 PE1 | ||||
|
r196 | |||
|
r203 | uint16_t bauds[]{4800,9600}; | ||
|
r132 | |||
|
r203 | #define BAUDRATE(x) bauds[x] | ||
#define BAUD_IDX_MAX 5 | ||||
#define LOCK_IDX_MAX 100 | ||||
|
r132 | |||
|
r203 | #define GNSS_PORT 0x01 | ||
#define RBP_PORT 0x02 | ||||
|
r196 | |||
|
r203 | class te_gnss{ | ||
|
r196 | |||
|
r203 | public: | ||
bool configure(gnss_config_struct &gcs); | ||||
bool activate(); | ||||
bool deactivate(); | ||||
bool sync_pps(); | ||||
bool set_baudrate(uint16_t baud); | ||||
bool wait_to_be_locked(); | ||||
bool get_pps_data(bool raw); | ||||
bool set_position(fix32 lat,fix32 lon); | ||||
bool activate_nmea_frames(uint16_t mask); | ||||
|
r196 | |||
|
r203 | inline void ISR_pps(); | ||
inline void ISR_pps_at(); | ||||
|
r196 | |||
|
r203 | private: | ||
void process_frame(const char* fr); | ||||
|
r196 | |||
|
r203 | void scan_baudrate(); | ||
void scan_baud_func(); | ||||
void scan_lock_func(); | ||||
void get_pps_data_func(); | ||||
void push(void (*pfunc)()){ | ||||
if(stk_ptr >= 5) return; | ||||
stack[stk_ptr++]=pfunc; | ||||
} | ||||
void pop(void (*pfunc)()){ | ||||
if(stk_ptr == 0) return; | ||||
pfunc = stack[--stk_ptr]; | ||||
stack[stk_ptr]=nullptr; | ||||
} | ||||
void write_baud(uint8_t port, uint16_t baud); | ||||
void open(uint8_t port); | ||||
void writeline(uint8_t port, char* frame);// abre y cierra puerto | ||||
char* readline(uint8_t port); | ||||
void close(uint8_t port); | ||||
bool is_gnss_frame_valid(); | ||||
bool is_locked(); | ||||
volatile bool scan_baud_success; | ||||
volatile bool scan_baud_finish; | ||||
volatile bool scan_lock_success; | ||||
volatile bool scan_lock_finish; | ||||
volatile uint8_t baud_idx; | ||||
volatile uint8_t lock_idx; | ||||
void (*pfunc_pps)(); | ||||
uint8_t stk_ptr; | ||||
void (*stack)()[5]; | ||||
bool is_raw; | ||||
}; | ||||
|
r175 | #endif /* LIBTE_GNSS_H_ */ | ||