aboutsummaryrefslogtreecommitdiffstats
path: root/demos/STM32/RT-STM32F407-DISCOVERY-fault_handlers/main.c
blob: f5f658431fa9c79f62d8a677a9cfadedbf692aef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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);
  }
}