-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMCP4725_ex.h
76 lines (61 loc) · 2.48 KB
/
MCP4725_ex.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*!\file MCP4725_ex.h
** \author SMFSW
** \copyright MIT (c) 2017-2024, SMFSW
** \brief MCP4725 Driver extensions
** \details MCP4725: 12-Bit Digital-to-Analog Converter with EEPROM Memory
**/
/****************************************************************/
#ifndef __MCP4725_EX_H__
#define __MCP4725_EX_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "sarmfsw.h"
#include "MCP4725.h"
#if defined(HAL_I2C_MODULE_ENABLED)
/****************************************************************/
// *****************************************************************************
// Section: Constants
// *****************************************************************************
#define MCP4725__RESET 0x06 //!< General call reset command
#define MCP4725__WAKEUP 0x09 //!< General call wake up command
// *****************************************************************************
// Section: Interface Routines
// *****************************************************************************
/*!\brief Write Command to MCP4725 peripheral
** \param[in] pCpnt - Pointer to MCP4725 component
** \param[in] val - Raw DAC value for MCP4725 to write
** \return FctERR - error code
**/
FctERR NONNULL__ MCP4725_Write_Command(MCP4725_t * const pCpnt, const uint16_t val);
/*!\brief General call reset function for MCP4725
** \param[in] hi2c - pointer to general call I2C instance
** \return FctERR - error code
**/
__INLINE FctERR NONNULL_INLINE__ MCP4725_Reset(I2C_HandleTypeDef * const hi2c) {
return MCP4725_General_Call(hi2c, MCP4725__RESET); }
/*!\brief General call wake up function for MCP4725
** \param[in] hi2c - pointer to general call I2C instance
** \return FctERR - error code
**/
__INLINE FctERR NONNULL_INLINE__ MCP4725_WakeUp(I2C_HandleTypeDef * const hi2c) {
return MCP4725_General_Call(hi2c, MCP4725__WAKEUP); }
/*!\brief Read DAC value
** \param[in] pCpnt - Pointer to MCP4725 component
** \param[in] val - pointer to DAC value to read to
** \return FctERR - error code
**/
FctERR NONNULL__ MCP4725_Read_DAC(MCP4725_t * const pCpnt, uint16_t * val);
/*!\brief Read DAC state
** \param[in] pCpnt - Pointer to MCP4725 component
** \param[in] state - pointer to state to read to (0 Ready, 1 Busy)
** \return FctERR - error code
**/
FctERR NONNULL__ MCP4725_Read_State(MCP4725_t * const pCpnt, bool * state);
/****************************************************************/
#endif
#ifdef __cplusplus
}
#endif
#endif /* __MCP4725_EX_H__ */
/****************************************************************/