board.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, James Jackson and Daniel Koch, BYU MAGICC Lab
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * * Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef ROSFLIGHT_FIRMWARE_BOARD_H
33 #define ROSFLIGHT_FIRMWARE_BOARD_H
34 
35 #include <stddef.h>
36 #include <stdbool.h>
37 #include <stdint.h>
38 
39 #include "sensors.h"
40 #include "state_manager.h"
41 
42 namespace rosflight_firmware
43 {
44 
45 class Board
46 {
47 
48 public:
49  typedef enum
50  {
53  } rc_type_t;
54 
55 // setup
56  virtual void init_board() = 0;
57  virtual void board_reset(bool bootloader) = 0;
58 
59 // clock
60  virtual uint32_t clock_millis() = 0;
61  virtual uint64_t clock_micros() = 0;
62  virtual void clock_delay(uint32_t milliseconds) = 0;
63 
64 // serial
65  virtual void serial_init(uint32_t baud_rate, uint32_t dev) = 0;
66  virtual void serial_write(const uint8_t *src, size_t len) = 0;
67  virtual uint16_t serial_bytes_available() = 0;
68  virtual uint8_t serial_read() = 0;
69  virtual void serial_flush() = 0;
70 
71 // sensors
72  virtual void sensors_init() = 0;
73  virtual uint16_t num_sensor_errors() = 0;
74 
75  virtual bool new_imu_data() = 0;
76  virtual bool imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time) = 0;
77  virtual void imu_not_responding_error() = 0;
78 
79  virtual bool mag_present() = 0;
80  virtual void mag_update() = 0;
81  virtual void mag_read(float mag[3]) = 0;
82 
83  virtual bool baro_present() = 0;
84  virtual void baro_update() = 0;
85  virtual void baro_read(float *pressure, float *temperature) = 0;
86 
87  virtual bool diff_pressure_present() = 0;
88  virtual void diff_pressure_update() = 0;
89  virtual void diff_pressure_read(float *diff_pressure, float *temperature) = 0;
90 
91  virtual bool sonar_present() = 0;
92  virtual void sonar_update() = 0;
93  virtual float sonar_read() = 0;
94 
95  virtual bool gnss_present() = 0;
96  virtual void gnss_update() = 0;
97 
98  virtual GNSSData gnss_read() = 0;
99  virtual bool gnss_has_new_data() = 0;
100  virtual GNSSRaw gnss_raw_read() = 0;
101 
102  virtual bool battery_voltage_present() const = 0;
103  virtual float battery_voltage_read() const = 0;
104  virtual void battery_voltage_set_multiplier(double multiplier) = 0;
105 
106  virtual bool battery_current_present() const = 0;
107  virtual float battery_current_read() const = 0;
108  virtual void battery_current_set_multiplier(double multiplier) = 0;
109 
110 // RC
111  virtual void rc_init(rc_type_t rc_type) = 0;
112  virtual bool rc_lost() = 0;
113  virtual float rc_read(uint8_t channel) = 0;
114 
115 // PWM
116  virtual void pwm_init(uint32_t refresh_rate, uint16_t idle_pwm) = 0;
117  virtual void pwm_disable() = 0;
118  virtual void pwm_write(uint8_t channel, float value) = 0;
119 
120 // non-volatile memory
121  virtual void memory_init() = 0;
122  virtual bool memory_read(void *dest, size_t len) = 0;
123  virtual bool memory_write(const void *src, size_t len) = 0;
124 
125 // LEDs
126  virtual void led0_on() = 0;
127  virtual void led0_off() = 0;
128  virtual void led0_toggle() = 0;
129 
130  virtual void led1_on() = 0;
131  virtual void led1_off() = 0;
132  virtual void led1_toggle() = 0;
133 
134 // Backup memory
135  virtual void backup_memory_init() = 0;
136  virtual bool backup_memory_read(void *dest, size_t len) = 0;
137  virtual void backup_memory_write(const void *src, size_t len) = 0;
138  virtual void backup_memory_clear(size_t len) = 0;
139 
140 };
141 
142 } // namespace rosflight_firmware
143 
144 #endif // ROSLFIGHT_FIRMWARE_BOARD_H
virtual void led0_off()=0
virtual void init_board()=0
virtual void pwm_init(uint32_t refresh_rate, uint16_t idle_pwm)=0
virtual void battery_current_set_multiplier(double multiplier)=0
virtual bool gnss_has_new_data()=0
virtual float rc_read(uint8_t channel)=0
static volatile int16_t gyro[3]
Definition: drv_mpu6050.c:277
virtual bool rc_lost()=0
virtual void sensors_init()=0
virtual bool battery_voltage_present() const =0
float pressure
Definition: ms4525.c:41
virtual void imu_not_responding_error()=0
virtual void memory_init()=0
virtual bool diff_pressure_present()=0
virtual void serial_write(const uint8_t *src, size_t len)=0
float temperature
Definition: ms4525.c:41
virtual bool memory_write(const void *src, size_t len)=0
virtual void backup_memory_write(const void *src, size_t len)=0
virtual void diff_pressure_update()=0
virtual bool new_imu_data()=0
virtual uint16_t serial_bytes_available()=0
virtual void led0_on()=0
virtual void led0_toggle()=0
virtual void sonar_update()=0
virtual void pwm_disable()=0
virtual void backup_memory_init()=0
virtual void diff_pressure_read(float *diff_pressure, float *temperature)=0
virtual void mag_update()=0
virtual void baro_read(float *pressure, float *temperature)=0
virtual void gnss_update()=0
virtual bool sonar_present()=0
virtual GNSSRaw gnss_raw_read()=0
virtual void battery_voltage_set_multiplier(double multiplier)=0
virtual void mag_read(float mag[3])=0
virtual GNSSData gnss_read()=0
static volatile int16_t accel[3]
Definition: drv_mpu6050.c:276
virtual void serial_flush()=0
virtual void pwm_write(uint8_t channel, float value)=0
virtual void backup_memory_clear(size_t len)=0
virtual void board_reset(bool bootloader)=0
virtual uint64_t clock_micros()=0
virtual uint16_t num_sensor_errors()=0
virtual void baro_update()=0
virtual void clock_delay(uint32_t milliseconds)=0
virtual bool gnss_present()=0
virtual bool memory_read(void *dest, size_t len)=0
virtual bool battery_current_present() const =0
virtual uint32_t clock_millis()=0
virtual void led1_on()=0
virtual void led1_toggle()=0
virtual float sonar_read()=0
virtual bool imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time)=0
virtual float battery_current_read() const =0
virtual bool baro_present()=0
virtual bool mag_present()=0
virtual void serial_init(uint32_t baud_rate, uint32_t dev)=0
virtual void led1_off()=0
virtual bool backup_memory_read(void *dest, size_t len)=0
virtual void rc_init(rc_type_t rc_type)=0
virtual float battery_voltage_read() const =0
virtual uint8_t serial_read()=0


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Fri Apr 3 2020 03:19:22