From c081915dfcdc6901b278c969f861458ee386eae0 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 27 Jul 2023 15:41:37 +0800 Subject: [PATCH] update --- chip/chip.c | 41 +++++++++++++++++++++- .../iflytop_can_slave_v1/iflytop_can_slave.cpp | 6 ++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/chip/chip.c b/chip/chip.c index eaae067..0fc37c1 100644 --- a/chip/chip.c +++ b/chip/chip.c @@ -69,4 +69,43 @@ GPIO_TypeDef* chip_get_gpio(Pin_t pin) { } return NULL; } -uint16_t chip_get_pinoff(Pin_t pin) { return (pin & 0xF); } \ No newline at end of file +uint16_t chip_get_pinoff(Pin_t pin) { + uint16_t pinoff = pin & 0x0F; + switch (pinoff) { + case 0: + return GPIO_PIN_0; + case 1: + return GPIO_PIN_1; + case 2: + return GPIO_PIN_2; + case 3: + return GPIO_PIN_3; + case 4: + return GPIO_PIN_4; + case 5: + return GPIO_PIN_5; + case 6: + return GPIO_PIN_6; + case 7: + return GPIO_PIN_7; + case 8: + return GPIO_PIN_8; + case 9: + return GPIO_PIN_9; + case 10: + return GPIO_PIN_10; + case 11: + return GPIO_PIN_11; + case 12: + return GPIO_PIN_12; + case 13: + return GPIO_PIN_13; + case 14: + return GPIO_PIN_14; + case 15: + return GPIO_PIN_15; + default: + break; + }; + return 0; +} \ No newline at end of file diff --git a/components/iflytop_can_slave_v1/iflytop_can_slave.cpp b/components/iflytop_can_slave_v1/iflytop_can_slave.cpp index 64f62c7..6699338 100644 --- a/components/iflytop_can_slave_v1/iflytop_can_slave.cpp +++ b/components/iflytop_can_slave_v1/iflytop_can_slave.cpp @@ -424,7 +424,7 @@ int IflytopCanProtocolStackProcesser::getRxPacketRemain() { } HAL_StatusTypeDef IflytopCanProtocolStackProcesser::activateRxIT() { - HAL_StatusTypeDef hal_status; + HAL_StatusTypeDef hal_status = HAL_ERROR; if (m_config->rxfifoNum == CAN_RX_FIFO0) { hal_status = HAL_CAN_ActivateNotification(m_config->canHandle, CAN_IT_RX_FIFO0_MSG_PENDING); } else if (m_config->rxfifoNum == CAN_RX_FIFO1) { @@ -436,7 +436,7 @@ HAL_StatusTypeDef IflytopCanProtocolStackProcesser::activateRxIT() { return hal_status; } HAL_StatusTypeDef IflytopCanProtocolStackProcesser::deactivateRxIT() { - HAL_StatusTypeDef hal_status; + HAL_StatusTypeDef hal_status = HAL_ERROR; if (m_config->rxfifoNum == CAN_RX_FIFO0) { hal_status = HAL_CAN_DeactivateNotification(m_config->canHandle, CAN_IT_RX_FIFO0_MSG_PENDING); } else if (m_config->rxfifoNum == CAN_RX_FIFO1) { @@ -478,7 +478,7 @@ HAL_StatusTypeDef IflytopCanProtocolStackProcesser::translate(uint32_t Id, uint8 } now = chip_get_ticket(); while (HAL_CAN_IsTxMessagePending(m_config->canHandle, txMailBox)) { - if (haspassedms(now) > overtimems) { + if (haspassedms(now) > (uint32_t)overtimems) { m_lastTransmitStatus = HAL_TIMEOUT; HAL_CAN_AbortTxRequest(m_config->canHandle, txMailBox); goto endtag;