From e924406a1d16c8d7003339899435fa9ab7a7d9eb Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 14 Nov 2024 09:00:12 -0800 Subject: [PATCH 1/2] Fix relative paths to custom upload method file, fix incorrect CAN length on STMicro --- targets/TARGET_STM/can_api.c | 4 ++-- tools/cmake/app.cmake | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_STM/can_api.c b/targets/TARGET_STM/can_api.c index 7cd93cc3933..346a9274f4c 100644 --- a/targets/TARGET_STM/can_api.c +++ b/targets/TARGET_STM/can_api.c @@ -1014,7 +1014,7 @@ int can_write(can_t *obj, CAN_Message msg, int cc) int can_read(can_t *obj, CAN_Message *msg, int handle) { //FIFO selection cannot be controlled by software for STM32, default FIFO is 0, hence handle is not used - int rxfifo_default = DEFAULT_RXFIFO; + const int rxfifo_default = DEFAULT_RXFIFO; CAN_TypeDef *can = obj->CanHandle.Instance; // check FPM0 which holds the pending message count in FIFO 0 @@ -1033,7 +1033,7 @@ int can_read(can_t *obj, CAN_Message *msg, int handle) msg->type = (CANType)(((uint8_t)0x02 & can->sFIFOMailBox[rxfifo_default].RIR) >> 1); /* Get the DLC */ - msg->len = ((uint8_t)0x0F & can->sFIFOMailBox[rxfifo_default].RDTR < 8) ? ((uint8_t)0x0F & can->sFIFOMailBox[rxfifo_default].RDTR) : ((uint8_t) 8); + msg->len = ((can->sFIFOMailBox[rxfifo_default].RDTR & CAN_RDT0R_DLC) < 8) ? ((uint8_t)0x0F & can->sFIFOMailBox[rxfifo_default].RDTR) : ((uint8_t) 8); /* Get the FMI */ // msg->FMI = (uint8_t)0xFF & (can->sFIFOMailBox[rxfifo_default].RDTR >> 8); /* Get the data field */ diff --git a/tools/cmake/app.cmake b/tools/cmake/app.cmake index d22fe71f6c1..6ab3bec629b 100644 --- a/tools/cmake/app.cmake +++ b/tools/cmake/app.cmake @@ -64,6 +64,8 @@ set(EXPECTED_MBED_UPLOAD_CFG_FILE_PATH ${MBED_SOURCE_DIR}/targets/upload_method_ # check if a custom upload config path is defined in top lvl cmake if((DEFINED CUSTOM_UPLOAD_CFG_PATH)) + # Make path absolute, as required by EXISTS + get_filename_component(CUSTOM_UPLOAD_CFG_PATH "${CUSTOM_UPLOAD_CFG_PATH}" ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR}) if(EXISTS ${CUSTOM_UPLOAD_CFG_PATH}) include(${CUSTOM_UPLOAD_CFG_PATH}) message(STATUS "Mbed: Custom upload config included from ${CUSTOM_UPLOAD_CFG_PATH}") From ec3c33e693479a5769722369ec43208da87ba55e Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 14 Nov 2024 09:20:07 -0800 Subject: [PATCH 2/2] Wait we can do this better --- targets/TARGET_STM/can_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/TARGET_STM/can_api.c b/targets/TARGET_STM/can_api.c index 346a9274f4c..a2df42de95f 100644 --- a/targets/TARGET_STM/can_api.c +++ b/targets/TARGET_STM/can_api.c @@ -1033,7 +1033,7 @@ int can_read(can_t *obj, CAN_Message *msg, int handle) msg->type = (CANType)(((uint8_t)0x02 & can->sFIFOMailBox[rxfifo_default].RIR) >> 1); /* Get the DLC */ - msg->len = ((can->sFIFOMailBox[rxfifo_default].RDTR & CAN_RDT0R_DLC) < 8) ? ((uint8_t)0x0F & can->sFIFOMailBox[rxfifo_default].RDTR) : ((uint8_t) 8); + msg->len = ((can->sFIFOMailBox[rxfifo_default].RDTR & CAN_RDT0R_DLC) < 8) ? (CAN_RDT0R_DLC & can->sFIFOMailBox[rxfifo_default].RDTR) : ((uint8_t) 8); /* Get the FMI */ // msg->FMI = (uint8_t)0xFF & (can->sFIFOMailBox[rxfifo_default].RDTR >> 8); /* Get the data field */