|
|
/*
|
|
|
* gnss.h
|
|
|
*
|
|
|
* Created on: Dec 29, 2014
|
|
|
* Author: aras
|
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
#ifndef LIBTE_GNSS_H_
|
|
|
#define LIBTE_GNSS_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include "te_structs.h"
|
|
|
#include "../libnmea++/libnmea++.h"
|
|
|
|
|
|
|
|
|
namespace te_gnss{
|
|
|
|
|
|
//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
|
|
|
|
|
|
uint16_t bauds[]{4800,9600};
|
|
|
|
|
|
#define BAUDRATE(x) bauds[x]
|
|
|
#define BAUD_IDX_MAX 5
|
|
|
#define LOCK_IDX_MAX 100
|
|
|
|
|
|
#define GNSS_PORT 0x01
|
|
|
#define RBP_PORT 0x02
|
|
|
|
|
|
void scan_baud_func();
|
|
|
void scan_lock_func();
|
|
|
void get_pps_data_func();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool configure(gnss_config_struct &gcs);
|
|
|
bool activate();
|
|
|
bool deactivate();
|
|
|
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);
|
|
|
|
|
|
inline void ISR_pps();
|
|
|
|
|
|
void process_frame(const char* fr);
|
|
|
|
|
|
void scan_baudrate();
|
|
|
|
|
|
|
|
|
void push(void (*pfunc)());
|
|
|
|
|
|
void pop(void (*pfunc)());
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif /* LIBTE_GNSS_H_ */
|
|
|
|