airbourne_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_AIRBOURNE_BOARD_H
33 #define ROSFLIGHT_FIRMWARE_AIRBOURNE_BOARD_H
34 
35 #include <stddef.h>
36 #include <stdbool.h>
37 #include <stdint.h>
38 
39 #include <revo_f4.h>
40 
41 #include "vcp.h"
42 #include "uart.h"
43 #include "i2c.h"
44 #include "spi.h"
45 #include "mpu6000.h"
46 #include "ms5611.h"
47 #include "M25P16.h"
48 #include "hmc5883l.h"
49 #include "ms4525.h"
50 #include "rc_base.h"
51 #include "rc_ppm.h"
52 #include "rc_sbus.h"
53 #include "pwm.h"
54 #include "led.h"
55 #include "serial.h"
56 #include "system.h"
57 #include "uart.h"
58 #include "mb1242.h"
59 #include "ublox.h"
60 #include "backup_sram.h"
61 
62 #include "board.h"
63 
64 namespace rosflight_firmware
65 {
66 
67 class AirbourneBoard : public Board
68 {
69 
70 private:
73  Serial *current_serial_;//A pointer to the serial stream currently in use.
92 
93  enum SerialDevice : uint32_t
94  {
97  };
99 
100  RC_BASE *rc_ = nullptr;
101 
102  std::function<void()> imu_callback_;
103 
105 
106  float _accel_scale = 1.0;
107  float _gyro_scale = 1.0;
108 
109  enum
110  {
114  };
116 
118  uint64_t imu_time_us_;
119 
120 public:
121  AirbourneBoard();
122 
123  // setup
124  void init_board() override;
125  void board_reset(bool bootloader) override;
126 
127  // clock
128  uint32_t clock_millis() override;
129  uint64_t clock_micros() override;
130  void clock_delay(uint32_t milliseconds) override;
131 
132  // serial
133  void serial_init(uint32_t baud_rate, uint32_t dev) override;
134  void serial_write(const uint8_t *src, size_t len) override;
135  uint16_t serial_bytes_available() override;
136  uint8_t serial_read() override;
137  void serial_flush() override;
138 
139  // sensors
140  void sensors_init() override;
141  uint16_t num_sensor_errors() override;
142 
143  bool new_imu_data() override;
144  bool imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time_us) override;
145  void imu_not_responding_error() override;
146 
147  bool mag_present() override;
148  void mag_update() override;
149  void mag_read(float mag[3]) override;
150 
151  bool baro_present() override;
152  void baro_update() override;
153  void baro_read(float *pressure, float *temperature) override;
154 
155  bool diff_pressure_present() override;
156  void diff_pressure_update() override;
157  void diff_pressure_read(float *diff_pressure, float *temperature) override;
158 
159  bool sonar_present() override;
160  void sonar_update() override;
161  float sonar_read() override;
162 
163  bool gnss_present() override;
164  void gnss_update() override;
165 
166  //GNSS
167  GNSSData gnss_read() override;
168  bool gnss_has_new_data() override;
169  GNSSRaw gnss_raw_read() override;
170  // RC
171  void rc_init(rc_type_t rc_type) override;
172  bool rc_lost() override;
173  float rc_read(uint8_t channel) override;
174 
175  // PWM
176  void pwm_init(uint32_t refresh_rate, uint16_t idle_pwm) override;
177  void pwm_disable() override;
178  void pwm_write(uint8_t channel, float value) override;
179 
180  // non-volatile memory
181  void memory_init() override;
182  bool memory_read(void *dest, size_t len) override;
183  bool memory_write(const void *src, size_t len) override;
184 
185  // LEDs
186  void led0_on() override;
187  void led0_off() override;
188  void led0_toggle() override;
189 
190  void led1_on() override;
191  void led1_off() override;
192  void led1_toggle() override;
193 
194  //Backup Data
195  bool has_backup_data() override;
197 };
198 
199 } // namespace rosflight_firmware
200 
201 #endif // ROSFLIGHT_FIRMWARE_AIRBOURNE_BOARD_H
static volatile int16_t gyro[3]
Definition: drv_mpu6050.c:277
void baro_read(float *pressure, float *temperature) override
float pressure
Definition: ms4525.c:41
float temperature
Definition: ms4525.c:41
Definition: spi.h:38
bool memory_write(const void *src, size_t len) override
Definition: ublox.h:15
void diff_pressure_read(float *diff_pressure, float *temperature) override
bool imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time_us) override
Definition: ms5611.h:39
Definition: rc_ppm.h:37
void clock_delay(uint32_t milliseconds) override
Definition: led.h:38
Definition: pwm.h:37
#define PWM_NUM_OUTPUTS
Definition: revo_f4.h:155
PWM_OUT esc_out_[PWM_NUM_OUTPUTS]
rosflight_firmware::BackupData get_backup_data() override
static volatile int16_t accel[3]
Definition: drv_mpu6050.c:276
Definition: M25P16.h:36
std::function< void()> imu_callback_
void serial_init(uint32_t baud_rate, uint32_t dev) override
Definition: uart.h:43
float rc_read(uint8_t channel) override
Definition: vcp.h:20
Definition: serial.h:43
bool memory_read(void *dest, size_t len) override
Definition: gpio.h:37
Definition: i2c.h:40
Definition: ms4525.h:35
void mag_read(float mag[3]) override
void pwm_write(uint8_t channel, float value) override
void pwm_init(uint32_t refresh_rate, uint16_t idle_pwm) override
void serial_write(const uint8_t *src, size_t len) override
void board_reset(bool bootloader) override
void rc_init(rc_type_t rc_type) override
uint16_t serial_bytes_available() override


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:24