Skip to content

Commit 171dda7

Browse files
committed
Merge pull request #63 from jorisa/master
Fix hardfault when attaching callback to CAN2 when CAN1 is not defined
2 parents cfa6a1d + efd3d8d commit 171dda7

File tree

1 file changed

+1
-1
lines changed
  • libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X

1 file changed

+1
-1
lines changed

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/can_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable) {
164164
obj->dev->MOD &= ~(1);
165165

166166
// Enable NVIC if at least 1 interrupt is active
167-
if(LPC_CAN1->IER | LPC_CAN2->IER) {
167+
if(((LPC_SC->PCONP & (1 << 13)) && LPC_CAN1->IER) || ((LPC_SC->PCONP & (1 << 14)) && LPC_CAN2->IER)) {
168168
NVIC_SetVector(CAN_IRQn, (uint32_t) &can_irq_n);
169169
NVIC_EnableIRQ(CAN_IRQn);
170170
}

0 commit comments

Comments
 (0)