diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-02-28 19:16:52 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-02-28 19:16:52 +0000 |
commit | 006c13952ffee23f7384b60efa95186333fbf69f (patch) | |
tree | 1aabaf89190c1514a97ad5d24363650f9b12ffa5 | |
parent | ab3e72edaa76d549f42947f1cfd1479545d9341c (diff) | |
download | ChibiOS-006c13952ffee23f7384b60efa95186333fbf69f.tar.gz ChibiOS-006c13952ffee23f7384b60efa95186333fbf69f.tar.bz2 ChibiOS-006c13952ffee23f7384b60efa95186333fbf69f.zip |
Better GPT test.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2781 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | testhal/STM32/GPT/main.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/testhal/STM32/GPT/main.c b/testhal/STM32/GPT/main.c index 6790e5eb0..8a07efec4 100644 --- a/testhal/STM32/GPT/main.c +++ b/testhal/STM32/GPT/main.c @@ -26,7 +26,19 @@ static void gpt1cb(GPTDriver *gptp) {
(void)gptp;
- palTogglePad(IOPORT3, GPIOC_LED);
+ palClearPad(IOPORT3, GPIOC_LED);
+ chSysLockFromIsr();
+ gptStartOneShotI(&GPTD2, 200); /* 0.02 second pulse.*/
+ chSysUnlockFromIsr();
+}
+
+/*
+ * GPT2 callback.
+ */
+static void gpt2cb(GPTDriver *gptp) {
+
+ (void)gptp;
+ palSetPad(IOPORT3, GPIOC_LED);
}
/*
@@ -38,6 +50,14 @@ static const GPTConfig gpt1cfg = { };
/*
+ * GPT2 configuration.
+ */
+static const GPTConfig gpt2cfg = {
+ 10000, /* 10KHz timer clock.*/
+ gpt2cb /* Timer callback.*/
+};
+
+/*
* Application entry point.
*/
int main(void) {
@@ -53,12 +73,14 @@ int main(void) { chSysInit();
/*
- * Initializes the GPT driver 1.
+ * Initializes the GPT drivers 1 and 2.
*/
gptStart(&GPTD1, &gpt1cfg);
+ gptStart(&GPTD2, &gpt2cfg);
/*
- * Normal main() thread activity, in this demo it does nothing.
+ * Normal main() thread activity, it changes the GPT1 period every
+ * five seconds.
*/
while (TRUE) {
gptStartContinuous(&GPTD1, 5000);
|