Skip to content
Snippets Groups Projects
Commit 8720a146 authored by dawehr's avatar dawehr
Browse files

WIP: Work on a second UART, separating comm and gps drivers.

parent 03df1151
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@
struct gam;
struct lidar;
struct px4flow;
struct gps;
struct RCReceiverDriver {
void *state;
......@@ -36,6 +37,7 @@ struct MotorDriver {
struct UARTDriver {
void *state;
int devId;
int (*reset)(struct UARTDriver *self);
int (*write)(struct UARTDriver *self, unsigned char c);
int (*read)(struct UARTDriver *self, unsigned char *c);
......@@ -93,4 +95,17 @@ struct OpticalFlowDriver {
int (*read)(struct OpticalFlowDriver *self, struct px4flow *of);
};
struct GPSDriver {
struct UARTDriver * uart;
int (*reset)(struct GPSDriver *self, struct gps *gps);
int (*read)(struct GPSDriver *self, struct gps *gps);
};
struct CommDriver {
struct UARTDriver * uart;
int (*reset)(struct CommDriver *self);
int (*write)(struct CommDriver *self, unsigned char c);
int (*read)(struct CommDriver *self, unsigned char *c);
};
#endif
......@@ -131,6 +131,14 @@ typedef struct px4flow {
SensorError_t error;
} px4flow_t;
typedef struct gps {
double lat, lon;
double vel, course;
int fixed;
unsigned int numSats;
} gps_t;
typedef struct PID_t {
float current_point; // Current value of the system
float setpoint; // Desired value of the system
......@@ -454,7 +462,10 @@ typedef struct hardware_t {
struct I2CDriver i2c_1;
struct RCReceiverDriver rc_receiver;
struct MotorDriver motors;
struct UARTDriver uart;
struct UARTDriver uart_0;
struct UARTDriver uart_1;
struct GPSDriver gps;
struct CommDriver comm;
struct TimerDriver global_timer;
struct TimerDriver axi_timer;
struct LEDDriver mio7_led;
......
#include "hw_impl_zybo.h"
struct UARTDriver create_zybo_uart() {
struct UARTDriver create_zybo_uart(int devId) {
struct UARTDriver uart;
uart.devId = devId;
uart.state = NULL;
uart.reset = zybo_uart_reset;
uart.write = zybo_uart_write;
......@@ -9,6 +10,32 @@ struct UARTDriver create_zybo_uart() {
return uart;
}
struct GPSDriver create_zybo_gps(struct UARTDriver *uart) {
struct GPSDriver gps;
gps.uart = uart;
gps.reset = zybo_gps_reset;
gps.read = zybo_gps_read;
return gps;
}
struct CommDriver create_zybo_comm(struct UARTDriver *uart) {
struct CommDriver comm;
comm.uart = uart;
comm.reset = zybo_comm_reset;
comm.read = zybo_comm_read;
return comm;
}
/*
* struct LidarDriver create_zybo_lidar(struct I2CDriver *i2c) {
struct LidarDriver lidar;
lidar.i2c = i2c;
lidar.reset = zybo_lidar_reset;
lidar.read = zybo_lidar_read;
return lidar;
}
*/
struct MotorDriver create_zybo_motors() {
struct MotorDriver motors;
motors.state = NULL;
......
......@@ -9,7 +9,8 @@
int setup_hardware(hardware_t *hardware) {
hardware->rc_receiver = create_zybo_rc_receiver();
hardware->motors = create_zybo_motors();
hardware->uart = create_zybo_uart();
hardware->uart_0 = create_zybo_uart(0);
hardware->uart_1 = create_zybo_uart(1);
hardware->global_timer = create_zybo_global_timer();
hardware->axi_timer = create_zybo_axi_timer();
hardware->mio7_led = create_zybo_mio7_led();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment