diff --git a/README.md b/README.md index 7090e34..fc950c4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This repository contains the firmware for the different Libre Solar Charge Controllers. Originally, the firmware was based on [ARM Mbed OS](https://www.mbed.com). The current version also supports using [Zephyr RTOS](https://www.zephyrproject.org/) for some boards. -Coding style is described [here](https://libre.solar/docs/coding_style/). +Coding style is described [here](https://github.com/LibreSolar/coding-style). **Warning:** This firmware is under active development. Even though we try our best not to break any features that worked before, not every commit is fully tested on every board before including it to the master branch. For stable and tested versions consider using the latest [release](https://github.com/LibreSolar/charge-controller-firmware/releases). diff --git a/src/bat_charger.cpp b/src/bat_charger.cpp index 779e67d..ea81eda 100644 --- a/src/bat_charger.cpp +++ b/src/bat_charger.cpp @@ -5,16 +5,17 @@ */ #include "bat_charger.h" -#include "config.h" -#include "pcb.h" -#include "helper.h" - -#include "device_status.h" -extern DeviceStatus dev_stat; #include // for fabs function #include +#include "config.h" +#include "pcb.h" +#include "helper.h" +#include "device_status.h" + +extern DeviceStatus dev_stat; + void battery_conf_init(BatConf *bat, BatType type, int num_cells, float nominal_capacity) { bat->nominal_capacity = nominal_capacity; diff --git a/src/bl_support.h b/src/bl_support.h index f22184b..a0c964f 100644 --- a/src/bl_support.h +++ b/src/bl_support.h @@ -11,10 +11,10 @@ #ifdef BOOTLOADER_ENABLED -#include - #include "config.h" +#include + /** Length of the bootloader name string (including \0 termination) */ const uint8_t BOOTLADER_NAME_LENGTH = 18; diff --git a/src/daq_zephyr.c b/src/daq_zephyr.c index 9ed6fe6..43e4678 100644 --- a/src/daq_zephyr.c +++ b/src/daq_zephyr.c @@ -8,15 +8,12 @@ #if defined(__ZEPHYR__) -#include -#include - -#include "pcb.h" -#include "debug.h" - #include #include +#include +#include + #if defined(CONFIG_SOC_SERIES_STM32L0X) #include #include @@ -29,6 +26,8 @@ #include #endif +#include "pcb.h" +#include "debug.h" #if !defined(CONFIG_SOC_SERIES_STM32F0X) && !defined(CONFIG_SOC_SERIES_STM32L0X) // Rank and sequence definitions for STM32G4 from adc_stm32.c Zephyr driver diff --git a/src/data_objects.cpp b/src/data_objects.cpp index a780596..8ebcc01 100644 --- a/src/data_objects.cpp +++ b/src/data_objects.cpp @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + #include "main.h" #include "pcb.h" @@ -17,7 +19,6 @@ #include "hardware.h" #include "dcdc.h" #include "eeprom.h" -#include const char* const manufacturer = "Libre Solar"; const char* const device_type = DEVICE_TYPE; diff --git a/src/dcdc.cpp b/src/dcdc.cpp index 1e5f012..7f2b111 100644 --- a/src/dcdc.cpp +++ b/src/dcdc.cpp @@ -5,18 +5,18 @@ */ #include "dcdc.h" -#include "pcb.h" -#include "device_status.h" -#include "debug.h" -#include "helper.h" - -#include "half_bridge.h" -#include "eeprom.h" #include // for fabs function #include // for min/max function #include +#include "pcb.h" +#include "device_status.h" +#include "debug.h" +#include "helper.h" +#include "half_bridge.h" +#include "eeprom.h" + extern DeviceStatus dev_stat; #if CONFIG_HAS_DCDC_CONVERTER == 0 diff --git a/src/device_status.cpp b/src/device_status.cpp index a945a24..098c3bf 100644 --- a/src/device_status.cpp +++ b/src/device_status.cpp @@ -5,15 +5,15 @@ */ #include "device_status.h" -#include "config.h" -#include "pcb.h" - -#include "main.h" -#include "helper.h" #include // for fabs function #include +#include "config.h" +#include "pcb.h" +#include "main.h" +#include "helper.h" + //---------------------------------------------------------------------------- // must be called exactly once per second, otherwise energy calculation gets wrong void DeviceStatus::update_energy() diff --git a/src/ext/can.cpp b/src/ext/can.cpp index 032acaf..358200b 100644 --- a/src/ext/can.cpp +++ b/src/ext/can.cpp @@ -6,66 +6,63 @@ #ifdef __MBED__ -#include "mbed.h" - #include "config.h" #ifdef CAN_ENABLED + +#include "ext.h" + +#include "mbed.h" + #include "pcb.h" +#include "thingset.h" +#include "data_objects.h" +#include "can_msg_queue.h" #ifndef HAS_CAN #error The hardware does not support CAN, please undefine CAN_ENABLED #endif -#include "can_msg_queue.h" -//#include "can_iso_tp.h" - -#include "thingset.h" - #ifndef CAN_SPEED #define CAN_SPEED 250000 // 250 kHz #endif -#include "data_objects.h" -#include "can_msg_queue.h" -#include "ext.h" - class ThingSetCAN: public ExtInterface { - public: - ThingSetCAN(uint8_t can_node_id, const unsigned int c); +public: + ThingSetCAN(uint8_t can_node_id, const unsigned int c); - void process_asap(); - void process_1s(); + void process_asap(); + void process_1s(); - void enable(); + void enable(); - private: - bool pub_object(const data_object_t& data_obj); - int pub(); - void process_outbox(); +private: + bool pub_object(const data_object_t& data_obj); + int pub(); + void process_outbox(); - #if defined(CAN_RECEIVE) - void process_inbox(); - void process_input(); - void send_object_name(int data_obj_id, uint8_t can_dest_id); - CANMsgQueue rx_queue; - #endif +#if defined(CAN_RECEIVE) + void process_inbox(); + void process_input(); + void send_object_name(int data_obj_id, uint8_t can_dest_id); + CANMsgQueue rx_queue; +#endif - CANMsgQueue tx_queue; - uint8_t node_id; - const unsigned int channel; - CAN can; - DigitalOut can_disable; + CANMsgQueue tx_queue; + uint8_t node_id; + const unsigned int channel; + CAN can; + DigitalOut can_disable; }; - extern const unsigned int PUB_CHANNEL_CAN; + #ifndef CAN_NODE_ID #define CAN_NODE_ID 10 #endif -ThingSetCAN ts_can(CAN_NODE_ID, PUB_CHANNEL_CAN); +ThingSetCAN ts_can(CAN_NODE_ID, PUB_CHANNEL_CAN); class ThingSetCAN_Device { @@ -292,6 +289,7 @@ void ThingSetCAN::process_input() } } #endif /* CAN_RECEIVE */ + #endif /* CAN_ENABLED */ #endif /* __MBED__ */ diff --git a/src/ext/can_msg_queue.cpp b/src/ext/can_msg_queue.cpp index 55ae5cb..6d9dab4 100644 --- a/src/ext/can_msg_queue.cpp +++ b/src/ext/can_msg_queue.cpp @@ -6,55 +6,66 @@ #if defined(__MBED__) && !defined(UNIT_TEST) +#include "ext/can_msg_queue.h" + #include "mbed.h" + #ifdef STM32F0 // STM32L0 does not have CAN -#include "can_msg_queue.h" - -bool CANMsgQueue::full() { +bool CANMsgQueue::full() +{ return _length == CAN_QUEUE_SIZE; } -bool CANMsgQueue::empty() { +bool CANMsgQueue::empty() +{ return _length == 0; } -void CANMsgQueue::enqueue(CANMessage msg) { +void CANMsgQueue::enqueue(CANMessage msg) +{ if (!full()) { _queue[(_first + _length) % CAN_QUEUE_SIZE] = msg; _length++; } } -int CANMsgQueue::dequeue() { +int CANMsgQueue::dequeue() +{ if (!empty()) { _first = (_first + 1) % CAN_QUEUE_SIZE; _length--; return 1; - } else { + } + else { return 0; } } -int CANMsgQueue::dequeue(CANMessage& msg) { +int CANMsgQueue::dequeue(CANMessage& msg) +{ if (!empty()) { msg = _queue[_first]; _first = (_first + 1) % CAN_QUEUE_SIZE; _length--; return 1; - } else { + } + else { return 0; } } -int CANMsgQueue::first(CANMessage& msg) { +int CANMsgQueue::first(CANMessage& msg) +{ if (!empty()) { msg = _queue[_first]; return 1; - } else { + } + else { return 0; } } #endif /* STM32F0 */ -#endif \ No newline at end of file + +#endif diff --git a/src/ext/can_msg_queue.h b/src/ext/can_msg_queue.h index ec87a09..4c620cd 100644 --- a/src/ext/can_msg_queue.h +++ b/src/ext/can_msg_queue.h @@ -7,13 +7,14 @@ #ifndef CAN_MSG_QUEUE_H #define CAN_MSG_QUEUE_H -#ifdef STM32F0 // STM32L0 does not have CAN - #include "mbed.h" +#ifdef STM32F0 // STM32L0 does not have CAN + #define CAN_QUEUE_SIZE 30 -class CANMsgQueue { +class CANMsgQueue +{ public: bool full(); bool empty(); @@ -30,4 +31,4 @@ private: #endif /* STM32F0 */ -#endif /* CAN_MSG_QUEUE_H */ \ No newline at end of file +#endif /* CAN_MSG_QUEUE_H */ diff --git a/src/ext/ext.cpp b/src/ext/ext.cpp index d550ad2..4efdbce 100644 --- a/src/ext/ext.cpp +++ b/src/ext/ext.cpp @@ -5,6 +5,7 @@ */ #include "ext.h" + #include // we use code to self register objects at construction time. @@ -16,41 +17,47 @@ std::vector* ExtManager::interfaces; // run the respective function on all objects in the "devices" list // use the c++11 lambda expressions here for the for_each loop, keeps things compact -void ExtManager::process_asap() { +void ExtManager::process_asap() +{ for_each(std::begin(*interfaces),std::end(*interfaces), [](ExtInterface* tsif) { tsif->process_asap(); }); } -void ExtManager::enable_all() { +void ExtManager::enable_all() +{ for_each(std::begin(*interfaces),std::end(*interfaces), [](ExtInterface* tsif) { tsif->enable(); }); } -void ExtManager::process_1s() { +void ExtManager::process_1s() +{ for_each(std::begin(*interfaces),std::end(*interfaces), [](ExtInterface* tsif) { tsif->process_1s(); }); } -void ExtManager::check_list() { - if (ExtManager::interfaces == NULL) - { +void ExtManager::check_list() +{ + if (ExtManager::interfaces == NULL) { ExtManager::interfaces = new std::vector; } } -void ExtManager::add_ext(ExtInterface* member) { +void ExtManager::add_ext(ExtInterface* member) +{ check_list(); interfaces->push_back(member); } -ExtManager::ExtManager() { +ExtManager::ExtManager() +{ check_list(); } -ExtInterface::ExtInterface() { +ExtInterface::ExtInterface() +{ ext_mgr.add_ext(this); } diff --git a/src/ext/ext.h b/src/ext/ext.h index 7ae30c2..f0b802e 100644 --- a/src/ext/ext.h +++ b/src/ext/ext.h @@ -16,53 +16,53 @@ class ExtInterface { - public: - ExtInterface(); - virtual void process_asap() {}; - virtual void process_1s() {}; - virtual void enable() {}; +public: + ExtInterface(); + virtual void process_asap() {}; + virtual void process_1s() {}; + virtual void enable() {}; }; class ExtManager { - public: - ExtManager(); +public: + ExtManager(); - /** UEXT interface process function - * - * This function is called in each main loop, as soon as all other tasks finished. - */ - virtual void process_asap(); + /** UEXT interface process function + * + * This function is called in each main loop, as soon as all other tasks finished. + */ + virtual void process_asap(); - /** UEXT interface process function - * - * This function is called every second, if no other task was blocking for a longer time. - * It should be used for state machines, etc. - */ - virtual void process_1s(); + /** UEXT interface process function + * + * This function is called every second, if no other task was blocking for a longer time. + * It should be used for state machines, etc. + */ + virtual void process_1s(); - /* UEXT interface initialization - * - * This function is called only once at startup. - */ - virtual void enable_all(); + /* UEXT interface initialization + * + * This function is called only once at startup. + */ + virtual void enable_all(); - /** - * Adds an ExtInterface object to the list of managed extensions, - * automatically called by ExtInterface objects during construction - */ - static void add_ext(ExtInterface*); + /** + * Adds an ExtInterface object to the list of managed extensions, + * automatically called by ExtInterface objects during construction + */ + static void add_ext(ExtInterface*); - private: - /** - * Stores list of all ExtInterface objects - */ - static std::vector* interfaces; +private: + /** + * Stores list of all ExtInterface objects + */ + static std::vector* interfaces; - /** - * Makes sure there is an internal interfacts vector created, does nothing if it exists - */ - static void check_list(); + /** + * Makes sure there is an internal interfacts vector created, does nothing if it exists + */ + static void check_list(); }; extern ExtManager ext_mgr; diff --git a/src/ext/oled.cpp b/src/ext/oled.cpp index 000088c..7dd3e90 100644 --- a/src/ext/oled.cpp +++ b/src/ext/oled.cpp @@ -10,11 +10,11 @@ #if CONFIG_EXT_OLED_DISPLAY // otherwise don't compile code to reduce firmware size +#include "ext/ext.h" + #include #include -#include "ext/ext.h" - #include "main.h" #include "pcb.h" #include "oled_ssd1306.h" @@ -22,10 +22,10 @@ // implement specific extension inherited from ExtInterface class ExtOled: public ExtInterface { - public: - ExtOled() {}; - void enable(); - void process_1s(); +public: + ExtOled() {}; + void enable(); + void process_1s(); }; static ExtOled ext_oled; // local instance, will self register itself diff --git a/src/ext/serial.cpp b/src/ext/serial.cpp index 06e72ba..ea37472 100644 --- a/src/ext/serial.cpp +++ b/src/ext/serial.cpp @@ -10,136 +10,134 @@ #if CONFIG_EXT_THINGSET_SERIAL // otherwise don't compile code to reduce firmware size -#include "thingset.h" #include "ext.h" -#ifdef __ZEPHYR__ -#define TX_BUF_SIZE CONFIG_EXT_THINGSET_SERIAL_TX_BUF_SIZE -#define RX_BUF_SIZE CONFIG_EXT_THINGSET_SERIAL_RX_BUF_SIZE -#else -#define TX_BUF_SIZE 1000 -#define RX_BUF_SIZE 500 -#endif - #ifdef __MBED__ - #include "mbed.h" - #elif defined(__ZEPHYR__) - #include #include #include #include #include +#endif /* MBED or ZEPHYR */ + +#include "thingset.h" + +#ifdef __ZEPHYR__ +#define TX_BUF_SIZE CONFIG_EXT_THINGSET_SERIAL_TX_BUF_SIZE +#define RX_BUF_SIZE CONFIG_EXT_THINGSET_SERIAL_RX_BUF_SIZE #define UART_DEVICE_NAME DT_ALIAS_UART_DBG_LABEL struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); - -#endif /* MBED or ZEPHYR */ +#else +#define TX_BUF_SIZE 1000 +#define RX_BUF_SIZE 500 +#endif class ThingSetStream: public ExtInterface { - public: - #ifdef __MBED__ - ThingSetStream(Stream& s, const unsigned int c): channel(c), stream(&s) {}; - #elif defined(__ZEPHYR__) - ThingSetStream(const unsigned int c): channel(c){}; - #endif +public: +#ifdef __MBED__ + ThingSetStream(Stream& s, const unsigned int c): channel(c), stream(&s) {}; +#elif defined(__ZEPHYR__) + ThingSetStream(const unsigned int c): channel(c){}; +#endif - virtual void process_asap(); - virtual void process_1s(); + virtual void process_asap(); + virtual void process_1s(); - protected: - #ifdef __MBED__ - virtual void process_input(); // this is called from the ISR typically - #elif defined (__ZEPHYR__) - static void process_input(void*); - #endif +protected: +#ifdef __MBED__ + virtual void process_input(); // this is called from the ISR typically +#elif defined (__ZEPHYR__) + static void process_input(void*); +#endif - const unsigned int channel; + const unsigned int channel; - #ifdef __MBED__ - virtual bool readable() - { - return stream->readable(); +#ifdef __MBED__ + virtual bool readable() + { + return stream->readable(); + } +#elif defined (__ZEPHYR__) + static bool readable() + { + // Start processing interrupts in ISR. + // This function should be called the first thing in the ISR. + if (!uart_irq_update(uart_dev)) { + // The function output should always be 1. + return false; } + // Check if data is available to read. + return uart_irq_rx_ready(uart_dev); + } - #elif defined (__ZEPHYR__) - static bool readable() - { - // Start processing interrupts in ISR. - // This function should be called the first thing in the ISR. - if (!uart_irq_update(uart_dev)) { - // The function output should always be 1. - return false; - } - // Check if data is available to read. - return uart_irq_rx_ready(uart_dev); - } + typedef struct { + char *buf_req_ptr; + size_t *req_pos_ptr; + bool *command_flag_ptr; + } DataStreamStruct; - typedef struct { - char *buf_req_ptr; - size_t *req_pos_ptr; - bool *command_flag_ptr; - } DataStreamStruct; + // Data structure used to pass member variables into a static callback ISR. + // Callback registration requires the function to be static. + // But static functions dont have access to the class members. + // Hence these members are passed as a structure of pointers. + DataStreamStruct data_stream = {buf_req, &req_pos, &command_flag}; +#endif /* MBED */ - // Data structure used to pass member variables into a static callback ISR. - // Callback registration requires the function to be static. - // But static functions dont have access to the class members. - // Hence these members are passed as a structure of pointers. - DataStreamStruct data_stream = {buf_req, &req_pos, &command_flag}; - #endif /* MBED */ +private: +#ifdef __MBED__ + Stream* stream; +#endif /* MBED */ - private: - #ifdef __MBED__ - Stream* stream; - #endif /* MBED */ - - char buf_resp[TX_BUF_SIZE]; - char buf_req[RX_BUF_SIZE]; - size_t req_pos = 0; - bool command_flag = false; + char buf_resp[TX_BUF_SIZE]; + char buf_req[RX_BUF_SIZE]; + size_t req_pos = 0; + bool command_flag = false; }; #ifdef __MBED__ + template class ThingSetSerial: public ThingSetStream { - public: - ThingSetSerial(T& s, const unsigned int c): ThingSetStream(s,c), ser(s) {} +public: + ThingSetSerial(T& s, const unsigned int c): ThingSetStream(s,c), ser(s) {} - void enable() { - Callback cb([this]() -> void { this->process_input();}); - ser.attach(cb); - } + void enable() { + Callback cb([this]() -> void { this->process_input();}); + ser.attach(cb); + } - private: - bool readable() - { - return ser.readable(); - } +private: + bool readable() + { + return ser.readable(); + } - private: - T& ser; +private: + T& ser; }; #elif defined(__ZEPHYR__) class ThingSetSerial: public ThingSetStream { - public: - ThingSetSerial(const int c): ThingSetStream(c){} +public: + ThingSetSerial(const int c): ThingSetStream(c){} - void enable() { - /* Configure UART ISR: Configure a Callback function */ - // Callback function to be given access to the class members using the below API. - // These members are accessed by the ISR using a pointer to the data structure. - uart_irq_callback_user_data_set(uart_dev, process_input, (void*)&data_stream); + void enable() { + /* Configure UART ISR: Configure a Callback function */ + // Callback function to be given access to the class members using the below API. + // These members are accessed by the ISR using a pointer to the data structure. + uart_irq_callback_user_data_set(uart_dev, process_input, (void*)&data_stream); - /* Enable Rx interrupt in the IER */ - uart_irq_rx_enable(uart_dev); - } + /* Enable Rx interrupt in the IER */ + uart_irq_rx_enable(uart_dev); + } }; + #endif /* MBED or ZEPHYR*/ /* @@ -149,14 +147,15 @@ class ThingSetSerial: public ThingSetStream */ #ifdef CONFIG_EXT_THINGSET_SERIAL - extern const int pub_channel_serial; - #ifdef __MBED__ - extern Serial serial; - ThingSetSerial ts_uart(serial, pub_channel_serial); - #elif defined(__ZEPHYR__) - ThingSetSerial ts_uart(pub_channel_serial); - #endif /* MBED or ZEPHYR */ +extern const int pub_channel_serial; + +#ifdef __MBED__ +extern Serial serial; +ThingSetSerial ts_uart(serial, pub_channel_serial); +#elif defined(__ZEPHYR__) +ThingSetSerial ts_uart(pub_channel_serial); +#endif /* MBED or ZEPHYR */ #endif /* CONFIG_EXT_THINGSET_SERIAL */ @@ -165,19 +164,17 @@ extern ThingSet ts; void ThingSetStream::process_1s() { if (ts.get_pub_channel(channel)->enabled) { - #ifdef __MBED__ +#ifdef __MBED__ ts.pub_msg_json(buf_resp, sizeof(buf_resp), channel); stream->puts(buf_resp); stream->putc('\n'); - - #elif defined(__ZEPHYR__) +#elif defined(__ZEPHYR__) int len = ts.pub_msg_json(buf_resp, sizeof(buf_resp), channel); for (int i = 0; i < len; i++) { uart_poll_out(uart_dev, buf_resp[i]); } uart_poll_out(uart_dev, '\n'); - - #endif /* MBED or ZREPHYR */ +#endif /* MBED or ZREPHYR */ } } @@ -186,21 +183,20 @@ void ThingSetStream::process_asap() if (command_flag) { // commands must have 2 or more characters if (req_pos > 1) { - #ifdef __MBED__ +#ifdef __MBED__ stream->printf("Received Request (%d bytes): %s\n", strlen(buf_req), buf_req); ts.process((uint8_t *)buf_req, strlen(buf_req), (uint8_t *)buf_resp, sizeof(buf_resp)); stream->puts(buf_resp); stream->putc('\n'); fflush(*stream); - - #elif defined(__ZEPHYR__) +#elif defined(__ZEPHYR__) printf("Received Request (%d bytes): %s\n", strlen(buf_req), buf_req); int len = ts.process((uint8_t *)buf_req, strlen(buf_req), (uint8_t *)buf_resp, sizeof(buf_resp)); for (int i = 0; i < len; i++) { uart_poll_out(uart_dev, buf_resp[i]); } uart_poll_out(uart_dev, '\n'); - #endif /* MBED or ZEPHYR */ +#endif /* MBED or ZEPHYR */ } // start listening for new commands @@ -219,20 +215,20 @@ void ThingSetStream::process_input() void ThingSetStream::process_input(void* user_data) #endif /* MBED or ZEPHYR */ { - #ifdef __ZEPHYR__ +#ifdef __ZEPHYR__ u8_t c; DataStreamStruct *data_stream_ptr = (DataStreamStruct *)user_data; bool command_flag = *(data_stream_ptr->command_flag_ptr); char *buf_req = data_stream_ptr->buf_req_ptr; size_t req_pos = *(data_stream_ptr->req_pos_ptr); - #endif /* __ZEPHYR__ */ +#endif /* __ZEPHYR__ */ while (readable() && command_flag == false) { - #ifdef __MBED__ +#ifdef __MBED__ int c = stream->getc(); - #elif defined(__ZEPHYR__) +#elif defined(__ZEPHYR__) uart_fifo_read(uart_dev, &c, 1); - #endif /* MBED */ +#endif /* MBED */ // \r\n and \n are markers for line end, i.e. command end // we accept this at any time, even if the buffer is 'full', since @@ -261,10 +257,10 @@ void ThingSetStream::process_input(void* user_data) buf_req[req_pos++] = c; } - #ifdef __ZEPHYR__ +#ifdef __ZEPHYR__ *(data_stream_ptr->command_flag_ptr) = command_flag; *(data_stream_ptr->req_pos_ptr) = req_pos; - #endif +#endif } } diff --git a/src/ext/template.cpp b/src/ext/template.cpp index 55cc31c..0c5b198 100644 --- a/src/ext/template.cpp +++ b/src/ext/template.cpp @@ -15,16 +15,16 @@ */ // Only compile if this EXT interface is enabled in config.h -#ifdef EXT_TEMPLATE_ENABLED +#ifdef CONFIG_EXT_TEMPLATE_ENABLED // implement specific extension inherited from ExtInterface class ExtTemplate: public ExtInterface { - public: - ExtTemplate(); - void enable(); - void process_asap(); - void process_1s(); +public: + ExtTemplate(); + void enable(); + void process_asap(); + void process_1s(); }; static ExtTemplate ext_template; // local instance, will self register itself diff --git a/src/ext/wifi.cpp b/src/ext/wifi.cpp index d72e46e..bd95008 100644 --- a/src/ext/wifi.cpp +++ b/src/ext/wifi.cpp @@ -10,12 +10,11 @@ #ifdef WIFI_ENABLED -#include "load.h" -#include "thingset.h" #include +#include "load.h" +#include "thingset.h" #include "pcb.h" - #include "ESP32.h" UARTSerial uext_serial(PIN_UEXT_TX, PIN_UEXT_RX, 115200); diff --git a/src/half_bridge.cpp b/src/half_bridge.cpp index 75af010..2611727 100644 --- a/src/half_bridge.cpp +++ b/src/half_bridge.cpp @@ -6,12 +6,12 @@ #include "half_bridge.h" +#include + #include "mcu.h" #include "pcb.h" #include "config.h" -#include - static int _pwm_resolution; static float _min_duty; static float _max_duty; diff --git a/src/hardware.cpp b/src/hardware.cpp index 07dbfc6..00dcaa1 100644 --- a/src/hardware.cpp +++ b/src/hardware.cpp @@ -14,7 +14,6 @@ #include "pcb.h" #include "load.h" #include "half_bridge.h" -//#include "us_ticker_data.h" #include "leds.h" extern LoadOutput load; diff --git a/src/helper.cpp b/src/helper.cpp index 7057772..3dae563 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -6,14 +6,14 @@ #include "helper.h" +#include + #ifdef __MBED__ #include "mbed.h" #elif defined(__ZEPHYR__) #include #endif -#include - uint32_t uptime() { #ifdef __ZEPHYR__ diff --git a/src/leds.cpp b/src/leds.cpp index 1d498a4..95ef4a8 100644 --- a/src/leds.cpp +++ b/src/leds.cpp @@ -5,6 +5,7 @@ */ #include "leds.h" + #include "pcb.h" static int led_states[NUM_LEDS]; // must be one of enum LedState diff --git a/src/load_drv.cpp b/src/load_drv.cpp index cbc8ba8..fa4ff3f 100644 --- a/src/load_drv.cpp +++ b/src/load_drv.cpp @@ -6,13 +6,6 @@ #include "load.h" -#include "pcb.h" -#include "config.h" -#include "hardware.h" -#include "leds.h" -#include "device_status.h" -#include "debug.h" - #if defined(__ZEPHYR__) #include @@ -27,6 +20,13 @@ #endif // __ZEPHYR__ +#include "pcb.h" +#include "config.h" +#include "hardware.h" +#include "leds.h" +#include "device_status.h" +#include "debug.h" + extern LoadOutput load; // necessary to call emergency stop function #if defined(PIN_I_LOAD_COMP) && PIN_LOAD_DIS == PB_2 diff --git a/src/pwm_switch.cpp b/src/pwm_switch.cpp index 8f638ca..d449ca6 100644 --- a/src/pwm_switch.cpp +++ b/src/pwm_switch.cpp @@ -5,16 +5,16 @@ */ #include "pwm_switch.h" -#include "config.h" -#include "pcb.h" - -#include "daq.h" -#include "debug.h" -#include "helper.h" #include #include +#include "config.h" +#include "pcb.h" +#include "daq.h" +#include "debug.h" +#include "helper.h" + #if CONFIG_HAS_PWM_SWITCH static bool _pwm_active;