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 "sensors.h"
36 #include "state_manager.h"
37 
38 #include <cstdbool>
39 #include <cstddef>
40 #include <cstdint>
41 
42 namespace rosflight_firmware
43 {
44 class Board
45 {
46 public:
47  typedef enum
48  {
51  } rc_type_t;
52 
53  // setup
54  virtual void init_board() = 0;
55  virtual void board_reset(bool bootloader) = 0;
56 
57  // clock
58  virtual uint32_t clock_millis() = 0;
59  virtual uint64_t clock_micros() = 0;
60  virtual void clock_delay(uint32_t milliseconds) = 0;
61 
62  // serial
63  virtual void serial_init(uint32_t baud_rate, uint32_t dev) = 0;
64  virtual void serial_write(const uint8_t *src, size_t len) = 0;
65  virtual uint16_t serial_bytes_available() = 0;
66  virtual uint8_t serial_read() = 0;
67  virtual void serial_flush() = 0;
68 
69  // sensors
70  virtual void sensors_init() = 0;
71  virtual uint16_t num_sensor_errors() = 0;
72 
73  virtual bool new_imu_data() = 0;
74  virtual bool imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time) = 0;
75  virtual void imu_not_responding_error() = 0;
76 
77  virtual bool mag_present() = 0;
78  virtual void mag_update() = 0;
79  virtual void mag_read(float mag[3]) = 0;
80 
81  virtual bool baro_present() = 0;
82  virtual void baro_update() = 0;
83  virtual void baro_read(float *pressure, float *temperature) = 0;
84 
85  virtual bool diff_pressure_present() = 0;
86  virtual void diff_pressure_update() = 0;
87  virtual void diff_pressure_read(float *diff_pressure, float *temperature) = 0;
88 
89  virtual bool sonar_present() = 0;
90  virtual void sonar_update() = 0;
91  virtual float sonar_read() = 0;
92 
93  virtual bool gnss_present() = 0;
94  virtual void gnss_update() = 0;
95 
96  virtual GNSSData gnss_read() = 0;
97  virtual bool gnss_has_new_data() = 0;
98  virtual GNSSFull gnss_full_read() = 0;
99 
100  virtual bool battery_voltage_present() const = 0;
101  virtual float battery_voltage_read() const = 0;
102  virtual void battery_voltage_set_multiplier(double multiplier) = 0;
103 
104  virtual bool battery_current_present() const = 0;
105  virtual float battery_current_read() const = 0;
106  virtual void battery_current_set_multiplier(double multiplier) = 0;
107 
108  // RC
109  virtual void rc_init(rc_type_t rc_type) = 0;
110  virtual bool rc_lost() = 0;
111  virtual float rc_read(uint8_t channel) = 0;
112 
113  // PWM
114  virtual void pwm_init(uint32_t refresh_rate, uint16_t idle_pwm) = 0;
115  virtual void pwm_disable() = 0;
116  virtual void pwm_write(uint8_t channel, float value) = 0;
117 
118  // non-volatile memory
119  virtual void memory_init() = 0;
120  virtual bool memory_read(void *dest, size_t len) = 0;
121  virtual bool memory_write(const void *src, size_t len) = 0;
122 
123  // LEDs
124  virtual void led0_on() = 0;
125  virtual void led0_off() = 0;
126  virtual void led0_toggle() = 0;
127 
128  virtual void led1_on() = 0;
129  virtual void led1_off() = 0;
130  virtual void led1_toggle() = 0;
131 
132  // Backup memory
133  virtual void backup_memory_init() = 0;
134  virtual bool backup_memory_read(void *dest, size_t len) = 0;
135  virtual void backup_memory_write(const void *src, size_t len) = 0;
136  virtual void backup_memory_clear(size_t len) = 0;
137 };
138 
139 } // namespace rosflight_firmware
140 
141 #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 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 GNSSFull gnss_full_read()=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 Oct 9 2020 03:17:15