Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Inc/can_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define CAN_HANDLER_H

#include "can.h"
#include "cmsis_os.h"
#include "ner_cmsis_os.h"

/**
* @brief Callback to be called when a message is received on CAN line 1.
Expand Down
2 changes: 1 addition & 1 deletion Core/Inc/cell_data_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <stdbool.h>
#include "datastructs.h"
#include "ringbuffer.h"
#include "cmsis_os.h"
#include "ner_cmsis_os.h"

// Number of stored cell data readings in ring buffer.
#define NUM_OF_READINGS 10
Expand Down
2 changes: 1 addition & 1 deletion Core/Inc/compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdint.h>
#include <stdbool.h>

#include "stm32f4xx.h"
#include "stm32xx_hal.h"

#define CURRENT_SENSOR_PIN_L A1
#define CURRENT_SENSOR_PIN_H A0
Expand Down
2 changes: 1 addition & 1 deletion Core/Inc/datastructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdint.h>
#include "bmsConfig.h"
#include "timer.h"
#include "cmsis_os2.h"
#include "ner_cmsis_os.h"
#include "adBms6830Data.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion Core/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"
#include "stm32xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
Expand Down
22 changes: 5 additions & 17 deletions Core/Inc/segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

#include "datastructs.h"

typedef bool discharge_config[NUM_CHIPS][NUM_CELLS_ALPHA];

/**
* @brief Initialize chips with default values.
*
*
*/
void segment_init(acc_data_t *bmsdata);
void segment_init(acc_data_t *bmsdata);
/**
* @brief Stop discharge quickly
*
Expand Down Expand Up @@ -72,7 +74,7 @@ void segment_manual_balancing(acc_data_t *bmsdata);
* @param discharge_config Array containing the discharge configuration. true = discharge, false = do not discharge.
*/
void segment_configure_balancing(
acc_data_t *bmsdata, bool discharge_config[NUM_CHIPS][NUM_CELLS_ALPHA]);
acc_data_t *bmsdata, discharge_config dc);

/**
* @brief Returns if any cells are balancing.
Expand Down Expand Up @@ -101,18 +103,4 @@ void segment_restart(acc_data_t *bmsdata);
*/
void get_adc_comparison(acc_data_t *bmsdata);

/**
* @brief Read the serial ID of the chip.
*
* @param chips Array of chips to read.
*/
void read_serial_id(cell_asic chips[NUM_CHIPS]);

/**
* @brief Read voltages in every register connected to AUX2 ADC.
*
* @param chips Array of chips to get voltages of.
*/
void adc_and_read_aux2_registers(cell_asic chips[NUM_CHIPS]);

#endif
2 changes: 1 addition & 1 deletion Core/Inc/shep_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef SHEP_TASKS_H
#define SHEP_TASKS_H

#include "cmsis_os.h"
#include "ner_cmsis_os.h"

/**
* @brief Task for retrieving segment data
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/cell_data_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "cell_data_logging.h"
#include "analyzer.h"
#include "bmsConfig.h"
#include "stm32f4xx_hal.h"
#include "stm32xx_hal.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/eepromdirectory.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "eepromdirectory.h"
#include "stm32f4xx_hal.h"
#include "stm32xx_hal.h"
#include "m24c32_eeprom_directory.h"
#include "m24c32.h"

Expand Down
2 changes: 1 addition & 1 deletion Drivers/adbms
Submodule adbms updated from 0a1939 to 60c702
8 changes: 8 additions & 0 deletions Tests/Inc/test_analyzer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#ifndef TEST_ANALYZER_H
#define TEST_ANALYZER_H

#include "unity.h"
#include "analyzer.h"

#endif
8 changes: 8 additions & 0 deletions Tests/Inc/test_charging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#ifndef TEST_CHARGING_H
#define TEST_CHARGING_H

#include "unity.h"
#include "charging.h"

#endif
38 changes: 38 additions & 0 deletions Tests/Src/test_analyzer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

#include "unity.h"
#include "mock_stub_functions.h"
#include "datastructs.h"
#include "analyzer.h"
#include <stdbool.h>
#include <stdlib.h>

I2C_HandleTypeDef hi2c1;
ADC_HandleTypeDef hadc1;

acc_data_t *bmsdata;
chipdata_t *chipdata;


void setUp(void) {
bmsdata = malloc(sizeof(acc_data_t));
chipdata = malloc(sizeof(chipdata_t));
}

void tearDown(void) {
free(bmsdata);
free(chipdata);
}

// A simple random test
void test_random(void) {
chipdata->alpha = true;
TEST_ASSERT_EQUAL_INT(get_num_cells(chipdata), NUM_CELLS_ALPHA);
chipdata->alpha = false;
TEST_ASSERT_EQUAL_INT(get_num_cells(chipdata), NUM_CELLS_BETA);
}

int main(void) {
UNITY_BEGIN();
RUN_TEST(test_random);
return UNITY_END();
}
34 changes: 34 additions & 0 deletions Tests/Src/test_charging.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#include "mock_stub_functions.h"
#include "test_charging.h"
#include "datastructs.h"
#include <stdbool.h>
#include <stdlib.h>

I2C_HandleTypeDef hi2c1;
ADC_HandleTypeDef hadc1;

acc_data_t *bmsdata;
chipdata_t *chipdata;


void setUp(void) {
bmsdata = malloc(sizeof(acc_data_t));
chipdata = malloc(sizeof(chipdata_t));
}

void tearDown(void) {
free(bmsdata);
free(chipdata);
}

// A simple random test
void test_charging(void) {

}

int main(void) {
UNITY_BEGIN();
RUN_TEST(test_charging);
return UNITY_END();
}
6 changes: 6 additions & 0 deletions Tests/mock_configs/test_analyzer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Core/Inc/adi_interaction.h
Drivers/adbms/program/inc/serialPrintResult.h
Core/Inc/cell_data_logging.h
Core/Inc/eepromdirectory.h
Drivers/Embedded-Base/general/include/sht30.h
Drivers/adbms/lib/inc/adBms6830ParseCreate.h
7 changes: 7 additions & 0 deletions Tests/mock_configs/test_charging.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Core/Inc/adi_interaction.h
Drivers/adbms/program/inc/serialPrintResult.h
Core/Inc/cell_data_logging.h
Core/Inc/eepromdirectory.h
Drivers/Embedded-Base/general/include/sht30.h
Drivers/adbms/lib/inc/adBms6830ParseCreate.h
Core/Inc/segment.h
Loading