main.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. ChibiOS - Copyright (C) 2016..2017 Theodore Ateba
  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. #include "ch.h"
  15. /*
  16. * UART 1 configuration structure.
  17. */
  18. const UARTConfig uartConf = {
  19. NULL, /* UART transmission buffer callback. */
  20. NULL, /* UART physical end of transmission callback. */
  21. NULL, /* UART Receiver receiver filled callback. */
  22. NULL, /* UART caracter received callback. */
  23. NULL, /* UART received error callback. */
  24. 38400, /* UART baudrate. */
  25. };
  26. THD_WORKING_AREA(waThread1, 32);
  27. THD_FUNCTION(Thread1, arg) {
  28. (void)arg;
  29. while (true) {
  30. palTogglePad(IOPORT2, PORTB_LED1);
  31. uartStartSend(&UARTD1, 30, (const void *) "ChibiOS PORT on ATtiny-167!.\n\r");
  32. chThdSleepMilliseconds(1000);
  33. }
  34. }
  35. /*
  36. * Threads static table, one entry per thread. The number of entries must
  37. * match NIL_CFG_NUM_THREADS.
  38. */
  39. THD_TABLE_BEGIN
  40. THD_TABLE_ENTRY(waThread1, "blinker", Thread1, NULL)
  41. THD_TABLE_END
  42. /*
  43. * Application entry point.
  44. */
  45. int main(void) {
  46. /*
  47. * System initializations.
  48. * - HAL initialization, this also initializes the configured device drivers
  49. * and performs the board-specific initializations.
  50. * - Kernel initialization, the main() function becomes a thread and the
  51. * RTOS is active.
  52. */
  53. halInit();
  54. chSysInit();
  55. /*
  56. * Initialize the UART interface.
  57. */
  58. uartInit();
  59. /*
  60. * Start the Uart 1 interface.
  61. */
  62. uartStart(&UARTD1, &uartConf);
  63. /*
  64. * Send an message via the UART 1 interface.
  65. */
  66. uartStartSend(&UARTD1, 15, (const void *) "Hello world!.\n\r");
  67. /*
  68. * This is now the idle thread loop, you may perform here a low priority
  69. * task but you must never try to sleep or wait in this loop. Note that
  70. * this tasks runs at the lowest priority level so any instruction added
  71. * here will be executed after all other tasks have been started.
  72. */
  73. while (true) {
  74. }
  75. }