标题:
IIC,从51移殖到STM32,第二次握手出问题
[打印本页]
作者:
我是MT
时间:
2014-5-30 17:38
标题:
IIC,从51移殖到STM32,第二次握手出问题
/******************** (C) COPYRIGHT 2013 XXXXXX *****************************
* File Name : iic.h
* Author :
* Description : iic simulation or iic hardware procedure.
********************************************************************************
History:
2013-12 Initial version.
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __IIC_H__
#define __IIC_H__
/* Includes ------------------------------------------------------------------*/
#include "stm8l15x.h"
/* Exported types ------------------------------------------------------------*/
typedef struct IIC_PORT_struct
{
__IO uint8_t *DDR;
__IO uint8_t *IDR;
__IO uint8_t *ODR;
uint8_t SCL_MASK;
uint8_t SCL_NMASK;
uint8_t SDA_MASK;
uint8_t SDA_NMASK;
uint8_t SlaveAddr;
}IIC_PORT;
/* Exported macro ------------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/
#define I2C_ACK 0
#define I2C_NAK 1
/* Exported variable --------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void IIC_Start(IIC_PORT *IICx);
void IIC_Stop(IIC_PORT *IICx);
ErrorStatus IIC_CheckAck(IIC_PORT *IICx);
void IIC_SendAck(IIC_PORT *IICx);
void IIC_SendNak(IIC_PORT *IICx);
void IIC_SendAByte(IIC_PORT *IICx, uint8_t dat);
uint8_t IIC_ReceiveAByte(IIC_PORT *IICx);
void IIC_WriteAByte(IIC_PORT *IICx, uint8_t RegAddr, uint8_t data);
uint8_t IIC_ReadAByte(IIC_PORT *IICx, uint8_t RegAddr);
void IIC_WriteData(IIC_PORT *IICx, uint8_t RegAddr, uint8_t *pdat, uint8_t num);
void IIC_ReadData(IIC_PORT *IICx, uint8_t RegAddr, uint8_t *pdat, uint8_t num);
#endif /* __IIC_H__ */
/******************* (C) COPYRIGHT 2013 XXXXXXXXXX *****************************/
/*******************************END OF FILE************************************/
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/)
Powered by Discuz! 7.0.0