Compare commits
2 Commits
feature/ml
...
debug/flic
| Author | SHA1 | Date | |
|---|---|---|---|
| 993920fb1c | |||
| b09121b876 |
@@ -23,7 +23,7 @@
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.116246094" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv5-d16" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.1041462468" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1294249446" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" value="genericBoard" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.19322524" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32H723VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../FATFS/Target | ../FATFS/App | ../USB_DEVICE/App | ../USB_DEVICE/Target | ../Drivers/STM32H7xx_HAL_Driver/Inc | ../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F | ../Middlewares/Third_Party/FatFs/src | ../Middlewares/ST/STM32_USB_Device_Library/Core/Inc | ../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc | ../Drivers/CMSIS/Device/ST/STM32H7xx/Include | ../Drivers/CMSIS/Include || || || USE_FULL_LL_DRIVER | USE_HAL_DRIVER | STM32H723xx || || Drivers | Core/Startup | Middlewares | Core | FATFS | USB_DEVICE || || || ${workspace_loc:/${ProjName}/STM32H723VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.19322524" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32H723VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../FATFS/Target | ../FATFS/App | ../USB_DEVICE/App | ../USB_DEVICE/Target | ../Drivers/STM32H7xx_HAL_Driver/Inc | ../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F | ../Middlewares/Third_Party/FatFs/src | ../Middlewares/ST/STM32_USB_Device_Library/Core/Inc | ../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc | ../Drivers/CMSIS/Device/ST/STM32H7xx/Include | ../Drivers/CMSIS/Include || || || USE_FULL_LL_DRIVER | USE_HAL_DRIVER | STM32H723xx || || EEPROM | Drivers | Core/Startup | Middlewares | Core | FATFS | USB_DEVICE || || || ${workspace_loc:/${ProjName}/STM32H723VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.784195808" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" value="275" valueType="string"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.550567667" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/CLS_Master}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1667139540" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
@@ -85,6 +85,7 @@
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="EEPROM"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="FATFS"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
||||
@@ -117,7 +118,7 @@
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.315263605" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv5-d16" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.861723814" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.575901382" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" value="genericBoard" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.41596049" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32H723VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../FATFS/Target | ../FATFS/App | ../USB_DEVICE/App | ../USB_DEVICE/Target | ../Drivers/STM32H7xx_HAL_Driver/Inc | ../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F | ../Middlewares/Third_Party/FatFs/src | ../Middlewares/ST/STM32_USB_Device_Library/Core/Inc | ../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc | ../Drivers/CMSIS/Device/ST/STM32H7xx/Include | ../Drivers/CMSIS/Include || || || USE_FULL_LL_DRIVER | USE_HAL_DRIVER | STM32H723xx || || Drivers | Core/Startup | Middlewares | Core | FATFS | USB_DEVICE || || || ${workspace_loc:/${ProjName}/STM32H723VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.41596049" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32H723VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../FATFS/Target | ../FATFS/App | ../USB_DEVICE/App | ../USB_DEVICE/Target | ../Drivers/STM32H7xx_HAL_Driver/Inc | ../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F | ../Middlewares/Third_Party/FatFs/src | ../Middlewares/ST/STM32_USB_Device_Library/Core/Inc | ../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc | ../Drivers/CMSIS/Device/ST/STM32H7xx/Include | ../Drivers/CMSIS/Include || || || USE_FULL_LL_DRIVER | USE_HAL_DRIVER | STM32H723xx || || EEPROM | Drivers | Core/Startup | Middlewares | Core | FATFS | USB_DEVICE || || || ${workspace_loc:/${ProjName}/STM32H723VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.669660917" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" value="275" valueType="string"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.62262984" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/CLS_Master}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1586300933" managedBuildOn="true" name="Gnu Make Builder.Release" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
@@ -175,6 +176,7 @@
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="EEPROM"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="FATFS"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
||||
|
||||
@@ -4,11 +4,11 @@ on: [push]
|
||||
|
||||
jobs:
|
||||
Build-Release:
|
||||
runs-on: cls-build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
#- name: Install dependencies
|
||||
# run: apt-get update && apt-get install -y gcc-arm-none-eabi binutils-arm-none-eabi ninja-build cmake protobuf-compiler python3 python3-grpcio python3-protobuf python3-pkg-resources python3-requests
|
||||
- name: Install dependencies
|
||||
run: apt-get update && apt-get install -y gcc-arm-none-eabi binutils-arm-none-eabi ninja-build cmake protobuf-compiler python3 python3-grpcio python3-protobuf python3-pkg-resources python3-requests
|
||||
# run: pip install setuptools
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
9
.gitmodules
vendored
9
.gitmodules
vendored
@@ -19,12 +19,3 @@
|
||||
[submodule "proto"]
|
||||
path = proto
|
||||
url = git@git.lan:oliver/cls-proto.git
|
||||
[submodule "lib/TinyFrame"]
|
||||
path = lib/TinyFrame
|
||||
url = https://github.com/MightyPork/TinyFrame.git
|
||||
[submodule "Application/MLZR_Comm"]
|
||||
path = Application/MLZR_Comm
|
||||
url = git@git.lan:ODDIY/MLZR_Comm.git
|
||||
[submodule "Application/MLZR_GLASM"]
|
||||
path = Application/MLZR_GLASM
|
||||
url = git@git.lan:ODDIY/MLZR_GLASM.git
|
||||
|
||||
100
.mxproject
100
.mxproject
File diff suppressed because one or more lines are too long
@@ -34,7 +34,7 @@ void BSP_SDLogger_Init(int log_number) {
|
||||
ULOG_ERROR("Failed to open file %s", file_name);
|
||||
}
|
||||
|
||||
//ULOG_SUBSCRIBE(BSP_SDLogger_ULOG, ULOG_DEBUG_LEVEL);
|
||||
ULOG_SUBSCRIBE(BSP_SDLogger_ULOG, ULOG_DEBUG_LEVEL);
|
||||
|
||||
// close the file
|
||||
f_close(&file);
|
||||
|
||||
Submodule Application/CLS updated: 58b50b2fb3...7080707f9d
@@ -1,5 +1,4 @@
|
||||
#include "CLS_BSP.h"
|
||||
#include "CLSAddress.h"
|
||||
|
||||
|
||||
#ifdef CLS_BSP_FDCAN
|
||||
@@ -69,8 +68,3 @@ CLS_Position_t CLS_BSP_GetPosition(void) {
|
||||
|
||||
void CLS_BSP_SetPosition(CLS_Position_t position) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "BSP_GPIO.h"
|
||||
|
||||
|
||||
@@ -12,4 +12,4 @@ target_sources(${PROJECT_NAME}
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE CLS BSP Vehicle)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE CLS)
|
||||
@@ -1,10 +1,5 @@
|
||||
include_directories(MLZR_Comm_Conf)
|
||||
|
||||
add_subdirectory(Tasks)
|
||||
add_subdirectory(CLS)
|
||||
add_subdirectory(CLS_BSP)
|
||||
add_subdirectory(BSP)
|
||||
add_subdirectory(ram_loader)
|
||||
add_subdirectory(MLZR_GLASM)
|
||||
add_subdirectory(MLZR_Comm)
|
||||
add_subdirectory(Vehicle)
|
||||
Submodule Application/MLZR_Comm deleted from baa031e9c3
@@ -1,14 +0,0 @@
|
||||
// Define macros for UART and DMA configurations
|
||||
#define MAIN_UART USART1
|
||||
#define MAIN_DMA_RX 1
|
||||
#define MAIN_DMA_RX_CHANNEL 0
|
||||
#define MAIN_DMA_TX 1
|
||||
#define MAIN_DMA_TX_CHANNEL 1
|
||||
|
||||
#define HALF_UART USART3
|
||||
#define HALF_DMA_RX 1
|
||||
#define HALF_DMA_RX_CHANNEL 2
|
||||
#define HALF_DMA_TX 1
|
||||
#define HALF_DMA_TX_CHANNEL 3
|
||||
|
||||
#define DMA_MEM_ATTR __attribute__((section(".data")))
|
||||
Submodule Application/MLZR_GLASM deleted from 613d6c69f8
@@ -12,9 +12,6 @@ target_sources(${PROJECT_NAME}
|
||||
${CMAKE_CURRENT_LIST_DIR}/FirmwareUpdate.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/LightTask.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/LightState.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/Headlight_can.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/DisplayComm.c
|
||||
|
||||
INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/UsbDataHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/CanDataTask.h
|
||||
@@ -25,4 +22,4 @@ target_sources(${PROJECT_NAME}
|
||||
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC PROTOS CLS)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Revision CLS_BSP BSP ulog Vehicle ram_loader mlzr_comm TinyFrame)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Revision CLS_BSP BSP ulog ram_loader)
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "ulog.h"
|
||||
#include "BSP_POWER.h"
|
||||
#include "BSP_GPIO.h"
|
||||
#include "Vehicle.h"
|
||||
// Define thread flags
|
||||
#define FLAG_FDCAN_RX_FIFO0 (1<<0)
|
||||
#define FLAG_FDCAN_RX_FIFO1 (1<<1)
|
||||
@@ -47,7 +46,7 @@ const osThreadAttr_t CarCanTask_attr = {
|
||||
.priority = osPriorityNormal,
|
||||
};
|
||||
|
||||
static uint64_t last_car_message_time = 0;
|
||||
|
||||
|
||||
uint32_t dlcDecode(uint32_t dlcCode) {
|
||||
switch(dlcCode) {
|
||||
@@ -131,6 +130,11 @@ void CanDataTask_func(void *argument) {
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t last_unlock_message_time = UINT64_MAX;
|
||||
static uint64_t last_car_message_time = 0;
|
||||
static uint8_t car_can_brightness = 255;
|
||||
static float car_can_speed = 0;
|
||||
static int car_can_direction = 0;
|
||||
|
||||
// convert byte to 2 hex characters
|
||||
void byteToHex(uint8_t byte, char * hex) {
|
||||
@@ -139,10 +143,6 @@ void byteToHex(uint8_t byte, char * hex) {
|
||||
hex[1] = hexLookup[byte & 0x0F];
|
||||
}
|
||||
|
||||
|
||||
static FDCAN_RxHeaderTypeDef RxHeader = {0};
|
||||
static uint8_t RxData[8] = {0};
|
||||
|
||||
void CarCanTask_func(void *argument) {
|
||||
|
||||
// for testing accept all messages from the car can bus
|
||||
@@ -152,8 +152,20 @@ void CarCanTask_func(void *argument) {
|
||||
}
|
||||
|
||||
|
||||
Vehicle_Setup_CAN();
|
||||
|
||||
FDCAN_FilterTypeDef sFilterConfig;
|
||||
sFilterConfig.IdType = FDCAN_STANDARD_ID;
|
||||
sFilterConfig.FilterIndex = 0;
|
||||
sFilterConfig.FilterType = CLS_BSP_CAN_FILTER_LIST;
|
||||
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO1;
|
||||
sFilterConfig.FilterID1 = 0x391;
|
||||
sFilterConfig.FilterID2 = 0x395;
|
||||
HAL_FDCAN_ConfigFilter(&hfdcan2, &sFilterConfig);
|
||||
|
||||
sFilterConfig.FilterIndex = 1;
|
||||
sFilterConfig.FilterID1 = 0x351;
|
||||
sFilterConfig.FilterID2 = 0x635;
|
||||
HAL_FDCAN_ConfigFilter(&hfdcan2, &sFilterConfig);
|
||||
|
||||
/* Start the FDCAN module */
|
||||
if (HAL_FDCAN_Start(&hfdcan2) != HAL_OK){
|
||||
@@ -164,7 +176,8 @@ void CarCanTask_func(void *argument) {
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
|
||||
FDCAN_RxHeaderTypeDef RxHeader;
|
||||
uint8_t RxData[8];
|
||||
|
||||
for(;;) {
|
||||
// wait for interrupt event on any fifo
|
||||
@@ -248,8 +261,71 @@ void CarCanTask_func(void *argument) {
|
||||
if (HAL_FDCAN_GetRxMessage(&hfdcan2, FDCAN_RX_FIFO1, &RxHeader, RxData) != HAL_OK) {
|
||||
Error_Handler();
|
||||
} else {
|
||||
char msg[17] = {0};
|
||||
|
||||
Vehicle_Receive_CAN(RxHeader, RxData);
|
||||
|
||||
// do something with the can data
|
||||
|
||||
|
||||
if(RxHeader.Identifier == 0x391) {
|
||||
byteToHex(RxData[0], &msg[0]);
|
||||
byteToHex(RxData[1], &msg[2]);
|
||||
byteToHex(RxData[2], &msg[4]);
|
||||
if (RxData[1] == 0x04)
|
||||
{
|
||||
// car was unlocked
|
||||
last_unlock_message_time = osKernelGetTickCount();
|
||||
}
|
||||
else if (RxData[1] ==0x80)
|
||||
{
|
||||
// car was locked
|
||||
if (!BSP_GPIO_K15isSet()) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (RxHeader.Identifier == 0x395) {
|
||||
byteToHex(RxData[0], &msg[0]);
|
||||
|
||||
// send the unlock message to the car
|
||||
if ((RxData[0] & 0x0F) == 0x01) {
|
||||
// car was unlocked
|
||||
last_unlock_message_time = osKernelGetTickCount();
|
||||
ULOG_DEBUG("Unlock message received");
|
||||
|
||||
} else if ((RxData[0] & 0x0F) == 0x02) {
|
||||
// car was locked
|
||||
if (!BSP_GPIO_K15isSet()) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// speed signal
|
||||
// AA BB XX YY 00 00 00 00
|
||||
// Speed (XX*(2^8)+(YY-1))/190
|
||||
// direction AA = 0x00 forward, 0x02 backward
|
||||
if (RxHeader.Identifier == 0x351) {
|
||||
|
||||
uint16_t speed = (RxData[2] << 8) + RxData[3];
|
||||
float speed_kmh = (speed - 1) / 190.0;
|
||||
car_can_speed = speed_kmh;
|
||||
car_can_direction = RxData[0];
|
||||
ULOG_DEBUG("Speed: %f, Direction: %d", car_can_speed, car_can_direction);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// brightness knob in 0 - 100
|
||||
if (RxHeader.Identifier == 0x635) {
|
||||
// scale the brightness to 0 - 255 only using integer math
|
||||
car_can_brightness = ((uint32_t)RxData[0] * 255) / 100;
|
||||
ULOG_DEBUG("Brightness: %d", car_can_brightness);
|
||||
|
||||
}
|
||||
|
||||
//ULOG_DEBUG("Used Car MSG: %x, %d %s", RxHeader.Identifier, CLS_BSP_DLC_ToBytes(RxHeader.DataLength), msg );
|
||||
}
|
||||
@@ -263,6 +339,9 @@ void CarCanTask_func(void *argument) {
|
||||
* @return true if a car can message has been received
|
||||
* @return false if no car can message has been received
|
||||
*/
|
||||
bool CanDataTask_gotCarCanMessage() {
|
||||
return last_unlock_message_time != UINT64_MAX;
|
||||
}
|
||||
|
||||
|
||||
bool CanDataTask_CarCanActive() {
|
||||
@@ -271,9 +350,20 @@ bool CanDataTask_CarCanActive() {
|
||||
}
|
||||
|
||||
return osKernelGetTickCount() - last_car_message_time < 1000;
|
||||
|
||||
}
|
||||
|
||||
uint8_t CanDataTask_CarCanBrightness() {
|
||||
return car_can_brightness;
|
||||
}
|
||||
|
||||
float CanDataTask_CarCanSpeed() {
|
||||
return car_can_speed;
|
||||
}
|
||||
|
||||
int CanDataTask_CarCanDirectionIsForward() {
|
||||
return car_can_direction == 0;
|
||||
}
|
||||
|
||||
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs) {
|
||||
// Notify the thread
|
||||
@@ -318,6 +408,7 @@ extern uint8_t gCLS_DEVICE_ADDRESS;
|
||||
void DataClbk_cls_device_RequestList(void* msg, uint32_t length) {
|
||||
memset(&list,0,sizeof(list));
|
||||
// add yourself
|
||||
|
||||
CLS_Position_t position = CLS_BSP_GetPosition();
|
||||
CLS_Type_t type = CLS_BSP_GetDeviceType();
|
||||
|
||||
@@ -332,20 +423,6 @@ void DataClbk_cls_device_RequestList(void* msg, uint32_t length) {
|
||||
list.devices[list.devices_count].fw_version[1] = VERSION_INFO.patch;
|
||||
list.devices[list.devices_count].fw_version[2] = VERSION_INFO.minor;
|
||||
list.devices[list.devices_count].fw_version[3] = VERSION_INFO.major;
|
||||
list.devices_count++;
|
||||
|
||||
//add display
|
||||
list.devices[list.devices_count].available = true;
|
||||
list.devices[list.devices_count].canid = GENERATE_CLS_ADDRESS(CLS_CODE_STATUS, gCLS_DEVICE_ADDRESS+1, CLS_CH_STA_HEATBEAT);
|
||||
list.devices[list.devices_count].device = gCLS_DEVICE_ADDRESS+1;
|
||||
list.devices[list.devices_count].type = cls_device_Type_DISPLAY; // enum to uint
|
||||
list.devices[list.devices_count].position[0] = position.p0;
|
||||
list.devices[list.devices_count].position[1] = position.p1;
|
||||
list.devices[list.devices_count].position_count = 2;
|
||||
list.devices[list.devices_count].fw_version[0] = 0;
|
||||
list.devices[list.devices_count].fw_version[1] = 0;
|
||||
list.devices[list.devices_count].fw_version[2] = 0;
|
||||
list.devices[list.devices_count].fw_version[3] = 0;
|
||||
|
||||
list.devices_count++;
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
#include "main.h"
|
||||
#include "UsbDataHandler.h"
|
||||
#include "stdint.h"
|
||||
#include "mlzr_comm.h"
|
||||
#include "pb_decode.h"
|
||||
#include "display.pb.h"
|
||||
|
||||
static cls_display_SetLayout msg_cls_display_SetLayout;
|
||||
|
||||
|
||||
void DataClbk_cls_display_SetLayout(void* msg, uint32_t length) {
|
||||
DATA_CLBK_SETUP(cls_display_SetLayout);
|
||||
uint8_t num = (uint8_t)msg_cls_display_SetLayout.layout;
|
||||
TF_SendSimple(tf_fallback,0x0F, &num, sizeof(num));
|
||||
}
|
||||
@@ -156,13 +156,8 @@ void DataClbk_cls_firmware_Done(void *msg, uint32_t length) {
|
||||
|
||||
if(msg_cls_firmware_Done.device_id == gCLS_DEVICE_ADDRESS) {
|
||||
RamLoader_LoadApplication();
|
||||
} else if (msg_cls_firmware_Done.device_id == gCLS_DEVICE_ADDRESS +1) {
|
||||
// send fw to display
|
||||
// todo !
|
||||
} else {
|
||||
|
||||
} {
|
||||
|
||||
// send fw to slave
|
||||
FirmwareUpdateArgs args;
|
||||
args.device = msg_cls_firmware_Done.device_id;
|
||||
memcpy(args.name, msg_cls_firmware_Start.name, sizeof(args.name));
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
|
||||
#include "UsbDataHandler.h"
|
||||
#include "headlight.pb.h"
|
||||
#include "CanDataHandler.h"
|
||||
#include "stdint.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "CLS.h"
|
||||
#include "CLS_BSP.h"
|
||||
#include "CLSAddress.h"
|
||||
#include "ulog.h"
|
||||
#include "Vehicle.h"
|
||||
|
||||
cls_headlight_RequestSettings msg_cls_headlight_RequestSettings;
|
||||
cls_headlight_Settings msg_cls_headlight_Settings;
|
||||
cls_headlight_SaveSettings msg_cls_headlight_SaveSettings;
|
||||
|
||||
|
||||
typedef struct Headlight_Control_Setting {
|
||||
float alpha;
|
||||
uint16_t on_threshold;
|
||||
uint16_t off_threshold;
|
||||
} Headlight_Control_Setting_t;
|
||||
|
||||
|
||||
uint16_t headlight_amblight = 0;
|
||||
|
||||
void CanData_ambilight(CanDataId canid, uint8_t* data, uint8_t len) {
|
||||
if(len == 2) {
|
||||
headlight_amblight = (data[1] << 8) | data[0];
|
||||
}
|
||||
|
||||
ULOG_INFO("Ambilight: %d", headlight_amblight);
|
||||
}
|
||||
|
||||
void AddHeadlightMessages() {
|
||||
CanData_regEventMsg(GENERATE_CLS_ADDRESS(CLS_CODE_STATUS, 0, CLS_CH_STA_AMBIENTLIGHT), CanData_ambilight);
|
||||
}
|
||||
|
||||
// whan a message is received, this function is called
|
||||
void DataClbk_cls_headlight_Settings(void* msg, uint32_t length) {
|
||||
DATA_CLBK_SETUP(cls_headlight_Settings);
|
||||
uint8_t device = msg_cls_headlight_Settings.deviceId;
|
||||
|
||||
uint16_t msg_light_setting = GENERATE_CLS_ADDRESS(CLS_CODE_CONFIG, device, 0);
|
||||
CLS_BSP_TxHeaderType can_header = CREATE_BSP_CAN_HEADER(msg_light_setting, CLS_BSP_DLC_BYTES_8);
|
||||
|
||||
|
||||
Headlight_Control_Setting_t data = {0};
|
||||
data.alpha = msg_cls_headlight_Settings.alpha;
|
||||
data.on_threshold = msg_cls_headlight_Settings.on_threshold;
|
||||
data.off_threshold = msg_cls_headlight_Settings.off_threshold;
|
||||
|
||||
CLS_BSP_CAN_AddMessageToSend(&can_header, (uint8_t*)&data);
|
||||
}
|
||||
|
||||
|
||||
void DataClbk_cls_headlight_SaveSettings(void* msg, uint32_t length) {
|
||||
DATA_CLBK_SETUP(cls_headlight_SaveSettings);
|
||||
|
||||
uint8_t device = msg_cls_headlight_SaveSettings.deviceId;
|
||||
uint16_t msg_light_setting = GENERATE_CLS_ADDRESS(CLS_CODE_CONFIG, device, 4);
|
||||
CLS_BSP_TxHeaderType can_header = CREATE_BSP_CAN_HEADER(msg_light_setting, CLS_BSP_DLC_BYTES_1);
|
||||
CLS_BSP_CAN_AddMessageToSend(&can_header, (uint8_t*)"X");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Headlight_Control_Setting_t response_theme = {0};
|
||||
static cls_headlight_Settings headligh_settings = {0};
|
||||
void CanData_responseHeadlightSetting(CanDataId canid, uint8_t* data, uint8_t len) {
|
||||
if(len == 8) {
|
||||
memcpy(&response_theme, data, 8);
|
||||
|
||||
headligh_settings.alpha = response_theme.alpha;
|
||||
headligh_settings.on_threshold = response_theme.on_threshold;
|
||||
headligh_settings.off_threshold = response_theme.off_threshold;
|
||||
headligh_settings.deviceId = (canid >> 3) & 0x1F;
|
||||
|
||||
|
||||
USBDataResonse(&headligh_settings,cls_headlight_Settings_fields, cls_usb_PackageType_HEADLIGHT_SETTINGS);
|
||||
}
|
||||
|
||||
CanData_removeEvent(canid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DataClbk_cls_headlight_RequestSettings(void* msg, uint32_t length) {
|
||||
DATA_CLBK_SETUP(cls_headlight_RequestSettings);
|
||||
uint8_t device = msg_cls_headlight_RequestSettings.deviceId;
|
||||
uint8_t data = 0;
|
||||
|
||||
uint16_t msg_light_setting = GENERATE_CLS_ADDRESS(CLS_CODE_CONFIG, device, 7);
|
||||
CLS_BSP_TxHeaderType can_header = CREATE_BSP_CAN_HEADER(msg_light_setting, CLS_BSP_DLC_BYTES_1);
|
||||
|
||||
|
||||
CanData_regEventMsg(msg_light_setting,CanData_responseHeadlightSetting);
|
||||
|
||||
|
||||
CLS_BSP_CAN_AddMessageToSend(&can_header, (uint8_t*)&data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DataClbk_cls_headlight_RequestBrightness(void* msg, uint32_t length) {
|
||||
|
||||
cls_headlight_RequestBrightness msg_cls_headlight_RequestBrightness;
|
||||
memcpy(&msg_cls_headlight_RequestBrightness, msg, sizeof(cls_headlight_RequestBrightness));
|
||||
|
||||
cls_headlight_Brightness msg_cls_headlight_Brightness;
|
||||
msg_cls_headlight_Brightness.brightness = headlight_amblight;
|
||||
USBDataResonse(&msg_cls_headlight_Brightness,cls_headlight_Brightness_fields, cls_usb_PackageType_HEADLIGHT_BRIGHTNESS);
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "LightTask.h"
|
||||
#include "ulog.h"
|
||||
#include "stdbool.h"
|
||||
#include "Vehicle.h"
|
||||
|
||||
// Create the task with a specific priority and stack size
|
||||
osThreadAttr_t task_attr = {
|
||||
@@ -25,15 +24,89 @@ void LightStateTask_start(void)
|
||||
|
||||
|
||||
|
||||
// Check if K15 is on for switching the light state
|
||||
static bool isK15On()
|
||||
{
|
||||
return BSP_GPIO_K15isSet();
|
||||
}
|
||||
|
||||
|
||||
// Define the threshold voltage for engine running
|
||||
#define ENGINE_RUNNING_THRESHOLD 13.3 // 13.5V
|
||||
|
||||
// Define thresholds with hysteresis
|
||||
#define ENGINE_RUNNING_THRESHOLD_HIGH (ENGINE_RUNNING_THRESHOLD + 0.125)
|
||||
#define ENGINE_RUNNING_THRESHOLD_LOW (ENGINE_RUNNING_THRESHOLD - 0.125)
|
||||
|
||||
// Global variable to store the current engine state
|
||||
static bool engineRunning = false;
|
||||
|
||||
// Function to initialize the engine state based on the initial voltage
|
||||
static void initializeEngineState()
|
||||
{
|
||||
float initialVoltage = BSP_ADC_ReadBusValue();
|
||||
if (initialVoltage > ENGINE_RUNNING_THRESHOLD)
|
||||
{
|
||||
engineRunning = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
engineRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the engine state is initialized once
|
||||
static bool isEngineInitialized = false;
|
||||
|
||||
static bool isEngineRunning()
|
||||
{
|
||||
if (!isEngineInitialized)
|
||||
{
|
||||
initializeEngineState();
|
||||
isEngineInitialized = true;
|
||||
}
|
||||
|
||||
float voltage = BSP_ADC_ReadBusValue();
|
||||
|
||||
if (engineRunning)
|
||||
{
|
||||
// If engine is currently running, use the lower threshold to turn it off
|
||||
if (voltage < ENGINE_RUNNING_THRESHOLD_LOW)
|
||||
{
|
||||
engineRunning = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If engine is currently off, use the higher threshold to turn it on
|
||||
if (voltage > ENGINE_RUNNING_THRESHOLD_HIGH)
|
||||
{
|
||||
engineRunning = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return engineRunning;
|
||||
}
|
||||
// check if the headlight is on and the engine is running to switch the light state
|
||||
// we can check the headlight using the GPIO functions
|
||||
static bool isHeadlightOn()
|
||||
{
|
||||
return BSP_GPIO_HeadLightIsSet();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Function to determine the next state of the light
|
||||
// return 1 as default state
|
||||
// return 2 if the engine is running
|
||||
// return 3 if the headlight and engine is running
|
||||
static int determineNextState()
|
||||
{
|
||||
if (Vehicle_isHeadlightOn() && Vehicle_isEngineRunning()) {
|
||||
if (isHeadlightOn() && isEngineRunning()) {
|
||||
return 2;
|
||||
} else if (Vehicle_isEngineRunning()) {
|
||||
} else if (isEngineRunning()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "BSP_GPIO.h"
|
||||
|
||||
#include "CanDataTask.h"
|
||||
#include "Vehicle.h"
|
||||
#include "BSP_ADC.h"
|
||||
#define DIMM_DEADZONE_VOLTAGE 0.7
|
||||
|
||||
@@ -78,19 +77,19 @@ void LightTask_func(void *argument) {
|
||||
|
||||
|
||||
// calculate the brightness to send
|
||||
uint8_t brightness = lightSettings.brightness;
|
||||
//uint8_t brightness = lightSettings.brightness;
|
||||
// Read ADC battery voltage and dimmer voltage
|
||||
|
||||
|
||||
|
||||
uint8_t dimm = 255;
|
||||
//float dimmfactor = 1.0;
|
||||
|
||||
// currenlty not working
|
||||
// only dimm if the headlight is on
|
||||
//if (Vehicle_isHeadlightOn()) {
|
||||
//if (BSP_GPIO_HeadLightIsSet()) {
|
||||
|
||||
// new version over CAN
|
||||
//dimm = Vehicle_Brightness();
|
||||
//uint8_t precent = CanDataTask_CarCanBrightness();
|
||||
//dimmfactor = (float)precent / 100.0;
|
||||
|
||||
// old version over ADC
|
||||
// calculate the dimmfactor based on the battery voltage and the dimmer voltage
|
||||
@@ -105,15 +104,14 @@ void LightTask_func(void *argument) {
|
||||
//} else {
|
||||
// dimmfactor = (v_dimm - 4.0) / (v_bus - 4.0);
|
||||
//}
|
||||
// }
|
||||
|
||||
//}
|
||||
//uint8_t adjustedBrightness = (uint8_t)(brightness * dimmfactor);
|
||||
//lightSettings_dimmed.brightness = adjustedBrightness;
|
||||
//lightSettings_dimmed.theme = lightSettings.theme;
|
||||
|
||||
uint8_t adjustedBrightness = (brightness * dimm)/ 255;
|
||||
lightSettings_dimmed.brightness = adjustedBrightness;
|
||||
lightSettings_dimmed.theme = lightSettings.theme;
|
||||
|
||||
|
||||
CLS_BSP_CAN_AddMessageToSend(&can_header,(uint8_t*)&lightSettings_dimmed);
|
||||
lightSettings.brightness = 255;
|
||||
CLS_BSP_CAN_AddMessageToSend(&can_header,(uint8_t*)&lightSettings);
|
||||
|
||||
if( settingChangeTime !=0 && tick > settingChangeTime + settingSaveTimeout) {
|
||||
BSP_EE24_PartWrite(BSP_EE24_PART_GLOBAL_LIGHT, (uint8_t*) &lightSettings, sizeof(lightSettings));
|
||||
|
||||
@@ -3,12 +3,10 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "firmware.pb.h"
|
||||
#include "light.pb.h"
|
||||
#include "headlight.pb.h"
|
||||
#include "usb_device.h"
|
||||
#include <pb_decode.h>
|
||||
#include "cls_device.pb.h"
|
||||
#include "usb.pb.h"
|
||||
#include "display.pb.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
/* Declare the thread function */
|
||||
@@ -64,11 +62,7 @@ union {
|
||||
cls_light_SaveThemeSettings msg_cls_light_SaveThemeSettings;
|
||||
cls_light_RequestThemeSetting msg_cls_light_RequestThemeSetting;
|
||||
cls_usb_JumpToBootloader msg_cls_usb_JumpToBootloader;
|
||||
cls_headlight_Settings msg_cls_headlight_Settings;
|
||||
cls_headlight_SaveSettings msg_cls_headlight_SaveSettings;
|
||||
cls_headlight_RequestSettings msg_cls_headlight_RequestSettings;
|
||||
cls_headlight_RequestBrightness msg_cls_headlight_RequestBrightness;
|
||||
cls_display_SetLayout msg_cls_display_SetLayout;
|
||||
|
||||
} mem_msg_decode;
|
||||
|
||||
|
||||
@@ -127,11 +121,6 @@ message_handler_t message_handlers[] = {
|
||||
MESSAGE_HANDLER(cls_usb_PackageType_LIGHT_SETTING_THEME_SAVE, cls_light_SaveThemeSettings),
|
||||
MESSAGE_HANDLER(cls_usb_PackageType_LIGHT_REQUEST_THEME, cls_light_RequestThemeSetting),
|
||||
MESSAGE_HANDLER(cls_usb_PackageType_JUMP_TO_BOOTLOADER, cls_usb_JumpToBootloader),
|
||||
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_SETTINGS, cls_headlight_Settings),
|
||||
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_SAVE_SETTINGS, cls_headlight_SaveSettings),
|
||||
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_REQUEST_SETTINGS, cls_headlight_RequestSettings),
|
||||
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_REQUEST_BRIGHTNESS, cls_headlight_RequestBrightness),
|
||||
MESSAGE_HANDLER(cls_usb_PackageType_DISPLAY_SET_LAYOUT, cls_display_SetLayout),
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -136,11 +136,6 @@ void DataClbk_cls_light_GlobalTheme(void* msg, uint32_t length);
|
||||
void DataClbk_cls_light_ThemeSettings(void* msg, uint32_t length);
|
||||
void DataClbk_cls_light_SaveThemeSettings(void* msg, uint32_t length);
|
||||
void DataClbk_cls_light_RequestThemeSetting(void* msg, uint32_t length);
|
||||
void DataClbk_cls_headlight_Settings(void* msg, uint32_t length);
|
||||
void DataClbk_cls_headlight_SaveSettings(void* msg, uint32_t length);
|
||||
void DataClbk_cls_headlight_RequestSettings(void* msg, uint32_t length);
|
||||
void DataClbk_cls_headlight_RequestBrightness(void* msg, uint32_t length);
|
||||
void DataClbk_cls_display_SetLayout(void* msg, uint32_t length);
|
||||
|
||||
#include "usb.pb.h"
|
||||
void USBDataResonse(void * msg, const pb_msgdesc_t *fields, cls_usb_PackageType typeid);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# Set the minimum required CMake version
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
# Set the project name
|
||||
project(Vehicle)
|
||||
|
||||
# Add the source files for the library
|
||||
set(SOURCES
|
||||
Vehicle.c
|
||||
Vehicle_can.c
|
||||
)
|
||||
|
||||
# Add the header files for the library
|
||||
set(HEADERS
|
||||
Vehicle.h
|
||||
)
|
||||
|
||||
# Create the library target
|
||||
add_library(Vehicle ${SOURCES} ${HEADERS})
|
||||
|
||||
# Set the include directories for the library
|
||||
target_include_directories(Vehicle PUBLIC ./)
|
||||
|
||||
# Set any additional compiler flags or options
|
||||
# target_compile_options(Vehicle PRIVATE ...)
|
||||
|
||||
# Set any additional linker flags or options
|
||||
# target_link_options(Vehicle PRIVATE ...)
|
||||
|
||||
# Specify any dependencies for the library
|
||||
target_link_libraries(Vehicle BSP CLS CLS_BSP)
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
|
||||
#include "Vehicle.h"
|
||||
#include "BSP_GPIO.h"
|
||||
#include "stdbool.h"
|
||||
#include "BSP_ADC.h"
|
||||
|
||||
// Define the threshold voltage for engine running
|
||||
#define ENGINE_RUNNING_THRESHOLD 13.0 // 13.5V
|
||||
|
||||
// Define thresholds with hysteresis
|
||||
#define ENGINE_RUNNING_THRESHOLD_HIGH (ENGINE_RUNNING_THRESHOLD + 0.225)
|
||||
#define ENGINE_RUNNING_THRESHOLD_LOW (ENGINE_RUNNING_THRESHOLD - 0.225)
|
||||
|
||||
// Global variable to store the current engine state
|
||||
static bool engineRunning = false;
|
||||
|
||||
|
||||
void Vehicle_Init() {
|
||||
engineRunning = false;
|
||||
}
|
||||
|
||||
bool Vehicle_isHeadlightOn()
|
||||
{
|
||||
return BSP_GPIO_HeadLightIsSet();
|
||||
}
|
||||
|
||||
bool Vehicle_isEngineRunning() {
|
||||
|
||||
|
||||
float voltage = BSP_ADC_ReadBusValue();
|
||||
|
||||
if (engineRunning)
|
||||
{
|
||||
// If engine is currently running, use the lower threshold to turn it off
|
||||
if (voltage < ENGINE_RUNNING_THRESHOLD_LOW)
|
||||
{
|
||||
engineRunning = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If engine is currently off, use the higher threshold to turn it on
|
||||
if (voltage > ENGINE_RUNNING_THRESHOLD_HIGH)
|
||||
{
|
||||
engineRunning = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return engineRunning;
|
||||
}
|
||||
|
||||
bool Vehicle_isK15On() {
|
||||
return BSP_GPIO_K15isSet();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "CLS.h"
|
||||
#include "CLS_BSP.h"
|
||||
#include "CLSAddress.h"
|
||||
|
||||
static CLS_VehicleStatus_t status = {0};
|
||||
_Static_assert(sizeof(status) == 8, "CLS_HeatbeatData_t is not 8 bytes");
|
||||
|
||||
void CLS_VehicleHeatbeat(void *argument) {
|
||||
CLS_BSP_TxHeaderType cls_vehicle_header = CREATE_BSP_CAN_HEADER(GENERATE_CLS_ADDRESS(CLS_CODE_STATUS,0,CLS_CH_STA_VEHICLE), CLS_BSP_DLC_BYTES_8);
|
||||
|
||||
|
||||
status.k15 = Vehicle_isK15On();
|
||||
status.headlight = Vehicle_isHeadlightOn();
|
||||
status.engine = Vehicle_isEngineRunning();
|
||||
status.speed = (uint8_t)Vehicle_Speed();
|
||||
status.unlocked = Vehicle_UnlockedSignal();
|
||||
|
||||
CLS_BSP_CAN_AddMessageToSend(&cls_vehicle_header, (uint8_t*)&status);
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
#include "fdcan.h"
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
void Vehicle_Init();
|
||||
|
||||
bool Vehicle_isHeadlightOn();
|
||||
|
||||
bool Vehicle_isEngineRunning();
|
||||
|
||||
bool Vehicle_isK15On();
|
||||
|
||||
|
||||
void Vehicle_Setup_CAN();
|
||||
|
||||
void Vehicle_Receive_CAN( FDCAN_RxHeaderTypeDef header, uint8_t* data);
|
||||
|
||||
|
||||
bool Vehicle_gotUnlockMessage();
|
||||
uint8_t Vehicle_Brightness();
|
||||
float Vehicle_Speed();
|
||||
int Vehicle_DirectionIsForward();
|
||||
bool Vehicle_UnlockedSignal();
|
||||
@@ -1,149 +0,0 @@
|
||||
#include "Vehicle.h"
|
||||
#include "fdcan.h"
|
||||
#include "CLS.h"
|
||||
#include "CLS_BSP.h"
|
||||
#include "BSP_GPIO.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
static uint64_t last_unlock_message_time = UINT64_MAX;
|
||||
static uint8_t car_can_brightness = 255;
|
||||
static float car_can_speed = 0;
|
||||
static int car_can_direction = 0;
|
||||
|
||||
|
||||
void Vehicle_Setup_CAN() {
|
||||
|
||||
|
||||
FDCAN_FilterTypeDef sFilterConfig;
|
||||
sFilterConfig.IdType = FDCAN_STANDARD_ID;
|
||||
sFilterConfig.FilterIndex = 0;
|
||||
sFilterConfig.FilterType = CLS_BSP_CAN_FILTER_LIST;
|
||||
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO1;
|
||||
sFilterConfig.FilterID1 = 0x391;
|
||||
sFilterConfig.FilterID2 = 0x395;
|
||||
HAL_FDCAN_ConfigFilter(&hfdcan2, &sFilterConfig);
|
||||
|
||||
sFilterConfig.FilterIndex = 1;
|
||||
sFilterConfig.FilterID1 = 0x351;
|
||||
sFilterConfig.FilterID2 = 0x635;
|
||||
HAL_FDCAN_ConfigFilter(&hfdcan2, &sFilterConfig);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void rx_unlock_key(uint8_t * RxData ) {
|
||||
if (RxData[1] == 0x04)
|
||||
{
|
||||
// car was unlocked
|
||||
last_unlock_message_time = osKernelGetTickCount();
|
||||
}
|
||||
else if (RxData[1] ==0x80)
|
||||
{
|
||||
// car was locked
|
||||
if (!BSP_GPIO_K15isSet()) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void rx_unlock_secure(uint8_t * RxData ) {
|
||||
if ((RxData[0] & 0x0F) == 0x01) {
|
||||
// car was unlocked
|
||||
last_unlock_message_time = osKernelGetTickCount();
|
||||
|
||||
} else if ((RxData[0] & 0x0F) == 0x02) {
|
||||
// car was locked
|
||||
if (!BSP_GPIO_K15isSet()) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void rx_speed(uint8_t * RxData) {
|
||||
// speed signal
|
||||
// AA BB XX YY 00 00 00 00
|
||||
// Speed (XX*(2^8)+(YY-1))/190
|
||||
// direction AA = 0x00 forward, 0x02 backward
|
||||
uint16_t speed = (RxData[2] << 8) + RxData[3];
|
||||
float speed_kmh = (speed - 1) / 190.0;
|
||||
car_can_speed = speed_kmh;
|
||||
car_can_direction = RxData[0];
|
||||
//ULOG_DEBUG("Speed: %f, Direction: %d", car_can_speed, car_can_direction);
|
||||
|
||||
}
|
||||
|
||||
static void rx_brightness(uint8_t* RxData) {
|
||||
// scale the brightness to 0 - 255 only using integer math
|
||||
car_can_brightness = ((uint32_t)RxData[0] * 255) / 100;
|
||||
//ULOG_DEBUG("Brightness: %d", car_can_brightness);
|
||||
}
|
||||
|
||||
void Vehicle_Receive_CAN( FDCAN_RxHeaderTypeDef RxHeader, uint8_t* RxData) {
|
||||
|
||||
if(RxHeader.Identifier == 0x391) {
|
||||
rx_unlock_key(RxData);
|
||||
}
|
||||
|
||||
if (RxHeader.Identifier == 0x395) {
|
||||
rx_unlock_secure(RxData);
|
||||
}
|
||||
|
||||
|
||||
if (RxHeader.Identifier == 0x351) {
|
||||
rx_speed(RxData);
|
||||
}
|
||||
|
||||
// brightness knob in 0 - 100
|
||||
if (RxHeader.Identifier == 0x635) {
|
||||
rx_brightness(RxData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Vehicle_gotUnlockMessage() {
|
||||
return last_unlock_message_time != UINT64_MAX;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t Vehicle_Brightness() {
|
||||
return car_can_brightness;
|
||||
}
|
||||
|
||||
float Vehicle_Speed() {
|
||||
return car_can_speed;
|
||||
}
|
||||
|
||||
int Vehicle_DirectionIsForward() {
|
||||
return car_can_direction == 0;
|
||||
}
|
||||
|
||||
|
||||
static bool unlocked = false;
|
||||
|
||||
|
||||
bool Vehicle_UnlockedSignal() {
|
||||
|
||||
if (unlocked) {
|
||||
if(Vehicle_isK15On()) {
|
||||
unlocked = false;
|
||||
last_unlock_message_time = UINT64_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
if (!unlocked) {
|
||||
if (Vehicle_gotUnlockMessage()) {
|
||||
unlocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
return unlocked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,43 +26,6 @@ ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_32CYCLES_5
|
||||
ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_32CYCLES_5
|
||||
ADC1.SamplingTime-4\#ChannelRegularConversion=ADC_SAMPLETIME_32CYCLES_5
|
||||
ADC1.master=1
|
||||
Bdma.LPUART1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Bdma.LPUART1_RX.0.EventEnable=DISABLE
|
||||
Bdma.LPUART1_RX.0.Instance=BDMA_Channel0
|
||||
Bdma.LPUART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Bdma.LPUART1_RX.0.MemInc=DMA_MINC_ENABLE
|
||||
Bdma.LPUART1_RX.0.Mode=DMA_NORMAL
|
||||
Bdma.LPUART1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Bdma.LPUART1_RX.0.PeriphInc=DMA_PINC_DISABLE
|
||||
Bdma.LPUART1_RX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING
|
||||
Bdma.LPUART1_RX.0.Priority=DMA_PRIORITY_LOW
|
||||
Bdma.LPUART1_RX.0.RequestNumber=1
|
||||
Bdma.LPUART1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
|
||||
Bdma.LPUART1_RX.0.SignalID=NONE
|
||||
Bdma.LPUART1_RX.0.SyncEnable=DISABLE
|
||||
Bdma.LPUART1_RX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
|
||||
Bdma.LPUART1_RX.0.SyncRequestNumber=1
|
||||
Bdma.LPUART1_RX.0.SyncSignalID=NONE
|
||||
Bdma.LPUART1_TX.1.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Bdma.LPUART1_TX.1.EventEnable=DISABLE
|
||||
Bdma.LPUART1_TX.1.Instance=BDMA_Channel1
|
||||
Bdma.LPUART1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Bdma.LPUART1_TX.1.MemInc=DMA_MINC_ENABLE
|
||||
Bdma.LPUART1_TX.1.Mode=DMA_NORMAL
|
||||
Bdma.LPUART1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Bdma.LPUART1_TX.1.PeriphInc=DMA_PINC_DISABLE
|
||||
Bdma.LPUART1_TX.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING
|
||||
Bdma.LPUART1_TX.1.Priority=DMA_PRIORITY_LOW
|
||||
Bdma.LPUART1_TX.1.RequestNumber=1
|
||||
Bdma.LPUART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
|
||||
Bdma.LPUART1_TX.1.SignalID=NONE
|
||||
Bdma.LPUART1_TX.1.SyncEnable=DISABLE
|
||||
Bdma.LPUART1_TX.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
|
||||
Bdma.LPUART1_TX.1.SyncRequestNumber=1
|
||||
Bdma.LPUART1_TX.1.SyncSignalID=NONE
|
||||
Bdma.Request0=LPUART1_RX
|
||||
Bdma.Request1=LPUART1_TX
|
||||
Bdma.RequestsNb=2
|
||||
CAD.formats=
|
||||
CAD.pinconfig=
|
||||
CAD.provider=
|
||||
@@ -235,38 +198,36 @@ I2C2.Timing=0x00D0D8FF
|
||||
KeepUserPlacement=false
|
||||
LPTIM4.ClockPrescaler=LPTIM_PRESCALER_DIV64
|
||||
LPTIM4.IPParameters=ClockPrescaler
|
||||
LPUART1.BaudRate=1000000
|
||||
LPUART1.FIFOMode=UART_FIFOMODE_DISABLE
|
||||
LPUART1.IPParameters=BaudRate,FIFOMode
|
||||
LPUART1.BaudRate=2000000
|
||||
LPUART1.IPParameters=BaudRate
|
||||
Mcu.CPN=STM32H723VGT6
|
||||
Mcu.Family=STM32H7
|
||||
Mcu.IP0=ADC1
|
||||
Mcu.IP1=BDMA
|
||||
Mcu.IP10=I2C1
|
||||
Mcu.IP11=I2C2
|
||||
Mcu.IP12=LPTIM4
|
||||
Mcu.IP13=LPUART1
|
||||
Mcu.IP14=NVIC
|
||||
Mcu.IP15=PWR
|
||||
Mcu.IP16=RCC
|
||||
Mcu.IP17=RNG
|
||||
Mcu.IP18=RTC
|
||||
Mcu.IP19=SDMMC1
|
||||
Mcu.IP2=CORTEX_M7
|
||||
Mcu.IP20=SYS
|
||||
Mcu.IP21=TIM2
|
||||
Mcu.IP22=USART1
|
||||
Mcu.IP23=USART3
|
||||
Mcu.IP24=USB_DEVICE
|
||||
Mcu.IP25=USB_OTG_HS
|
||||
Mcu.IP3=CRC
|
||||
Mcu.IP4=DEBUG
|
||||
Mcu.IP5=DMA
|
||||
Mcu.IP6=FATFS
|
||||
Mcu.IP7=FDCAN1
|
||||
Mcu.IP8=FDCAN2
|
||||
Mcu.IP9=FREERTOS
|
||||
Mcu.IPNb=26
|
||||
Mcu.IP1=CORTEX_M7
|
||||
Mcu.IP10=I2C2
|
||||
Mcu.IP11=LPTIM4
|
||||
Mcu.IP12=LPUART1
|
||||
Mcu.IP13=NVIC
|
||||
Mcu.IP14=PWR
|
||||
Mcu.IP15=RCC
|
||||
Mcu.IP16=RNG
|
||||
Mcu.IP17=RTC
|
||||
Mcu.IP18=SDMMC1
|
||||
Mcu.IP19=SYS
|
||||
Mcu.IP2=CRC
|
||||
Mcu.IP20=TIM2
|
||||
Mcu.IP21=USART1
|
||||
Mcu.IP22=USART3
|
||||
Mcu.IP23=USB_DEVICE
|
||||
Mcu.IP24=USB_OTG_HS
|
||||
Mcu.IP3=DEBUG
|
||||
Mcu.IP4=DMA
|
||||
Mcu.IP5=FATFS
|
||||
Mcu.IP6=FDCAN1
|
||||
Mcu.IP7=FDCAN2
|
||||
Mcu.IP8=FREERTOS
|
||||
Mcu.IP9=I2C1
|
||||
Mcu.IPNb=25
|
||||
Mcu.Name=STM32H723VGTx
|
||||
Mcu.Package=LQFP100
|
||||
Mcu.Pin0=PE2
|
||||
@@ -341,8 +302,6 @@ Mcu.UserName=STM32H723VGTx
|
||||
MxCube.Version=6.9.2
|
||||
MxDb.Version=DB.6.0.92
|
||||
NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.BDMA_Channel0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.BDMA_Channel1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
@@ -358,7 +317,6 @@ NVIC.FDCAN2_IT1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
NVIC.LPTIM4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.LPUART1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
NVIC.OTG_HS_EP1_IN_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
@@ -582,7 +540,7 @@ ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UAScriptAfterPath=
|
||||
ProjectManager.UAScriptBeforePath=
|
||||
ProjectManager.UnderRoot=true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_BDMA_Init-BDMA-false-HAL-true,5-MX_I2C2_Init-I2C2-false-HAL-true,6-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,7-MX_USART1_UART_Init-USART1-false-LL-true,8-MX_USART3_UART_Init-USART3-false-LL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,11-MX_FATFS_Init-FATFS-false-HAL-false,12-MX_ADC1_Init-ADC1-false-HAL-true,13-MX_FDCAN1_Init-FDCAN1-false-HAL-true,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_FDCAN2_Init-FDCAN2-false-HAL-true,16-MX_I2C1_Init-I2C1-false-HAL-true,17-MX_CRC_Init-CRC-false-HAL-true,18-MX_RNG_Init-RNG-false-HAL-true,19-MX_LPTIM4_Init-LPTIM4-false-HAL-true,20-MX_TIM2_Init-TIM2-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true,0-MX_PWR_Init-PWR-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_I2C2_Init-I2C2-false-HAL-true,5-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,6-MX_USART1_UART_Init-USART1-false-LL-true,7-MX_USART3_UART_Init-USART3-false-LL-true,8-MX_RTC_Init-RTC-false-HAL-true,9-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,10-MX_FATFS_Init-FATFS-false-HAL-false,11-MX_ADC1_Init-ADC1-false-HAL-true,12-MX_FDCAN1_Init-FDCAN1-false-HAL-true,13-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,14-MX_FDCAN2_Init-FDCAN2-false-HAL-true,15-MX_I2C1_Init-I2C1-false-HAL-true,16-MX_CRC_Init-CRC-false-HAL-true,17-MX_RNG_Init-RNG-false-HAL-true,18-MX_TIM2_Init-TIM2-false-HAL-true,19-MX_LPTIM4_Init-LPTIM4-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true,0-MX_VREFBUF_Init-VREFBUF-false-HAL-true,0-MX_PWR_Init-PWR-false-HAL-true
|
||||
RCC.ADCFreq_Value=96000000
|
||||
RCC.AHB12Freq_Value=275000000
|
||||
RCC.AHB4Freq_Value=275000000
|
||||
|
||||
@@ -124,8 +124,6 @@ nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS RELPATH proto
|
||||
proto/cls_device.proto
|
||||
proto/light.proto
|
||||
proto/usb.proto
|
||||
proto/headlight.proto
|
||||
proto/display.proto
|
||||
)
|
||||
add_library(PROTOS ${PROTO_SRCS} ${PROTO_HDRS})
|
||||
target_include_directories(PROTOS PUBLIC ${NANOPB_INCLUDE_DIRS} ${PROJECT_BINARY_DIR})
|
||||
@@ -142,9 +140,9 @@ add_subdirectory("Application")
|
||||
add_executable(${CMAKE_PROJECT_NAME})
|
||||
target_sources(${CMAKE_PROJECT_NAME} PUBLIC ${sources_SRCS})
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC Tasks CLS CLS_BSP BSP EE24 INA219 ulog ram_loader Vehicle)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC Tasks CLS CLS_BSP BSP EE24 INA219 ulog ram_loader)
|
||||
#target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC PROTOS)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC mlzr_comm TinyFrame uart_driver mlzr_glasm)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC uart_driver)
|
||||
#target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC lwrb)
|
||||
|
||||
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file bdma.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the bdma.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __BDMA_H__
|
||||
#define __BDMA_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* DMA memory to memory transfer handles -------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_BDMA_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BDMA_H__ */
|
||||
|
||||
@@ -72,10 +72,7 @@ void SDMMC1_IRQHandler(void);
|
||||
void OTG_HS_EP1_OUT_IRQHandler(void);
|
||||
void OTG_HS_EP1_IN_IRQHandler(void);
|
||||
void OTG_HS_IRQHandler(void);
|
||||
void BDMA_Channel0_IRQHandler(void);
|
||||
void BDMA_Channel1_IRQHandler(void);
|
||||
void LPTIM4_IRQHandler(void);
|
||||
void LPUART1_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file bdma.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of all the requested memory to memory DMA transfers.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "bdma.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Configure DMA */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/**
|
||||
* Enable DMA controller clock
|
||||
*/
|
||||
void MX_BDMA_Init(void)
|
||||
{
|
||||
|
||||
/* DMA controller clock enable */
|
||||
__HAL_RCC_BDMA_CLK_ENABLE();
|
||||
|
||||
/* DMA interrupt init */
|
||||
/* BDMA_Channel0_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(BDMA_Channel0_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(BDMA_Channel0_IRQn);
|
||||
/* BDMA_Channel1_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(BDMA_Channel1_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(BDMA_Channel1_IRQn);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
#include "BSP_GPIO.h"
|
||||
#include "BSP_ADC.h"
|
||||
#include "BSP_SDLogger.h"
|
||||
#include "Vehicle.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -152,8 +150,6 @@ void MX_FREERTOS_Init(void) {
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Header_StartDefaultTask */
|
||||
void AddHeadlightMessages();
|
||||
|
||||
/**
|
||||
* @brief Function implementing the defaultTask thread.
|
||||
* @param argument: Not used
|
||||
@@ -162,8 +158,6 @@ void AddHeadlightMessages();
|
||||
|
||||
#include "CLS_BSP.h"
|
||||
#include "CLSAddress.h"
|
||||
#include "mlzr_comm.h"
|
||||
#include "glasm.h"
|
||||
/* USER CODE END Header_StartDefaultTask */
|
||||
void StartDefaultTask(void *argument)
|
||||
{
|
||||
@@ -173,10 +167,6 @@ void StartDefaultTask(void *argument)
|
||||
BSP_EE24_Init();
|
||||
BSP_INA_Init();
|
||||
|
||||
MLZR_INIT();
|
||||
|
||||
GLASM_Init();
|
||||
|
||||
retSD = f_mount(&SDFatFS,SDPath,0);
|
||||
retSD = f_open(&SDFile, "counter.bin", FA_READ);
|
||||
|
||||
@@ -198,7 +188,6 @@ void StartDefaultTask(void *argument)
|
||||
}
|
||||
|
||||
BSP_SDLogger_Init(counter);
|
||||
AddHeadlightMessages();
|
||||
|
||||
char INA_LOG[72];
|
||||
|
||||
@@ -247,7 +236,7 @@ void WaitForStartConfirm_Task(void *argument) {
|
||||
while(1) {
|
||||
osDelayUntil(tick);
|
||||
tick += delayTime;
|
||||
if(BSP_GPIO_K15isSet() || Vehicle_gotUnlockMessage()) {
|
||||
if(BSP_GPIO_K15isSet() || CanDataTask_gotCarCanMessage()) {
|
||||
BSP_POWER_FullPowerMode();
|
||||
ULOG_INFO("Power systems started");
|
||||
osThreadExit();
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "main.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "adc.h"
|
||||
#include "bdma.h"
|
||||
#include "crc.h"
|
||||
#include "dma.h"
|
||||
#include "fatfs.h"
|
||||
@@ -43,14 +42,11 @@
|
||||
#include "BSP_GPIO.h"
|
||||
#include "BSP_ADC.h"
|
||||
#include "ram_loader.h"
|
||||
#include "AsyncComm.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
extern uart_desc_t uart_half;
|
||||
__attribute__((__section__(".dma_buffer"))) uint8_t lp_buffer[2][2048] = {0};
|
||||
uint8_t swap_index = 0;
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
@@ -65,6 +61,7 @@ uint8_t swap_index = 0;
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
// define the magic number for the bootloader 8 bytes
|
||||
/* USER CODE BEGIN PV */
|
||||
uint8_t gCLS_DEVICE_ADDRESS = 0x11;
|
||||
/* USER CODE END PV */
|
||||
@@ -124,7 +121,6 @@ int main(void)
|
||||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_DMA_Init();
|
||||
MX_BDMA_Init();
|
||||
MX_I2C2_Init();
|
||||
MX_LPUART1_UART_Init();
|
||||
MX_USART1_UART_Init();
|
||||
@@ -137,8 +133,8 @@ int main(void)
|
||||
MX_I2C1_Init();
|
||||
MX_CRC_Init();
|
||||
MX_RNG_Init();
|
||||
MX_LPTIM4_Init();
|
||||
MX_TIM2_Init();
|
||||
MX_LPTIM4_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
BSP_GPIO_PeriperalsOn();
|
||||
@@ -150,14 +146,6 @@ int main(void)
|
||||
ULOG_DEBUG("Setting Global CLS address to 0b10001");
|
||||
ULOG_DEBUG("Init Kernel and start schedule");
|
||||
|
||||
//HAL_UART_Receive(&hlpuart1, lp_buffer[swap_index], 10, 10000);
|
||||
|
||||
HAL_StatusTypeDef status = HAL_UARTEx_ReceiveToIdle_DMA(&hlpuart1, lp_buffer[swap_index], 2048);
|
||||
if(status != HAL_OK){
|
||||
ULOG_ERROR("Failed to start DMA");
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Init scheduler */
|
||||
@@ -180,37 +168,6 @@ int main(void)
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
|
||||
if(huart->Instance ==LPUART1){
|
||||
uint8_t new_index = (swap_index + 1) % 2;
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&hlpuart1, lp_buffer[new_index], 2048);
|
||||
usart_send_data(&uart_half, lp_buffer[swap_index], 2048);
|
||||
swap_index = new_index;
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size){
|
||||
//restarts the DMA listening of the UART rx (next 247 bytes)
|
||||
if(huart->Instance ==LPUART1){
|
||||
|
||||
uint8_t new_index = (swap_index + 1) % 2;
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&hlpuart1, lp_buffer[new_index], 2048);
|
||||
usart_send_data(&uart_half, lp_buffer[swap_index], Size);
|
||||
swap_index = new_index;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
if(huart->Instance ==LPUART1){
|
||||
swap_index = (swap_index + 1) % 2;
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&hlpuart1, lp_buffer[swap_index], 2048);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief System Clock Configuration
|
||||
* @retval None
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "stm32h7xx_it.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "AsyncComm.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -42,8 +41,7 @@
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
extern uart_desc_t uart_duplex;
|
||||
extern uart_desc_t uart_half;
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@@ -63,9 +61,6 @@ extern ADC_HandleTypeDef hadc1;
|
||||
extern FDCAN_HandleTypeDef hfdcan1;
|
||||
extern FDCAN_HandleTypeDef hfdcan2;
|
||||
extern LPTIM_HandleTypeDef hlptim4;
|
||||
extern DMA_HandleTypeDef hdma_lpuart1_rx;
|
||||
extern DMA_HandleTypeDef hdma_lpuart1_tx;
|
||||
extern UART_HandleTypeDef hlpuart1;
|
||||
extern RTC_HandleTypeDef hrtc;
|
||||
extern SD_HandleTypeDef hsd1;
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
@@ -238,7 +233,7 @@ void DMA1_Stream0_IRQHandler(void)
|
||||
/* USER CODE END DMA1_Stream0_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream0_IRQn 1 */
|
||||
usart_dma_irq_handler(&uart_duplex);
|
||||
|
||||
/* USER CODE END DMA1_Stream0_IRQn 1 */
|
||||
}
|
||||
|
||||
@@ -252,7 +247,7 @@ void DMA1_Stream1_IRQHandler(void)
|
||||
/* USER CODE END DMA1_Stream1_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream1_IRQn 1 */
|
||||
usart_dma_irq_handler_tx(&uart_duplex);
|
||||
|
||||
/* USER CODE END DMA1_Stream1_IRQn 1 */
|
||||
}
|
||||
|
||||
@@ -266,7 +261,7 @@ void DMA1_Stream2_IRQHandler(void)
|
||||
/* USER CODE END DMA1_Stream2_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream2_IRQn 1 */
|
||||
usart_dma_irq_handler(&uart_half);
|
||||
|
||||
/* USER CODE END DMA1_Stream2_IRQn 1 */
|
||||
}
|
||||
|
||||
@@ -280,7 +275,7 @@ void DMA1_Stream3_IRQHandler(void)
|
||||
/* USER CODE END DMA1_Stream3_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream3_IRQn 1 */
|
||||
usart_dma_irq_handler_tx(&uart_half);
|
||||
|
||||
/* USER CODE END DMA1_Stream3_IRQn 1 */
|
||||
}
|
||||
|
||||
@@ -405,7 +400,7 @@ void USART1_IRQHandler(void)
|
||||
|
||||
/* USER CODE END USART1_IRQn 0 */
|
||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
||||
usart_irq_handler(&uart_duplex);
|
||||
|
||||
/* USER CODE END USART1_IRQn 1 */
|
||||
}
|
||||
|
||||
@@ -418,7 +413,7 @@ void USART3_IRQHandler(void)
|
||||
|
||||
/* USER CODE END USART3_IRQn 0 */
|
||||
/* USER CODE BEGIN USART3_IRQn 1 */
|
||||
usart_irq_handler(&uart_half);
|
||||
|
||||
/* USER CODE END USART3_IRQn 1 */
|
||||
}
|
||||
|
||||
@@ -478,34 +473,6 @@ void OTG_HS_IRQHandler(void)
|
||||
/* USER CODE END OTG_HS_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles BDMA channel0 global interrupt.
|
||||
*/
|
||||
void BDMA_Channel0_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN BDMA_Channel0_IRQn 0 */
|
||||
|
||||
/* USER CODE END BDMA_Channel0_IRQn 0 */
|
||||
HAL_DMA_IRQHandler(&hdma_lpuart1_rx);
|
||||
/* USER CODE BEGIN BDMA_Channel0_IRQn 1 */
|
||||
|
||||
/* USER CODE END BDMA_Channel0_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles BDMA channel1 global interrupt.
|
||||
*/
|
||||
void BDMA_Channel1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN BDMA_Channel1_IRQn 0 */
|
||||
|
||||
/* USER CODE END BDMA_Channel1_IRQn 0 */
|
||||
HAL_DMA_IRQHandler(&hdma_lpuart1_tx);
|
||||
/* USER CODE BEGIN BDMA_Channel1_IRQn 1 */
|
||||
|
||||
/* USER CODE END BDMA_Channel1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles LPTIM4 global interrupt.
|
||||
*/
|
||||
@@ -520,22 +487,6 @@ void LPTIM4_IRQHandler(void)
|
||||
/* USER CODE END LPTIM4_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles LPUART1 global interrupt.
|
||||
*/
|
||||
void LPUART1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN LPUART1_IRQn 0 */
|
||||
|
||||
/* USER CODE END LPUART1_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&hlpuart1);
|
||||
/* USER CODE BEGIN LPUART1_IRQn 1 */
|
||||
|
||||
|
||||
|
||||
/* USER CODE END LPUART1_IRQn 1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
/* USER CODE END 0 */
|
||||
|
||||
UART_HandleTypeDef hlpuart1;
|
||||
DMA_HandleTypeDef hdma_lpuart1_rx;
|
||||
DMA_HandleTypeDef hdma_lpuart1_tx;
|
||||
|
||||
/* LPUART1 init function */
|
||||
|
||||
@@ -41,7 +39,7 @@ void MX_LPUART1_UART_Init(void)
|
||||
|
||||
/* USER CODE END LPUART1_Init 1 */
|
||||
hlpuart1.Instance = LPUART1;
|
||||
hlpuart1.Init.BaudRate = 3000000;
|
||||
hlpuart1.Init.BaudRate = 2000000;
|
||||
hlpuart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
hlpuart1.Init.StopBits = UART_STOPBITS_1;
|
||||
hlpuart1.Init.Parity = UART_PARITY_NONE;
|
||||
@@ -159,7 +157,7 @@ void MX_USART1_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART1_Init 1 */
|
||||
USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1;
|
||||
USART_InitStruct.BaudRate = 2000000;
|
||||
USART_InitStruct.BaudRate = 1000000;
|
||||
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
||||
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
||||
USART_InitStruct.Parity = LL_USART_PARITY_NONE;
|
||||
@@ -275,7 +273,7 @@ void MX_USART3_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART3_Init 1 */
|
||||
USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1;
|
||||
USART_InitStruct.BaudRate = 2000000;
|
||||
USART_InitStruct.BaudRate = 1000000;
|
||||
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
||||
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
||||
USART_InitStruct.Parity = LL_USART_PARITY_NONE;
|
||||
@@ -342,44 +340,6 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||
GPIO_InitStruct.Alternate = GPIO_AF8_LPUART;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* LPUART1 DMA Init */
|
||||
/* LPUART1_RX Init */
|
||||
hdma_lpuart1_rx.Instance = BDMA_Channel0;
|
||||
hdma_lpuart1_rx.Init.Request = BDMA_REQUEST_LPUART1_RX;
|
||||
hdma_lpuart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_lpuart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_lpuart1_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_lpuart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_lpuart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_lpuart1_rx.Init.Mode = DMA_NORMAL;
|
||||
hdma_lpuart1_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
if (HAL_DMA_Init(&hdma_lpuart1_rx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA(uartHandle,hdmarx,hdma_lpuart1_rx);
|
||||
|
||||
/* LPUART1_TX Init */
|
||||
hdma_lpuart1_tx.Instance = BDMA_Channel1;
|
||||
hdma_lpuart1_tx.Init.Request = BDMA_REQUEST_LPUART1_TX;
|
||||
hdma_lpuart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||
hdma_lpuart1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_lpuart1_tx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_lpuart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_lpuart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_lpuart1_tx.Init.Mode = DMA_NORMAL;
|
||||
hdma_lpuart1_tx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
if (HAL_DMA_Init(&hdma_lpuart1_tx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA(uartHandle,hdmatx,hdma_lpuart1_tx);
|
||||
|
||||
/* LPUART1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(LPUART1_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(LPUART1_IRQn);
|
||||
/* USER CODE BEGIN LPUART1_MspInit 1 */
|
||||
|
||||
/* USER CODE END LPUART1_MspInit 1 */
|
||||
@@ -405,12 +365,6 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
|
||||
|
||||
/* LPUART1 DMA DeInit */
|
||||
HAL_DMA_DeInit(uartHandle->hdmarx);
|
||||
HAL_DMA_DeInit(uartHandle->hdmatx);
|
||||
|
||||
/* LPUART1 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(LPUART1_IRQn);
|
||||
/* USER CODE BEGIN LPUART1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END LPUART1_MspDeInit 1 */
|
||||
|
||||
@@ -171,17 +171,6 @@ SECTIONS
|
||||
. = ALIGN(8);
|
||||
} >RAM_D1
|
||||
|
||||
|
||||
.dma_buffer (NOLOAD):
|
||||
{
|
||||
/*_framebuffer =.; */
|
||||
/*__framebuffer_start__ = _framebuffer; */
|
||||
*(.dma_buffer)
|
||||
*(.dma_buffer*)
|
||||
|
||||
} >RAM_D3
|
||||
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@ set(sources_SRCS ${sources_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/adc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/crc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/dma.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/bdma.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/fdcan.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/gpio.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/i2c.c
|
||||
|
||||
@@ -4,10 +4,5 @@ add_subdirectory(nanopb)
|
||||
add_subdirectory(ulog)
|
||||
add_subdirectory(ina219)
|
||||
|
||||
|
||||
add_library(EE24 STATIC "ee24/ee24.c")
|
||||
target_include_directories(EE24 PUBLIC "ee24")
|
||||
|
||||
|
||||
add_library(TinyFrame STATIC "TinyFrame/TinyFrame.c")
|
||||
target_include_directories(TinyFrame PUBLIC "./TinyFrame" "./TinyFrameConf")
|
||||
|
||||
Submodule lib/TinyFrame deleted from a29167a69f
@@ -1,81 +0,0 @@
|
||||
//
|
||||
// TinyFrame configuration file.
|
||||
//
|
||||
// Rename to TF_Config.h
|
||||
//
|
||||
|
||||
#ifndef TF_CONFIG_H
|
||||
#define TF_CONFIG_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h> // used by the TF_Error() macro defined below
|
||||
//#include <esp8266.h> // when using with esphttpd
|
||||
|
||||
//----------------------------- FRAME FORMAT ---------------------------------
|
||||
// The format can be adjusted to fit your particular application needs
|
||||
|
||||
// If the connection is reliable, you can disable the SOF byte and checksums.
|
||||
// That can save up to 9 bytes of overhead.
|
||||
|
||||
// ,-----+-----+-----+------+------------+- - - -+-------------,
|
||||
// | SOF | ID | LEN | TYPE | HEAD_CKSUM | DATA | DATA_CKSUM |
|
||||
// | 0-1 | 1-4 | 1-4 | 1-4 | 0-4 | ... | 0-4 | <- size (bytes)
|
||||
// '-----+-----+-----+------+------------+- - - -+-------------'
|
||||
|
||||
// !!! BOTH PEERS MUST USE THE SAME SETTINGS !!!
|
||||
|
||||
// Adjust sizes as desired (1,2,4)
|
||||
#define TF_ID_BYTES 2
|
||||
#define TF_LEN_BYTES 2
|
||||
#define TF_TYPE_BYTES 2
|
||||
|
||||
// Checksum type. Options:
|
||||
// TF_CKSUM_NONE, TF_CKSUM_XOR, TF_CKSUM_CRC8, TF_CKSUM_CRC16, TF_CKSUM_CRC32
|
||||
// TF_CKSUM_CUSTOM8, TF_CKSUM_CUSTOM16, TF_CKSUM_CUSTOM32
|
||||
// Custom checksums require you to implement checksum functions (see TinyFrame.h)
|
||||
#define TF_CKSUM_TYPE TF_CKSUM_CRC16
|
||||
|
||||
// Use a SOF byte to mark the start of a frame
|
||||
#define TF_USE_SOF_BYTE 1
|
||||
// Value of the SOF byte (if TF_USE_SOF_BYTE == 1)
|
||||
#define TF_SOF_BYTE 0x55
|
||||
|
||||
//----------------------- PLATFORM COMPATIBILITY ----------------------------
|
||||
|
||||
// used for timeout tick counters - should be large enough for all used timeouts
|
||||
typedef uint16_t TF_TICKS;
|
||||
|
||||
// used in loops iterating over listeners
|
||||
typedef uint8_t TF_COUNT;
|
||||
|
||||
//----------------------------- PARAMETERS ----------------------------------
|
||||
|
||||
// Maximum received payload size (static buffer)
|
||||
// Larger payloads will be rejected.
|
||||
#define TF_MAX_PAYLOAD_RX 1024
|
||||
// Size of the sending buffer. Larger payloads will be split to pieces and sent
|
||||
// in multiple calls to the write function. This can be lowered to reduce RAM usage.
|
||||
#define TF_SENDBUF_LEN 1024
|
||||
|
||||
// --- Listener counts - determine sizes of the static slot tables ---
|
||||
|
||||
// Frame ID listeners (wait for response / multi-part message)
|
||||
#define TF_MAX_ID_LST 50
|
||||
// Frame Type listeners (wait for frame with a specific first payload byte)
|
||||
#define TF_MAX_TYPE_LST 5
|
||||
// Generic listeners (fallback if no other listener catches it)
|
||||
#define TF_MAX_GEN_LST 5
|
||||
|
||||
// Timeout for receiving & parsing a frame
|
||||
// ticks = number of calls to TF_Tick()
|
||||
#define TF_PARSER_TIMEOUT_TICKS 10
|
||||
|
||||
// Whether to use mutex - requires you to implement TF_ClaimTx() and TF_ReleaseTx()
|
||||
#define TF_USE_MUTEX 1
|
||||
|
||||
// Error reporting function. To disable debug, change to empty define
|
||||
#define TF_Error(format, ...) printf("[TF] " format "\n", ##__VA_ARGS__)
|
||||
|
||||
//------------------------- End of user config ------------------------------
|
||||
|
||||
#endif //TF_CONFIG_H
|
||||
2
proto
2
proto
Submodule proto updated: c46afcd594...2142d03586
@@ -6,8 +6,6 @@ ${PROTO_SRC_DIR}/firmware.proto
|
||||
${PROTO_SRC_DIR}/light.proto
|
||||
${PROTO_SRC_DIR}/usb.proto
|
||||
${PROTO_SRC_DIR}/cls_device.proto
|
||||
${PROTO_SRC_DIR}/headlight.proto
|
||||
${PROTO_SRC_DIR}/display.proto
|
||||
)
|
||||
|
||||
# Specify where you want to generate the python code
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
import serial
|
||||
import struct
|
||||
from google.protobuf.message import DecodeError
|
||||
from serial.tools import list_ports
|
||||
|
||||
from display_pb2 import SetLayout
|
||||
from usb_pb2 import PackageType
|
||||
from vcp_driver import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
ser = setup_connection()
|
||||
# Create a message
|
||||
#request = GlobalBrightness()
|
||||
#request.brightness = 100
|
||||
# Serialize the request to a bytearray
|
||||
#request_data = request.SerializeToString()
|
||||
|
||||
# Send the request
|
||||
#send_package(PackageType.LIGHT_GLOBAL_BRIGHT, request_data, ser)
|
||||
|
||||
|
||||
#request = GlobalTheme()
|
||||
#request.theme = 1
|
||||
#request_data = request.SerializeToString()
|
||||
#send_package(PackageType.LIGHT_GLOBAL_THEME, request_data, ser)
|
||||
|
||||
|
||||
# request = ThemeSettings()
|
||||
# request.deviceId = 1
|
||||
# request.theme = 1
|
||||
# request.rgb = 0x00f000f0
|
||||
# request.brightness = 255
|
||||
# request.animation = 2
|
||||
# request_data = request.SerializeToString()
|
||||
# send_package(PackageType.LIGHT_SETTING_THEME, request_data, ser)
|
||||
|
||||
|
||||
request = SetLayout()
|
||||
request.layout = 2
|
||||
request_data = request.SerializeToString()
|
||||
send_package(PackageType.DISPLAY_SET_LAYOUT, request_data, ser)
|
||||
@@ -4,26 +4,25 @@ from google.protobuf.message import DecodeError
|
||||
from serial.tools import list_ports
|
||||
|
||||
from light_pb2 import GlobalBrightness, Theme, GlobalTheme, ThemeSettings
|
||||
from headlight_pb2 import Settings, RequestSettings
|
||||
from usb_pb2 import PackageType
|
||||
from vcp_driver import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
ser = setup_connection()
|
||||
# Create a message
|
||||
#request = GlobalBrightness()
|
||||
#request.brightness = 100
|
||||
request = GlobalBrightness()
|
||||
request.brightness = 100
|
||||
# Serialize the request to a bytearray
|
||||
#request_data = request.SerializeToString()
|
||||
request_data = request.SerializeToString()
|
||||
|
||||
# Send the request
|
||||
#send_package(PackageType.LIGHT_GLOBAL_BRIGHT, request_data, ser)
|
||||
send_package(PackageType.LIGHT_GLOBAL_BRIGHT, request_data, ser)
|
||||
|
||||
|
||||
#request = GlobalTheme()
|
||||
#request.theme = 1
|
||||
#request_data = request.SerializeToString()
|
||||
#send_package(PackageType.LIGHT_GLOBAL_THEME, request_data, ser)
|
||||
request = GlobalTheme()
|
||||
request.theme = 1
|
||||
request_data = request.SerializeToString()
|
||||
send_package(PackageType.LIGHT_GLOBAL_THEME, request_data, ser)
|
||||
|
||||
|
||||
# request = ThemeSettings()
|
||||
@@ -34,14 +33,3 @@ if __name__ == "__main__":
|
||||
# request.animation = 2
|
||||
# request_data = request.SerializeToString()
|
||||
# send_package(PackageType.LIGHT_SETTING_THEME, request_data, ser)
|
||||
|
||||
|
||||
request = Settings()
|
||||
request.deviceId = 1
|
||||
request.alpha = 0.001
|
||||
request.on_threshold = 600
|
||||
request.off_threshold = 400
|
||||
request.on_time = 100
|
||||
request.input_invert = False
|
||||
request_data = request.SerializeToString()
|
||||
send_package(PackageType.HEADLIGHT_SETTINGS, request_data, ser)
|
||||
|
||||
@@ -6,10 +6,10 @@ if __name__ == "__main__":
|
||||
ser = setup_connection()
|
||||
# Create a message
|
||||
request = UpdateDeviceSettings()
|
||||
request.device = 0
|
||||
request.type = Type.COMMING_HOME
|
||||
request.position.append(Position.LEFT)
|
||||
request.position.append(Position.CENTER)
|
||||
request.device = 5
|
||||
request.type = Type.LIGHT
|
||||
request.position.append(Position.RIGHT)
|
||||
request.position.append(Position.FLOOR)
|
||||
# Serialize the request to a bytearray
|
||||
request_data = request.SerializeToString()
|
||||
|
||||
|
||||
@@ -3,20 +3,21 @@ import struct
|
||||
from google.protobuf.message import DecodeError
|
||||
from serial.tools import list_ports
|
||||
|
||||
from headlight_pb2 import Settings, RequestSettings
|
||||
from light_pb2 import RequestThemeSetting, Theme, ThemeSettings
|
||||
from usb_pb2 import PackageType
|
||||
from vcp_driver import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
ser = setup_connection()
|
||||
|
||||
request = RequestSettings()
|
||||
request.deviceId = 1
|
||||
request = RequestThemeSetting()
|
||||
request.deviceId = 0
|
||||
request.theme = 1
|
||||
print("send request")
|
||||
print(request)
|
||||
|
||||
request_data = request.SerializeToString()
|
||||
send_package(PackageType.HEADLIGHT_REQUEST_SETTINGS, request_data, ser)
|
||||
send_package(PackageType.LIGHT_REQUEST_THEME, request_data, ser)
|
||||
|
||||
|
||||
print("wait for response")
|
||||
@@ -29,13 +30,13 @@ if __name__ == "__main__":
|
||||
print(length, typeid, check)
|
||||
|
||||
# Check if the type is RESPONSE_DEVICE_LIST
|
||||
if typeid == PackageType.HEADLIGHT_SETTINGS:
|
||||
if typeid == PackageType.LIGHT_SETTING_THEME:
|
||||
# Read the response data from the serial port
|
||||
response_data = ser.read(length)
|
||||
|
||||
# Try to parse the data as a ResponseDeviceList message
|
||||
try:
|
||||
response = Settings.FromString(response_data)
|
||||
response = ThemeSettings.FromString(response_data)
|
||||
|
||||
except DecodeError:
|
||||
# If we get a DecodeError, it means the data we read is not a valid
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import serial
|
||||
|
||||
# Open the serial port
|
||||
ser = serial.Serial('/dev/ttyACM1', baudrate=1000000)
|
||||
|
||||
# Send 10 bytes of data
|
||||
data = b'01234567890123456789012345678901234567890123456789'
|
||||
|
||||
for i in range(10):
|
||||
ser.write(data)
|
||||
|
||||
# Close the serial port
|
||||
ser.close()
|
||||
Reference in New Issue
Block a user