main.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 "portab.h"
  16. void txend1(UARTDriver *uartp) {
  17. (void)uartp;
  18. }
  19. void txend2(UARTDriver *uartp) {
  20. (void)uartp;
  21. }
  22. void rxend(UARTDriver *uartp) {
  23. (void)uartp;
  24. }
  25. void rxchar(UARTDriver *uartp, uint16_t c) {
  26. (void)uartp;
  27. (void)c;
  28. }
  29. void rxerr(UARTDriver *uartp, uartflags_t e) {
  30. (void)uartp;
  31. (void)e;
  32. }
  33. /*
  34. * Application entry point.
  35. */
  36. int main(void) {
  37. static const char teststr[] = "0123456789ABCDEF";
  38. msg_t msg;
  39. size_t sz;
  40. /*
  41. * System initializations.
  42. * - HAL initialization, this also initializes the configured device drivers
  43. * and performs the board-specific initializations.
  44. * - Kernel initialization, the main() function becomes a thread and the
  45. * RTOS is active.
  46. */
  47. halInit();
  48. chSysInit();
  49. /*
  50. * Board-dependent setup code.
  51. */
  52. portab_setup();
  53. /*
  54. * Activates the UART driver 2.
  55. */
  56. uartStart(&PORTAB_UART1, &uart_cfg_1);
  57. /*
  58. * Blocking API test, send and restart send.
  59. */
  60. sz = 3;
  61. msg = uartSendTimeout(&PORTAB_UART1, &sz, teststr, TIME_INFINITE);
  62. if (msg != MSG_OK)
  63. chSysHalt("invalid return code");
  64. sz = 12;
  65. msg = uartSendTimeout(&PORTAB_UART1, &sz, teststr, TIME_INFINITE);
  66. if (msg != MSG_OK)
  67. chSysHalt("invalid return code");
  68. sz = 2;
  69. msg = uartSendTimeout(&PORTAB_UART1, &sz, teststr, TIME_INFINITE);
  70. if (msg != MSG_OK)
  71. chSysHalt("invalid return code");
  72. sz = 16;
  73. msg = uartSendFullTimeout(&PORTAB_UART1, &sz, teststr, TIME_INFINITE);
  74. if (msg != MSG_OK)
  75. chSysHalt("invalid return code");
  76. sz = 7;
  77. msg = uartSendFullTimeout(&PORTAB_UART1, &sz, teststr, TIME_INFINITE);
  78. if (msg != MSG_OK)
  79. chSysHalt("invalid return code");
  80. /*
  81. * Normal main() thread activity.
  82. */
  83. while (true) {
  84. chThdSleepMilliseconds(500);
  85. }
  86. }