Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 committed Jan 17, 2024
1 parent e7eee70 commit 8f9cc64
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 54 deletions.
57 changes: 24 additions & 33 deletions hepa-uv/core/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,39 @@
#include "common/core/freertos_timer.hpp"
#include "hepa-uv/core/can_task.hpp"
#include "hepa-uv/firmware/gpio_drive_hardware.hpp"
#include "hepa-uv/firmware/utility_gpio.h"


#pragma GCC diagnostic push
// NOLINTNEXTLINE(clang-diagnostic-unknown-warning-option)
#pragma GCC diagnostic ignored "-Wvolatile"
#include "platform_specific_hal_conf.h"
#include "hepa-uv/firmware/utility_gpio.h"
#pragma GCC diagnostic pop

static auto tasks = hepauv_tasks::AllTask{};
static auto queues = hepauv_tasks::QueueClient{can::ids::NodeId::hepa_uv};

static auto gpio_drive_pins = gpio_drive_hardware::GpioDrivePins {
.door_open = gpio::PinConfig{
.port = DOOR_OPEN_MCU_PORT,
.pin = DOOR_OPEN_MCU_PIN,
.active_setting = DOOR_OPEN_MCU_AS
},
.reed_switch = gpio::PinConfig{
.port = REED_SW_MCU_PORT,
.pin = REED_SW_MCU_PIN,
.active_setting = REED_SW_MCU_AS
},
.hepa_push_button = gpio::PinConfig{
.port = HEPA_NO_MCU_PORT,
.pin = HEPA_NO_MCU_PIN,
},
.uv_push_button = gpio::PinConfig{
.port = UV_NO_MCU_PORT,
.pin = UV_NO_MCU_PIN,
},
.hepa_on_off = gpio::PinConfig{
.port = HEPA_ON_OFF_PORT,
.pin = HEPA_ON_OFF_PIN,
.active_setting = HEPA_ON_OFF_AS
},
.uv_on_off = gpio::PinConfig{
.port = UV_ON_OFF_MCU_PORT,
.pin = UV_ON_OFF_MCU_PIN,
.active_setting = UV_ON_OFF_AS
}
};
static auto gpio_drive_pins = gpio_drive_hardware::GpioDrivePins{
.door_open = gpio::PinConfig{.port = DOOR_OPEN_MCU_PORT,
.pin = DOOR_OPEN_MCU_PIN,
.active_setting = DOOR_OPEN_MCU_AS},
.reed_switch = gpio::PinConfig{.port = REED_SW_MCU_PORT,
.pin = REED_SW_MCU_PIN,
.active_setting = REED_SW_MCU_AS},
.hepa_push_button =
gpio::PinConfig{
.port = HEPA_NO_MCU_PORT,
.pin = HEPA_NO_MCU_PIN,
},
.uv_push_button =
gpio::PinConfig{
.port = UV_NO_MCU_PORT,
.pin = UV_NO_MCU_PIN,
},
.hepa_on_off = gpio::PinConfig{.port = HEPA_ON_OFF_PORT,
.pin = HEPA_ON_OFF_PIN,
.active_setting = HEPA_ON_OFF_AS},
.uv_on_off = gpio::PinConfig{.port = UV_ON_OFF_MCU_PORT,
.pin = UV_ON_OFF_MCU_PIN,
.active_setting = UV_ON_OFF_AS}};

static auto hepa_task_builder =
freertos_task::TaskStarter<512, hepa_task::HepaTask>{};
Expand Down
5 changes: 3 additions & 2 deletions hepa-uv/firmware/main_rev1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "common/firmware/gpio.hpp"
#include "common/firmware/iwdg.hpp"
#include "common/firmware/utility_gpio.h"
#include "hepa-uv/core/messages.hpp"
#include "hepa-uv/core/tasks.hpp"
#include "hepa-uv/firmware/utility_gpio.h"
#include "hepa-uv/core/messages.hpp"

static auto iWatchdog = iwdg::IndependentWatchDog{};

Expand Down Expand Up @@ -64,7 +64,8 @@ extern "C" void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
case UV_NO_MCU_PIN:
if (hepa_queue_client.hepa_queue != nullptr) {
static_cast<void>(hepa_queue_client.hepa_queue->try_write_isr(
interrupt_task_messages::GPIOInterruptChanged{.pin = GPIO_Pin }));
interrupt_task_messages::GPIOInterruptChanged{
.pin = GPIO_Pin}));
}
// send to uv queue here
break;
Expand Down
19 changes: 8 additions & 11 deletions include/hepa-uv/core/hepa_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@
#include "common/core/bit_utils.hpp"
#include "common/core/logging.h"
#include "common/core/message_queue.hpp"
#include "messages.hpp"
#include "hepa-uv/firmware/gpio_drive_hardware.hpp"
#include "messages.hpp"

namespace hepa_task {

using TaskMessage = interrupt_task_messages::TaskMessage;

class HepaMessageHandler {
public:
explicit HepaMessageHandler(
gpio_drive_hardware::GpioDrivePins& drive_pins)
explicit HepaMessageHandler(gpio_drive_hardware::GpioDrivePins &drive_pins)
: drive_pins{drive_pins} {}
HepaMessageHandler(const HepaMessageHandler &) = delete;
HepaMessageHandler(const HepaMessageHandler &&) = delete;
auto operator=(const HepaMessageHandler &)
-> HepaMessageHandler & = delete;
auto operator=(const HepaMessageHandler &) -> HepaMessageHandler & = delete;
auto operator=(const HepaMessageHandler &&)
-> HepaMessageHandler && = delete;
~HepaMessageHandler() { }
~HepaMessageHandler() {}

void handle_message(const TaskMessage &m) {
std::visit([this](auto o) { this->visit(o); }, m);
Expand All @@ -35,7 +33,7 @@ class HepaMessageHandler {
void visit(const interrupt_task_messages::GPIOInterruptChanged &m) {
if (m.pin == drive_pins.hepa_push_button.pin) {
hepa_push_button = !hepa_push_button;
// handle state changes here
// handle state changes here
if (hepa_push_button) {
gpio::set(drive_pins.hepa_on_off);
} else {
Expand All @@ -50,7 +48,7 @@ class HepaMessageHandler {
bool hepa_push_button = false;
bool hepa_fan_on = false;

gpio_drive_hardware::GpioDrivePins& drive_pins;
gpio_drive_hardware::GpioDrivePins &drive_pins;
};

/**
Expand All @@ -62,8 +60,7 @@ class HepaTask {
public:
using Messages = TaskMessage;
using QueueType = QueueImpl<TaskMessage>;
HepaTask(QueueType &queue)
: queue{queue} {}
HepaTask(QueueType &queue) : queue{queue} {}
HepaTask(const HepaTask &c) = delete;
HepaTask(const HepaTask &&c) = delete;
auto operator=(const HepaTask &c) = delete;
Expand All @@ -74,7 +71,7 @@ class HepaTask {
* Task entry point.
*/
[[noreturn]] void operator()(
gpio_drive_hardware::GpioDrivePins* drive_pins) {
gpio_drive_hardware::GpioDrivePins *drive_pins) {
auto handler = HepaMessageHandler{*drive_pins};
TaskMessage message{};
for (;;) {
Expand Down
3 changes: 1 addition & 2 deletions include/hepa-uv/core/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ struct GPIOInterruptChanged {
uint8_t state;
};

using TaskMessage =
std::variant<std::monostate, GPIOInterruptChanged>;
using TaskMessage = std::variant<std::monostate, GPIOInterruptChanged>;

} // namespace interrupt_task_messages
11 changes: 5 additions & 6 deletions include/hepa-uv/core/tasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ void start_tasks(can::bus::CanBus& can_bus);
struct QueueClient : can::message_writer::MessageWriter {
QueueClient(can::ids::NodeId this_fw);

void send_interrupt_message(
const hepa_task::TaskMessage& m);
void send_interrupt_message(const hepa_task::TaskMessage& m);

freertos_message_queue::FreeRTOSMessageQueue<
hepa_task::TaskMessage>* hepa_queue{nullptr};
freertos_message_queue::FreeRTOSMessageQueue<hepa_task::TaskMessage>*
hepa_queue{nullptr};
};

/**
Expand All @@ -30,8 +29,8 @@ struct AllTask {
can::message_writer_task::MessageWriterTask<
freertos_message_queue::FreeRTOSMessageQueue>* can_writer{nullptr};

hepa_task::HepaTask<
freertos_message_queue::FreeRTOSMessageQueue>* hepa_task_handler{nullptr};
hepa_task::HepaTask<freertos_message_queue::FreeRTOSMessageQueue>*
hepa_task_handler{nullptr};
};

/**
Expand Down
2 changes: 2 additions & 0 deletions include/hepa-uv/firmware/utility_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ void utility_gpio_init();

#pragma GCC diagnostic push
// NOLINTNEXTLINE(clang-diagnostic-unknown-warning-option)
#include "platform_specific_hal_conf.h"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic pop


/* ---- Generic Pins ---- */
Expand Down

0 comments on commit 8f9cc64

Please sign in to comment.