仓库提交练习
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.
 
 
 

109 lines
2.7 KiB

/*
* bsp_DLT_Log.c
*
* Created on: Aug 8, 2024
* Author: akeguo
*/
#include "bsp_DLT_Log.h"
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;
typedef enum _send_out_port
{
udp = 0, serialport = 1, tcp = 3,
} send_out_port;
char send_out_is_udp_or_serial_port = 0;
void dLT_Log_intialize(struct UARTHandler *Handler)
{
dLT_Log_UART_Handler = Handler;
dLT_Log_UART_Handler->Wait_time = 40;
Handler->dispacherController->Dispacher_Enable = 1;
//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);
send_out_is_udp_or_serial_port = serialport;
}
//dlt log 日志配置 默认为udp发送
/*This CallBack was registered in main function using function: DLTuc_RegisterTransmitSerialDataFunction*/
void DLT_DataTransmit(uint8_t *DltLogData, uint8_t Size)
{
if (send_out_is_udp_or_serial_port == udp)
{
//udp_dlt_send_back(DltLogData, Size);
}
else if (send_out_is_udp_or_serial_port == serialport)
{
dLT_Log_UART_Handler->AddSendList(dLT_Log_UART_Handler, DltLogData,
Size, 100, NULL);
}
else if (send_out_is_udp_or_serial_port == tcp)
{
//tcp_send_to_all_clients(DltLogData, Size);//
//tcp_add_sendList(DltLogData,Size);
}
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();
}