66 lines
2.1 KiB
C
66 lines
2.1 KiB
C
/*
|
|
* arduino_com.h
|
|
*
|
|
* Created on: 26 okt. 2016
|
|
* Author: Philip
|
|
*/
|
|
|
|
#ifndef DRIVERS_ARDUINO_COM_H_
|
|
#define DRIVERS_ARDUINO_COM_H_
|
|
|
|
#include "drivers/usart.h"
|
|
|
|
#define ARDUINO_BAUD 115200
|
|
#define ARDUINO_DMA_SIZE 20
|
|
|
|
|
|
/***********************************************************************
|
|
* BRIEF: RX packet structure from arduino com *
|
|
* INFORMATION: Contains the whole compass message *
|
|
***********************************************************************/
|
|
typedef struct compass_data_t {
|
|
uint8_t header;
|
|
int16_t x;
|
|
int16_t y;
|
|
int16_t z;
|
|
uint8_t crc;
|
|
} compass_data_t;
|
|
|
|
/***********************************************************************
|
|
* BRIEF: RX packet structure from arduino com *
|
|
* INFORMATION: Contains the whole gps data message *
|
|
***********************************************************************/
|
|
typedef struct gps_data_t {
|
|
uint8_t header;
|
|
float latitude;
|
|
float longitude;
|
|
uint8_t crc;
|
|
} gps_data_t;
|
|
|
|
/* An instance of the GPS data read from Arduino Com */
|
|
gps_data_t gps_data;
|
|
|
|
/* An instance of the compass data read from Arduino Com */
|
|
compass_data_t compass_data;
|
|
|
|
|
|
/***********************************************************************
|
|
* BRIEF: Initializes the UART for Arduino com *
|
|
* INFORMATION: A DMA Buffer starts storing the bytes received from RX *
|
|
***********************************************************************/
|
|
void arduinoCom_init(USART_TypeDef* usart_inst);
|
|
|
|
/***********************************************************************
|
|
* BRIEF: Checks if new RX packet is available *
|
|
* INFORMATION: Is called by the scheduler *
|
|
***********************************************************************/
|
|
bool arduino_frame_available();
|
|
|
|
/***********************************************************************
|
|
* BRIEF: Updates "gps_data" and "compass_data" *
|
|
* INFORMATION: Is called by the scheduler *
|
|
***********************************************************************/
|
|
void arduino_read();
|
|
|
|
#endif /* DRIVERS_ARDUINO_COM_H_ */
|