1:
9:
10:
14:
15:
#ifndef _I2CPRM_H_
16:
#define _I2CPRM_H_
17:
18:
19:
#include <stdint.h>
20:
#include "lib_common/AG903_common.h"
21:
#include "register/AG903_i2creg.h"
22:
23:
#ifdef __cplusplus
24:
extern "C" {
25:
#endif
26:
27:
28:
#define AG903_I2C_CH_NUM (2)
29:
30:
#define AG903_I2C_CR_STARTIEN_BIT (1<<
AG903_IICn_CR_STARTI_EN_POS)
31:
#define AG903_I2C_CR_ALIEN_BIT (1<<
AG903_IICn_CR_ALI_EN_POS)
32:
#define AG903_I2C_CR_SAMIEN_BIT (1<<
AG903_IICn_CR_SAMI_EN_POS)
33:
#define AG903_I2C_CR_STOPIEN_BIT (1<<
AG903_IICn_CR_STOPI_EN_POS)
34:
#define AG903_I2C_CR_BERRIEN_BIT (1<<
AG903_IICn_CR_BERRI_EN_POS)
35:
#define AG903_I2C_CR_DRIEN_BIT (1<<
AG903_IICn_CR_DRI_EN_POS)
36:
#define AG903_I2C_CR_DTIEN_BIT (1<<
AG903_IICn_CR_DTI_EN_POS)
37:
#define AG903_I2C_CR_TBEN_BIT (1<<
AG903_IICn_CR_TB_EN_POS)
38:
#define AG903_I2C_CR_ACKNACK_BIT (1<<
AG903_IICn_CR_NACK_POS)
39:
#define AG903_I2C_CR_STOP_BIT (1<<
AG903_IICn_CR_STOP_POS)
40:
#define AG903_I2C_CR_START_BIT (1<<
AG903_IICn_CR_START_POS)
41:
#define AG903_I2C_CR_GCEN_BIT (1<<
AG903_IICn_CR_GC_EN_POS)
42:
#define AG903_I2C_CR_SCLEN_BIT (1<<
AG903_IICn_CR_SCL_EN_POS)
43:
#define AG903_I2C_CR_I2CEN_BIT (1<<
AG903_IICn_CR_I2C_EN_POS)
44:
#define AG903_I2C_CR_I2CRST_BIT (1<<
AG903_IICn_CR_I2C_RST_POS)
45:
46:
47:
#define AG903_I2C_CR_ALLINT_BIT (
AG903_I2C_CR_STARTIEN_BIT|
AG903_I2C_CR_ALIEN_BIT|
AG903_I2C_CR_SAMIEN_BIT|
AG903_I2C_CR_STOPIEN_BIT|
AG903_I2C_CR_BERRIEN_BIT|
AG903_I2C_CR_DRIEN_BIT|
AG903_I2C_CR_DTIEN_BIT)
48:
49:
50:
#define AG903_I2C_CR_ALLCTRL_BIT (
AG903_I2C_CR_TBEN_BIT|
AG903_I2C_CR_ACKNACK_BIT|
AG903_I2C_CR_STOP_BIT|
AG903_I2C_CR_START_BIT|
AG903_I2C_CR_GCEN_BIT|
AG903_I2C_CR_SCLEN_BIT|
AG903_I2C_CR_I2CEN_BIT)
51:
52:
#define AG903_I2C_SR_SAL_BIT (1<<
AG903_IICn_SR_SAL_POS)
53:
#define AG903_I2C_SR_DDA_BIT (1<<
AG903_IICn_SR_DDA_POS)
54:
#define AG903_I2C_SR_ARA_BIT (1<<
AG903_IICn_SR_ARA_POS)
55:
#define AG903_I2C_SR_RESUME_BIT (1<<
AG903_IICn_SR_RESUME_POS)
56:
#define AG903_I2C_SR_SUSPEND_BIT (1<<
AG903_IICn_SR_SUSPEND_POS)
57:
#define AG903_I2C_SR_ALERT_BIT (1<<
AG903_IICn_SR_ALERT_POS)
58:
#define AG903_I2C_SR_TOUTMAX_BIT (1<<
AG903_IICn_SR_TOUTMax_POS)
59:
#define AG903_I2C_SR_TOUTMIN_BIT (1<<
AG903_IICn_SR_TOUTMin_POS)
60:
#define AG903_I2C_SR_MEXT_BIT (1<<
AG903_IICn_SR_MEXT_POS)
61:
#define AG903_I2C_SR_SEXT_BIT (1<<
AG903_IICn_SR_SEXT_POS)
62:
#define AG903_I2C_SR_START_BIT (1<<
AG903_IICn_SR_START_POS)
63:
#define AG903_I2C_SR_AL_BIT (1<<
AG903_IICn_SR_AL_POS)
64:
#define AG903_I2C_SR_GC_BIT (1<<
AG903_IICn_SR_GC_POS)
65:
#define AG903_I2C_SR_SAM_BIT (1<<
AG903_IICn_SR_SAM_POS)
66:
#define AG903_I2C_SR_STOP_BIT (1<<
AG903_IICn_SR_STOP_POS)
67:
#define AG903_I2C_SR_BERR_BIT (1<<
AG903_IICn_SR_BERR_POS)
68:
#define AG903_I2C_SR_DR_BIT (1<<
AG903_IICn_SR_DR_POS)
69:
#define AG903_I2C_SR_DT_BIT (1<<
AG903_IICn_SR_DT_POS)
70:
#define AG903_I2C_SR_BB_BIT (1<<
AG903_IICn_SR_BB_POS)
71:
#define AG903_I2C_SR_I2CB_BIT (1<<
AG903_IICn_SR_I2CB_POS)
72:
#define AG903_I2C_SR_ACK_BIT (1<<
AG903_IICn_SR_ACK_POS)
73:
#define AG903_I2C_SR_RW_BIT (1<<
AG903_IICn_SR_RW_POS)
74:
75:
void AG903_I2CPrmResetController(uint8_t ch);
76:
void AG903_I2CPrmGetResetStatus(uint8_t ch, uint8_t* status);
77:
void AG903_I2CPrmSetControl(uint8_t ch, uint32_t setbit);
78:
void AG903_I2CPrmClearControl(uint8_t ch, uint32_t clrbit);
79:
void AG903_I2CPrmGetStatus(uint8_t ch, uint32_t* status);
80:
void AG903_I2CPrmWriteData(uint8_t ch, uint8_t data);
81:
void AG903_I2CPrmReadData(uint8_t ch, uint8_t* data);
82:
void AG903_I2CPrmSetClockDivision(uint8_t ch, uint32_t cdr);
83:
void AG903_I2CPrmSetGlitchSuppression(uint8_t ch, uint16_t tsr, uint8_t gsr);
84:
void AG903_I2CPrmSetExtAddrMode(uint8_t ch);
85:
void AG903_I2CPrmClearExtAddrMode(uint8_t ch);
86:
void AG903_I2CPrmSetSlaveAddr(uint8_t ch, uint16_t saddr);
87:
88:
#ifdef __cplusplus
89: }
90:
#endif
91:
#endif