mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 16:58:48 +08:00
new gps uart handling
This commit is contained in:
@@ -163,3 +163,13 @@ void uart1_init( void ) {
|
||||
sbi(UCSR1B, RXCIE );
|
||||
}
|
||||
|
||||
|
||||
bool_t uart1_buffer_size;
|
||||
uint8_t uart1_buffer[UART_BUFFER_LEN];
|
||||
|
||||
SIGNAL( SIG_UART1_RECV ) {
|
||||
if (uart1_buffer_size < UART_BUFFER_LEN) {
|
||||
uart1_buffer[uart1_buffer_size] = UDR1;
|
||||
uart1_buffer_size++;
|
||||
} /** else overrun */
|
||||
}
|
||||
|
||||
@@ -39,3 +39,5 @@
|
||||
uint8_t c = UDR1; \
|
||||
cb(c); \
|
||||
}
|
||||
|
||||
#define UART_BUFFER_LEN 16
|
||||
|
||||
@@ -74,5 +74,14 @@ extern struct svinfo gps_svinfos[GPS_NB_CHANNELS];
|
||||
#include "ubx.h"
|
||||
#endif
|
||||
|
||||
#define GPS_BUFFER uart1_buffer
|
||||
#define GPS_BUFFER_SIZE uart1_buffer_size
|
||||
|
||||
|
||||
#define GpsBuffer() (GPS_BUFFER_SIZE > 0)
|
||||
#define ReadGpsBuffer() { \
|
||||
GpsParse(GPS_BUFFER, GPS_BUFFER_SIZE); \
|
||||
GPS_BUFFER_SIZE = 0; \
|
||||
}
|
||||
|
||||
#endif /* GPS_H */
|
||||
|
||||
+1
-15
@@ -141,7 +141,7 @@ void parse_gps_msg( void ) {
|
||||
uint8_t gps_nb_ovrn;
|
||||
|
||||
|
||||
static inline void parse_ubx( uint8_t c ) {
|
||||
void parse_ubx( uint8_t c ) {
|
||||
if (ubx_status < GOT_PAYLOAD) {
|
||||
ck_a += c;
|
||||
ck_b += ck_a;
|
||||
@@ -207,17 +207,3 @@ static inline void parse_ubx( uint8_t c ) {
|
||||
ubx_status = UNINIT;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef AVR_ARCH
|
||||
|
||||
#ifdef SIMUL
|
||||
ReceiveUart0(parse_ubx);
|
||||
#endif
|
||||
|
||||
#ifndef WAVECARD_ON_GPS
|
||||
ReceiveUart1(parse_ubx);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* AVR_ARCH */
|
||||
|
||||
|
||||
@@ -130,6 +130,9 @@ void periodic_task_ap( void) {
|
||||
|
||||
void event_task_ap( void ) {
|
||||
#ifdef GPS
|
||||
if (GpsBuffer()) {
|
||||
ReadGpsBuffer();
|
||||
}
|
||||
if (gps_msg_received) {
|
||||
/* parse and use GPS messages */
|
||||
parse_gps_msg();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define _UART_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "std.h"
|
||||
#include "uart_ap_hw.h"
|
||||
|
||||
extern void uart0_init_tx(void);
|
||||
@@ -37,5 +38,7 @@ extern void uart0_print_hex16(const uint16_t);
|
||||
extern void uart0_transmit(const uint8_t);
|
||||
extern void uart1_transmit(const uint8_t);
|
||||
|
||||
extern bool_t uart1_buffer_size;
|
||||
extern uint8_t uart1_buffer[UART_BUFFER_LEN];
|
||||
|
||||
#endif
|
||||
|
||||
@@ -57,5 +57,13 @@ extern uint8_t send_ck_a, send_ck_b;
|
||||
|
||||
#define GPS_FIX_VALID(gps_mode) (gps_mode == 3)
|
||||
|
||||
extern void parse_ubx( uint8_t c );
|
||||
|
||||
#define GpsParse(_gps_buffer, _gps_buffer_size) { \
|
||||
uint8_t i; \
|
||||
for(i = 0; i < _gps_buffer_size; i++) { \
|
||||
parse_ubx(_gps_buffer[i]); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif /* UBX_H */
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ let parse_message = fun class_name m ->
|
||||
let s = sizeof (format f) in
|
||||
let p = param_name f in
|
||||
let t = param_type f in
|
||||
fprintf out " %s _%s = %s; UbxSend%dByAddr((uint8_t*)_%s);\\\n" t p p s p
|
||||
fprintf out " %s _%s = %s; UbxSend%dByAddr((uint8_t*)&_%s);\\\n" t p p s p
|
||||
| "block" ->
|
||||
List.iter send_one_field (Xml.children f)
|
||||
| _ -> assert (false) in
|
||||
|
||||
Reference in New Issue
Block a user