From 85fa3c02ae135e8136e6c064930a6a04e39f8570 Mon Sep 17 00:00:00 2001 From: rbiasini Date: Sun, 7 Jul 2019 22:19:02 -0700 Subject: [PATCH] Misra 5.5: Identifiers shall be distinct from macro names (#246) * Misra 5.5: Identifiers shall be distinct from macro names --- board/drivers/llcan.h | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/board/drivers/llcan.h b/board/drivers/llcan.h index c2aa0dd3512009..488945cff15057 100644 --- a/board/drivers/llcan.h +++ b/board/drivers/llcan.h @@ -10,31 +10,31 @@ void puts(const char *a); -bool llcan_set_speed(CAN_TypeDef *CAN, uint32_t speed, bool loopback, bool silent) { +bool llcan_set_speed(CAN_TypeDef *CAN_obj, uint32_t speed, bool loopback, bool silent) { // initialization mode - CAN->MCR = CAN_MCR_TTCM | CAN_MCR_INRQ; - while((CAN->MSR & CAN_MSR_INAK) != CAN_MSR_INAK); + CAN_obj->MCR = CAN_MCR_TTCM | CAN_MCR_INRQ; + while((CAN_obj->MSR & CAN_MSR_INAK) != CAN_MSR_INAK); // set time quanta from defines - CAN->BTR = (CAN_BTR_TS1_0 * (CAN_SEQ1-1)) | + CAN_obj->BTR = (CAN_BTR_TS1_0 * (CAN_SEQ1-1)) | (CAN_BTR_TS2_0 * (CAN_SEQ2-1)) | (can_speed_to_prescaler(speed) - 1U); // silent loopback mode for debugging if (loopback) { - CAN->BTR |= CAN_BTR_SILM | CAN_BTR_LBKM; + CAN_obj->BTR |= CAN_BTR_SILM | CAN_BTR_LBKM; } if (silent) { - CAN->BTR |= CAN_BTR_SILM; + CAN_obj->BTR |= CAN_BTR_SILM; } // reset - CAN->MCR = CAN_MCR_TTCM | CAN_MCR_ABOM; + CAN_obj->MCR = CAN_MCR_TTCM | CAN_MCR_ABOM; #define CAN_TIMEOUT 1000000 int tmp = 0; bool ret = false; - while(((CAN->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) && (tmp < CAN_TIMEOUT)) tmp++; + while(((CAN_obj->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) && (tmp < CAN_TIMEOUT)) tmp++; if (tmp < CAN_TIMEOUT) { ret = true; } @@ -42,32 +42,32 @@ bool llcan_set_speed(CAN_TypeDef *CAN, uint32_t speed, bool loopback, bool silen return ret; } -void llcan_init(CAN_TypeDef *CAN) { +void llcan_init(CAN_TypeDef *CAN_obj) { // accept all filter - CAN->FMR |= CAN_FMR_FINIT; + CAN_obj->FMR |= CAN_FMR_FINIT; // no mask - CAN->sFilterRegister[0].FR1 = 0; - CAN->sFilterRegister[0].FR2 = 0; - CAN->sFilterRegister[14].FR1 = 0; - CAN->sFilterRegister[14].FR2 = 0; - CAN->FA1R |= 1U | (1U << 14); + CAN_obj->sFilterRegister[0].FR1 = 0; + CAN_obj->sFilterRegister[0].FR2 = 0; + CAN_obj->sFilterRegister[14].FR1 = 0; + CAN_obj->sFilterRegister[14].FR2 = 0; + CAN_obj->FA1R |= 1U | (1U << 14); - CAN->FMR &= ~(CAN_FMR_FINIT); + CAN_obj->FMR &= ~(CAN_FMR_FINIT); // enable certain CAN interrupts - CAN->IER |= CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_WKUIE; + CAN_obj->IER |= CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_WKUIE; - if (CAN == CAN1) { + if (CAN_obj == CAN1) { NVIC_EnableIRQ(CAN1_TX_IRQn); NVIC_EnableIRQ(CAN1_RX0_IRQn); NVIC_EnableIRQ(CAN1_SCE_IRQn); - } else if (CAN == CAN2) { + } else if (CAN_obj == CAN2) { NVIC_EnableIRQ(CAN2_TX_IRQn); NVIC_EnableIRQ(CAN2_RX0_IRQn); NVIC_EnableIRQ(CAN2_SCE_IRQn); #ifdef CAN3 - } else if (CAN == CAN3) { + } else if (CAN_obj == CAN3) { NVIC_EnableIRQ(CAN3_TX_IRQn); NVIC_EnableIRQ(CAN3_RX0_IRQn); NVIC_EnableIRQ(CAN3_SCE_IRQn); @@ -77,9 +77,9 @@ void llcan_init(CAN_TypeDef *CAN) { } } -void llcan_clear_send(CAN_TypeDef *CAN) { - CAN->TSR |= CAN_TSR_ABRQ0; - CAN->MSR &= ~(CAN_MSR_ERRI); - CAN->MSR = CAN->MSR; +void llcan_clear_send(CAN_TypeDef *CAN_obj) { + CAN_obj->TSR |= CAN_TSR_ABRQ0; + CAN_obj->MSR &= ~(CAN_MSR_ERRI); + CAN_obj->MSR = CAN_obj->MSR; }