Skip to content

Commit

Permalink
add doxygen style comments to functions, and change function names fo…
Browse files Browse the repository at this point in the history
…r consistency
  • Loading branch information
lenvm committed Dec 13, 2024
1 parent 470860f commit 115c1c8
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Software/Software.ino
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void core_loop(void* task_time_us) {
receive_RS485(); // Process serial2 RS485 interface
#endif // RS485_INVERTER_SELECTED
#if defined(SERIAL_LINK_RECEIVER) || defined(SERIAL_LINK_TRANSMITTER)
runSerialDataLink();
run_serialDataLink();
#endif // SERIAL_LINK_RECEIVER || SERIAL_LINK_TRANSMITTER
END_TIME_MEASUREMENT_MAX(comm, datalayer.system.status.time_comm_us);
#ifdef WEBSERVER
Expand Down
40 changes: 20 additions & 20 deletions Software/src/communication/can/comm_can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,6 @@ void receive_can(CAN_frame* rx_frame, int interface) {
}
}

#ifdef CANFD_ADDON
// Functions
void receive_canfd_addon() { // This section checks if we have a complete CAN-FD message incoming
CANFDMessage frame;
int count = 0;
while (canfd.available() && count++ < 16) {
canfd.receive(frame);

CAN_frame rx_frame;
rx_frame.ID = frame.id;
rx_frame.ext_ID = frame.ext;
rx_frame.DLC = frame.len;
memcpy(rx_frame.data.u8, frame.data, MIN(rx_frame.DLC, 64));
//message incoming, pass it on to the handler
receive_can(&rx_frame, CANFD_ADDON_MCP2518);
receive_can(&rx_frame, CANFD_NATIVE);
}
}
#endif // CANFD_ADDON

void receive_can_native() { // This section checks if we have a complete CAN message incoming on native CAN port
CAN_frame_t rx_frame_native;
if (xQueueReceive(CAN_cfg.rx_queue, &rx_frame_native, 0) == pdTRUE) {
Expand Down Expand Up @@ -267,6 +247,26 @@ void receive_can_addon() { // This section checks if we have a complete CAN mes
}
#endif // CAN_ADDON

#ifdef CANFD_ADDON
// Functions
void receive_canfd_addon() { // This section checks if we have a complete CAN-FD message incoming
CANFDMessage frame;
int count = 0;
while (canfd.available() && count++ < 16) {
canfd.receive(frame);

CAN_frame rx_frame;
rx_frame.ID = frame.id;
rx_frame.ext_ID = frame.ext;
rx_frame.DLC = frame.len;
memcpy(rx_frame.data.u8, frame.data, MIN(rx_frame.DLC, 64));
//message incoming, pass it on to the handler
receive_can(&rx_frame, CANFD_ADDON_MCP2518);
receive_can(&rx_frame, CANFD_NATIVE);
}
}
#endif // CANFD_ADDON

// Support functions
void print_can_frame(CAN_frame frame, frameDirection msgDir) {
#ifdef DEBUG_CAN_DATA // If enabled in user settings, print out the CAN messages via USB
Expand Down
57 changes: 54 additions & 3 deletions Software/src/communication/can/comm_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "src/lib/pierremolinaro-ACAN2517FD/ACAN2517FD.h"
#endif //CANFD_ADDON

enum frameDirection { MSG_RX, MSG_TX }; //RX = 0, TX = 1

/**
* @brief Initialization function for CAN.
*
Expand All @@ -24,19 +26,68 @@
*/
void init_CAN();

/**
* @brief Transmit one CAN frame
*
* @param[in] CAN_frame* tx_frame
* @param[in] int interface
*
* @return void
*/
void transmit_can();

/**
* @brief Send CAN messages to all components
*
* @param[in] void
*
* @return void
*/
void send_can();

/**
* @brief Receive CAN messages from all interfaces
*
* @param[in] void
*
* @return void
*/
void receive_can();

void receive_canfd_addon();

/**
* @brief Receive CAN messages from CAN tranceiver natively installed on Lilygo hardware
*
* @param[in] void
*
* @return void
*/
void receive_can_native();

/**
* @brief Receive CAN messages from CAN addon chip
*
* @param[in] void
*
* @return void
*/
void receive_can_addon();

enum frameDirection { MSG_RX, MSG_TX }; //RX = 0, TX = 1
/**
* @brief Receive CAN messages from CANFD addon chip
*
* @param[in] void
*
* @return void
*/
void receive_canfd_addon();

/**
* @brief print CAN frames via USB
*
* @param[in] void
*
* @return void
*/
void print_can_frame(CAN_frame frame, frameDirection msgDir);

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,31 @@
#include "../../datalayer/datalayer.h"
#include "../../devboard/utils/events.h"

/**
* @brief Contactor initialization
*
* @param[in] void
*
* @return void
*/
void init_contactors();

/**
* @brief Handle contactors
*
* @param[in] void
*
* @return void
*/
void handle_contactors();

/**
* @brief Handle contactors of battery 2
*
* @param[in] void
*
* @return void
*/
void handle_contactors_battery2();

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@
#include "../../devboard/utils/debounce_button.h"
#endif

/**
* @brief Initialization of equipment stop button
*
* @param[in] void
*
* @return void
*/
void init_equipment_stop_button();

/**
* @brief Monitor equipment stop button
*
* @param[in] void
*
* @return void
*/
void monitor_equipment_stop_button();

#endif
2 changes: 1 addition & 1 deletion Software/src/communication/nvm/comm_nvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void store_settings_equipment_stop() {
settings.end();
}

void storeSettings() {
void store_settings() {
settings.begin("batterySettings", false);
#ifdef WIFI
settings.putString("SSID", String(ssid.c_str()));
Expand Down
23 changes: 22 additions & 1 deletion Software/src/communication/nvm/comm_nvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,31 @@
#include "../../devboard/utils/events.h"
#include "../../devboard/wifi/wifi.h"

/**
* @brief Initialization of setting storage
*
* @param[in] void
*
* @return void
*/
void init_stored_settings();

/**
* @brief Store settings of equipment stop button
*
* @param[in] void
*
* @return void
*/
void store_settings_equipment_stop();

void storeSettings();
/**
* @brief Store settings
*
* @param[in] void
*
* @return void
*/
void store_settings();

#endif
7 changes: 7 additions & 0 deletions Software/src/communication/rs485/comm_rs485.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
#include "../../lib/eModbus-eModbus/ModbusServerRTU.h"
#include "../../lib/eModbus-eModbus/scripts/mbServerFCs.h"

/**
* @brief Initialization of RS485
*
* @param[in] void
*
* @return void
*/
void init_rs485();

#endif
2 changes: 1 addition & 1 deletion Software/src/communication/seriallink/comm_seriallink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void init_serialDataLink() {
// Main functions

#if defined(SERIAL_LINK_RECEIVER) || defined(SERIAL_LINK_TRANSMITTER)
void runSerialDataLink() {
void run_serialDataLink() {
static unsigned long updateTime = 0;
unsigned long currentMillis = millis();

Expand Down
9 changes: 8 additions & 1 deletion Software/src/communication/seriallink/comm_seriallink.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@

#include "../../include.h"

/**
* @brief Initialization of serial data link
*
* @param[in] void
*
* @return void
*/
void init_serialDataLink();

void runSerialDataLink();
void run_serialDataLink();

#endif
16 changes: 8 additions & 8 deletions Software/src/devboard/webserver/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void init_webserver() {
String value = request->getParam("value")->value();
if (value.length() <= 63) { // Check if SSID is within the allowable length
ssid = value.c_str();
storeSettings();
store_settings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "SSID must be 63 characters or less");
Expand All @@ -148,7 +148,7 @@ void init_webserver() {
String value = request->getParam("value")->value();
if (value.length() > 8) { // Check if password is within the allowable length
password = value.c_str();
storeSettings();
store_settings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Password must be atleast 8 characters");
Expand All @@ -165,7 +165,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
datalayer.battery.info.total_capacity_Wh = value.toInt();
storeSettings();
store_settings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
Expand All @@ -179,7 +179,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
datalayer.battery.settings.soc_scaling_active = value.toInt();
storeSettings();
store_settings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
Expand All @@ -193,7 +193,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
datalayer.battery.settings.max_percentage = static_cast<uint16_t>(value.toFloat() * 100);
storeSettings();
store_settings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
Expand Down Expand Up @@ -237,7 +237,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
datalayer.battery.settings.min_percentage = static_cast<uint16_t>(value.toFloat() * 100);
storeSettings();
store_settings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
Expand All @@ -251,7 +251,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
datalayer.battery.settings.max_user_set_charge_dA = static_cast<uint16_t>(value.toFloat() * 10);
storeSettings();
store_settings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
Expand All @@ -265,7 +265,7 @@ void init_webserver() {
if (request->hasParam("value")) {
String value = request->getParam("value")->value();
datalayer.battery.settings.max_user_set_discharge_dA = static_cast<uint16_t>(value.toFloat() * 10);
storeSettings();
store_settings();
request->send(200, "text/plain", "Updated successfully");
} else {
request->send(400, "text/plain", "Bad Request");
Expand Down
2 changes: 1 addition & 1 deletion Software/src/devboard/webserver/webserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void onOTAEnd(bool success);
template <typename T>
String formatPowerValue(String label, T value, String unit, int precision, String color = "white");

extern void storeSettings();
extern void store_settings();

void ota_monitor();

Expand Down

0 comments on commit 115c1c8

Please sign in to comment.