aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPiotr Esden-Tempski2012-11-08 15:21:40 -0800
committerPiotr Esden-Tempski2012-11-08 15:21:40 -0800
commit898691e5ef922d90760d28c18f75b0284738a5b2 (patch)
treecbdf70679bc24b9bdf3ab2938047dd76f9b92abb /examples
parent5d4d84026a2bd67b0e772333488cd2695aa79547 (diff)
Updated and backported improvements form the Lisa/M 2.0 CAN example.
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32/f1/lisa-m-1/can/README4
-rw-r--r--examples/stm32/f1/lisa-m-1/can/can.c12
2 files changed, 11 insertions, 5 deletions
diff --git a/examples/stm32/f1/lisa-m-1/can/README b/examples/stm32/f1/lisa-m-1/can/README
new file mode 100644
index 0000000..3a14e3b
--- /dev/null
+++ b/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.
diff --git a/examples/stm32/f1/lisa-m-1/can/can.c b/examples/stm32/f1/lisa-m-1/can/can.c
index 41432b6..a4cf30d 100644
--- a/examples/stm32/f1/lisa-m-1/can/can.c
+++ b/examples/stm32/f1/lisa-m-1/can/can.c
@@ -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. */
@@ -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;