main.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 "chprintf.h"
  16. BaseSequentialStream * chp = (BaseSequentialStream *) &SD1;
  17. static void gpt3cb(GPTDriver *gptp) {
  18. palTogglePad(IOPORT2, 7);
  19. }
  20. static GPTConfig gpt3cfg = {
  21. 1000, /* Timer clock. */
  22. gpt3cb /* Timer callback. */
  23. };
  24. /*
  25. * Application entry point.
  26. */
  27. int main(void) {
  28. /*
  29. * System initializations.
  30. * - HAL initialization, this also initializes the configured device drivers
  31. * and performs the board-specific initializations.
  32. * - Kernel initialization, the main() function becomes a thread and the
  33. * RTOS is active.
  34. */
  35. halInit();
  36. chSysInit();
  37. palSetPadMode(IOPORT2, 7, PAL_MODE_OUTPUT_PUSHPULL);
  38. sdStart(&SD1, NULL);
  39. gptStart(&GPTD3, &gpt3cfg);
  40. gptStartContinuous(&GPTD3, 500);
  41. while (1) {
  42. chprintf(chp, "OCR3A: %d, TCCR3B: %x, period: %d, counter: %d , TCNT3: %d\r\n",
  43. OCR3A,
  44. TCCR3B,
  45. GPTD3.period,
  46. GPTD3.counter,
  47. TCNT3);
  48. chThdSleepMilliseconds(100);
  49. }
  50. }