main.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*****************************************************************************
  2. * Product: "Orthogonal Component" example, Console based
  3. * Last updated for version 6.4.0
  4. * Last updated on 2019-02-08
  5. *
  6. * Q u a n t u m L e a P s
  7. * ------------------------
  8. * Modern Embedded Software
  9. *
  10. * Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
  11. *
  12. * This program is open source software: you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as published
  14. * by the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * Alternatively, this program may be distributed and modified under the
  18. * terms of Quantum Leaps commercial licenses, which expressly supersede
  19. * the GNU General Public License and are specifically designed for
  20. * licensees interested in retaining the proprietary status of their code.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program. If not, see <www.gnu.org/licenses/>.
  29. *
  30. * Contact information:
  31. * <www.state-machine.com/licensing>
  32. * <info@state-machine.com>
  33. *****************************************************************************/
  34. #include "qpc.h"
  35. #include "alarm.h"
  36. #include "clock.h"
  37. #include "bsp.h"
  38. #include "safe_std.h" /* portable "safe" <stdio.h>/<string.h> facilities */
  39. Q_DEFINE_THIS_FILE
  40. /*..........................................................................*/
  41. int main(int argc, char *argv[]) {
  42. static QEvt const *l_alarmClockQSto[10]; /* queue storage for AlarmClock */
  43. static QF_MPOOL_EL(TimeEvt) l_smlPoolSto[10]; /* storage for small pool */
  44. PRINTF_S("Orthogonal Component pattern\nQP version: %s\n"
  45. "Press 'o' to turn the Alarm ON\n"
  46. "Press 'f' to turn the Alarm OFF\n"
  47. "Press '0'..'9' to set the Alarm time\n"
  48. "Press 'a' to set the Clock in 12-hour mode\n"
  49. "Press 'b' to set the Clock in 24-hour mode\n"
  50. "Press ESC to quit...\n",
  51. QP_VERSION_STR);
  52. BSP_init(argc, argv); /* initialize the BSP */
  53. QF_init(); /* initialize the framework and the underlying RT kernel */
  54. /* publish-subscribe not used, no call to QF_psInit() */
  55. /* initialize event pools... */
  56. QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
  57. /* instantiate and start the active objects... */
  58. AlarmClock_ctor();
  59. QACTIVE_START(APP_alarmClock, 1U,
  60. l_alarmClockQSto, Q_DIM(l_alarmClockQSto),
  61. (void *)0, 0U, (QEvt *)0);
  62. return QF_run(); /* run the QF application */
  63. }