aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testhal/STM32/GPT/main.c28
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);