📄 i2cs.h
字号:
/******************************************************************************
COPYRIGHT 2002 STMicroelectronics
Source File Name : i2cs.h
Group : IPSW,CMG
Author : MCD Application Team
Date First Issued: 07/03/2002
********************************Documentation**********************************
General Purpose - Contains prototypes for all the functions of I2C Slave
********************************Revision History*******************************
_______________________________________________________________________________
Date :14/10/2003 Release:1.0
Date :28/04/04 MISRA changes
******************************************************************************/
#ifndef I2C_SLAVE_H
#define I2C_SLAVE_H
#include "ST7lib_config.h"
/*----------------------------------ENUMS------------------------------------*/
/* Parameters for initialisation of i2cs control and status registers */
typedef enum {
I2Cs_DEFAULT_PARAM = (unsigned char) 0x00,
I2Cs_ENABLE_ACK = (unsigned char) 0x04,
I2Cs_ENABLE_ENGC = (unsigned char) 0x10
}I2Cs_Control_Param;
/* Parameter for detecting the mode of communication */
typedef enum {
I2Cs_DEFAULT = (unsigned char) 0x00,
I2Cs_TX_MODE = (unsigned char) 0x01,
I2Cs_RX_MODE = (unsigned char) 0x02
}I2Cs_Mode;
/* Prameters for getting the status of the I2c bus after any
communication event */
typedef enum {
I2Cs_TX_DATA_OK = (unsigned char) 0x01,
I2Cs_RX_DATA_OK = (unsigned char) 0x10,
I2Cs_OVERFLOW_TX = (unsigned char) 0x02,
I2Cs_OVERFLOW_RX = (unsigned char) 0x20,
I2Cs_BUFF_TX_ONGOING = (unsigned char) 0x03,
I2Cs_BUFF_RX_ONGOING = (unsigned char) 0x30,
I2Cs_ADDRESS_DETECTED = (unsigned char) 0x04,
I2Cs_GENERAL_CALL = (unsigned char) 0x40,
I2Cs_STOP_DETECTED = (unsigned char) 0x05,
I2Cs_BERR = (unsigned char) 0x06,
I2Cs_TX_AF = (unsigned char) 0x07,
I2Cs_EMPTY = (unsigned char) 0x08,
I2Cs_DEFAULT_STATUS = (unsigned char) 0x00
}I2Cs_ErrCode_t;
/*---------------------------------MACROS------------------------------------*/
#define I2Cs_PeripheralDisable() I2CCR &=0xDF
/*-----------------------------FUNCTION PROTOTYPES---------------------------*/
/* Description of all the functions defined in this module */
/* Initialize i2cs */
void I2Cs_Init( I2Cs_Control_Param InitParam,unsigned char I2Cs_OAR1Value,
unsigned char I2Cs_OAR2Value);
I2Cs_Mode I2Cs_GetCommMode(void);
/* Transmits single byte of data */
void I2Cs_PutByte(unsigned char Tx_Byte);
I2Cs_ErrCode_t I2Cs_IsTransmitCompleted(void);
/* Receives single byte of data */
unsigned char I2Cs_GetByte (void) ;
I2Cs_ErrCode_t I2Cs_IsReceptionCompleted(void);
void I2Cs_ErrorClear(void );
void I2Cs_ITFunction(void);
#ifdef I2C_POLLING_TX
/* Transmits data bytes continuously and returns the transmission status */
I2Cs_ErrCode_t I2Cs_PutBuffer(unsigned char *PtrToBuffer, unsigned
char MaxSize);
#endif
#ifdef I2C_POLLING_RX
/* Receives bytes continuously and returns the reception status */
I2Cs_ErrCode_t I2Cs_GetBuffer(unsigned char *PtrToBuffer, unsigned
char MaxSize );
#endif
#ifdef I2C_ITDRV_WITHOUTBUF_TX
/* Starts continuous data bytes transmission in ISR */
void I2Cs_PutBuffer(unsigned char *PtrToBuffer,unsigned char MaxSize );
#endif
#ifdef I2C_ITDRV_WITHOUTBUF_RX
/* Starts continuous data bytes reception in ISR */
void I2Cs_GetBuffer(unsigned char *PtrToBuffer,unsigned char MaxSize );
#endif
#endif
/**** (c) 2003 STMicroelectronics *************************** END OF FILE **/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -