本文整理汇总了C++中I2C_WriteByte函数的典型用法代码示例。如果您正苦于以下问题:C++ I2C_WriteByte函数的具体用法?C++ I2C_WriteByte怎么用?C++ I2C_WriteByte使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了I2C_WriteByte函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: I2C_WriteBytes
/*! \brief Writes data from buffer.
\param indata Pointer to data buffer
\param bytes Number of bytes to transfer
\param slave_adr Slave address on I2C bus
\param slave_reg Slave memory address from which the reading is started
\return 1 if successful, otherwise 0
*/
u8 I2C_WriteBytes(u8* indata, u8 bytes, u8 slave_adr, u8 slave_reg)
{
u8 index, ack = 0;
if(!I2C_StartCond())
{
return 0;
}
if(!I2C_WriteByte((u8)(slave_adr | WRITE)))
{
return 0;
}
if(!I2C_WriteByte(slave_reg))
{
return 0;
}
for(index = 0; index < bytes; index++)
{
ack = I2C_WriteByte(indata[index]);
if(!ack)
{
break;
}
}
//put stop here
write_scl(1);
DELAY_US(SCL_SDA_DELAY);
SDA_HIGH;
return ack;
}
示例2: BMP180_StartTemperature
/**
* @ Opis Rozpoczyna pomiar temperatury.
* @ Parametry Brak.
* @ Zwracana wartosc Brak.
*/
void BMP180_StartTemperature() {
I2C_Start();
I2C_Write_SLA(BMP180_SLA);
I2C_WriteByte(BMP180_CTRL_MEAS_REG);
I2C_WriteByte(BMP180_T_MEASURE);
I2C_Stop();
}
示例3: BMP180_StartPressure
/**
* @ Opis Rozpoczyna pomiar cisnienia.
* @ Parametry Brak.
* @ Zwracana wartosc Brak.
*/
void BMP180_StartPressure() {
I2C_Start();
I2C_Write_SLA(BMP180_SLA);
I2C_WriteByte(BMP180_CTRL_MEAS_REG);
I2C_WriteByte(BMP180_Struct.BMP180_Mode);
I2C_Stop();
}
示例4: Sensor_Init
/*******************************************************************************
* Function Name : Sensor_Init
* Description : Sensor初始化
* Input : None
* Output : None
* Return : None
* Attention : 返回1成功,返回0失败
*******************************************************************************/
int Sensor_Init(void)
{
uint16_t i=0;
uint8_t Sensor_IDCode = 0;
I2C_Configuration();
if( 0 == I2C_WriteByte ( 0x12, 0x80 , ADDR_OV7670 ) ) /* Reset SCCB */
{
return 0 ;
}
Delay(1500);
if( 0 == I2C_ReadByte( &Sensor_IDCode, 1, 0x0b, ADDR_OV7670 ) ) /* read ID */
{
return 0; /* error*/
}
if(Sensor_IDCode == OV7670) /* ID = OV7670 */
{
for( i=0 ; i < OV7670_REG_NUM ; i++ )
{
if( 0 == I2C_WriteByte( OV7670_Reg[i][0], OV7670_Reg[i][1] , ADDR_OV7670 ) )
{
return 0;
}
}
}
else /* NO ID */
{
return 0;
}
return 1;
}
示例5: HotPlugService
void HotPlugService (void) {
DisableInterrupts(0xFF);
Active9232();
if ((HDCP_TxSupports == true)) {
if (HDCP_AksvValid == true) {
// AV MUTE
TPI_DEBUG_PRINT (("TMDS -> Enabled (Video Muted)\n"));
ReadModifyWriteTPI(0x1A, BIT_6 | BIT_4 | BIT_3,
0x40 | 0x00 | 0x08);
tmdsPoweredUp = true;
EnableInterrupts(BIT_0 | 0x02 | 0x10 | 0x20 | 0x40 | 0x80);
}
} else {
TPI_DEBUG_PRINT (("TMDS -> Enabled\n"));
ReadModifyWriteTPI(0x1A,
BIT_6 | BIT_4 | BIT_3,
0x40 | 0x00 | 0x08);
tmdsPoweredUp = TRUE;
EnableInterrupts(0x01 | 0x02 | 0x10 | 0x40);
}
TxPowerStateD0();
I2C_WriteByte(TPI_SLAVE_ADDR, 0xcd, 0x0);
I2C_WriteByte(TPI_SLAVE_ADDR, 0x19, 0x0);
}
示例6: GetDDC_Access
bool GetDDC_Access(uint8_t* SysCtrlRegVal)
{
uint8_t sysCtrl, TPI_ControlImage, DDCReqTimeout = T_DDC_ACCESS;
sysCtrl = I2C_ReadByte(TPI_SLAVE_ADDR, 0x1A);
*SysCtrlRegVal = sysCtrl;
sysCtrl |= BIT_2;
I2C_WriteByte(TPI_SLAVE_ADDR, 0x1A, sysCtrl);
while (DDCReqTimeout--) {
TPI_ControlImage = I2C_ReadByte(TPI_SLAVE_ADDR, 0x1A);
if (TPI_ControlImage & BIT_1) {
sysCtrl |= BIT_1;
I2C_WriteByte(TPI_SLAVE_ADDR, 0x1A, sysCtrl);
return true;
}
I2C_WriteByte(TPI_SLAVE_ADDR, 0x1A, sysCtrl);
DelayMS(200);
}
I2C_WriteByte(TPI_SLAVE_ADDR, 0x1A, sysCtrl);
return false;
}
示例7: BU9792_Refresh
//************************************************************
//BU9792 refresh display
unsigned char BU9792_Refresh(unsigned char * Src, unsigned int Len) {
unsigned char temp = 0, i;
Len = Len;
//I2C_Stop(I2C_BUS_0);
I2C_Start(I2C_BUS_0);
while (I2C_WriteByte(BU9799_ADDR, I2C_BUS_0) && (temp < 218)) {
I2C_Stop(I2C_BUS_0);
DelayMs(1);
I2C_Start(I2C_BUS_0);
temp++;
}
if (temp >= 218) {
I2C_Stop(I2C_BUS_0);
return (0xff);
}
//I2C_WriteByte(LCD_ICSET_M|0x80,I2C_BUS_0) ; /*high address*/
I2C_WriteByte(LCD_ICSET_M | 0x80, I2C_BUS_0); /* 高地址 */
//I2C_WriteByte(0x00,I2C_BUS_0) ; /*send data low address*/
I2C_WriteByte(0x00, I2C_BUS_0); /* 发送数据低地址*/
for (i = 0; i < 18; i++) {
//I2C_WriteByte(*Src++,I2C_BUS_0) ; /*send device address*/
I2C_WriteByte(*Src++, I2C_BUS_0); /* 发送器件地址 */
}
I2C_Stop(I2C_BUS_0);
return 0;
}
示例8: save_adjdata
//保存校准参数
//保存区域:FM24C16的 0~12这段地址区间,总共12个字节
void save_adjdata(void)
{
u32 temp;
//保存校正结果!
temp=penConfig.xfac*100000000;//保存x校正因素
I2C_WriteByte(temp&0xff, 0, ADDR_24LC08);
I2C_WriteByte((temp>>8)&0xff, 1, ADDR_24LC08);
I2C_WriteByte((temp>>16)&0xff, 2, ADDR_24LC08);
I2C_WriteByte((temp>>24)&0xff, 3, ADDR_24LC08);
temp=penConfig.yfac*100000000;//保存y校正因素
I2C_WriteByte(temp&0xff, 4, ADDR_24LC08);
I2C_WriteByte((temp>>8)&0xff, 5, ADDR_24LC08);
I2C_WriteByte((temp>>16)&0xff, 6, ADDR_24LC08);
I2C_WriteByte((temp>>24)&0xff, 7, ADDR_24LC08);
//保存x偏移量
I2C_WriteByte(penConfig.xoff&0xff,8,ADDR_24LC08);
I2C_WriteByte((penConfig.xoff>>8)&0xff,9,ADDR_24LC08);
//保存y偏移量
I2C_WriteByte(penConfig.yoff&0xff,10,ADDR_24LC08);
I2C_WriteByte((penConfig.yoff>>8)&0xff,11,ADDR_24LC08);
I2C_WriteByte(0xff,12,ADDR_24LC08); //标记校准过了
}
示例9: I2C_SendAddr
// send address via IIC.
BOOL I2C_SendAddr(BYTE DevAddr, WORD Addr, BYTE ReadWriteFlag, BYTE I2cDevice)
{
I2C_Start(I2cDevice);
if(!I2C_WriteByte(DevAddr, I2cDevice))
{
WaitMs(EEPROM_WRITE_TIME); // Wairt for Programming-time.
I2C_Start(I2cDevice);
if(!I2C_WriteByte(DevAddr, I2cDevice))// | PageAddr))
{
I2C_Stop(I2cDevice);
return FALSE;
}
}
if(!I2C_WriteByte((BYTE)Addr, I2cDevice))
{
I2C_Stop(I2cDevice);
return FALSE;
}
if(ReadWriteFlag == IIC_READ)
{
I2C_Start(I2cDevice);
if(!I2C_WriteByte((DevAddr | IIC_READ), I2cDevice))
{
I2C_Stop(I2cDevice);
return FALSE;
}
}
return TRUE;
}
示例10: FM31256_SetTime
/*
@brief 设置时间.
@param None.
@retval None.
*/
void FM31256_SetTime (unsigned char *data)
{
/* 读时间 */
I2C_WriteByte(REG_WRITE,FLAGS,0x2);
I2C_WriteSByte (REG_WRITE, SECONDS, data, 7);
/* 读完要恢复0 */
I2C_WriteByte(REG_WRITE,FLAGS,0);
}
示例11: FM31256_GetTime
/*
@brief 获取时间 BCD码.
@param None.
@retval None.
*/
void FM31256_GetTime (unsigned char *data)
{
/* 读时间 */
I2C_WriteByte(REG_WRITE,FLAGS,1);
I2C_ReadSByte (REG_READ, SECONDS, data, 7);
/* 读完要恢复0 */
I2C_WriteByte(REG_WRITE,FLAGS,0);
}
示例12: Single_WriteI2C
/*
*=========================================================
* 函数功能:写MPU6050寄存器
* 参数:
* Regs_Addr - 寄存器地址
* Regs_Data - 寄存器值
* 函数返回值:
*=========================================================
*/
void Single_WriteI2C(unsigned char Regs_Addr,unsigned char Regs_Data)
{
I2C_Start();
I2C_WriteByte(SlaveAddress); //先写Slave地址,并配置成写模式
I2C_WriteByte(Regs_Addr); //写寄存器地址
I2C_WriteByte(Regs_Data); //写寄存器内容
I2C_Stop(); //结束本段IIC进程
}
示例13: DS3231_SetInfo
//==============================================================================
//Sets Information in the RTC.
//byte0: Sets "Word Address".
//byte1: Sets the information.
//==============================================================================
void DS3231_SetInfo(unsigned char byte0, unsigned char byte1){
I2C_Start();
I2C_WriteByte(0xD0);
I2C_WriteByte(byte0);
I2C_WriteByte(byte1);
I2C_Stop();
Nop();
Nop();
}
示例14: HMC5883L_Init
// 磁力计初始化
void HMC5883L_Init(void)
{
// 设置标准数据输出速率为75HZ
I2C_WriteByte(HMC5883L_Addr, HMC5883L_ConfigurationRegisterA, 0x18);
// 设置采样频率为+-1.3Ga
I2C_WriteByte(HMC5883L_Addr, HMC5883L_ConfigurationRegisterB, 0x20);
// 开启连续测量模式
I2C_WriteByte(HMC5883L_Addr, HMC5883L_ModeRegister, 0x00);
}
示例15: DS3231_GetInfo
//==============================================================================
//Gets information of RTC.
//byte 0: Sets the "Word Address"
//byte1: Return the information.
//==============================================================================
unsigned char DS3231_GetInfo(unsigned char byte0){
unsigned char byte1 = 0;
I2C_Start();
I2C_WriteByte(0xD0);
I2C_WriteByte(byte0);
I2C_RepeatedStart();
I2C_WriteByte(0xD1);
byte1 = I2C_ReadByte(0);
I2C_Stop();
return(byte1);
}