aboutsummaryrefslogtreecommitdiffstats
path: root/testhal
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-01-20 09:07:35 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-01-20 09:07:35 +0000
commit88b8b3eea1cf7c073e8312ca592ea1e5813e0338 (patch)
tree3efe9bf4efcda05d419593920ae27a939f1948d3 /testhal
parent0da4614441571b33783c124d6308fdf9dfd10764 (diff)
downloadChibiOS-88b8b3eea1cf7c073e8312ca592ea1e5813e0338.tar.gz
ChibiOS-88b8b3eea1cf7c073e8312ca592ea1e5813e0338.tar.bz2
ChibiOS-88b8b3eea1cf7c073e8312ca592ea1e5813e0338.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5084 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal')
-rw-r--r--testhal/STM32F4xx/CAN/main.c26
-rw-r--r--testhal/STM32F4xx/CAN/mcuconf.h2
2 files changed, 21 insertions, 7 deletions
diff --git a/testhal/STM32F4xx/CAN/main.c b/testhal/STM32F4xx/CAN/main.c
index 6992facb7..a5db154ed 100644
--- a/testhal/STM32F4xx/CAN/main.c
+++ b/testhal/STM32F4xx/CAN/main.c
@@ -21,6 +21,14 @@
#include "ch.h"
#include "hal.h"
+struct can_instance {
+ CANDriver *canp;
+ uint32_t led;
+};
+
+static const struct can_instance can1 = {&CAND1, GPIOD_LED5};
+//static const struct can_instance can2 = {&CAND2, GPIOD_LED3};
+
/*
* Internal loopback mode, 500KBaud, automatic wakeup, automatic recover
* from abort mode.
@@ -37,20 +45,22 @@ static const CANConfig cancfg = {
/*
* Receiver thread.
*/
-static WORKING_AREA(can_rx_wa, 256);
+static WORKING_AREA(can_rx1_wa, 256);
+//static WORKING_AREA(can_rx2_wa, 256);
static msg_t can_rx(void *p) {
+ struct can_instance *cip = p;
EventListener el;
CANRxFrame rxmsg;
(void)p;
chRegSetThreadName("receiver");
- chEvtRegister(&CAND1.rxfull_event, &el, 0);
+ chEvtRegister(&cip->canp->rxfull_event, &el, 0);
while(!chThdShouldTerminate()) {
if (chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(100)) == 0)
continue;
- while (canReceive(&CAND1, &rxmsg, TIME_IMMEDIATE) == RDY_OK) {
+ while (canReceive(cip->canp, &rxmsg, TIME_IMMEDIATE) == RDY_OK) {
/* Process message.*/
- palTogglePad(GPIOD, GPIOD_LED5);
+ palTogglePad(GPIOD, cip->led);
}
}
chEvtUnregister(&CAND1.rxfull_event, &el);
@@ -103,8 +113,12 @@ int main(void) {
/*
* Starting the transmitter and receiver threads.
*/
- chThdCreateStatic(can_rx_wa, sizeof(can_rx_wa), NORMALPRIO + 7, can_rx, NULL);
- chThdCreateStatic(can_tx_wa, sizeof(can_tx_wa), NORMALPRIO + 7, can_tx, NULL);
+ 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_tx_wa, sizeof(can_tx_wa), NORMALPRIO + 7,
+ can_tx, NULL);
/*
* Normal main() thread activity, in this demo it does nothing.
diff --git a/testhal/STM32F4xx/CAN/mcuconf.h b/testhal/STM32F4xx/CAN/mcuconf.h
index 0b732c558..c3b1a182a 100644
--- a/testhal/STM32F4xx/CAN/mcuconf.h
+++ b/testhal/STM32F4xx/CAN/mcuconf.h
@@ -87,7 +87,7 @@
* CAN driver system settings.
*/
#define STM32_CAN_USE_CAN1 TRUE
-#define STM32_CAN_USE_CAN2 FALSE
+#define STM32_CAN_USE_CAN2 TRUE
#define STM32_CAN_CAN1_IRQ_PRIORITY 11
#define STM32_CAN_CAN2_IRQ_PRIORITY 11