sensorsim.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. /** @file
  13. *
  14. * @defgroup ble_sdk_lib_sensorsim Sensor Data Simulator
  15. * @{
  16. * @ingroup ble_sdk_lib
  17. * @brief Functions for simulating sensor data.
  18. *
  19. * @details Currently only a triangular waveform simulator is implemented.
  20. */
  21. #ifndef SENSORSIM_H__
  22. #define SENSORSIM_H__
  23. #include <stdint.h>
  24. #include <stdbool.h>
  25. /**@brief Triangular waveform sensor simulator configuration. */
  26. typedef struct
  27. {
  28. uint32_t min; /**< Minimum simulated value. */
  29. uint32_t max; /**< Maximum simulated value. */
  30. uint32_t incr; /**< Increment between each measurement. */
  31. bool start_at_max; /**< TRUE is measurement is to start at the maximum value, FALSE if it is to start at the minimum. */
  32. } sensorsim_cfg_t;
  33. /**@brief Triangular waveform sensor simulator state. */
  34. typedef struct
  35. {
  36. uint32_t current_val; /**< Current sensor value. */
  37. bool is_increasing; /**< TRUE if the simulator is in increasing state, FALSE otherwise. */
  38. } sensorsim_state_t;
  39. /**@brief Function for initializing a triangular waveform sensor simulator.
  40. *
  41. * @param[out] p_state Current state of simulator.
  42. * @param[in] p_cfg Simulator configuration.
  43. */
  44. void sensorsim_init(sensorsim_state_t * p_state,
  45. const sensorsim_cfg_t * p_cfg);
  46. /**@brief Function for generating a simulated sensor measurement using a triangular waveform generator.
  47. *
  48. * @param[in,out] p_state Current state of simulator.
  49. * @param[in] p_cfg Simulator configuration.
  50. *
  51. * @return Simulator output.
  52. */
  53. uint32_t sensorsim_measure(sensorsim_state_t * p_state,
  54. const sensorsim_cfg_t * p_cfg);
  55. /**@brief Function for incrementing a simulated sensor measurement value.
  56. *
  57. * @param[in,out] p_state Current state of simulator.
  58. * @param[in] p_cfg Simulator configuration.
  59. *
  60. * @return Simulator output.
  61. */
  62. void sensorsim_increment(sensorsim_state_t * p_state,
  63. const sensorsim_cfg_t * p_cfg);
  64. /**@brief Function for decrementing a simulated sensor measurement value.
  65. *
  66. * @param[in,out] p_state Current state of simulator.
  67. * @param[in] p_cfg Simulator configuration.
  68. *
  69. * @return Simulator output.
  70. */
  71. void sensorsim_decrement(sensorsim_state_t * p_state,
  72. const sensorsim_cfg_t * p_cfg);
  73. #endif // SENSORSIM_H__
  74. /** @} */