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

📄 i2c.h

📁 STM32F10xx的LCD驱动源码
💻 H
字号:
/************************************************************************************
  File Name:I2C.h
Description:
**************************************************************************************/
#include "stm32f10x_lib.h"
#include "stm32f10x_map.h"

 
#define Reciver              1
#define Transmitter           !Reciver
#define Addring_Mode_10       1
#define Addring_Mode_7        !Addring_Mode_10
#define ERR_FLAG_ERR          1
#define ERR_FLAG_NOERR        !ERR_FLAG_ERR

/************************************************************************************8
Function Name:I2C_MasterIni()
     Function:To initiate the I2C controllor as an I2C master.
    Parameter:I2C_TypeDef *I2Cx:The target I2C controllor.
       Return:none
         Note:
*************************************************************************************/
void I2C_MasterIni(void);
/*********************************************************************************
Function Name:I2C_Start( )
     Function:This function will be used by the master to generate a start signal
    Parameter:I2C_TypeDef *I2Cx:The target I2C controllor.
       Return:none
         Note:
**********************************************************************************/
void I2C_Start(void);
/**********************************************************************************************************************************************
Function Name:Address_Sending( )
     Function:To send the slave address.
    Parameter:u8 Dataphase_Mode:Reciver or Transmitter
              u8 AddressHeader :In 10_bit address mode ,here is the address header.
              u8 Low_Address   :The address to be sent in 7_bit address mode or the lower 8 bits address to be sent in 10_bit address mode.
              u8 Addring_Mode  :Addring_Mode_10 to indicate here is a 10_bit address or Addring_Mode_7 to indicate here is a 7_bit address.
              I2C_TypeDef  I2Cx:The target I2C controllor.
       Return:none
         Note:
*********************************************************************************************************************************************/
void Address_Sending(u8 Dataphase_Mode,u8 AddressHeader,u8 Low_Address,u8 Addring_Mode);
/****************************************************************************************
Function Name:I2C_ReciveByte( )
     Function:To process the reciption of a byte.
    Parameter:none
       Return:         u8 RecivedByte:The recived byte.
              I2C_TypeDef *I2Cx:The target I2C controllor.
         Note:
****************************************************************************************/
u8 I2C_ReciveByte(void);
/****************************************************************************************
Function Name:I2C_SendByte( )
     Function:To send a byte of data.
    Parameter:         u8 ByteToSend
              I2C_TypeDef *I2Cx:The target I2C controllor.
       Return:none
         Note:
****************************************************************************************/
void I2C_SendByte(u8 ByteToSend);
/**********************************************************************************************************************************************
Function Name:I2C_SendBlock( )
     Function:To send a data block.
    Parameter:         u8 *BlockToSend:The address of the first byte of the block to be sent.
                       u8 Total_Btyes :The size of the block in byte.
              I2C_TypeDef *I2Cx        :The target I2C controllor.
       Return:none
         Note:
*********************************************************************************************************************************************/
void I2C_SendBlock(u8 *BlockToSend,u8 Total_Bytes);
/**************************************************************************************
Function Name:I2C_Stop()
     Function:This function will be used by the master to generate a stop signal of the transmittion
    Parameter:I2C_TypeDef *I2Cx:The target I2C controllor.
       Return:none
         Note:
****************************************************************************************/
void I2C_Stop_Write(void);
void I2C_Stop_Read(void);
/**********************************************************************************************************************************************
Function Name:Recive_Data_From_A_slave()
     Function:To send the slave address.
    Parameter:u8 AddressHeader :In 10_bit address mode ,here is the address header.
              u8 Low_Address   :The address to be sent in 7_bit address mode or the lower 8 bits address to be sent in 10_bit address mode.
              u8 Addring_Mode  :Addring_Mode_10 to indicate here is a 10_bit address or Addring_Mode_7 to indicate here is a 7_bit address.
              u8 *Buffer       :The recived data buffer address.
              u8 Total         :The total number of bytes to be recived from a slave.
       Return:u8 ERR_Flag      :The erro type if occured .
         Note:
*********************************************************************************************************************************************/
u8 Recive_Data_From_A_slave(u8 *Buffer,u8 Total,u8 Header,u8 Low_Address,u8 Addring_Mode);
/************************************************************************************8
Function Name:I2C_SlaveIni( )
     Function:Initiate the I2C controllor working in slave mode .
    Parameter:I2C_TypeDef *I2Cx:The target I2C controllor.
       Return:none
         Note:
*************************************************************************************/
void I2C_SlaveIni(void);
/************************************************************************************8
Function Name:I2C_Slave_ByteTransmit( )
     Function:To transmit a byte as a slave.
    Parameter:         u8 Data:The byte to be transmit.
              I2C_TypeDef *I2Cx:The target I2C controllor.
       Return:none
         Note:
*************************************************************************************/
void I2C_Slave_ByteTransmit(u8 Data);
/************************************************************************************8
Function Name:I2C_Slave_BlockTransmit( )
     Function:To transmit a block as a slave .
    Parameter:         u8 *Data:The address of the first byte of the block to be transmit.
                       u8 Total:The size of the block in byte,
              I2C_TypeDef *I2Cx :The target I2C controllor.
       Return:none
         Note:
*************************************************************************************/
void I2C_Slave_BlockTransmit(u8 *Data ,u8 Total);
/************************************************************************************8
Function Name:I2C_Slave_BlockReception( )
     Function:To recive a block of data as a slave.
    Parameter:         u8 *Buffer:The address of the first byte of the recived data buffer.
              I2C_TypeDef *I2Cx   :The target I2C controllor.
       Return:none
         Note:
*************************************************************************************/
u8 I2C_Slave_BlockReception(u8 *Buffer );
/************************************************************************************8
Function Name:I2C_Slave_ByteReception()
     Function:To recive a byte as a slave.
    Parameter:I2C_TypeDef *I2Cx:The target I2C controllor.
       Return:u8 Data :The recived byte.
         Note:
*************************************************************************************/
u8 I2C_Slave_ByteReception(void);

⌨️ 快捷键说明

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