main.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * GPT1 configuration.
  18. */
  19. static const GPTConfig gpt1cfg = {
  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. GPIOC,
  40. GPIOC_LED4,
  41. &GPTD1,
  42. &GPTD3,
  43. &gpt1cfg,
  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 1.*/
  61. sdStart(&SD1, NULL);
  62. palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1)); /* USART1 TX. */
  63. palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(1)); /* USART1 RX. */
  64. /* Running the test.*/
  65. irq_storm_execute(&irq_storm_config);
  66. /* Normal main() thread activity, nothing in this test.*/
  67. while (true) {
  68. chThdSleepMilliseconds(5000);
  69. }
  70. }