From 92bf9bdac3071fc6586f3bb2f2445e3e7c5cefd0 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 3 Feb 2013 10:29:01 +0000 Subject: Added CAN2 support. Tested on the STM32F4xx only. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5105 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F4xx/CAN/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'testhal') diff --git a/testhal/STM32F4xx/CAN/main.c b/testhal/STM32F4xx/CAN/main.c index 5f32d868c..e7a10247b 100644 --- a/testhal/STM32F4xx/CAN/main.c +++ b/testhal/STM32F4xx/CAN/main.c @@ -27,7 +27,7 @@ struct can_instance { }; static const struct can_instance can1 = {&CAND1, GPIOD_LED5}; -//static const struct can_instance can2 = {&CAND2, GPIOD_LED3}; +static const struct can_instance can2 = {&CAND2, GPIOD_LED3}; /* * Internal loopback mode, 500KBaud, automatic wakeup, automatic recover @@ -37,16 +37,14 @@ static const struct can_instance can1 = {&CAND1, GPIOD_LED5}; static const CANConfig cancfg = { CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP, CAN_BTR_LBKM | CAN_BTR_SJW(0) | CAN_BTR_TS2(1) | - CAN_BTR_TS1(8) | CAN_BTR_BRP(6), - 0, - NULL + CAN_BTR_TS1(8) | CAN_BTR_BRP(6) }; /* * Receiver thread. */ static WORKING_AREA(can_rx1_wa, 256); -//static WORKING_AREA(can_rx2_wa, 256); +static WORKING_AREA(can_rx2_wa, 256); static msg_t can_rx(void *p) { struct can_instance *cip = p; EventListener el; @@ -85,6 +83,7 @@ static msg_t can_tx(void * p) { while (!chThdShouldTerminate()) { canTransmit(&CAND1, &txmsg, MS2ST(100)); + canTransmit(&CAND2, &txmsg, MS2ST(100)); chThdSleepMilliseconds(500); } return 0; @@ -106,17 +105,18 @@ int main(void) { chSysInit(); /* - * Activates the CAN driver 1. + * Activates the CAN drivers 1 and 2. */ canStart(&CAND1, &cancfg); + canStart(&CAND2, &cancfg); /* * Starting the transmitter and receiver threads. */ chThdCreateStatic(can_rx1_wa, sizeof(can_rx1_wa), NORMALPRIO + 7, can_rx, (void *)&can1); -// chThdCreateStatic(can_rx2_wa, sizeof(can_rx2_wa), NORMALPRIO + 7, -// can_rx, (void *)&can2); + chThdCreateStatic(can_rx2_wa, sizeof(can_rx2_wa), NORMALPRIO + 7, + can_rx, (void *)&can2); chThdCreateStatic(can_tx_wa, sizeof(can_tx_wa), NORMALPRIO + 7, can_tx, NULL); -- cgit v1.2.3