本文整理汇总了C++中I2C_WriteByte函数的典型用法代码示例。如果您正苦于以下问题:C++ I2C_WriteByte函数的具体用法?C++ I2C_WriteByte怎么用?C++ I2C_WriteByte使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了I2C_WriteByte函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:eos1d3,项目名称:stm8-distance-sensor-2-400-cm,代码行数:37,代码来源:softi2c.c
示例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();
}
开发者ID:SurionPL,项目名称:ANSI-C,代码行数:12,代码来源:BMP180.c
示例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();
}
开发者ID:SurionPL,项目名称:ANSI-C,代码行数:12,代码来源:BMP180.c
示例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;
}
开发者ID:wareash,项目名称:stm32-camera,代码行数:43,代码来源:OV7670.c
示例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);
}
开发者ID:Flemmard,项目名称:htc7x30-3.0,代码行数:29,代码来源:mhl_tpi.c
示例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;
}
开发者ID:Flemmard,项目名称:htc7x30-3.0,代码行数:25,代码来源:mhl_tpi.c
示例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;
}
开发者ID:bnthang,项目名称:single-phase-multy-tarriff,代码行数:37,代码来源:BU9792_Driver.c
示例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); //标记校准过了
}
开发者ID:luckywqf,项目名称:STM32_mp3,代码行数:27,代码来源:touch.c
示例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;
}
开发者ID:BarryChen,项目名称:au6210_oem_bt168,代码行数:33,代码来源:test.c
示例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);
}
开发者ID:qiurenguo2014,项目名称:youjiesun,代码行数:13,代码来源:fm31256.c
示例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);
}
开发者ID:qiurenguo2014,项目名称:youjiesun,代码行数:13,代码来源:fm31256.c
示例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进程
}
开发者ID:JokerGeek,项目名称:Raging_Fire_Quad-rotor,代码行数:17,代码来源:I2C_MPU6050.c
示例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();
}
开发者ID:recog006,项目名称:rpcMPLABX,代码行数:14,代码来源:DS3231.c
示例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);
}
开发者ID:ChenQingya,项目名称:Pheonix,代码行数:10,代码来源:MPU6050.c
示例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);
}
开发者ID:recog006,项目名称:rpcMPLABX,代码行数:16,代码来源:DS3231.c
示例16: ReadSector
void ReadSector(char SectorNum, unsigned char *SectorData)
{
unsigned char RxBuffer[10];
unsigned char IDCode; // needed only if read procedure is different between cut. Today the procedure is identical
//read sector
RxBuffer[0]=SectorNum;
I2C_WriteByte(0xE0,0x45,RxBuffer,1);
RxBuffer[0]=0xC9;
I2C_WriteByte(0xE0,0x46,RxBuffer,1);
msleep(5); // wait
I2C_ReadByte(0xE0,0x20,SectorData,8); //read RAM
}
开发者ID:dflow81,项目名称:android_kernel_samsung_goyawifi,代码行数:13,代码来源:stc3115_configsecure_lt02.c
示例17: initRTCmodule
unsigned char initRTCmodule(unsigned char devADDR){
unsigned char btemp;
Nop();
Nop();
//
I2C_Close();
I2C_Init(39); // I2C 100 KHZ, 16 MHZ OSC (see note in "myI2C.c")
Nop();
Nop();
//
I2C_Start();
I2C_Idle();
btemp = I2C_WriteByte(devADDR);
Nop();
Nop();
Nop();
if (btemp != 0){
Nop();
Nop();
I2C_Stop();
I2C_Close();
return 0xFF;
} else {
btemp = DS3231_GetInfo(0x0F);
Nop();
Nop();
return btemp;
};
}
开发者ID:recog006,项目名称:rpcMPLABX,代码行数:30,代码来源:DS3231.c
示例18: I2C_ReadRepeated
int I2C_ReadRepeated(I2C_ConfigStruct* conf, uint8_t addr, uint8_t* data, uint32_t len)
{
int i;
I2C_Start(conf);
//Write addr | read command
if(I2C_WriteByte(conf, (addr | 1)) != 0)
{
printf("Received NACK at address phase!!\r\n");
return -1;
}
//Read data
for(i=0; i<len; i++)
{
data[i] = I2C_ReadByte(conf);
if( i == (len - 1) )
I2C_SendNACK(conf);
else
I2C_SendACK(conf);
}
return 0;//success
}
开发者ID:bingdo,项目名称:Loopback_BSD_WIZwiki-W7500_Eclipse,代码行数:26,代码来源:W7500x_i2c.c
示例19: i2c_imx_write
static bool i2c_imx_write(struct device *dev, u8_t *txBuffer, u8_t txSize)
{
I2C_Type *base = DEV_BASE(dev);
struct i2c_imx_data *data = DEV_DATA(dev);
struct i2c_master_transfer *transfer = &data->transfer;
transfer->isBusy = true;
/* Clear I2C interrupt flag to avoid spurious interrupt */
I2C_ClearStatusFlag(base, i2cStatusInterrupt);
/* Set I2C work under Tx mode */
I2C_SetDirMode(base, i2cDirectionTransmit);
transfer->currentDir = i2cDirectionTransmit;
transfer->txBuff = txBuffer;
transfer->txSize = txSize;
I2C_WriteByte(base, *transfer->txBuff);
transfer->txBuff++;
transfer->txSize--;
/* Enable I2C interrupt, subsequent data transfer will be handled
* in ISR.
*/
I2C_SetIntCmd(base, true);
/* Wait for the transfer to complete */
k_sem_take(&data->device_sync_sem, K_FOREVER);
return transfer->ack;
}
开发者ID:milinddeore,项目名称:zephyr,代码行数:32,代码来源:i2c_imx.c
示例20: PressureSensorRegRead
I2C_Status PressureSensorRegRead(uint8_t reg, uint8_t* val)
{
I2C_Status retVal = I2C_OK;
do
{
I2C_Start(ALB_I2C, MPL311_ADDR, 0);
retVal = I2C_WriteByte(ALB_I2C, reg);
if(retVal != I2C_OK)
{
break;
}
retVal = I2C_WaitForTX(ALB_I2C);
if(retVal != I2C_OK)
{
break;
}
I2C_Start(ALB_I2C, MPL311_ADDR, 1);
if((retVal = I2C_ReadBytes(ALB_I2C, val, 1)) != I2C_OK)
{
break;
}
I2C_Stop(ALB_I2C);
} while(0);
return retVal;
}
开发者ID:project-reservoir,项目名称:project-dandelion,代码行数:30,代码来源:sensors.c
注:本文中的I2C_WriteByte函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论