⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i2c_interface.h

📁 基于MMA7260QR2的跌落检查程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/*===== I2c_Disable =====*/
/**
@brief  The function is called to disable I2C module.

@param  None

@return parameter of type I2cErr_t with following possible values:

    gI2cErrModuleBusy_c      - if I2C module is busy
    gI2cErrModuleIsDis_c     - if the I2C module is already disabled
    gI2CErrNoError_c         - in rest

 Revision history:
      Date                          Author                            Comments
   ----------               ----------------------                    -------
   16.07.2007                       B04839                             Created
*/
/*===============================================================================================*/
extern I2cErr_t I2c_Disable(void);

/*================================================================================================*/
/*===== I2c_RecoverBus =====*/
/**
@brief  The function is called to recover I2C bus.
        Force the I2C module to become the I2C bus master and drive the SCL signal (even though SDA may
        already be driven, which indicates that the bus is busy)

@param  None

@return parameter of type I2cErr_t with following possible values:

    gI2cErrModuleIsDis_c     - if the I2C module is previously disabled; the function must be called 
                               when the module is enabled.
    gI2CErrNoError_c         - in rest

 Revision history:
      Date                          Author                            Comments
   ----------               ----------------------                    -------
   16.07.2007                       B04839                             Created
*/
/*===============================================================================================*/
extern I2cErr_t I2c_RecoverBus(void);

/*================================================================================================*/
/*===== I2c_SetCallbackFunction =====*/
/**
@brief  Set pointer to a data containing the address of the callback function for the I2C events.

@param  I2cCallbackFunction_t pI2cCallback  - input parameter: pointer to a callback function.

@return parameter of type I2cErr_t with following possible values:

    gI2cErrModuleIsDis_c     - if the I2C module is previously disabled. The function must be called 
                               when the module is enabled.
    gI2CErrNoError_c         - in rest

 Revision history:
      Date                          Author                            Comments
   ----------               ----------------------                    -------
   16.07.2007                       B04839                             Created
*/
/*===============================================================================================*/
extern I2cErr_t I2c_SetCallbackFunction(I2cCallbackFunction_t pI2cCallback);

/*================================================================================================*/
/*===== I2c_SetConfig =====*/
/**
@brief  Set the parameters for the I2C peripheral (enable/disable interrupts, enable/disable 
        broadcast capability, slave address, set I2C frequency divider and I2C sampling rate).

@param  I2cConfig_t *pI2cConfig             - input parameter: pointer to a structure which contain the 
                                              configuration parameters.

@return parameter of type I2cErr_t with following possible values:

    gI2cErrModuleIsDis_c     - if the I2C module is previously disabled; the function must be called 
                               when the module is enabled.
    gI2cErrNullPointer_c     - if pI2cConfig parameter is NULL
    gI2CErrNoError_c         - in rest

 Revision history:
      Date                          Author                            Comments
   ----------               ----------------------                    -------
   16.07.2007                       B04839                             Created
*/
/*===============================================================================================*/
extern I2cErr_t I2c_SetConfig(I2cConfig_t* pI2cConfig);

/*================================================================================================*/
/*===== I2c_GetStatus =====*/
/**
@brief  Get the status of the I2C module.

@param  uint8_t* status                     - output parameter: pointer to data where the status of the 
                                              I2C bus will be written.

@return parameter of type I2cErr_t with following possible values:

    gI2cErrNullPointer_c     - if status parameter is NULL
    gI2CErrNoError_c         - in rest

 Revision history:
      Date                          Author                            Comments
   ----------               ----------------------                    -------
   16.07.2007                       B04839                             Created
*/
/*===============================================================================================*/
extern I2cErr_t I2c_GetStatus(uint8_t* status);

/*================================================================================================*/
/*===== I2c_CancelTransfer =====*/
/**
@brief  Cancel transmitting/receiving data.

@param  I2cTransferType_t transferType      - input parameter: type of the trasfer that will be canceled.

@return parameter of type I2cErr_t with following possible values:
    gI2cErrModuleIsDis_c     - if the I2C module is previously disabled. The function must be called when
                               the module is enabled.
    gI2cErrInvalidOp_c       - if the function is called when the module is master and interrupts are not 
                               enabled.
    gI2CErrNoError_c         - in rest

 Revision history:
      Date                          Author                            Comments
   ----------               ----------------------                    -------
   16.07.2007                       B04839                             Created
*/
/*===============================================================================================*/
extern I2cErr_t I2c_CancelTransfer(I2cTransferType_t transferType);

/*================================================================================================*/
/*===== I2c_SendData =====*/
/**
@brief  Send a sequence of bytes to the device specified by slaveDestAddr parameter (if master mode 
        is used) or to the device which will address the module to read data from (if slave mode is 
        used). The function attempts to send dataLength bytes which are read from i2cBuffData buffer.

@param  uint8_t slaveDestAddr               - input parameter: destination  address  of slave device
                                              (only for module working in master mode).
@param  uint8_t* i2cBuffData                - input parameter: pointer to a memory location wherefrom 
                                              data will be sent.
@param  uint16_t dataLength                 - input parameter: length of data.
@param  I2cTransferMode_t transferMode      - input parameter: type of data transfer (master/slave).

@return parameter of type I2cErr_t with following possible values:

    gI2cErrModuleIsDis_c     - if the I2C module is previously disabled. The function must be called when
                               the module is enabled.
    gI2CErrNullPointer_c
    gI2cErrInvalidOp_c       - if the function is called when the module is slave and interrupts are not 
                               enabled.
    gI2cErrModuleBusy_c      - if the previous transaction is not completed.
    gI2cErrBusBusy_c         - if the bus is busy (there is another device that is transmitting data).
    gI2CErrNoAckResp_c       - if the receiving device doesn't acknowledge at least one byte sent during transmission.
    gI2cErrNoDevResp_c       - if there is no slave device with address slaveDestAddr.
    gI2CErrNoError_c         - in rest

 Revision history:
      Date                          Author                            Comments
   ----------               ----------------------                    -------
   16.07.2007                       B04839                             Created
*/
/*===============================================================================================*/
extern I2cErr_t I2c_SendData(uint8_t slaveDestAddr, uint8_t* i2cBuffData, uint16_t dataLength, I2cTransferMode_t transferMode);


/*================================================================================================*/
/*===== I2c_ReceiveData =====*/
/**
@brief  Receive a sequence of bytes from the device specified by slaveDestAddr parameter (if master mode is used) 
        or from the device which will address the module (if slave mode is used).

@param  uint8_t slaveDestAddr               - input parameter: destination  address  of slave device
                                              (only for module working in master mode).
@param  uint8_t* i2cBuffData                - input parameter: pointer to a memory location wherefrom 
                                              data will be sent.
@param  uint16_t dataLength                 - input parameter: length of data.
@param  I2cTransferMode_t transferMode      - input parameter: type of data transfer.

@return parameter of type I2cErr_t with following possible values:

    gI2cErrModuleIsDis_c     - if the I2C module is previously disabled. The function must be called when
                               the module is enabled.
    gI2CErrNullPointer_c
    gI2cErrInvalidOp_c       - if the function is called when the module is slave and interrupts are not 
                               enabled.
    gI2cErrModuleBusy_c      - if the previous transaction is not completed.
    gI2cErrBusBusy_c         - if the bus is busy (there is another device that is transmitting data).
    gI2CErrNoAckResp_c       - if the receiving device doesn't acknowledge at least one byte sent during transmission.
    gI2cErrNoDevResp_c       - if there is no slave device with address slaveDestAddr.
    gI2CErrNoError_c         - in rest

 Revision history:
      Date                          Author                            Comments
   ----------               ----------------------                    -------
   16.07.2007                       B04839                             Created
*/
/*===============================================================================================*/
extern I2cErr_t I2c_ReceiveData(uint8_t slaveDestAddr, uint8_t* i2cBuffData, uint16_t dataLength, I2cTransferMode_t transferMode);

/*================================================================================================*/
/*===== I2c_Isr =====*/
/**
@brief  I2C interrupt service routine.

@param  None

@return None

 Revision history:
      Date                          Author                            Comments
   ----------               ----------------------                    -------
   16.07.2007                       B04839                             Created
*/
/*===============================================================================================*/
extern void I2c_Isr(void);

#endif /* _I2C_INTERFACE_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -