diff options
Diffstat (limited to 'lib/chibios-contrib/testhal/TIVA/TM4C123x/GPT/main.c')
-rw-r--r-- | lib/chibios-contrib/testhal/TIVA/TM4C123x/GPT/main.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/lib/chibios-contrib/testhal/TIVA/TM4C123x/GPT/main.c b/lib/chibios-contrib/testhal/TIVA/TM4C123x/GPT/main.c new file mode 100644 index 000000000..e739075ad --- /dev/null +++ b/lib/chibios-contrib/testhal/TIVA/TM4C123x/GPT/main.c | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | Copyright (C) 2014..2017 Marco Veeneman | ||
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 | |||
17 | #include "ch.h" | ||
18 | #include "hal.h" | ||
19 | |||
20 | /* | ||
21 | * GPT1 callback | ||
22 | */ | ||
23 | static void gpt1cb(GPTDriver *gptp) | ||
24 | { | ||
25 | (void)gptp; | ||
26 | palClearLine(LINE_LED_RED); | ||
27 | } | ||
28 | |||
29 | /* | ||
30 | * GPT7 callback | ||
31 | */ | ||
32 | static void gpt7cb(GPTDriver *gptp) | ||
33 | { | ||
34 | (void)gptp; | ||
35 | palSetLine(LINE_LED_RED); | ||
36 | chSysLockFromISR(); | ||
37 | gptStartOneShotI(&GPTD1, 31250); /* 0.1 second pulse.*/ | ||
38 | chSysUnlockFromISR(); | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | * GPT1 configuration. | ||
43 | */ | ||
44 | static const GPTConfig gpt1cfg = | ||
45 | { | ||
46 | 312500, /* 312500 kHz timer clock.*/ | ||
47 | gpt1cb, /* Timer callback.*/ | ||
48 | }; | ||
49 | |||
50 | /* | ||
51 | * GPT7 configuration. | ||
52 | */ | ||
53 | static const GPTConfig gpt7cfg = | ||
54 | { | ||
55 | 10000, /* 10000 kHz timer clock.*/ | ||
56 | gpt7cb, /* Timer callback.*/ | ||
57 | }; | ||
58 | |||
59 | /* | ||
60 | * Application entry point. | ||
61 | */ | ||
62 | int main(void) | ||
63 | { | ||
64 | /* | ||
65 | * System initializations. | ||
66 | * - HAL initialization, this also initializes the configured device drivers | ||
67 | * and performs the board-specific initializations. | ||
68 | * - Kernel initialization, the main() function becomes a thread and the | ||
69 | * RTOS is active. | ||
70 | */ | ||
71 | halInit(); | ||
72 | chSysInit(); | ||
73 | |||
74 | palSetLineMode(LINE_LED_RED, PAL_MODE_OUTPUT_PUSHPULL); | ||
75 | |||
76 | /* | ||
77 | * Start the gpt drivers with the custom configurations. | ||
78 | */ | ||
79 | gptStart(&GPTD1, &gpt1cfg); | ||
80 | gptStart(&GPTD7, &gpt7cfg); | ||
81 | |||
82 | /* | ||
83 | * Normal main() thread activity | ||
84 | */ | ||
85 | while (TRUE) { | ||
86 | gptStartContinuous(&GPTD7, 5000); | ||
87 | chThdSleepMilliseconds(5000); | ||
88 | gptStopTimer(&GPTD7); | ||
89 | gptStartContinuous(&GPTD7, 2500); | ||
90 | chThdSleepMilliseconds(5000); | ||
91 | gptStopTimer(&GPTD7); | ||
92 | } | ||
93 | |||
94 | return 0; | ||
95 | } | ||