Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/low_level_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Set up Build
run: cmake -B build
- name: Run LCOV
run: lcov --no-external -r "build/*" --capture --directory . --output-file coverage.info
run: lcov --no-external --capture --directory . --output-file coverage.info
- name: Gen HTML
run: genhtml coverage.info --output-directory coverage
- name: Move HTML
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* [Test Reports](https://toolboxplane.github.io/FlightControllerSoftware/report/)
* [Coverage Reports](https://toolboxplane.github.io/FlightControllerSoftware/coverage/)

## Building and flashing
## Building and flashing

### Build
### Build

To compile the firmware run:

Expand Down Expand Up @@ -54,18 +54,20 @@ The error IDs are:
| Component | Exception | LED configuration |
|----------------|--------------------------|-------------------|
| Application | - | xxxx ◯◯◯🔴 |
| System | Timer Runtime | ◯◯◯🔴 ◯◯🔴◯ |
| | Watchdog | ◯◯🔴◯ ◯◯🔴◯ |
| | Brownout | ◯◯🔴🔴 ◯◯🔴◯ |
| ERROR_HANDLER_GROUP_IMU | Init timeout error | ◯◯◯🔴 ◯◯🔴🔴 |
| System | Watchdog | ◯◯◯🔴 ◯◯🔴◯ |
| | Brownout | ◯◯🔴◯ ◯◯🔴◯ |
| | Low-Prio Timer Runtime | ◯◯🔴🔴 ◯◯🔴◯ |
| | High-Prio Timer Runtime | ◯🔴◯◯ ◯◯🔴◯ |
| IMU | Init timeout error | ◯◯◯🔴 ◯◯🔴🔴 |
| | Init self test error | ◯◯🔴◯ ◯◯🔴🔴 |
| | Status error | ◯◯🔴🔴 ◯◯🔴🔴 |
| | Read timeout | ◯🔴◯◯ ◯◯🔴🔴 |
| Flightcomputer | - | xxxx ◯🔴◯◯ |
| Remote | - | xxxx ◯🔴◯🔴 |
| Mode Handler | No ERROR_HANDLER_GROUP_IMU Data | ◯◯◯🔴 ◯🔴🔴◯ |
| Mode Handler | No IMU Data | ◯◯◯🔴 ◯🔴🔴◯ |
| | No FCP Data | ◯◯🔴◯ ◯🔴🔴◯ |
| | No Remote Data | ◯◯🔴🔴 ◯🔴🔴◯ |
| ERROR_HANDLER_GROUP_BNO055 | Unexpected read success | ◯◯◯🔴 ◯🔴🔴🔴 |
| BNO055 | Unexpected read success | ◯◯◯🔴 ◯🔴🔴🔴 |
| | Unexpected write success | ◯◯🔴◯ ◯🔴🔴🔴 |
| | Read fail | ◯◯🔴🔴 ◯🔴🔴🔴 |
| | Write fail | ◯🔴◯◯ ◯🔴🔴🔴 |
Expand Down
9 changes: 2 additions & 7 deletions Src/Application/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Frequency divider between the timer interrupt and sending new messages.
*/
enum { FLIGHT_COMPUTER_SEND_PERIOD = (uint16_t) (100 / 16.383) };
enum { FLIGHT_COMPUTER_SEND_PERIOD = (int) (100 / 16.383) };

/**
* Offset from the remote data (in [0, 1000]) to the servo_motor_cmd data (in [-500, 500])
Expand Down Expand Up @@ -76,15 +76,10 @@ static void timer_tick(void) {
flight_computer_send(&imu_data, &remote_data, &actuator_cmd);
fcps_send_mux = 0;
}

/*
* Read the next IMU data
*/
imu_start_sampling();
}

void application_init(void) {
system_pre_init(timer_tick);
system_pre_init(timer_tick, imu_start_sampling);
error_handler_init();

imu_init();
Expand Down
5 changes: 3 additions & 2 deletions Src/Application/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
* @brief Main application that performs initialization and starts the timer.
*
* The initialization consists of the following tasks:
* * System Pre-Initialization (::system_pre_init)
* * System Pre-Initialization (::system_pre_init) with the internal timer callback for the low priority callback and
* ::imu_start_sampling for the high priority callback
* * Error Handler initialization (::error_handler_init)
* * IMU initialization (::imu_init)
* * Remote initialization (::remote_init)
Expand All @@ -37,7 +38,7 @@
* and use the result as elevon commands, the motor command is always 0
* * In failsafe mode: set all three commands to 0
* * Pass the actuator commands to the actuators (::actuators_set)
* * Every FLIGHT_COMPUTER_SEND_PERIOD frame: pass the current data to ::flight-computer_send
* * Every FLIGHT_COMPUTER_SEND_PERIOD frame: pass the current data to ::flight_computer_send
* * Call ::imu_start_sampling
*
*/
Expand Down
18 changes: 9 additions & 9 deletions Src/Application/mode_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
#include "error_handler.h"

enum {
IMU_TIMEOUT = (uint16_t) (100 / 16.384),
FLIGHTCOMPUTER_TIMEOUT = (uint16_t) ((2 * 100) / 16.384),
REMOTE_TIMEOUT = (uint16_t) (100 / 16.384),
IMU_TIMEOUT = (int) (100 / 16.384),
FLIGHT_COMPUTER_TIMEOUT = (int) ((2 * 100) / 16.384),
REMOTE_TIMEOUT = (int) (100 / 16.384),
};

static uint8_t imu_timeout_counter;
static uint8_t flightcomputer_timeout_counter;
static uint8_t flight_computer_timeout_counter;
static uint8_t remote_timeout_counter;

void mode_handler_init(void) {
imu_timeout_counter = IMU_TIMEOUT;
flightcomputer_timeout_counter = FLIGHTCOMPUTER_TIMEOUT;
flight_computer_timeout_counter = FLIGHT_COMPUTER_TIMEOUT;
remote_timeout_counter = REMOTE_TIMEOUT;
}

Expand Down Expand Up @@ -55,13 +55,13 @@ mode_handler_mode_t mode_handler_handle(imu_data_t *imu_data, remote_data_t *rem
*remote_data = remote_get_data();

if (!flight_computer_set_point_available()) {
flightcomputer_timeout_counter += 1;
flight_computer_timeout_counter += 1;
} else {
flightcomputer_timeout_counter = 0;
flight_computer_timeout_counter = 0;
}
bool flightcomputer_active = true;
if (flightcomputer_timeout_counter >= FLIGHTCOMPUTER_TIMEOUT) {
flightcomputer_timeout_counter = FLIGHTCOMPUTER_TIMEOUT;
if (flight_computer_timeout_counter >= FLIGHT_COMPUTER_TIMEOUT) {
flight_computer_timeout_counter = FLIGHT_COMPUTER_TIMEOUT;
flightcomputer_active = false;
}
*flightcomputer_setpoint = flight_computer_get_set_point();
Expand Down
2 changes: 1 addition & 1 deletion Src/Components/actuators.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void actuators_init(void);
/**
* @brief Set the actuators.
*
* This function sets the actuators, using ::ppm_set, according to the following mapping:
* This function sets the actuators, using ::ppm_channel_set, according to the following mapping:
* * elevon-left mapped from [-500, 500] to [0, 1000] to channel 1
* * throttle to channel 2
* * elevon-right mapped from [-500, 500] to [0, 1000] to channel 3
Expand Down
10 changes: 5 additions & 5 deletions Src/Components/flight_computer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
* @brief Implementation of the Flight-Computer interface component.
* @ingroup Components
*/
#include <Drivers/protobuf.h>

#include "flight_computer.h"

#include <Drivers/protobuf.h>

void flight_computer_init(void) {
protobuf_init();
}

void flight_computer_send(const imu_data_t *imu_data, const remote_data_t *remote_data,
const actuator_cmd_t *actuator_cmd) {
const actuator_cmd_t *actuator_cmd) {
fc_message_t message = {.has_imu = true,
.imu =
{
Expand Down Expand Up @@ -50,8 +50,8 @@ bool flight_computer_set_point_available(void) {
flight_computer_set_point_t flight_computer_get_set_point(void) {
set_point_message_t message = protobuf_get();
flight_computer_set_point_t setpoint = {.motor = message.motor,
.pitch = (int16_t) message.pitch,
.roll = (int16_t) message.roll};
.pitch = (int16_t) message.pitch,
.roll = (int16_t) message.roll};

return setpoint;
}
Loading