Skip to content

Commit

Permalink
Update to the latest version of locm3
Browse files Browse the repository at this point in the history
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
  • Loading branch information
devanlai committed Aug 25, 2017
1 parent 9612bc8 commit 6311fd2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion libopencm3
Submodule libopencm3 updated 235 files
22 changes: 11 additions & 11 deletions src/CAN/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -133,22 +133,22 @@ 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 */
0, /* FIFO assignment (here: FIFO0) */
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;
}
Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f103/stlinkv2-1/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 6311fd2

Please sign in to comment.