CAN Packet fix, CAN benchmark
This commit is contained in:
18
firmware/.gdbinit
Normal file
18
firmware/.gdbinit
Normal file
@@ -0,0 +1,18 @@
|
||||
#/com: target extended-remote /dev/ttyBmpGDB
|
||||
#/com: redefine "target remote" as "target extended-remote":
|
||||
define target remote
|
||||
tar ext $arg0
|
||||
mon tpwr en
|
||||
shell sleep 1
|
||||
#/com: monitor SWD
|
||||
mon s
|
||||
attach 1
|
||||
#mon erase_mass
|
||||
#flash-erase
|
||||
|
||||
#/com: enable peripheral view
|
||||
set mem inaccessible-by-default off
|
||||
|
||||
load
|
||||
compare-sections
|
||||
#b main
|
||||
@@ -25,7 +25,7 @@ set(CMAKE_C_STANDARD 11)
|
||||
|
||||
#Uncomment for software floating point
|
||||
#add_compile_options(-mfloat-abi=soft)
|
||||
#
|
||||
|
||||
#add_compile_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
|
||||
#add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0)
|
||||
|
||||
@@ -53,6 +53,7 @@ else ()
|
||||
add_compile_options(-Og -g)
|
||||
endif ()
|
||||
|
||||
#include_directories()
|
||||
include_directories(
|
||||
Core/Inc
|
||||
|
||||
@@ -71,12 +72,14 @@ include_directories(
|
||||
USB_DEVICE/Target
|
||||
)
|
||||
|
||||
#add_definitions()
|
||||
add_definitions(-DDEBUG -DUSE_HAL_DRIVER -DSTM32F107xC)
|
||||
|
||||
|
||||
file(GLOB_RECURSE SOURCES "startup/*.*" "USB_DEVICE/*.*" "Middlewares/*.*" "Drivers/*.*" "Core/*.*")
|
||||
|
||||
#set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/)
|
||||
#
|
||||
|
||||
#add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map)
|
||||
#add_link_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
|
||||
#add_link_options(-T ${LINKER_SCRIPT})
|
||||
|
||||
@@ -83,7 +83,7 @@ file(GLOB_RECURSE SOURCES ${sources})
|
||||
#add_link_options(-mcpu=${mcpu} -mthumb -mthumb-interwork)
|
||||
#add_link_options(-T $${LINKER_SCRIPT})
|
||||
|
||||
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/STM32F107VCTX_FLASH.ld)
|
||||
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/STM32F107VCTx_FLASH.ld)
|
||||
|
||||
add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map)
|
||||
add_link_options(-mcpu=cortex-m3 -mthumb -mthumb-interwork)
|
||||
|
||||
@@ -372,6 +372,8 @@ void usbTIM(uint8_t OnOff) {
|
||||
}
|
||||
}
|
||||
|
||||
u8_t TestData[8] = {1,2,3,4,5,6,7,8};
|
||||
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
if (htim->Instance == TIM2)
|
||||
@@ -381,15 +383,19 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
}
|
||||
else if (htim->Instance == TIM3)
|
||||
{
|
||||
CAN_TransmitRTR(0x500, 8, &hcan2);
|
||||
if (!(TIM3_Clock % 10)){
|
||||
CAN_TransmitRTR(0x500, 8, &hcan2);
|
||||
}
|
||||
|
||||
|
||||
if (TIM3_Clock % 2)
|
||||
{
|
||||
transmitCanPacketFromQueue(&can1_transmit_queue, &can1_transmit_queue_size, &hcan1);
|
||||
// transmitCanPacketFromQueue(&can1_transmit_queue, &can1_transmit_queue_size, &hcan1);
|
||||
}
|
||||
else
|
||||
if (!(TIM3_Clock % 3))
|
||||
{
|
||||
transmitCanPacketFromQueue(&can2_transmit_queue, &can2_transmit_queue_size, &hcan2);
|
||||
CAN_Transmit(0x501, TestData, 8, &hcan2);
|
||||
// transmitCanPacketFromQueue(&can2_transmit_queue, &can2_transmit_queue_size, &hcan2);
|
||||
}
|
||||
|
||||
TIM3_Clock++;
|
||||
@@ -1302,19 +1308,14 @@ void transmitCan2Packet()
|
||||
memcpy(buffer + 4, &endFaultVoltage, sizeof(endFaultVoltage));
|
||||
addCanPacketToQueue(0x503, buffer, &can2_transmit_queue, &can2_transmit_queue_size);
|
||||
|
||||
// sending charge starting and ending command
|
||||
// sending charge start current
|
||||
float chargeStartingCurrent = 15; // TODO move to generalConfig
|
||||
float chargeEndingCurrent = 5; // TODO move to generalConfig
|
||||
|
||||
u32_t chargeStartingCurrentInterval = 20; // in seconds TODO move to generalConfig
|
||||
memcpy(buffer, &chargeStartingCurrent, sizeof(chargeStartingCurrent));
|
||||
memcpy(buffer + 4, &chargeEndingCurrent, sizeof(chargeEndingCurrent));
|
||||
addCanPacketToQueue(0x504, buffer, &can2_transmit_queue, &can2_transmit_queue_size);
|
||||
|
||||
// sending charge permission, charge ending, charge/discharge state and table current command
|
||||
const uint8_t chargeAllowed = packState.chargeAllowed ? 0xFF : 0x00;
|
||||
const uint8_t chargeEnding = packState.SoC > 95 ? 0xFF : 0x00;
|
||||
const uint8_t chargeSwitchState = charge_switch_state ? 0xFF : 0x00;
|
||||
memcpy(buffer + 4, &chargeStartingCurrentInterval, sizeof(chargeStartingCurrentInterval));
|
||||
addCanPacketToQueue(0x504, buffer, &can2_transmit_queue, &can2_transmit_queue_size);
|
||||
|
||||
// sending table current and end-of-charge current command
|
||||
const int socIndex = getIndexBySoc();
|
||||
const int temperatureIndex = getIndexByTemperature();
|
||||
float tableCurrent = 0;
|
||||
@@ -1326,16 +1327,25 @@ void transmitCan2Packet()
|
||||
tableCurrent = pureCurrent ? tableValue : generalConfig->batteryCapacity * tableValue;
|
||||
}
|
||||
|
||||
float chargeEndingCurrent = 5; // TODO move to generalConfig
|
||||
memcpy(buffer + 0, &tableCurrent, sizeof(tableCurrent));
|
||||
memcpy(buffer + 4, &chargeEndingCurrent, sizeof(chargeEndingCurrent));
|
||||
addCanPacketToQueue(0x505, buffer, &can2_transmit_queue, &can2_transmit_queue_size);
|
||||
|
||||
// sending charge permission, charge ending, charge/discharge state command
|
||||
const uint8_t chargeAllowed = packState.chargeAllowed ? 0xFF : 0x00;
|
||||
const uint8_t chargeEnding = packState.SoC > 95 ? 0xFF : 0x00;
|
||||
const uint8_t chargeSwitchState = charge_switch_state ? 0xFF : 0x00;
|
||||
memset(buffer, '\0', sizeof(buffer));
|
||||
memcpy(buffer + 0, &chargeAllowed, sizeof(chargeAllowed));
|
||||
memcpy(buffer + 1, &chargeEnding, sizeof(chargeEnding));
|
||||
memcpy(buffer + 2, &chargeSwitchState, sizeof(chargeSwitchState));
|
||||
memcpy(buffer + 4, &tableCurrent, sizeof(tableCurrent));
|
||||
addCanPacketToQueue(0x505, buffer, &can2_transmit_queue, &can2_transmit_queue_size);
|
||||
addCanPacketToQueue(0x506, buffer, &can2_transmit_queue, &can2_transmit_queue_size);
|
||||
}
|
||||
|
||||
void addCanPacketToQueue(uint16_t id, uint8_t* data, uint8_t** queue, uint16_t* queueSize)
|
||||
{
|
||||
return;
|
||||
*queueSize += 10;
|
||||
*queue = (uint8_t*)realloc(*queue, *queueSize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user