Skip to content

Commit

Permalink
feat(canlib): Update canlib version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tonidotpy committed Aug 9, 2024
1 parent 194573b commit c74b120
Show file tree
Hide file tree
Showing 8 changed files with 3,574 additions and 2,874 deletions.
2 changes: 1 addition & 1 deletion cellboard/Core/Lib/can
Submodule can updated 42 files
+1 −1 dbc/bms/bms.dbc
+35 −30 dbc/primary/primary.dbc
+40 −36 dbc/secondary/secondary.dbc
+1 −1 dbc/simulator/simulator.dbc
+1 −1 lib/bms/bms_network.c
+2 −2 lib/bms/bms_network.h
+1 −1 lib/bms/bms_utils.h
+1 −1 lib/bms/bms_utils.hpp
+1 −1 lib/inverters/inverters_network.c
+2 −2 lib/inverters/inverters_network.h
+3 −3 lib/inverters/inverters_utils.h
+3 −3 lib/inverters/inverters_utils.hpp
+1 −1 lib/ivts/ivts_network.c
+2 −2 lib/ivts/ivts_network.h
+6 −6 lib/ivts/ivts_utils.h
+6 −6 lib/ivts/ivts_utils.hpp
+265 −75 lib/primary/primary_network.c
+246 −107 lib/primary/primary_network.h
+104 −61 lib/primary/primary_utils.c
+104 −58 lib/primary/primary_utils.cpp
+10 −3 lib/primary/primary_utils.h
+10 −3 lib/primary/primary_utils.hpp
+18 −17 lib/primary/primary_watchdog.c
+84 −83 lib/primary/primary_watchdog.h
+409 −233 lib/secondary/secondary_network.c
+229 −128 lib/secondary/secondary_network.h
+84 −66 lib/secondary/secondary_utils.c
+84 −66 lib/secondary/secondary_utils.cpp
+13 −8 lib/secondary/secondary_utils.h
+13 −8 lib/secondary/secondary_utils.hpp
+41 −32 lib/secondary/secondary_watchdog.c
+20 −18 lib/secondary/secondary_watchdog.h
+1 −1 lib/simulator/simulator_network.c
+2 −2 lib/simulator/simulator_network.h
+2 −2 lib/simulator/simulator_utils.h
+2 −2 lib/simulator/simulator_utils.hpp
+25 −5 networks/primary/network.json
+28 −15 networks/secondary/network.json
+95 −84 proto/primary/primary.proto
+33 −8 proto/primary/primary_proto_interface.h
+24 −20 proto/secondary/secondary.proto
+45 −24 proto/secondary/secondary_proto_interface.h
16 changes: 9 additions & 7 deletions cellboard/Core/Src/temp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ static const uint8_t adc_addresses[6] = {
};

static const bool excluded_temps[CELLBOARD_COUNT][CELLBOARD_TEMP_SENSOR_COUNT] = {
[0] = { 0 },
[1] = { [0] = true, [4] = true, [6] = true, [8] = true, [13] = true },
[2] = { [29] = true },
[3] = { [5] = true, [25] = true, [26] = true },
[4] = { [1] = true, [3] = true, [13] = true, [35] = true },
[5] = { [7] = true, [9] = true, [14] = true, [29] = true }
[0] = { [7] = true, [26] = true },
[1] = { [0] = true, [4] = true, [6] = true, [8] = true, [13] = true, [35] = true },
[2] = { [15] = true, [21] = true, [26] = true, [29] = true },
[3] = { [5] = true, [6] = true, [25] = true, [26] = true },
[4] = { [1] = true, [3] = true, [13] = true, [14] = true, [23] = true, [35] = true },
[5] = { [3] = true, [7] = true, [9] = true, [14] = true, [18] = true, [29] = true }
};

/**
Expand Down Expand Up @@ -95,7 +95,9 @@ void temp_measure(uint8_t adc_index) {
if (!_temp_include_cell(temp_index)) {
size_t cnt = 0U;
temperature_t temp = 0U;
for (size_t i = temp_index - 2U; i <= temp_index + 2U; ++i) {

size_t base = (temp_index / 6U) * 6U;
for (size_t i = base; i < base + 6U; ++i) {
if (_temp_include_cell(i)) {
temp += temperatures[i];
++cnt;
Expand Down
246 changes: 246 additions & 0 deletions mainboard/Inc/error/error-handler.h.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
/*******************************************************************************
* Critical error handler library generator
* Generated by error_gen ruby gem, for more information see:
* https://github.com/eagletrt/micro-utils/tree/master/error-handler-generator
*
* Error_gen version 1.6.3
* Generation date: 2024-08-06 16:25:54 +0200
* Generated from: data/errors.json
* With prefix: none
* The error handler contains:
* - 15 error groups
* - 66 total error instances
******************************************************************************/

#ifndef ERROR_HANDLER_H
#define ERROR_HANDLER_H

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

// Total number of error instances
#define ERROR_INSTANCE_COUNT 66

/**
* @brief Set or reset an instance of an error based on a condition
*
* @details If the condition is true the error is set, otherwise it is reset
*
* @param condition A boolean expression
* @param group The group to which the error belongs
* @param instance The instance of the error
* @param The current time (in ms)
*/
#define ERROR_TOGGLE_IF(condition, group, instance, timestamp) \
((condition) ? error_set(group, instance, timestamp) : error_reset(group, instance))

/**
* @brief Type of the error that categorize a group of instances
*
* @details
* - ERROR_GROUP_ERROR_CELL_UNDER_VOLTAGE no description
* - ERROR_GROUP_ERROR_CELL_OVER_VOLTAGE no description
* - ERROR_GROUP_ERROR_CELL_UNDER_TEMPERATURE no description
* - ERROR_GROUP_ERROR_CELL_OVER_TEMPERATURE no description
* - ERROR_GROUP_ERROR_OVER_CURRENT no description
* - ERROR_GROUP_ERROR_CAN no description
* - ERROR_GROUP_ERROR_INT_VOLTAGE_MISMATCH no description
* - ERROR_GROUP_ERROR_CELLBOARD_COMM no description
* - ERROR_GROUP_ERROR_CELLBOARD_INTERNAL no description
* - ERROR_GROUP_ERROR_CONNECTOR_DISCONNECTED no description
* - ERROR_GROUP_ERROR_FANS_DISCONNECTED no description
* - ERROR_GROUP_ERROR_FEEDBACK no description
* - ERROR_GROUP_ERROR_FEEDBACK_CIRCUITRY no description
* - ERROR_GROUP_ERROR_EEPROM_COMM no description
* - ERROR_GROUP_ERROR_EEPROM_WRITE no description
*/
typedef enum {
ERROR_GROUP_ERROR_CELL_UNDER_VOLTAGE,
ERROR_GROUP_ERROR_CELL_OVER_VOLTAGE,
ERROR_GROUP_ERROR_CELL_UNDER_TEMPERATURE,
ERROR_GROUP_ERROR_CELL_OVER_TEMPERATURE,
ERROR_GROUP_ERROR_OVER_CURRENT,
ERROR_GROUP_ERROR_CAN,
ERROR_GROUP_ERROR_INT_VOLTAGE_MISMATCH,
ERROR_GROUP_ERROR_CELLBOARD_COMM,
ERROR_GROUP_ERROR_CELLBOARD_INTERNAL,
ERROR_GROUP_ERROR_CONNECTOR_DISCONNECTED,
ERROR_GROUP_ERROR_FANS_DISCONNECTED,
ERROR_GROUP_ERROR_FEEDBACK,
ERROR_GROUP_ERROR_FEEDBACK_CIRCUITRY,
ERROR_GROUP_ERROR_EEPROM_COMM,
ERROR_GROUP_ERROR_EEPROM_WRITE,
ERROR_GROUP_COUNT
} ErrorGroup;

/** @brief Single error instance type definition */
typedef uint16_t ErrorInstance;

/**
* @brief Error type definition
*
* @param group The group to which the error belongs
* @param timestamp The time when the error was set (in ms)
* @param is_running True if the error is set, false otherwise
* @param is_expired True if the error has expired, false otherwise
*/
typedef struct {
ErrorGroup group;
uint32_t timestamp;
bool is_running;
bool is_expired;
} Error;

/**
* @brief Initialize the internal error handler structures
*
* @details A critical section is defined as a block of code where, if an interrupt
* happens, undefined behaviour with the modified data within the block can happen
*
* @param cs_enter A pointer to a function that should manage a critical section
* @param cs_exit A pointer to a function that shuold manage a critical section
*/
void error_init(void (* cs_enter)(void), void (* cs_exit)(void));

/**
* @brief Get the number of errors that has been set but they still have to expire
*
* @param size_t The number of running errors
*/
size_t error_get_running(void);

/**
* @brief Get the number of expired errors
*
* @param size_t The number of expired errors
*/
size_t error_get_expired(void);

/**
* @brief Get the number of running error of a specific group
*
* @param group The error group
*
* @return uint16_t The number of running errors
*/
uint16_t error_get_group_running(ErrorGroup group);

/**
* @brief Get the number of expired error of a specific group
*
* @param group The error group
*
* @return uint16_t The number of running errors
*/
uint16_t error_get_group_expired(ErrorGroup group);

/**
* @brief Get a copy of all the errors that are currently running
*
* @attention This function can be quite expensive in terms of time
* and should be used wisely, do not call to often
* @attention This function calls the critical section handler functions
*
* @details The out array should be able to contain all the instances
*
* @param out A pointer to an array of errors where the data is copied into
*
* @return size_t The number of copied errors
*/
size_t error_dump_running(Error * out);

/**
* @brief Get a copy of all the errors that are expired
*
* @attention This function can be quite expensive in terms of time
* and should be used wisely, do not call to often
* @attention This function calls the critical section handler functions
*
* @details The out array should be able to contain all the instances
*
* @param out A pointer to an array of errors where the data is copied into
*
* @return size_t The number of copied errors
*/
size_t error_dump_expired(Error * out);

/**
* @brief Get all the groups in which at least one error is running
*
* @param out A pointer to an array of groups where the data is copied into
*
* @return size_t The number of copied groups
*/
size_t error_dump_running_groups(ErrorGroup * out);

/**
* @brief Get all the groups in which at least one error is expired
*
* @param out A pointer to an array of groups where the data is copied into
*
* @return size_t The number of copied groups
*/
size_t error_dump_expired_groups(ErrorGroup * out);

/**
* @brief Set an error which will expire after a certain amount of time (the timeout)
*
* @param group The group to which the error belongs
* @param instance The instance of the error
* @param The current time (in ms)
*/
void error_set(ErrorGroup group, ErrorInstance instance, uint32_t timestamp);

/**
* @brief Reset an error to avoid its expiration
*
* @param group The group to which the error belongs
* @param instance The instance of the error
*/
void error_reset(ErrorGroup group, ErrorInstance instance);

/** @brief Set the error as expired */
void error_expire(void);

/**
* @brief Set the error as expired immediately even if it is not running
*
* @param group The group to which the error belongs
* @param instance The instance of the error
*/
void error_expire_immediate(ErrorGroup group, ErrorInstance instance);

/**
* @brief Routine that updates the internal error states
*
* @attention This function should not be called inside interrupts callback
* or other threads
*
* @details This function should be called periodically
*/
void error_routine(void);

/**
* @brief Update the timer that should expire the error after a certain amount of time
*
* @attention This function have to be defined by the user
*
* @details This function is called internally when an error is set, reset or expired
*
* @param timestamp The time in which the error was set (in ms)
* @param timeout The time that should elapse after the timestamp to expire the error (in ms)
*/
void error_update_timer_callback(uint32_t timestamp, uint16_t timeout);

/**
* @brief Stop the timer that should expire the errors
*
* @attention This function have to be defined by the user
*
* @details This function is called internally when an error is reset or expired
*/
void error_stop_timer_callback(void);

#endif // ERROR_HANDLER_H

Loading

0 comments on commit c74b120

Please sign in to comment.