diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-12-07 19:26:30 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-12-07 19:26:30 +0000 |
commit | 2fbafd292a430fef8a16bc0c8cbe53e1a6a53bd0 (patch) | |
tree | 279017ee5967c48a5d750b4ad0df9d73ea6bef7d /testhal/STM32F1xx/I2C/main.c | |
parent | 3799bf56f52f7a5be9eeda6757c6642105c4ed66 (diff) | |
download | ChibiOS-2fbafd292a430fef8a16bc0c8cbe53e1a6a53bd0.tar.gz ChibiOS-2fbafd292a430fef8a16bc0c8cbe53e1a6a53bd0.tar.bz2 ChibiOS-2fbafd292a430fef8a16bc0c8cbe53e1a6a53bd0.zip |
I2C. Testhal updated.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3573 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32F1xx/I2C/main.c')
-rw-r--r-- | testhal/STM32F1xx/I2C/main.c | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/testhal/STM32F1xx/I2C/main.c b/testhal/STM32F1xx/I2C/main.c index ae1bea5af..0ca040e88 100644 --- a/testhal/STM32F1xx/I2C/main.c +++ b/testhal/STM32F1xx/I2C/main.c @@ -17,12 +17,15 @@ * amount of time.
*/
+#include <stdlib.h>
+
#include "ch.h"
#include "hal.h"
#include "i2c_pns.h"
#include "lis3.h"
-
+#include "tmp75.h"
+#include "fake.h"
/*
@@ -45,35 +48,45 @@ static msg_t Blink(void *arg) { */
static WORKING_AREA(PollAccelThreadWA, 128);
static msg_t PollAccelThread(void *arg) {
+ chRegSetThreadName("PollAccel");
(void)arg;
- systime_t time = chTimeNow();
-
while (TRUE) {
- time += MS2ST(20);
+// chThdSleepMilliseconds(rand() & 31);
+ chThdSleepMilliseconds(32);
request_acceleration_data();
- chThdSleepUntil(time);
}
return 0;
}
-/*
- * Accelerometer thread
- */
-static WORKING_AREA(PollAccelThreadWA, 128);
-static msg_t PollAccelThread(void *arg) {
+/* Temperature polling thread */
+static WORKING_AREA(PollTmp75ThreadWA, 128);
+static msg_t PollTmp75Thread(void *arg) {
+ chRegSetThreadName("PollTmp75");
(void)arg;
- systime_t time = chTimeNow();
-
while (TRUE) {
- time += MS2ST(20);
- request_acceleration_data();
- chThdSleepUntil(time);
+// chThdSleepMilliseconds(rand() & 31);
+ chThdSleepMilliseconds(15);
+ /* Call reading function */
+ request_temperature();
}
return 0;
}
+/* Temperature polling thread */
+static WORKING_AREA(PollFakeThreadWA, 128);
+static msg_t PollFakeThread(void *arg) {
+ chRegSetThreadName("PollFake");
+ (void)arg;
+ while (TRUE) {
+ chThdSleepMilliseconds(16);
+ /* Call reading function */
+ request_fake();
+ }
+ return 0;
+}
+
/*
* Entry point, note, the main() function is already a thread in the system
@@ -84,18 +97,32 @@ int main(void) { halInit();
chSysInit();
- chThdSleepMilliseconds(1000);
+ chThdSleepMilliseconds(200);
I2CInit_pns();
/* Create accelerometer thread */
chThdCreateStatic(PollAccelThreadWA,
sizeof(PollAccelThreadWA),
- HIGHPRIO,
+ NORMALPRIO,
PollAccelThread,
NULL);
+ /* Create temperature thread */
+ chThdCreateStatic(PollTmp75ThreadWA,
+ sizeof(PollTmp75ThreadWA),
+ NORMALPRIO,
+ PollTmp75Thread,
+ NULL);
+
+ /* Create not responding thread */
+ chThdCreateStatic(PollFakeThreadWA,
+ sizeof(PollFakeThreadWA),
+ NORMALPRIO,
+ PollFakeThread,
+ NULL);
+
/* Creates the blinker thread. */
- chThdCreateStatic(BlinkWA, sizeof(BlinkWA), LOWPRIO, Blink, NULL);
+ chThdCreateStatic(BlinkWA, sizeof(BlinkWA), HIGHPRIO, Blink, NULL);
/* main loop that do nothing */
while (TRUE) {
|