main.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #include "ch.h"
  14. #include "hal.h"
  15. #include "irq_storm.h"
  16. /*
  17. * GPT4 configuration.
  18. */
  19. static const GPTConfig gpt4cfg = {
  20. 1000000, /* 1MHz timer clock.*/
  21. irq_storm_gpt1_cb, /* Timer callback.*/
  22. 0,
  23. 0
  24. };
  25. /*
  26. * GPT3 configuration.
  27. */
  28. static const GPTConfig gpt3cfg = {
  29. 1000000, /* 1MHz timer clock.*/
  30. irq_storm_gpt2_cb, /* Timer callback.*/
  31. 0,
  32. 0
  33. };
  34. /*
  35. * IRQ Storm configuration.
  36. */
  37. static const irq_storm_config_t irq_storm_config = {
  38. (BaseSequentialStream *)&SD1,
  39. GPIOI,
  40. GPIOI_ARD_D13,
  41. &GPTD4,
  42. &GPTD3,
  43. &gpt4cfg,
  44. &gpt3cfg,
  45. STM32_SYSCLK
  46. };
  47. /*
  48. * Application entry point.
  49. */
  50. int main(void) {
  51. /*
  52. * System initializations.
  53. * - HAL initialization, this also initializes the configured device drivers
  54. * and performs the board-specific initializations.
  55. * - Kernel initialization, the main() function becomes a thread and the
  56. * RTOS is active.
  57. */
  58. halInit();
  59. chSysInit();
  60. /* Prepares the Serial driver 2.*/
  61. sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
  62. palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
  63. palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));
  64. palSetLineMode(LINE_ARD_D13, PAL_MODE_OUTPUT_PUSHPULL);
  65. /* Running the test.*/
  66. irq_storm_execute(&irq_storm_config);
  67. /* Normal main() thread activity, nothing in this test.*/
  68. while (true) {
  69. chThdSleepMilliseconds(5000);
  70. }
  71. }