From f2b786c6ad14fd2c2d2148d82f025c3b089d27dd Mon Sep 17 00:00:00 2001 From: smartinezs <smartinezs@upc.iri.edu> Date: Tue, 18 May 2021 11:03:26 +0200 Subject: [PATCH] minor changes --- f1/can/include/can.h | 2 +- f1/can/src/can.c | 44 +++++--------------------------------------- 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/f1/can/include/can.h b/f1/can/include/can.h index 3c1d1f5..49587e1 100644 --- a/f1/can/include/can.h +++ b/f1/can/include/can.h @@ -90,7 +90,7 @@ void can_config(TComm *comm_dev,CAN_InitTypeDef *conf); void can_set_priorities(TComm *comm_dev,TCAN_IRQ_Priorities *priorities); void can_set_bitrate(TComm *comm_dev,CAN_SPEED bitrate); void can_set_filter(TComm *comm_dev,CAN_FilterConfTypeDef *filter); -void can_set_can_id(TComm *comm_dev,unsigned char id); +void can_set_can_id(TComm *comm_dev,unsigned int id); /* IRQ functions */ unsigned char can_send_irq(unsigned char first_byte); unsigned char can_enable_tx_irq(void); diff --git a/f1/can/src/can.c b/f1/can/src/can.c index bc95bcb..a8de97a 100644 --- a/f1/can/src/can.c +++ b/f1/can/src/can.c @@ -126,8 +126,6 @@ void can_init(TComm *comm_dev,CAN_InitTypeDef *conf,TCAN_IRQ_Priorities *priorit CANHandle.pTxMsg->RTR = CAN_RTR_DATA; CANHandle.pTxMsg->IDE = CAN_ID_STD; - //HAL_CAN_Receive_IT(&CANHandle,CAN_FIFO0); - } void can_config(TComm *comm_dev,CAN_InitTypeDef *conf) @@ -216,10 +214,9 @@ void can_set_bitrate(TComm *comm_dev,CAN_SPEED bitrate) void can_set_filter(TComm *comm_dev,CAN_FilterConfTypeDef *filter) { HAL_CAN_ConfigFilter(&CANHandle, filter); - //HAL_CAN_Receive_IT(&CANHandle,CAN_FIFO0); } -void can_set_can_id(TComm *comm_dev,unsigned char id) +void can_set_can_id(TComm *comm_dev,unsigned int id) { CANHandle.pTxMsg->StdId = id; } @@ -238,16 +235,11 @@ void HAL_CAN_ErrorCallback(CAN_HandleTypeDef* CANHandle) void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef* CANHandle) { - // HAL_CAN_StateTypeDef status = HAL_CAN_GetState(CANHandle); - // while(HAL_CAN_STATE_READY != status) - // { - // status = HAL_CAN_GetState(CANHandle); - // } - if (can_send_lenght != 0) { if (can_send_lenght > 8) { + CANHandle->pTxMsg->DLC = 8; for (uint8_t i=0;i<8;i++) { CANHandle->pTxMsg->Data[i] = can_send_data[i+(8*can_send_iterations)]; @@ -258,6 +250,7 @@ void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef* CANHandle) } else { + CANHandle->pTxMsg->DLC = can_send_lenght; for (uint8_t i=0;i<can_send_lenght;i++) { CANHandle->pTxMsg->Data[i] = can_send_data[i+(8*can_send_iterations)]; @@ -388,35 +381,6 @@ unsigned char can_cancel_receive_irq(void) /* DMA functions */ unsigned char can_send_dma(unsigned char *data,unsigned short int length) { - // if (length <= 8) - // { - // CANHandle.pTxMsg->DLC = length; - // for (uint8_t i=0;i<length;i++) - // { - // CANHandle.pTxMsg->Data[i] = data[i]; - // } - // HAL_CAN_Transmit_IT(&CANHandle); - // } - // else - // { - // unsigned char iterations = 0x00; - // while (length > 0) - // { - // if(length > 8) - // CANHandle.pTxMsg->DLC = 8; - // else - // CANHandle.pTxMsg->DLC = length; - // for (uint8_t i=0;i<CANHandle.pTxMsg->DLC;i++) - // { - // CANHandle.pTxMsg->Data[i] = data[i+iterations]; - // } - // HAL_CAN_Transmit_IT(&CANHandle); - // HAL_Delay(5); - // iterations = iterations + 8; - // length = length - CANHandle.pTxMsg->DLC; - // } - // } - if(length > 8){ CANHandle.pTxMsg->DLC = 8; for (uint8_t i=0;i<length;i++) @@ -464,6 +428,8 @@ unsigned char can_cancel_receive_dma(void) can_dma_phase_data=0x00; can_dma_phase_length=0; can_dma_phase_write_ptr=0; + //can_missing_bytes_length=0; + //can_missing_bytes_write_ptr=0; return 0x00; } -- GitLab