bsp.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*****************************************************************************
  2. * Product: Console-based BSP, MinGW
  3. * Last updated for version 5.6.0
  4. * Last updated on 2015-12-18
  5. *
  6. * Q u a n t u m L e a P s
  7. * ---------------------------
  8. * innovating embedded systems
  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 "bsp.h"
  36. #include "safe_std.h" /* portable "safe" <stdio.h>/<string.h> facilities */
  37. #include <stdlib.h>
  38. //Q_DEFINE_THIS_FILE
  39. /*..........................................................................*/
  40. void BSP_init(int argc, char *argv[]) {
  41. (void)argc; /* unused parameter */
  42. (void)argv; /* unused parameter */
  43. }
  44. /*..........................................................................*/
  45. void QF_onStartup(void) {
  46. QF_setTickRate(BSP_TICKS_PER_SEC, 30); /* set the desired tick rate */
  47. QF_consoleSetup();
  48. }
  49. /*..........................................................................*/
  50. void QF_onCleanup(void) {
  51. PRINTF_S("\n%s\n", "Bye! Bye!");
  52. QF_consoleCleanup();
  53. }
  54. /*..........................................................................*/
  55. void QF_onClockTick(void) {
  56. int ch;
  57. QTIMEEVT_TICK_X(0U, &l_clock_tick); /* perform the QF clock tick processing */
  58. ch = QF_consoleGetKey();
  59. if (ch != 0) { /* any key pressed? */
  60. BSP_onKeyboardInput(ch);
  61. }
  62. }
  63. /*..........................................................................*/
  64. Q_NORETURN Q_onAssert(char const * const module, int_t const loc) {
  65. FPRINTF_S(stderr, "Assertion failed in %s:%d", module, loc);
  66. QF_onCleanup();
  67. exit(-1);
  68. }