nrfx_temp.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef NRFX_TEMP_H__
  2. #define NRFX_TEMP_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "nrf_temp.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /**
  10. * @brief Macro for setting @ref nrfx_temp_config_t to default settings.
  11. */
  12. #define NRFX_TEMP_DEFAULT_CONFIG \
  13. { \
  14. .interrupt_priority = NRFX_TEMP_CONFIG_IRQ_PRIORITY \
  15. }
  16. /**
  17. * @brief temperature measurement Driver event types.
  18. */
  19. typedef enum
  20. {
  21. NRFX_TEMP_EVT_NULL,
  22. NRFX_TEMP_EVT_DATARDY ///< Event generated when the buffer is filled with samples.
  23. } nrfx_temp_evt_type_t;
  24. /**
  25. * @brief temperature measurement converter driver event structure.
  26. */
  27. typedef struct
  28. {
  29. nrfx_temp_evt_type_t type; ///< Event type.
  30. int32_t data;
  31. } nrfx_temp_evt_t;
  32. /**
  33. * @brief TEMP event handler.
  34. *
  35. * @param[in] p_event Pointer to an TEMP event. The event structure is allocated on
  36. * the stack, so it is valid only within the context of
  37. * the event handler.
  38. */
  39. typedef void (* nrfx_temp_event_handler_t)(nrfx_temp_evt_t const * p_event);
  40. /**
  41. * @brief temperature measurement converter driver configuration structure.
  42. */
  43. typedef struct
  44. {
  45. uint8_t interrupt_priority; ///< Interrupt priority.
  46. } nrfx_temp_config_t;
  47. /** @brief TEMP control block.*/
  48. typedef struct
  49. {
  50. nrfx_temp_event_handler_t event_handler; ///< Event handler function pointer.
  51. nrfx_drv_state_t state; ///< Driver initialization state.
  52. int32_t *data;
  53. } nrfx_temp_cb_t;
  54. /**
  55. * @brief Function for initializing the TEMP.
  56. *
  57. * @param[in] p_config Pointer to the structure with initial configuration.
  58. * @param[in] event_handler Event handler provided by the user.
  59. * Must not be NULL.
  60. *
  61. * @retval NRFX_SUCCESS If initialization was successful.
  62. * @retval NRFX_ERROR_INVALID_STATE If the driver is already initialized.
  63. */
  64. nrfx_err_t nrfx_temp_init(nrfx_temp_config_t const * p_config,
  65. nrfx_temp_event_handler_t event_handler);
  66. /**
  67. * @brief Function for uninitializing the TEMP.
  68. *
  69. * This function stops all ongoing conversions and disables all channels.
  70. */
  71. void nrfx_temp_uninit(void);
  72. /**
  73. * @brief Function for start the TEMP.
  74. *
  75. *
  76. */
  77. nrfx_err_t nrfx_temp_start(void);
  78. /**
  79. * @brief Function for stop the TEMP.
  80. *
  81. *
  82. */
  83. nrfx_err_t nrfx_temp_stop(void);
  84. extern float temp_value;
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif // NRFX_TEMP_H__
  89. /** @} */