hal_gpt.dox 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /**
  14. * @defgroup GPT GPT Driver
  15. * @brief Generic GPT Driver.
  16. * @details This module implements a generic GPT (General Purpose Timer)
  17. * driver. The timer can be programmed in order to trigger callbacks
  18. * after a specified time period or continuously with a specified
  19. * interval.
  20. * @pre In order to use the GPT driver the @p HAL_USE_GPT option
  21. * must be enabled in @p halconf.h.
  22. *
  23. * @section gpt_1 Driver State Machine
  24. * The driver implements a state machine internally, not all the driver
  25. * functionalities can be used in any moment, any transition not explicitly
  26. * shown in the following diagram has to be considered an error and shall
  27. * be captured by an assertion (if enabled).
  28. * @dot
  29. digraph example {
  30. rankdir="LR";
  31. node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true",
  32. width="0.9", height="0.9"];
  33. edge [fontname=Helvetica, fontsize=8];
  34. stop [label="GPT_STOP\nLow Power"];
  35. uninit [label="GPT_UNINIT", style="bold"];
  36. ready [label="GPT_READY\nClock Enabled"];
  37. continuous [label="GPT_CONT..S\nContinuous\nMode"];
  38. oneshot [label="GPT_ONESHOT\nOne Shot\nMode"];
  39. uninit -> stop [label=" gptInit()", constraint=false];
  40. stop -> stop [label="\ngptStop()"];
  41. stop -> ready [label="\ngptStart()"];
  42. ready -> stop [label="\ngptStop()"];
  43. ready -> ready [label="\ngptStart()"];
  44. ready -> continuous [label="\ngptStartContinuous()"];
  45. continuous -> ready [label="\ngptStopTimer()"];
  46. continuous -> continuous [label=">callback<"];
  47. ready -> oneshot [label="\ngptStartOneShot()\ngptPolledDelay()"];
  48. oneshot -> ready [label="\n>callback<\nor\nDelay Over"];
  49. }
  50. * @enddot
  51. *
  52. * @section gpt_2 GPT Operations.
  53. * This driver abstracts a generic timer composed of:
  54. * - A clock prescaler.
  55. * - A main up counter.
  56. * - A comparator register that resets the main counter to zero when the limit
  57. * is reached. A callback is invoked when this happens.
  58. * .
  59. * The timer can operate in three different modes:
  60. * - <b>Continuous Mode</b>, a periodic callback is invoked until the driver
  61. * is explicitly stopped.
  62. * - <b>One Shot Mode</b>, a callback is invoked after the programmed period
  63. * and then the timer automatically stops.
  64. * - <b>Delay Mode</b>, the timer is used for inserting a brief delay into
  65. * the execution flow, no callback is invoked in this mode.
  66. * .
  67. * @ingroup HAL_NORMAL_DRIVERS
  68. */