test_board.cpp
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 #include "test_board.h"
33 
34 #pragma GCC diagnostic push
35 #pragma GCC diagnostic ignored "-Wunused-parameter"
36 
37 namespace rosflight_firmware
38 {
39 
40 void testBoard::set_rc(uint16_t *values)
41 {
42  for (int i = 0; i < 8; i++)
43  {
44  rc_values[i] = values[i];
45  }
46 }
47 
48 void testBoard::set_time(uint64_t time_us)
49 {
50  time_us_ = time_us;
51 }
52 
53 void testBoard::set_pwm_lost(bool lost)
54 {
55  rc_lost_ = lost;
56 }
57 
58 void testBoard::set_imu(float *acc, float *gyro, uint64_t time_us)
59 {
60  time_us_ = time_us;
61  for (int i = 0; i < 3; i++)
62  {
63  acc_[i] = acc[i];
64  gyro_[i] = gyro[i];
65  }
66  new_imu_ = true;
67 }
68 
69 
70 // setup
72 void testBoard::board_reset(bool bootloader) {}
73 
74 // clock
76 {
77  return time_us_/1000;
78 }
80 {
81  return time_us_;
82 }
83 void testBoard::clock_delay(uint32_t milliseconds) {}
84 
85 // serial
86 void testBoard::serial_init(uint32_t baud_rate, uint32_t dev) {}
87 void testBoard::serial_write(const uint8_t *src, size_t len) {}
89 {
90  return 0;
91 }
93 {
94  return 0;
95 }
97 
98 // sensors
101 {
102  return 0;
103 }
104 
106 {
107  if (new_imu_)
108  {
109  new_imu_ = false;
110  return true;
111  }
112  return false;
113 }
114 
115 
116 bool testBoard::imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time)
117 {
118  for (int i = 0; i < 3; i++)
119  {
120  accel[i] = acc_[i];
121  gyro[i] = gyro_[i];
122  }
123  *temperature = 25.0;
124  *time = time_us_;
125  return true;
126 }
127 
129 
131 {
132  return false;
133 }
135 void testBoard::mag_read(float mag[3]) {}
136 
138 {
139  return false;
140 }
143 
145 {
146  return false;
147 }
149 void testBoard::diff_pressure_read(float *diff_pressure, float *temperature) {}
150 
152 {
153  return false;
154 }
157 {
158  return 0;
159 }
160 
161 //GNSS is not support on the test board
163 {
164  return {};
165 }
166 
167 //GNSS is not support on the test board
169 {
170  return {};
171 }
172 
173 //GNSS is not support on the test board
175 {
176  return false;
177 }
178 
179 
180 // PWM
181 // TODO make these deal in normalized (-1 to 1 or 0 to 1) values (not pwm-specific)
184 {
185  return rc_lost_;
186 }
187 float testBoard::rc_read(uint8_t channel)
188 {
189  return static_cast<float>(rc_values[channel] - 1000)/1000.0 ;
190 }
191 void testBoard::pwm_write(uint8_t channel, float value) {}
192 void testBoard::pwm_init(uint32_t refresh_rate, uint16_t idle_pwm) {}
194 
195 // non-volatile memory
197 bool testBoard::memory_read(void *dest, size_t len)
198 {
199  return false;
200 }
201 bool testBoard::memory_write(const void *src, size_t len)
202 {
203  return false;
204 }
205 
206 // LEDs
210 
214 
215 //Backup memory
217 {
218  return false;
219 }
221 {
222 #pragma GCC diagnostic push //Ignore blank fields in struct
223 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
224  BackupData blank_data = {0};
225 #pragma GCC diagnostic pop
226  return blank_data;
227 }
228 
229 } // namespace rosflight_firmware
230 
231 #pragma GCC diagnostic pop
uint32_t clock_millis() override
Definition: test_board.cpp:75
void pwm_write(uint8_t channel, float value) override
Definition: test_board.cpp:191
static volatile int16_t gyro[3]
Definition: drv_mpu6050.c:277
void board_reset(bool bootloader) override
Definition: test_board.cpp:72
void serial_init(uint32_t baud_rate, uint32_t dev) override
Definition: test_board.cpp:86
float pressure
Definition: ms4525.c:41
void mag_read(float mag[3]) override
Definition: test_board.cpp:135
float temperature
Definition: ms4525.c:41
void set_imu(float *acc, float *gyro, uint64_t time_us)
Definition: test_board.cpp:58
bool diff_pressure_present() override
Definition: test_board.cpp:144
uint16_t serial_bytes_available() override
Definition: test_board.cpp:88
void sensors_init() override
Definition: test_board.cpp:99
uint64_t clock_micros() override
Definition: test_board.cpp:79
void rc_init(rc_type_t rc_type) override
Definition: test_board.cpp:182
void set_rc(uint16_t *values)
Definition: test_board.cpp:40
bool has_backup_data() override
Definition: test_board.cpp:216
float rc_read(uint8_t channel) override
Definition: test_board.cpp:187
static volatile int16_t accel[3]
Definition: drv_mpu6050.c:276
GNSSRaw gnss_raw_read() override
Definition: test_board.cpp:168
uint8_t serial_read() override
Definition: test_board.cpp:92
void baro_read(float *pressure, float *temperature) override
Definition: test_board.cpp:142
void serial_flush() override
Definition: test_board.cpp:96
bool gnss_has_new_data() override
Definition: test_board.cpp:174
void diff_pressure_read(float *diff_pressure, float *temperature) override
Definition: test_board.cpp:149
void set_time(uint64_t time_us)
Definition: test_board.cpp:48
BackupData get_backup_data() override
Definition: test_board.cpp:220
bool memory_read(void *dest, size_t len) override
Definition: test_board.cpp:197
void diff_pressure_update() override
Definition: test_board.cpp:148
bool imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time) override
Definition: test_board.cpp:116
void clock_delay(uint32_t milliseconds) override
Definition: test_board.cpp:83
void imu_not_responding_error() override
Definition: test_board.cpp:128
GNSSData gnss_read() override
Definition: test_board.cpp:162
void set_pwm_lost(bool lost)
Definition: test_board.cpp:53
void serial_write(const uint8_t *src, size_t len) override
Definition: test_board.cpp:87
bool memory_write(const void *src, size_t len) override
Definition: test_board.cpp:201
void pwm_init(uint32_t refresh_rate, uint16_t idle_pwm) override
Definition: test_board.cpp:192


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