📄 i2c.h
字号:
/******************************************************************************* Copyright (C) 2001 by Ingenient Technologies, Inc.* All Rights Reserved.** Use of this software is restricted to the terms and* conditions of Ingenient's software license agreement.** www.ingenient.com********************************************************************************* Filename:** i2c.h** File Description:** Function prototypes, etc. for functions in i2c.c*******************************************************************************/#ifndef I2C_H#define I2C_H/* *************************** Definitions **************************** */#define REG *(unsigned short *)#define UINT8 unsigned char#define UINT16 unsigned short#define UINT32 unsigned long#define INT16 short#define GIO_REGISTER_BASE 0x00030580 // GIO register address#define DIR0 (volatile UINT16 *)(GIO_REGISTER_BASE)#define BITSET0 (volatile UINT16 *)(GIO_REGISTER_BASE + 0x000C)#define BITCLR0 (volatile UINT16 *)(GIO_REGISTER_BASE + 0x0012)#define DIR1 (volatile UINT16 *)(GIO_REGISTER_BASE + 2)#define BITSET1 (volatile UINT16 *)(GIO_REGISTER_BASE + 0x000E)#define BITCLR1 (volatile UINT16 *)(GIO_REGISTER_BASE + 0x0014)#define DIR2 (volatile UINT16 *)(GIO_REGISTER_BASE + 4)#define BITSET2 (volatile UINT16 *)(GIO_REGISTER_BASE + 0x0010)#define BITCLR2 (volatile UINT16 *)(GIO_REGISTER_BASE + 0x0016)#define BOOL unsigned chartypedef enum {I2C_SUCCESS, I2C_ERROR} I2C_RETURN;/* **************************** Structures **************************** *//* ************************* Global Variables ************************* *//* *********************** Function Prototypes ************************ */void I2C_init(INT16 scl_gio, INT16 sda_gio);void I2C_writeReg(UINT8 slaveAddr, UINT8 subAddr, UINT8 val, UINT8 *successFlag);void I2C_writeRegs(UINT8 slaveAddr, UINT8 subAddr, UINT8 *val, UINT32 count, UINT8 *successFlag);unsigned char I2C_readReg(UINT8 slaveAddr, UINT8 subAddr, UINT8 *successFlag);void I2C_readRegs(UINT8 slaveAddr, UINT8 subAddr, UINT8 *val, UINT32 count, UINT8 *successFlag);#endif /* I2C_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -