|
|
/*
|
|
|
* gnss.cpp
|
|
|
*
|
|
|
* Created on: Dec 29, 2014
|
|
|
* Author: aras
|
|
|
*/
|
|
|
|
|
|
#include <gnss.h>
|
|
|
#include <cassert>
|
|
|
#include <cctype>
|
|
|
|
|
|
|
|
|
bool te_gnss::configure(gnss_config_struct &gcs) {
|
|
|
bool r;
|
|
|
r = activate();
|
|
|
r = r && set_baudrate(gcs.baudrate);
|
|
|
r = r && set_position(gcs.lat,gcs.lon);
|
|
|
return r && activate_nmea_frames(gcs.nmea_mask);
|
|
|
}
|
|
|
|
|
|
|
|
|
bool te_gnss::activate() {
|
|
|
PORTD |= (1<<PK0);
|
|
|
return PORTD & (1<<PK0);
|
|
|
}
|
|
|
|
|
|
|
|
|
bool te_gnss::deactivate() {
|
|
|
PORTD &= ~(1<<PK0);
|
|
|
return (~PORTD) & (1<<PK0);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool te_gnss::sync_pps() {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool te_gnss::set_baudrate(uint16_t baud){
|
|
|
if(not scan_baud_success){
|
|
|
scan_baud_finish = false;
|
|
|
scan_baudrate();
|
|
|
while(not scan_baud_finish){}// TODO sleep()
|
|
|
}
|
|
|
if(scan_baud_success){
|
|
|
write_baud(GNSS_PORT,baud);
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
bool te_gnss::wait_to_be_locked(){
|
|
|
scan_lock_finish = false;
|
|
|
scan_lock_success = false;
|
|
|
if(scan_baud_success){
|
|
|
lock_idx = 0;
|
|
|
push(pfunc_pps);
|
|
|
pfunc_pps = &scan_lock_func;
|
|
|
while(! scan_lock_finish){}// TODO sleep()
|
|
|
if(scan_lock_success){
|
|
|
PORTL != (1<<PL7);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
bool te_gnss::get_pps_data(bool raw){
|
|
|
if(scan_baud_success){
|
|
|
is_raw = raw;
|
|
|
stk_ptr = 0;
|
|
|
stack[0] = nullptr;
|
|
|
pfunc_pps = &get_pps_data_func;
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
bool te_gnss::set_position(fix32 lat, fix32 lon){
|
|
|
return true; // TODO all
|
|
|
}
|
|
|
|
|
|
|
|
|
bool te_gnss::activate_nmea_frames(uint16_t mask){
|
|
|
return true; // TODO all
|
|
|
}
|
|
|
|
|
|
|
|
|
void te_gnss::ISR_pps(){
|
|
|
pfunc_pps();
|
|
|
}
|
|
|
|
|
|
|
|
|
void te_gnss::ISR_pps_at(){
|
|
|
// TODO inicializa interrupcion de contador
|
|
|
}
|
|
|
|