Compare commits
3 Commits
7080707f9d
...
58b50b2fb3
| Author | SHA1 | Date | |
|---|---|---|---|
| 58b50b2fb3 | |||
| 4744762b4c | |||
| 4620d0a7ed |
33
CLS.c
33
CLS.c
@@ -6,7 +6,9 @@
|
|||||||
#include "CanDataHandler.h"
|
#include "CanDataHandler.h"
|
||||||
|
|
||||||
osTimerId_t CLS_HeatbeatTimerId = NULL; // Timer ID
|
osTimerId_t CLS_HeatbeatTimerId = NULL; // Timer ID
|
||||||
|
osTimerId_t CLS_VehicleTimerId = NULL; // Timer ID
|
||||||
static CLS_HeatbeatData_t cls_heatbeat_data = {0};
|
static CLS_HeatbeatData_t cls_heatbeat_data = {0};
|
||||||
|
static CLS_VehicleStatus_t cls_vehicle = {0};
|
||||||
static uint8_t EventChangeTypeData[2] ={0};
|
static uint8_t EventChangeTypeData[2] ={0};
|
||||||
static CLS_Type_t newType = 0;
|
static CLS_Type_t newType = 0;
|
||||||
static CLS_Position_t newPostion = {0};
|
static CLS_Position_t newPostion = {0};
|
||||||
@@ -28,6 +30,10 @@ void CLS_Heatbeat(void *argument) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__weak void CLS_VehicleHeatbeat(void *argument) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CLS_SendEventChangeTypePostion(CanDataId canid, CLS_Type_t newType, CLS_Position_t newPostion) {
|
void CLS_SendEventChangeTypePostion(CanDataId canid, CLS_Type_t newType, CLS_Position_t newPostion) {
|
||||||
const uint16_t cls_address = GENERATE_CLS_ADDRESS(CLS_CODE_CONFIG,canid,CLS_CHANNEL7);
|
const uint16_t cls_address = GENERATE_CLS_ADDRESS(CLS_CODE_CONFIG,canid,CLS_CHANNEL7);
|
||||||
EventChangeTypeData[0] = (uint8_t)newType;
|
EventChangeTypeData[0] = (uint8_t)newType;
|
||||||
@@ -36,6 +42,16 @@ void CLS_SendEventChangeTypePostion(CanDataId canid, CLS_Type_t newType, CLS_Pos
|
|||||||
CLS_BSP_CAN_AddMessageToSend(&cls_hartbeat_header, (uint8_t*)&EventChangeTypeData);
|
CLS_BSP_CAN_AddMessageToSend(&cls_hartbeat_header, (uint8_t*)&EventChangeTypeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CLS_VehicleStatus_t * CLS_GetVehicleStatus(void) {
|
||||||
|
return &cls_vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLS_OnVehicleStatus(CanDataId canid, uint8_t* data, uint8_t len) {
|
||||||
|
if(len == 8) {
|
||||||
|
memcpy((uint8_t*)&cls_vehicle, data, 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CLS_OnEventChangeTypePostion(CanDataId canid, uint8_t* data, uint8_t len) {
|
void CLS_OnEventChangeTypePostion(CanDataId canid, uint8_t* data, uint8_t len) {
|
||||||
|
|
||||||
if(len >= 2) {
|
if(len >= 2) {
|
||||||
@@ -70,8 +86,25 @@ void CLS_Init(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (cls_heatbeat_data.type == cls_device_Type_MASTER) {
|
||||||
|
timerAttr.name = "CLS_Vehicle_Heatbeat";
|
||||||
|
CLS_VehicleTimerId = osTimerNew((osTimerFunc_t)CLS_VehicleHeatbeat, osTimerPeriodic, NULL, &timerAttr);
|
||||||
|
if (CLS_VehicleTimerId != NULL) { // Timer object created
|
||||||
|
|
||||||
|
if (osTimerStart(CLS_VehicleTimerId, 100) == osOK) { // Timer started
|
||||||
|
// Timer started successfully
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t cls_address = GENERATE_CLS_ADDRESS(CLS_CODE_CONFIG,gCLS_DEVICE_ADDRESS,CLS_CHANNEL7);
|
uint16_t cls_address = GENERATE_CLS_ADDRESS(CLS_CODE_CONFIG,gCLS_DEVICE_ADDRESS,CLS_CHANNEL7);
|
||||||
//setup endpoint for changing the Device Type/Position
|
//setup endpoint for changing the Device Type/Position
|
||||||
CanData_regEventMsg(cls_address, CLS_OnEventChangeTypePostion);
|
CanData_regEventMsg(cls_address, CLS_OnEventChangeTypePostion);
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t cls_vehicle_address = GENERATE_CLS_ADDRESS(CLS_CODE_STATUS,0,CLS_CH_STA_VEHICLE);
|
||||||
|
CanData_regEventMsg(cls_vehicle_address, CLS_OnVehicleStatus);
|
||||||
}
|
}
|
||||||
16
CLS.h
16
CLS.h
@@ -30,8 +30,22 @@ typedef struct CLS_HeatbeatData
|
|||||||
CLS_Position_t position;
|
CLS_Position_t position;
|
||||||
} CLS_HeatbeatData_t;
|
} CLS_HeatbeatData_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct CLS_VehicleStatus {
|
||||||
|
uint8_t k15;
|
||||||
|
uint8_t headlight;
|
||||||
|
uint8_t engine;
|
||||||
|
uint8_t speed;
|
||||||
|
uint8_t unlocked;
|
||||||
|
uint8_t reserved[3];
|
||||||
|
} CLS_VehicleStatus_t;
|
||||||
|
|
||||||
extern uint8_t gCLS_DEVICE_ADDRESS;
|
extern uint8_t gCLS_DEVICE_ADDRESS;
|
||||||
|
|
||||||
|
|
||||||
void CLS_Init(void);
|
void CLS_Init(void);
|
||||||
void CLS_SendEventChangeTypePostion(uint16_t canid, CLS_Type_t newType, CLS_Position_t newPostion);
|
void CLS_SendEventChangeTypePostion(uint16_t canid, CLS_Type_t newType, CLS_Position_t newPostion);
|
||||||
|
|
||||||
|
const CLS_VehicleStatus_t * CLS_GetVehicleStatus(void);
|
||||||
|
|
||||||
|
void CLS_VehicleHeatbeat(void *argument);
|
||||||
@@ -39,8 +39,8 @@ typedef enum {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CLS_CH_STA_HEATBEAT = 0, // 0b000
|
CLS_CH_STA_HEATBEAT = 0, // 0b000
|
||||||
CLS_CH_STA_1 = 1, // 0b001
|
CLS_CH_STA_VEHICLE = 1, // 0b001
|
||||||
CLS_CH_STA_2 = 2, // 0b010
|
CLS_CH_STA_AMBIENTLIGHT = 2, // 0b010
|
||||||
CLS_CH_STA_3 = 3, // 0b011
|
CLS_CH_STA_3 = 3, // 0b011
|
||||||
CLS_CH_STA_4 = 4, // 0b100
|
CLS_CH_STA_4 = 4, // 0b100
|
||||||
CLS_CH_STA_5 = 5, // 0b101
|
CLS_CH_STA_5 = 5, // 0b101
|
||||||
|
|||||||
Reference in New Issue
Block a user