Updated and backported improvements form the Lisa/M 2.0 CAN example.
This commit is contained in:
parent
5d4d84026a
commit
898691e5ef
4
examples/stm32/f1/lisa-m-1/can/README
Normal file
4
examples/stm32/f1/lisa-m-1/can/README
Normal file
@ -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.
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user