Skip to content

Commit

Permalink
Updated and backported improvements form the Lisa/M 2.0 CAN example.
Browse files Browse the repository at this point in the history
  • Loading branch information
esden committed Nov 8, 2012
1 parent 5d4d840 commit 898691e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions examples/stm32/f1/lisa-m-1/can/README
@@ -0,0 +1,4 @@
This test sets up the CAN interface on Lisa/M and transmits 8 bites every
100ms. The first byte is being incremented in each cycle. The demo also
receives messages and is displaing the first 4 bits of the first byte on the
board LEDs.
12 changes: 7 additions & 5 deletions examples/stm32/f1/lisa-m-1/can/can.c
Expand Up @@ -106,15 +106,15 @@ void can_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_CANEN);

AFIO_MAPR = AFIO_MAPR_CAN1_REMAP_PORTB;
AFIO_MAPR |= AFIO_MAPR_CAN1_REMAP_PORTB;

/* Configure CAN pin: RX (input pull-up). */
gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
gpio_set_mode(GPIO_BANK_CAN1_PB_RX, GPIO_MODE_INPUT,
GPIO_CNF_INPUT_PULL_UPDOWN, GPIO_CAN1_PB_RX);
gpio_set(GPIOB, GPIO_CAN1_PB_RX);

/* Configure CAN pin: TX. */
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
gpio_set_mode(GPIO_BANK_CAN1_PB_TX, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_CAN1_PB_TX);

/* NVIC setup. */
Expand Down Expand Up @@ -165,8 +165,10 @@ void sys_tick_handler(void)
static int temp32 = 0;
static u8 data[8] = {0, 1, 2, 0, 0, 0, 0, 0};

/* We call this handler every 1ms so 1000ms = 1s on/off. */
if (++temp32 != 1000)
/* We call this handler every 1ms so 100ms = 1s
* Resulting in 100Hz message frequency.
*/
if (++temp32 != 100)
return;

temp32 = 0;
Expand Down

0 comments on commit 898691e

Please sign in to comment.