regular_conversion_manager.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. ******************************************************************************
  3. * @file regular_conversion_manager.h
  4. * @author Motor Control SDK Team, ST Microelectronics
  5. * @brief This file contains all definitions and functions prototypes for the
  6. * regular_conversion_manager component of the Motor Control SDK.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under Ultimate Liberty license
  14. * SLA0044, the "License"; You may not use this file except in compliance with
  15. * the License. You may obtain a copy of the License at:
  16. * www.st.com/SLA0044
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __regular_conversion_manager_h
  22. #define __regular_conversion_manager_h
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /* __cplusplus */
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "stdint.h"
  28. #include "stdbool.h"
  29. #include "mc_stm_types.h"
  30. /** @addtogroup MCSDK
  31. * @{
  32. */
  33. /** @addtogroup RCM
  34. * @{
  35. */
  36. /* Exported types ------------------------------------------------------------*/
  37. /**
  38. * @brief RegConv_t contains all the parameters required to execute a regular conversion
  39. *
  40. * it is used by all regular_conversion_manager's client
  41. *
  42. */
  43. typedef struct
  44. {
  45. ADC_TypeDef * regADC;
  46. uint8_t channel;
  47. uint32_t samplingTime;
  48. } RegConv_t;
  49. typedef enum
  50. {
  51. RCM_USERCONV_IDLE,
  52. RCM_USERCONV_REQUESTED,
  53. RCM_USERCONV_EOC
  54. }RCM_UserConvState_t;
  55. typedef void (*RCM_exec_cb_t)(uint8_t handle, uint16_t data, void *UserData);
  56. /* Exported functions ------------------------------------------------------- */
  57. /* Function used to register a regular conversion */
  58. uint8_t RCM_RegisterRegConv(RegConv_t * regConv);
  59. /* Function used to register a regular conversion with a callback attached*/
  60. uint8_t RCM_RegisterRegConv_WithCB (RegConv_t * regConv, RCM_exec_cb_t fctCB, void *data);
  61. /* Function used to execute an already registered regular conversion */
  62. uint16_t RCM_ExecRegularConv (uint8_t handle);
  63. /* select the handle conversion to be executed during the next call to RCM_ExecUserConv */
  64. bool RCM_RequestUserConv(uint8_t handle);
  65. /* return the latest user conversion value*/
  66. uint16_t RCM_GetUserConv(void);
  67. /* Must be called by MC_TASK only to grantee proper scheduling*/
  68. void RCM_ExecUserConv (void);
  69. /* return the state of the user conversion state machine*/
  70. RCM_UserConvState_t RCM_GetUserConvState(void);
  71. /**
  72. * @}
  73. */
  74. /**
  75. * @}
  76. */
  77. #ifdef __cplusplus
  78. }
  79. #endif /* __cpluplus */
  80. #endif /* __regular_conversion_manager_h */
  81. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/