You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.2 KiB

2 days ago
/*
* bsp_DLT_Log.c
*
* Created on: Aug 8, 2024
* Author: akeguo
*/
#include "bsp_DLT_Log.h"
#define DLT_LOG_CONTEX "MAIN"
#define DLT_LOG_APPID "NUM1"
uint32_t GetSysTime(void);
void DltInjectDataRcvd(uint32_t AppId, uint32_t ConId, uint32_t ServId,
uint8_t *Data, uint16_t Size);
void DLT_LowLevelReceiveDmaToIdle(uint8_t *rxBuf, uint16_t size);
void DLT_DataReceiveEndCallback(uint8_t *rxBuf, uint16_t Size);
void DLT_DataTransmit(uint8_t *DltLogData, uint8_t Size);
struct UARTHandler *dLT_Log_UART_Handler;
void dLT_Log_intialize(struct UARTHandler *Handler)
{
dLT_Log_UART_Handler = Handler;
//log_info("angle_encoder_intialize");
dLT_Log_UART_Handler->UART_Decode = DLT_DataReceiveEndCallback;
/*Register Low Level Transmit/Receive functions for DLTuc Library*/
DLTuc_RegisterTransmitSerialDataFunction(DLT_DataTransmit);
DLTuc_RegisterReceiveSerialDataFunction(DLT_LowLevelReceiveDmaToIdle);
DLTuc_RegisterGetTimeStampMsCallback(GetSysTime); /*Register GetSysTime function*/
/*The function "GetSysTime" must return the time in ms*/
DLTuc_RegisterInjectionDataReceivedCb(DltInjectDataRcvd);
}
/*This CallBack was registered in main function using function: DLTuc_RegisterTransmitSerialDataFunction*/
void DLT_DataTransmit(uint8_t *DltLogData, uint8_t Size)
{
dLT_Log_UART_Handler->AddSendList(dLT_Log_UART_Handler,DltLogData,Size,100,NULL);
DLTuc_MessageTransmitDone();
}
/*CallBacks used by ucDltLibrary section end..*/
void DLT_DataReceiveEndCallback(uint8_t *rxBuf, uint16_t Size)
{
if(Size==3)
{
if(rxBuf[2])
{
DLT_LOG_ENABLE_LEVEL=7;
}
else
{
DLT_LOG_ENABLE_LEVEL=0;
}
}
DLTuc_RawDataReceiveDone(Size);
/*
*In case of STM32 HAL lib, you have to subsitute this function using:
*void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
*/
}
//HAL_UARTEx_RxEventCallback
void DLT_LowLevelReceiveDmaToIdle(uint8_t *rxBuf, uint16_t Size)
{
memcpy(rxBuf, dLT_Log_UART_Handler->Rx_Buf, Size);
}
void DltInjectDataRcvd(uint32_t AppId, uint32_t ConId, uint32_t ServId,
uint8_t *Data, uint16_t Size)
{
LOG("RecInjectionData: %s, ServId: %d Size: %d", Data, ServId, Size)
}
uint32_t GetSysTime(void)
{
return HAL_GetTick();
}