From 6a3337160e7e316acd3e4ff6cf7983da251ac0c2 Mon Sep 17 00:00:00 2001 From: marcoveeneman Date: Wed, 6 Apr 2016 21:26:50 +0200 Subject: Tiva. WDG. Added testhal demo for Watchdog driver. --- testhal/TIVA/TM4C123x/WDG/main.c | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 testhal/TIVA/TM4C123x/WDG/main.c (limited to 'testhal/TIVA/TM4C123x/WDG/main.c') diff --git a/testhal/TIVA/TM4C123x/WDG/main.c b/testhal/TIVA/TM4C123x/WDG/main.c new file mode 100644 index 0000000..3aa8a07 --- /dev/null +++ b/testhal/TIVA/TM4C123x/WDG/main.c @@ -0,0 +1,79 @@ +/* + Copyright (C) 2014 Marco Veeneman + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "hal.h" + +static bool watchdog_timeout(WDGDriver *wdgp) +{ + (void)wdgp; + + palSetPad(GPIOF, GPIOF_LED_RED); + + return true; +} + +/* + * Watchdog deadline set to more than one second (LSI=40000 / (64 * 1000)). + */ +static const WDGConfig wdgcfg = +{ + 80000000, + watchdog_timeout, + TEST_STALL +}; + +/* + * Application entry point. + */ +int main(void) { + + /* + * System initializations. + * - HAL initialization, this also initializes the configured device drivers + * and performs the board-specific initializations. + * - Kernel initialization, the main() function becomes a thread and the + * RTOS is active. + */ + halInit(); + chSysInit(); + + palSetPadMode(GPIOF, GPIOF_LED_RED, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOF, GPIOF_LED_BLUE, PAL_MODE_OUTPUT_PUSHPULL); + + palSetPadMode(GPIOF, GPIOF_SW1, PAL_MODE_INPUT_PULLUP); + palSetPadMode(GPIOF, GPIOF_SW2, PAL_MODE_INPUT_PULLUP); + + /* + * Starting the watchdog driver. + */ + wdgStart(&WDGD1, &wdgcfg); + + /* + * Normal main() thread activity, it resets the watchdog. + */ + while (true) { + if (palReadPad(GPIOF, GPIOF_SW1)) { + wdgReset(&WDGD1); + palClearPad(GPIOF, GPIOF_LED_RED); + } + + palTogglePad(GPIOF, GPIOF_LED_BLUE); + + chThdSleepMilliseconds(500); + } + return 0; +} -- cgit v1.2.3 From 1244b8c9abb99eb6280aad5a5e3caa9da81d8d99 Mon Sep 17 00:00:00 2001 From: marcoveeneman Date: Mon, 11 Apr 2016 20:12:36 +0200 Subject: Disabled SPI support in halconf.h and added some comments in main.c --- testhal/TIVA/TM4C123x/WDG/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'testhal/TIVA/TM4C123x/WDG/main.c') diff --git a/testhal/TIVA/TM4C123x/WDG/main.c b/testhal/TIVA/TM4C123x/WDG/main.c index 3aa8a07..d8bb265 100644 --- a/testhal/TIVA/TM4C123x/WDG/main.c +++ b/testhal/TIVA/TM4C123x/WDG/main.c @@ -23,11 +23,14 @@ static bool watchdog_timeout(WDGDriver *wdgp) palSetPad(GPIOF, GPIOF_LED_RED); + /* Return true to prevent a reset on the next timeout.*/ return true; } /* - * Watchdog deadline set to more than one second (LSI=40000 / (64 * 1000)). + * Watchdog deadline set to one second. + * Use callback on first timeout. + * Stall timer if paused by debugger. */ static const WDGConfig wdgcfg = { @@ -67,6 +70,7 @@ int main(void) { */ while (true) { if (palReadPad(GPIOF, GPIOF_SW1)) { + /* Only reset the watchdog if the button is not pressed */ wdgReset(&WDGD1); palClearPad(GPIOF, GPIOF_LED_RED); } -- cgit v1.2.3 From d4cb8ca216bec40481eb1c4d94839db1c0c36420 Mon Sep 17 00:00:00 2001 From: marcoveeneman Date: Thu, 28 Apr 2016 22:07:07 +0200 Subject: Mass license update. --- testhal/TIVA/TM4C123x/WDG/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testhal/TIVA/TM4C123x/WDG/main.c') diff --git a/testhal/TIVA/TM4C123x/WDG/main.c b/testhal/TIVA/TM4C123x/WDG/main.c index d8bb265..16c26dc 100644 --- a/testhal/TIVA/TM4C123x/WDG/main.c +++ b/testhal/TIVA/TM4C123x/WDG/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Marco Veeneman + Copyright (C) 2014..2016 Marco Veeneman Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -- cgit v1.2.3 From 277989a04854b32f57c710b3c42d2ab376e838be Mon Sep 17 00:00:00 2001 From: marcoveeneman Date: Thu, 28 Apr 2016 22:10:35 +0200 Subject: Tiva. WDG. Changed fixed load value to the system clock in the demo. --- testhal/TIVA/TM4C123x/WDG/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testhal/TIVA/TM4C123x/WDG/main.c') diff --git a/testhal/TIVA/TM4C123x/WDG/main.c b/testhal/TIVA/TM4C123x/WDG/main.c index 16c26dc..da08cfb 100644 --- a/testhal/TIVA/TM4C123x/WDG/main.c +++ b/testhal/TIVA/TM4C123x/WDG/main.c @@ -34,7 +34,7 @@ static bool watchdog_timeout(WDGDriver *wdgp) */ static const WDGConfig wdgcfg = { - 80000000, + TIVA_SYSCLK, watchdog_timeout, TEST_STALL }; -- cgit v1.2.3