本文整理汇总了C++中I2C_Write函数的典型用法代码示例。如果您正苦于以下问题:C++ I2C_Write函数的具体用法?C++ I2C_Write怎么用?C++ I2C_Write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了I2C_Write函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: i2c_data_verify
bool i2c_data_verify(alt_u32 scl_base, alt_u32 sda_base, alt_u8 ControlAddr){
bool bPass;
const alt_8 DeviceAddr = 0xA0;
alt_u8 OrgData, TestData, Data;
TestData = alt_nticks();
if (TestData == 0)
TestData = 0x12;
bPass = I2C_Read(scl_base, sda_base, DeviceAddr, ControlAddr, &OrgData);
if (bPass) // write
bPass = I2C_Write(scl_base, sda_base, DeviceAddr, ControlAddr, TestData);
if (bPass) // read
bPass = I2C_Read(scl_base, sda_base, DeviceAddr, ControlAddr, &Data);
if (bPass && (Data != TestData)) // verify
bPass = FALSE;
// restore
if (bPass) // write back
bPass = I2C_Write(scl_base, sda_base, DeviceAddr, ControlAddr, OrgData);
if (bPass) // read
bPass = I2C_Read(scl_base, sda_base, DeviceAddr, ControlAddr, &Data);
if (bPass && (Data != OrgData)) // verify
bPass = FALSE;
return bPass;
}
开发者ID:pghu,项目名称:obstacle_avoider,代码行数:26,代码来源:I2C.c
示例2: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main()
{
int i;
/*System clock configuration*/
SystemInit();
/* Configure UART2 */
S_UART_Init(115200);
conf.scl = I2C_PA_9;
conf.sda = I2C_PA_10;
I2C_Init(&conf);
//============ Write ==============
I2C_Write(&conf, 0xa0, &Transmit_Data[0], MAX_SIZE);
delay_function(4000);
//========= Read =============
//Write memory address
I2C_Write(&conf, 0xA0, &Transmit_Data[0], 1);
delay_function(4000);
//Read data
I2C_Read(&conf, 0xA0, &Recv_Data[0], MAX_SIZE - 1);
printf("Recv data : ");
for(i=0; i<MAX_SIZE - 1; i++)
{
printf("0x%x ", Recv_Data[i]);
}
printf("\r\n");
}
开发者ID:edwin-oetelaar,项目名称:W7500P,代码行数:40,代码来源:main.c
示例3: Init_MPU6050
//------------------------------------------------------------------------------------------------------------------------------------------------------------------
// MPU-6050 initialisieren
//------------------------------------------------------------------------------------------------------------------------------------------------------------------
void Init_MPU6050(void) {
// Abtastrate des Sensors einstellen - Register 0x19 mit 7 beschreiben
i2cData[0] = 0x19;
i2cData[1] = 7;
I2C_Write(I2C1, i2cData, 2, I2C_MPUAddress);
// internen Tiefpassfilter deaktivieren - Register 0x1A mit 0 beschreiben
i2cData[0] = 0x1A;
i2cData[1] = 0x00;
I2C_Write(I2C1, i2cData, 2, I2C_MPUAddress);
// max. Messbereich des Drehratensensors auf +/-250°/s einstellen - Register 0x1B mit 0 beschreiben
i2cData[0] = 0x1B;
i2cData[1] = 0x00;
I2C_Write(I2C1, i2cData, 2, I2C_MPUAddress);
// max. Messbereich des Beschleunigungssensors auf +/-2g einstellen - Register 0x1C mit 0 beschreiben
i2cData[0] = 0x1C;
i2cData[1] = 0x00;
I2C_Write(I2C1, i2cData, 2, I2C_MPUAddress);
// Taktquelle auswählen - Register 0x6B mit 1 beschreiben
PLL[0] = 0x6B;
PLL[1] = 0x01;
I2C_Write(I2C1, PLL, 2, I2C_MPUAddress);
}
开发者ID:GMHSA,项目名称:Test,代码行数:30,代码来源:balancing.c
示例4: MPL3115A2_write8
bool MPL3115A2_write8(uint8_t a, uint8_t d) {
unsigned char data_write[2];
data_write[0] = a;
data_write[1] = d;
int i;
for(i=0;i<5;i++)
{
if(I2C_Write(MPL3115A2_ADDRESS,
data_write,
2,
1)) // no stop bit
break;
}
if(i<5) {
d = MPL3115A2_read8(a);
while(d != data_write[1])
{
if(I2C_Write(MPL3115A2_ADDRESS,
data_write,
2,
1)) // no stop bit
{
d = MPL3115A2_read8(a);
if (d == data_write[1])
return true;
}
i++;
if (i>5)
break;
}
return true;
}
return false;
}
开发者ID:cliveboyd,项目名称:SmartCane,代码行数:34,代码来源:MPL3115.c
示例5: I2C_PCA9532_SetPwm
/*********************************************************************
*
* I2C_PCA9532_SetPwm
*
* Function description
* Sets the timing for PWM0 or PWM1 and assigns the pin to the
* according PWM.
*
* Return value
* 0: O.K.
* != 0: Error
*/
U8 I2C_PCA9532_SetPwm(U32 I2CBaseAddr, U8 Addr, U8 Pin, U8 PwmNumber, U8 Pwm, U8 Psc) {
U8 Data[2];
U8 r;
if (PwmNumber > 1) {
return 1; // Error, invalid PWM number
}
if (PwmNumber) {
Data[0] = PSC1;
} else {
Data[0] = PSC0;
}
Data[1] = Psc;
r = I2C_Write(I2CBaseAddr, Addr, Data, 2);
if (r == 0) {
if (PwmNumber) {
Data[0] = PWM1;
} else {
Data[0] = PWM0;
}
Data[1] = Pwm;
r = I2C_Write(I2CBaseAddr, Addr, Data, 2);
if (r == 0) {
r = _SetPinSelect(I2CBaseAddr, Addr, Pin, I2C_PCA9532_PWM0 + PwmNumber);
}
}
return r;
}
开发者ID:FutureDesigns,项目名称:uEZ,代码行数:41,代码来源:I2C_PCA9532.c
示例6: BusyXLCD
unsigned char BusyXLCD(void) {
OLATB_curr |= 0xC0; // RW and RS are on
clockLCDLow();
I2C_Write(EXPANDER_IODIRB, 0x1E); // data bus is now an input
I2C_Write(EXPANDER_OLATB, OLATB_curr);
DelayFor18TCY();
clockLCDHigh(); // Clock in the command with E
DelayFor18TCY();
busy = I2C_Read(EXPANDER_GPIOB);
clockLCDLow(); // Reset clock line
DelayFor18TCY();
clockLCDHigh(); // Clock out other nibble
DelayFor18TCY();
clockLCDLow();
OLATB_curr &= 0xBF; // Reset control line
I2C_Write(EXPANDER_OLATB, OLATB_curr);
I2C_Write(EXPANDER_IODIRB, 0x00); // set data bus back to output
// busy bit is high?
if (busy & 0x02)
{
return 1;
}
// Busy bit is low
return 0;
}
开发者ID:yahooguntu,项目名称:DoorOpener,代码行数:29,代码来源:busyxlcd.c
示例7: I2C_StoreDate
//--------------------------------------------------------
void I2C_StoreDate(stDS1307Time *time)
{
I2C_Write(TMR_ADDR,REG_MONTH,time->Month);
_delay_us(100);
I2C_Write(TMR_ADDR,REG_DATE,time->Date);
_delay_us(100);
}
开发者ID:nowhard,项目名称:LED_CLOCK,代码行数:9,代码来源:i2c.c
示例8: I2C_WriteRegister
void I2C_WriteRegister(uint8_t deviceRegister, uint8_t data) {
I2C_Start(DS1307);
// send address
I2C_Write(deviceRegister);
// write data to that address
I2C_Write(data);
I2C_Stop();
}
开发者ID:trnila,项目名称:avr-totp,代码行数:10,代码来源:i2c.c
示例9: Init_L3G4200D
void Init_L3G4200D(void)
{
SCLDirOut();
SDADirOut();
I2C_Write(L3G4200D_SLAVE_ADDR, CTRL_REG1,0x4f);
I2C_Write(L3G4200D_SLAVE_ADDR, CTRL_REG2,0x00);
I2C_Write(L3G4200D_SLAVE_ADDR, CTRL_REG3,0x08);
I2C_Write(L3G4200D_SLAVE_ADDR, CTRL_REG4,0x00);
I2C_Write(L3G4200D_SLAVE_ADDR, CTRL_REG5,0x00);
}
开发者ID:EmuxEvans,项目名称:contiki-cc2530eb,代码行数:10,代码来源:l3g4200d.c
示例10: I2C_StoreTime
//---------------------------------------------------
void I2C_StoreTime(stDS1307Time *time)
{
I2C_Write(TMR_ADDR,REG_HOURS,time->Hours);
_delay_us(100);
I2C_Write(TMR_ADDR,REG_MINUTES,time->Minutes);
_delay_us(100);
I2C_Write(TMR_ADDR,REG_SECONDS,0x0);
_delay_us(100);
}
开发者ID:nowhard,项目名称:LED_CLOCK,代码行数:12,代码来源:i2c.c
示例11: RTC_Init
/***************************************************************************************************
void RTC_Init()
***************************************************************************************************
* I/P Arguments: none.
* Return value : none
* description :This function is used to Initialize the Ds1307 RTC.
***************************************************************************************************/
void RTC_Init()
{
I2C_Init(); // Initialize the I2c module.
I2C_Start(); // Start I2C communication
I2C_Write(C_Ds1307WriteMode_U8); // Connect to DS1307 by sending its ID on I2c Bus
I2C_Write(C_Ds1307ControlRegAddress_U8);// Select the Ds1307 ControlRegister to configure Ds1307
I2C_Write(0x00); // Write 0x00 to Control register to disable SQW-Out
I2C_Stop(); // Stop I2C communication after initializing DS1307
}
开发者ID:Amritach,项目名称:Code-Libraries,代码行数:20,代码来源:rtc.c
示例12: RTC_SetDate
/***************************************************************************************************
void RTC_SetDate(uint8_t var_day_u8, uint8_t var_month_u8, uint8_t var_year_u8)
****************************************************************************************************
* I/P Arguments: uint8_t,uint8_t,uint8_t-->day,month,year to Initialize the Date into DS1307.
* Return value : none
* description :This function is used to set Date(dd,mm,yy) into the Ds1307 RTC.
The new Date is updated into the non volatile memory of Ds1307.
Note: The I/P arguments should of BCD,
like 0x15,0x08,0x47 for 15th day,8th month and 47th year.
***************************************************************************************************/
void RTC_SetDate(uint8_t var_day_u8, uint8_t var_month_u8, uint8_t var_year_u8)
{
I2C_Start(); // Start I2C communication
I2C_Write(C_Ds1307WriteMode_U8); // connect to DS1307 by sending its ID on I2c Bus
I2C_Write(C_Ds1307DateRegAddress_U8); // Request DAY RAM address at 04H
I2C_Write(var_day_u8); // Write date on RAM address 04H
I2C_Write(var_month_u8); // Write month on RAM address 05H
I2C_Write(var_year_u8); // Write year on RAM address 06h
I2C_Stop(); // Stop I2C communication after Setting the Date
}
开发者ID:Amritach,项目名称:Code-Libraries,代码行数:24,代码来源:rtc.c
示例13: DS1307_SetTime
void DS1307_SetTime(unsigned char hh, unsigned char mm, unsigned char ss)
{
I2C_Start(); // Start I2C communication
I2C_Write(DS1307_ID); // connect to DS1307 by sending its ID on I2c Bus
I2C_Write(SEC_ADDRESS); // Select the SEC RAM address
I2C_Write(ss); // Write sec on RAM address 00H
I2C_Write(mm); // Write min on RAM address 01H
I2C_Write(hh); // Write hour on RAM address 02H
I2C_Stop(); // Stop I2C communication after Setting the Time
}
开发者ID:hidayahsidiq,项目名称:source-AVR,代码行数:13,代码来源:RTC.c
示例14: RTC_SetTime
/***************************************************************************************************
void RTC_SetTime(uint8_t var_hour_u8, uint8_t var_min_u8, uint8_t var_sec_u8)
****************************************************************************************************
* I/P Arguments: uint8_t,uint8_t,uint8_t-->hh,mm,ss to Initialize the time into DS1307.
* Return value : none
* description :This function is used to update the Time(hh,mm,ss) of Ds1307 RTC.
The new time is updated into the non volatile memory of Ds1307.
Note: The I/P arguments should of BCD,
like 0x12,0x39,0x26 for 12hr,39min and 26sec.
***************************************************************************************************/
void RTC_SetTime(uint8_t var_hour_u8, uint8_t var_min_u8, uint8_t var_sec_u8)
{
I2C_Start(); // Start I2C communication
I2C_Write(C_Ds1307WriteMode_U8); // connect to DS1307 by sending its ID on I2c Bus
I2C_Write(C_Ds1307SecondRegAddress_U8); // Select the SEC RAM address
I2C_Write(var_sec_u8); // Write sec from RAM address 00H
I2C_Write(var_min_u8); // Write min from RAM address 01H
I2C_Write(var_hour_u8); // Write hour from RAM address 02H
I2C_Stop(); // Stop I2C communication after Setting the Time
}
开发者ID:Amritach,项目名称:Code-Libraries,代码行数:24,代码来源:rtc.c
示例15: DS1307_SetDate
void DS1307_SetDate(unsigned char dd, unsigned char mm, unsigned char yy)
{
I2C_Start(); // Start I2C communication
I2C_Write(DS1307_ID); // connect to DS1307 by sending its ID on I2c Bus
I2C_Write(DATE_ADDRESS); // Request DAY RAM address at 04H
I2C_Write(dd); // Write date on RAM address 04H
I2C_Write(mm); // Write month on RAM address 05H
I2C_Write(yy); // Write year on RAM address 06h
I2C_Stop(); // Stop I2C communication after Setting the Date
}
开发者ID:hidayahsidiq,项目名称:source-AVR,代码行数:13,代码来源:RTC.c
示例16: function
int function(void)
{
void DS1307_Init()
{
I2C_Init(); // Initilize the I2c module.
I2C_Start(); // Start I2C communication
I2C_Write(DS1307_ID); // Connect to DS1307 by sending its ID on I2c Bus
I2C_Write(CONTROL); // Select the Ds1307 ControlRegister to configure Ds1307
I2C_Write(0x00); // Write 0x00 to Control register to disable SQW-Out
I2C_Stop(); // Stop I2C communication after initilizing DS1307
}
开发者ID:hidayahsidiq,项目名称:source-AVR,代码行数:14,代码来源:RTC.c
示例17: I2C_Write
void MP3Player::setVolume(byte volume)
{
#define DLA 0x46
#define DRA 0x48
byte Vol;
Vol=255-volume;
I2C_Write(DLA, Vol); //left channel volume
I2C_Write(DRA, Vol); //right channel volume
vol = volume;
}
开发者ID:CytronTechnologies,项目名称:Cytron_MP3Shield,代码行数:14,代码来源:MP3Player.cpp
示例18: display
void display(void)
{
uint16_t i=0 ;
uint8_t x ;
// pointer to OLED data buffer
uint8_t * p = poledbuff;
unsigned char buff[17] ;
ssd1306_singleCMD(0x21);
ssd1306_singleCMD(0x00);
ssd1306_singleCMD(0x7F);
ssd1306_singleCMD(0x22);
ssd1306_singleCMD(0x00);
ssd1306_singleCMD(0x07);
// Setup D/C to switch to data mode
buff[0] = SSD_Data_Mode;
// loop trough all OLED buffer and
// send a bunch of 16 data byte in one xmission
for ( i=0; i<(ssd1306_lcdwidth*ssd1306_lcdheight)>>7; i++ ){
for (x=1; x<=16; x++)
buff[x] = *p++;
I2C_Write(0x3C, &buff[0], 17);
}
}
开发者ID:RGassmann,项目名称:FRDM,代码行数:29,代码来源:SSD1306.c
示例19: Temperature_Get
/*---------------------------------------------------------------------------*
* Routine: Temperature_Get
*---------------------------------------------------------------------------*
* Description:
* Read the value of the ADT7420 and return the temperature in Celcius.
* Inputs:
* void
* Outputs:
* uint16_t -- temperature with 4 bits of fraction and 12 bits of
* integer.
*---------------------------------------------------------------------------*/
uint16_t Temperature_Get(void)
{
uint8_t target_reg;
uint8_t target_data[2] = {0x00, 0x00};
uint16_t temp = 0;
uint32_t timeout = MSTimerGet();
I2C_Request r;
r.iAddr = ADT7420_ADDR>>1;
r.iSpeed = 100;
r.iWriteData = &target_reg;
r.iWriteLength = 1;
r.iReadData = target_data;
r.iReadLength = 2;
I2C_Write(&r, 0);
while ((I2C_IsBusy()) && (MSTimerDelta(timeout) < 10))
{}
I2C_Read(&r, 0);
while ((I2C_IsBusy()) && (MSTimerDelta(timeout) < 10))
{}
/* Convert the device measurement into a decimal number and insert
into a temporary string to be displayed */
temp = (target_data[0] << 8) + target_data[1];
// temp = temp >> 3;
return temp;
}
开发者ID:hyller,项目名称:GladiatorLaboratory,代码行数:39,代码来源:Temperature.c
示例20: MPL3115A2_read8
uint8_t MPL3115A2_read8(uint8_t a) {
int i=0;
uint8_t out;
for(;i<5;i++)
{
if(I2C_Write(MPL3115A2_ADDRESS,
(unsigned char*)&a,
1,
0))
break; // if written length > 0
}
if (i>=5)
return 0xff; // failed
for(i=0;i<5;i++)
{
if(I2C_Read(MPL3115A2_ADDRESS,
&out,
1,
0))
break; // if read length > 0
}
if (i<5)
return out;
return 0xff;
}
开发者ID:cliveboyd,项目名称:SmartCane,代码行数:25,代码来源:MPL3115.c
注:本文中的I2C_Write函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论