diff options
author | Diego Ismirlian <dismirlian@gmail.com> | 2019-10-03 14:00:34 -0300 |
---|---|---|
committer | Diego Ismirlian <dismirlian@gmail.com> | 2019-10-03 14:00:34 -0300 |
commit | ea844db44656f481cda59bc71234d54be37ed5bf (patch) | |
tree | 22c21b29afc393b5813b58776cfa728e90f1b916 /demos/STM32/RT-STM32F407-DISCOVERY-fault_handlers/main.c | |
parent | 2800f71230de7684cb805701ac40791f5d0876b6 (diff) | |
parent | 75027a647490d62d875c8012c0eac83a441304a8 (diff) | |
download | ChibiOS-Contrib-ea844db44656f481cda59bc71234d54be37ed5bf.tar.gz ChibiOS-Contrib-ea844db44656f481cda59bc71234d54be37ed5bf.tar.bz2 ChibiOS-Contrib-ea844db44656f481cda59bc71234d54be37ed5bf.zip |
Merge branch 'master' into segger_systemview
Diffstat (limited to 'demos/STM32/RT-STM32F407-DISCOVERY-fault_handlers/main.c')
-rw-r--r-- | demos/STM32/RT-STM32F407-DISCOVERY-fault_handlers/main.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/demos/STM32/RT-STM32F407-DISCOVERY-fault_handlers/main.c b/demos/STM32/RT-STM32F407-DISCOVERY-fault_handlers/main.c new file mode 100644 index 0000000..f5f6584 --- /dev/null +++ b/demos/STM32/RT-STM32F407-DISCOVERY-fault_handlers/main.c @@ -0,0 +1,69 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + 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" +#include "fault_handlers.h" + +int crash(int option); + +void _fault_info_hook(const struct fault_info *info) { + (void)info; + /* _print_message(info->decoded_info_string); */ +} + +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(); + + /* + 1) MSP Rounded to multiple of 8 bytes. + 2) MSP Not Rounded to multiple of 8 bytes. + 3) PSP in use. + 4) Precise fault. + 5) Imprecise fault. + 6) Fault with FPU disabled. + 7) Fault with FPU auto-stacking disabled. + 8) Fault with FPU auto-stacking enabled. + 9) Fault with FPU lazy auto-stacking. + 10) Issue two breakpoints and return. + */ + crash(4); + + /* + * Activates the serial driver 2 using the driver default configuration. + * PA2(TX) and PA3(RX) are routed to USART2. + */ + sdStart(&SD2, NULL); + palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7)); + palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)); + + /* + * Normal main() thread activity, in this demo it does nothing except + * sleeping in a loop and check the button state. + */ + while (true) { + chThdSleepMilliseconds(500); + } +} |