diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-02-28 18:58:07 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-02-28 18:58:07 +0000 |
commit | ab3e72edaa76d549f42947f1cfd1479545d9341c (patch) | |
tree | 16d511c069292b460680db8d6277f89547fc3660 | |
parent | 6b5ddb71fcb396ec826a283427b4771018d193e8 (diff) | |
download | ChibiOS-ab3e72edaa76d549f42947f1cfd1479545d9341c.tar.gz ChibiOS-ab3e72edaa76d549f42947f1cfd1479545d9341c.tar.bz2 ChibiOS-ab3e72edaa76d549f42947f1cfd1479545d9341c.zip |
GPT tested.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2780 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/hal/platforms/STM32/hal_lld.c | 2 | ||||
-rw-r--r-- | testhal/STM32/GPT/main.c | 35 |
2 files changed, 18 insertions, 19 deletions
diff --git a/os/hal/platforms/STM32/hal_lld.c b/os/hal/platforms/STM32/hal_lld.c index cbbdf1587..7878bb518 100644 --- a/os/hal/platforms/STM32/hal_lld.c +++ b/os/hal/platforms/STM32/hal_lld.c @@ -57,7 +57,7 @@ */
void hal_lld_init(void) {
- /* Reset of all the peripherals.*/
+ /* Reset of all peripherals.*/
RCC->APB1RSTR = 0xFFFFFFFF;
RCC->APB2RSTR = 0xFFFFFFFF;
RCC->APB1RSTR = 0;
diff --git a/testhal/STM32/GPT/main.c b/testhal/STM32/GPT/main.c index 771434029..6790e5eb0 100644 --- a/testhal/STM32/GPT/main.c +++ b/testhal/STM32/GPT/main.c @@ -21,22 +21,23 @@ #include "hal.h"
/*
- * Red LEDs blinker thread, times are in milliseconds.
+ * GPT1 callback.
*/
-static WORKING_AREA(waThread1, 128);
-static msg_t Thread1(void *arg) {
+static void gpt1cb(GPTDriver *gptp) {
- (void)arg;
- while (TRUE) {
- palClearPad(IOPORT3, GPIOC_LED);
- chThdSleepMilliseconds(500);
- palSetPad(IOPORT3, GPIOC_LED);
- chThdSleepMilliseconds(500);
- }
- return 0;
+ (void)gptp;
+ palTogglePad(IOPORT3, GPIOC_LED);
}
/*
+ * GPT1 configuration.
+ */
+static const GPTConfig gpt1cfg = {
+ 10000, /* 10KHz timer clock.*/
+ gpt1cb /* Timer callback.*/
+};
+
+/*
* Application entry point.
*/
int main(void) {
@@ -52,20 +53,18 @@ int main(void) { chSysInit();
/*
- * Creates the blinker thread.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
-
- /*
* Initializes the GPT driver 1.
*/
-// gptStart(&GPTD1, &pwmcfg);
+ gptStart(&GPTD1, &gpt1cfg);
/*
* Normal main() thread activity, in this demo it does nothing.
*/
while (TRUE) {
- chThdSleepMilliseconds(500);
+ gptStartContinuous(&GPTD1, 5000);
+ chThdSleepMilliseconds(5000);
+ gptStartContinuous(&GPTD1, 2500);
+ chThdSleepMilliseconds(5000);
}
return 0;
}
|