aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/testhal/KINETIS/TEENSY3_x/GPT/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/testhal/KINETIS/TEENSY3_x/GPT/main.c')
-rw-r--r--lib/chibios-contrib/testhal/KINETIS/TEENSY3_x/GPT/main.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/chibios-contrib/testhal/KINETIS/TEENSY3_x/GPT/main.c b/lib/chibios-contrib/testhal/KINETIS/TEENSY3_x/GPT/main.c
new file mode 100644
index 000000000..30ad0cc92
--- /dev/null
+++ b/lib/chibios-contrib/testhal/KINETIS/TEENSY3_x/GPT/main.c
@@ -0,0 +1,65 @@
1/*
2 ChibiOS - Copyright (C) 2015 RedoX https://github.com/RedoXyde
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16#include "hal.h"
17
18/*
19 * GPT1 callback.
20 */
21static void gpt1cb(GPTDriver *gptp) {
22
23 (void)gptp;
24 palTogglePad(TEENSY_PIN13_IOPORT, TEENSY_PIN13);
25}
26
27static const GPTConfig gpt1cfg = {
28 10000, /* 10kHz timer clock.*/
29 gpt1cb /* Timer callback.*/
30};
31
32/*
33 * Application entry point.
34 */
35int main(void) {
36
37 /*
38 * System initializations.
39 * - HAL initialization, this also initializes the configured device drivers
40 * and performs the board-specific initializations.
41 * - Kernel initialization, the main() function becomes a thread and the
42 * RTOS is active.
43 */
44 halInit();
45 chSysInit();
46
47 /*
48 * Activates the GPT driver 1.
49 */
50 gptStart(&GPTD1, &gpt1cfg);
51 gptStartContinuous(&GPTD1, 5000); /* 500ms */
52 //~ gptPolledDelay(&GPTD1, 10); /* Small delay.*/
53
54 /*
55 * Normal main() thread activity, it changes the GPT1 period every
56 * five seconds.
57 */
58 while (!chThdShouldTerminateX()) {
59 chThdSleepMilliseconds(5000);
60 gptChangeInterval(&GPTD1,gptGetIntervalX(&GPTD1)/2); /* 25ms */
61 chThdSleepMilliseconds(5000);
62 gptChangeInterval(&GPTD1,gptGetIntervalX(&GPTD1)*2); /* 50ms */
63 }
64 return 0;
65}