From 6311fd2e493db22c2e85f04dd17374b205507926 Mon Sep 17 00:00:00 2001 From: Devan Lai Date: Fri, 25 Aug 2017 09:04:23 -0700 Subject: [PATCH] Update to the latest version of locm3 can: use CAN1 instead of CAN, update parameters for can_receive console: replace usart_get_interrupt_source with usart_get_flag stlinkv2-1: replace RCC_CFGR_MCO_HSECLK with RCC_CFGR_MCO_HSE --- libopencm3 | 2 +- src/CAN/can.c | 22 +++++++++++----------- src/console.c | 2 +- src/stm32f103/stlinkv2-1/target.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libopencm3 b/libopencm3 index c165345..b0e050d 160000 --- a/libopencm3 +++ b/libopencm3 @@ -1 +1 @@ -Subproject commit c165345379d26084ae7ea38c1ee6d108dc503324 +Subproject commit b0e050d10d12c42be031c34822117cfd3c5a0ea7 diff --git a/src/CAN/can.c b/src/CAN/can.c index 7332cf3..dfc2070 100644 --- a/src/CAN/can.c +++ b/src/CAN/can.c @@ -84,8 +84,8 @@ void can_rx_buffer_get(CAN_Message* msg) { bool can_reconfigure(uint32_t baudrate, CanMode mode) { nvic_disable_irq(CAN_NVIC_LINE); - can_disable_irq(CAN, CAN_IER_FMPIE0); - can_reset(CAN); + can_disable_irq(CAN1, CAN_IER_FMPIE0); + can_reset(CAN1); if (mode == MODE_RESET) { // Just stop after resetting the CAN controller. @@ -133,14 +133,14 @@ bool can_reconfigure(uint32_t baudrate, CanMode mode) { bool TXFP = false; /* TXFP: Transmit FIFO priority? */ /* CAN cell init. */ - if (can_init(CAN, TTCM, ABOM, AWUM, NART, RFLM, TXFP, + if (can_init(CAN1, TTCM, ABOM, AWUM, NART, RFLM, TXFP, sjw, ts1, ts2, brp, /* BRP+1: Baud rate prescaler */ loopback, silent) != 0) { return false; } else { - can_filter_id_mask_32bit_init(CAN, + can_filter_id_mask_32bit_init(CAN1, 0, /* Filter ID */ 0, /* CAN ID */ 0, /* CAN ID mask */ @@ -148,7 +148,7 @@ bool can_reconfigure(uint32_t baudrate, CanMode mode) { true); /* Enable the filter. */ } - can_enable_irq(CAN, CAN_IER_FMPIE0); + can_enable_irq(CAN1, CAN_IER_FMPIE0); nvic_enable_irq(CAN_NVIC_LINE); return true; } @@ -170,9 +170,9 @@ bool can_setup(uint32_t baudrate, CanMode mode) { } static uint8_t can_fifo_depth(void) { - uint8_t fifo_depth = (CAN_RF0R(CAN) & CAN_RF0R_FMP0_MASK); + uint8_t fifo_depth = (CAN_RF0R(CAN1) & CAN_RF0R_FMP0_MASK); // Account for one fifo entry possibly going away - if (CAN_RF0R(CAN) & CAN_RF0R_RFOM0) { + if (CAN_RF0R(CAN1) & CAN_RF0R_RFOM0) { fifo_depth = fifo_depth > 0 ? (fifo_depth - 1) : 0; } @@ -184,11 +184,11 @@ bool can_read(CAN_Message* msg) { if (can_fifo_depth() > 0) { // Wait for the previous message to be released - while (CAN_RF0R(CAN) & CAN_RF0R_RFOM0); + while (CAN_RF0R(CAN1) & CAN_RF0R_RFOM0); - uint32_t fmi; + uint8_t fmi; bool ext, rtr; - can_receive(CAN, 0, true, &msg->id, &ext, &rtr, &fmi, &msg->len, msg->data); + can_receive(CAN1, 0, true, &msg->id, &ext, &rtr, &fmi, &msg->len, msg->data, NULL); msg->format = ext ? CANExtended : CANStandard; msg->type = rtr ? CANRemote : CANData; success = true; @@ -210,7 +210,7 @@ bool can_read_buffer(CAN_Message* msg) { bool can_write(CAN_Message* msg) { bool ext = msg->format == CANExtended; bool rtr = msg->type == CANRemote; - return (can_transmit(CAN, msg->id, ext, rtr, msg->len, msg->data) != -1); + return (can_transmit(CAN1, msg->id, ext, rtr, msg->len, msg->data) != -1); } void cec_can_isr(void) { diff --git a/src/console.c b/src/console.c index c143e1b..39c3592 100644 --- a/src/console.c +++ b/src/console.c @@ -205,7 +205,7 @@ uint8_t console_recv_blocking(void) { } void CONSOLE_USART_IRQ_NAME(void) { - if (usart_get_interrupt_source(CONSOLE_USART, USART_SR_TXE)) { + if (usart_get_flag(CONSOLE_USART, USART_SR_TXE)) { if (!console_tx_buffer_empty()) { usart_word_t buffered_byte = console_tx_buffer_get(); usart_send(CONSOLE_USART, buffered_byte); diff --git a/src/stm32f103/stlinkv2-1/target.c b/src/stm32f103/stlinkv2-1/target.c index 04c4a2f..f3f9dce 100644 --- a/src/stm32f103/stlinkv2-1/target.c +++ b/src/stm32f103/stlinkv2-1/target.c @@ -67,7 +67,7 @@ void gpio_setup(void) { gpio_clear(GPIOB, GPIO15); /* Enable MCO output */ - rcc_set_mco(RCC_CFGR_MCO_HSECLK); + rcc_set_mco(RCC_CFGR_MCO_HSE); gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO8); /* Setup LEDs as open-drain outputs */