main.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "hal.h"
  14. /*
  15. * Application entry point.
  16. */
  17. int main(void) {
  18. /*
  19. * System initializations.
  20. * - HAL initialization, this also initializes the configured device drivers
  21. * and performs the board-specific initializations.
  22. */
  23. halInit();
  24. /*
  25. * Enabling interrupts, initialization done.
  26. */
  27. osalSysEnable();
  28. /*
  29. * Activates the serial driver 2 using the driver default configuration.
  30. * PA2(TX) and PA3(RX) are routed to USART2.
  31. */
  32. sdStart(&SD2, NULL);
  33. palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
  34. palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));
  35. /*
  36. * Normal main() thread activity, in this demo it just performs
  37. * a shell respawn upon its termination.
  38. */
  39. while (true) {
  40. chnWriteTimeout(&SD2, (uint8_t *)"Hello World!\r\n", 14, TIME_INFINITE);
  41. palSetPad(GPIOD, GPIOD_LED3); /* Orange. */
  42. osalThreadSleepMilliseconds(500);
  43. palClearPad(GPIOD, GPIOD_LED3); /* Orange. */
  44. osalThreadSleepMilliseconds(500);
  45. }
  46. }