mbed_wait_api.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /** \addtogroup platform */
  2. /** @{*/
  3. /**
  4. * \defgroup platform_wait_api wait_api functions
  5. * @{
  6. */
  7. /* mbed Microcontroller Library
  8. * Copyright (c) 2006-2013 ARM Limited
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. */
  22. #ifndef MBED_WAIT_API_H
  23. #define MBED_WAIT_API_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /** Generic wait functions.
  28. *
  29. * These provide simple NOP type wait capabilities.
  30. *
  31. * Example:
  32. * @code
  33. * #include "mbed.h"
  34. *
  35. * DigitalOut heartbeat(LED1);
  36. *
  37. * int main() {
  38. * while (1) {
  39. * heartbeat = 1;
  40. * wait(0.5);
  41. * heartbeat = 0;
  42. * wait(0.5);
  43. * }
  44. * }
  45. * @endcode
  46. */
  47. /** Waits for a number of seconds, with microsecond resolution (within
  48. * the accuracy of single precision floating point).
  49. *
  50. * @param s number of seconds to wait
  51. *
  52. * @note
  53. * If the RTOS is present, this function always spins to get the exact number of microseconds,
  54. * which potentially affects power (such as preventing deep sleep) and multithread performance.
  55. * You can avoid it by using Thread::wait().
  56. */
  57. void wait(float s);
  58. /** Waits a number of milliseconds.
  59. *
  60. * @param ms the whole number of milliseconds to wait
  61. *
  62. * @note
  63. * If the RTOS is present, this function always spins to get the exact number of microseconds,
  64. * which potentially affects power (such as preventing deep sleep) and multithread performance.
  65. * You can avoid it by using Thread::wait().
  66. */
  67. void wait_ms(int ms);
  68. /** Waits a number of microseconds.
  69. *
  70. * @param us the whole number of microseconds to wait
  71. *
  72. * @note
  73. * If the RTOS is present, this function always spins to get the exact number of microseconds,
  74. * which potentially affects power (such as preventing deep sleep) and multithread performance.
  75. */
  76. void wait_us(int us);
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif
  81. /** @}*/
  82. /** @}*/