36 #include <libopencm3/stm32/rcc.h>
37 #include <libopencm3/stm32/gpio.h>
38 #include <libopencm3/stm32/can.h>
39 #include <libopencm3/cm3/nvic.h>
45 #define NVIC_USB_LP_CAN_RX0_IRQ_PRIO RTOS_PRIO+1
47 #define NVIC_USB_LP_CAN_RX0_IRQ_PRIO 1
48 #define NVIC_CAN1_RX_IRQ_PRIO 1
61 rcc_periph_clock_enable(RCC_AFIO);
62 rcc_periph_clock_enable(RCC_GPIOB);
63 rcc_periph_clock_enable(RCC_CAN1);
66 AFIO_MAPR |= AFIO_MAPR_CAN1_REMAP_PORTB;
69 gpio_set_mode(GPIO_BANK_CAN1_PB_RX, GPIO_MODE_INPUT,
70 GPIO_CNF_INPUT_PULL_UPDOWN, GPIO_CAN1_PB_RX);
71 gpio_set(GPIO_BANK_CAN1_PB_RX, GPIO_CAN1_PB_RX);
74 gpio_set_mode(GPIO_BANK_CAN1_PB_TX, GPIO_MODE_OUTPUT_50_MHZ,
75 GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_CAN1_PB_TX);
78 nvic_enable_irq(NVIC_USB_LP_CAN_RX0_IRQ);
84 rcc_periph_clock_enable(RCC_GPIOB);
85 rcc_periph_clock_enable(RCC_CAN1);
92 nvic_enable_irq(NVIC_CAN1_RX0_IRQ);
155 can_filter_id_mask_32bit_init(
CAN1,
163 can_enable_irq(
CAN1, CAN_IER_FMPIE0);
185 return can_transmit(
CAN1,
187 #ifdef USE_CAN_EXT_ID
197 void usb_lp_can_rx0_isr(
void)
218 can_fifo_release(
CAN1, 0);
221 void can1_rx0_isr(
void){
241 can_fifo_release(
CAN1, 0);