used ChatGPT to add comments and proper Headers to all SourceFiles

This commit is contained in:
2024-01-09 12:54:05 +01:00
parent 62cc2bf982
commit f52f4103f6
21 changed files with 945 additions and 99 deletions

View File

@@ -1,3 +1,17 @@
/**
* @file can.cpp
*
* @brief Implementation file for CAN-related functions in the ChainLube application.
*
* This file contains the implementation of functions related to CAN (Controller Area Network)
* communication within the ChainLube application. It includes the initialization of the CAN module,
* setup of masks and filters, and processing of CAN messages. Additionally, a debug message function
* is included if CAN debugging is enabled.
*
* @author Your Name
* @date Date
*/
#include "can.h"
MCP_CAN CAN0(GPIO_CS_CAN);
@@ -6,9 +20,14 @@ MCP_CAN CAN0(GPIO_CS_CAN);
void sendCANDebugMessage();
#endif
/**
* @brief Initializes the CAN module, sets masks, and filters based on the configured CAN source.
*
* This function initializes the CAN module, sets masks and filters based on the configured CAN source
* in the application settings, and sets the CAN module in normal mode for communication.
*/
void Init_CAN()
{
if (CAN0.begin(MCP_STDEXT, CAN_500KBPS, MCP_16MHZ) != CAN_OK)
MaintainDTC(DTC_CAN_TRANSCEIVER_FAILED, true);
@@ -30,6 +49,11 @@ void Init_CAN()
CAN0.setMode(MCP_NORMAL);
}
/**
* @brief Processes CAN messages and sends a CAN debug message periodically.
*
* This function processes CAN messages and sends a CAN debug message periodically based on a time interval.
*/
void CAN_Process()
{
static uint32_t previousMillis = 0;
@@ -40,7 +64,15 @@ void CAN_Process()
previousMillis = millis();
}
}
/**
* @brief Processes CAN messages to determine the wheel speed based on the configured CAN source.
*
* This function reads incoming CAN messages and extracts the rear wheel speed information.
* The wheel speed is then converted to millimeters per second based on the configured CAN source.
* The function also monitors the CAN signal for potential issues and triggers diagnostic trouble codes (DTCs).
*
* @return The calculated distance traveled in millimeters since the last call.
*/
uint32_t Process_CAN_WheelSpeed()
{
#define FACTOR_RWP_KMH_890ADV 18 // Divider to convert Raw Data to km/h
@@ -87,6 +119,13 @@ uint32_t Process_CAN_WheelSpeed()
}
#ifdef CAN_DEBUG_MESSAGE
/**
* @brief Sends periodic CAN debug messages for monitoring and diagnostics.
*
* This function sends periodic CAN debug messages containing various system information for monitoring and diagnostics.
* The information includes system status, timestamps, tank percentage, DTC flags, and other relevant data.
* The debug messages are sent with a configurable multiplexer to broadcast different types of information in each cycle.
*/
void sendCANDebugMessage()
{
#define MAX_DEBUG_MULTIPLEXER 6