您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ I2CMasterControl函数代码示例

51自学网 2021-06-01 21:26:36
  C++
这篇教程C++ I2CMasterControl函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中I2CMasterControl函数的典型用法代码示例。如果您正苦于以下问题:C++ I2CMasterControl函数的具体用法?C++ I2CMasterControl怎么用?C++ I2CMasterControl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了I2CMasterControl函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: I2CReadSingle

uint32_t I2CReadSingle(uint32_t i2c_base, uint8_t address, uint8_t reg) {	uint32_t data = 0;	// Set slave register to be read	while(I2CMasterBusy(i2c_base));	I2CMasterSlaveAddrSet(i2c_base, address, 0);	I2CMasterDataPut(i2c_base, reg);	I2CMasterControl(i2c_base, I2C_MASTER_CMD_SINGLE_SEND);	while(I2CMasterBusy(i2c_base));	// Check for errors	if (I2CMasterErr(i2c_base) != I2C_MASTER_ERR_NONE) return 0;	// Request for register data	I2CMasterSlaveAddrSet(i2c_base, address, 1);	I2CMasterControl(i2c_base, I2C_MASTER_CMD_SINGLE_RECEIVE);	while(I2CMasterBusy(i2c_base));	// Check for errors	if (I2CMasterErr(i2c_base) != I2C_MASTER_ERR_NONE) return 0;	// Read received data	data = I2CMasterDataGet(i2c_base);	return data;}
开发者ID:luisbc92,项目名称:quad-glove-remote,代码行数:26,


示例2: I2CWriteSingle

uint32_t I2CWriteSingle(uint32_t i2c_base, uint8_t address, uint8_t reg, uint8_t data) {	// Set slave register to be written	while(I2CMasterBusy(i2c_base));	I2CMasterSlaveAddrSet(i2c_base, address, 0);	I2CMasterDataPut(i2c_base, reg);	I2CMasterControl(i2c_base, I2C_MASTER_CMD_BURST_SEND_START);	while(I2CMasterBusy(i2c_base));	// Check for errors	if (I2CMasterErr(i2c_base) != I2C_MASTER_ERR_NONE) return 0;	// Write data	I2CMasterDataPut(i2c_base, data);	I2CMasterControl(i2c_base, I2C_MASTER_CMD_BURST_SEND_CONT);	while(I2CMasterBusy(i2c_base));	// Check for errors	if (I2CMasterErr(i2c_base) != I2C_MASTER_ERR_NONE) return 0;	// End transmission	I2CMasterControl(i2c_base, I2C_MASTER_CMD_BURST_SEND_FINISH);	while(I2CMasterBusy(i2c_base));	// Check for errors	if (I2CMasterErr(i2c_base) != I2C_MASTER_ERR_NONE) return 0;	return 1;}
开发者ID:luisbc92,项目名称:quad-glove-remote,代码行数:29,


示例3: i2c_read_bytes

uint32_t i2c_read_bytes(uint8_t address, uint8_t* buffer, uint32_t length) {    uint32_t future = I2C_MAX_DELAY_US;        // Receive operation    I2CMasterSlaveAddrSet(address, true);    // Multiple receive operation    I2CMasterControl(I2C_MASTER_CMD_BURST_RECEIVE_START);    // Calculate timeout    future += board_timer_get();    // Iterate overall all bytes    while (length) {        // Wait until complete or timeout        while (I2CMasterBusy()) {            // Update timeout status and return if expired            if (board_timer_expired(future)) return length;        }                // Read data from I2C        *buffer++ = I2CMasterDataGet();        length--;        // Check if it's the last byte        if (length == 1) I2CMasterControl(I2C_MASTER_CMD_BURST_RECEIVE_FINISH);        else             I2CMasterControl(I2C_MASTER_CMD_BURST_RECEIVE_CONT);    }        // Return bytes read    return length;}
开发者ID:rromero83,项目名称:openwsn-fw-openDemo,代码行数:32,


示例4: i2c_rx_multi

void i2c_rx_multi(unsigned char SlaveAddr, unsigned char dest, unsigned char num_bytes, unsigned long *data){    unsigned int i=0;        // Set the address    I2CMasterSlaveAddrSet( I2C1_MASTER_BASE, SlaveAddr, I2C_SEND );    I2CMasterDataPut( I2C1_MASTER_BASE, dest );    I2CMasterControl( I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND );    while (I2CMasterBusy( I2C1_MASTER_BASE ));        // Set the address again to tell the device to start sending data    I2CMasterSlaveAddrSet( I2C1_MASTER_BASE, SlaveAddr, I2C_RECEIVE );        I2CMasterControl( I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START );    while(I2CMasterBusy( I2C1_MASTER_BASE ));    *data++ = I2CMasterDataGet(I2C1_MASTER_BASE);            while(i++ < (num_bytes-2))    {        I2CMasterControl( I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT );        while(I2CMasterBusy( I2C1_MASTER_BASE ));        *data++ = I2CMasterDataGet(I2C1_MASTER_BASE);    }        I2CMasterControl( I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH );    while(I2CMasterBusy( I2C1_MASTER_BASE ));    *data++ = I2CMasterDataGet(I2C1_MASTER_BASE);}
开发者ID:lusher00,项目名称:balancing_robot,代码行数:28,


示例5: guard

unsigned long I2CController::read8(uint8_t addr, uint8_t *data, bool sendStartCondition, bool sendStopCondition){	RecursiveMutexGuard guard(&_lock);	unsigned long ret;	I2CMasterSlaveAddrSet(_base, addr, 1);	if (sendStartCondition) {		I2CMasterControl(_base, sendStopCondition ? I2C_MASTER_CMD_SINGLE_SEND : I2C_MASTER_CMD_BURST_RECEIVE_START);		ret = I2CMasterErr(_base);		if (ret != I2C_MASTER_ERR_NONE) {			return ret;		}	} else {		I2CMasterControl(_base, sendStopCondition ? I2C_MASTER_CMD_BURST_RECEIVE_FINISH : I2C_MASTER_CMD_BURST_RECEIVE_CONT);		ret = I2CMasterErr(_base);		if (ret != I2C_MASTER_ERR_NONE) {			return ret;		}	}	ret = waitFinish(_defaultTimeout);	if (ret != I2C_MASTER_ERR_NONE) {		return ret;	}	*data = I2CMasterDataGet(_base);	ret = I2CMasterErr(_base);	if (ret != I2C_MASTER_ERR_NONE) {		return ret;	}	return 0;}
开发者ID:germaneers,项目名称:openstella,代码行数:31,


示例6: I2C_Write0

void I2C_Write0(uint16_t device_address, uint16_t device_register, uint8_t device_data){   //specify that we want to communicate to device address with an intended write to bus   I2CMasterSlaveAddrSet(I2C0_BASE, device_address, false);   //register to be read   I2CMasterDataPut(I2C0_BASE, device_register);   //send control byte and register address byte to slave device   I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);   //wait for MCU to finish transaction   while(I2CMasterBusy(I2C0_BASE));   I2CMasterSlaveAddrSet(I2C0_BASE, device_address, true);   //specify data to be written to the above mentioned device_register   I2CMasterDataPut(I2C0_BASE, device_data);   //wait while checking for MCU to complete the transaction   I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);   //wait for MCU & device to complete transaction   while(I2CMasterBusy(I2C0_BASE));}
开发者ID:thrasher8390,项目名称:TIVA_Hardware,代码行数:25,


示例7: I2C_Read0

uint32_t I2C_Read0(uint16_t device_address, uint16_t device_register){   //specify that we want to communicate to device address with an intended write to bus   I2CMasterSlaveAddrSet(I2C0_BASE, device_address, false);   //the register to be read   I2CMasterDataPut(I2C0_BASE, device_register);   //send control byte and register address byte to slave device   I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);   //wait for MCU to complete send transaction   while(I2CMasterBusy(I2C0_BASE));   //read from the specified slave device   I2CMasterSlaveAddrSet(I2C0_BASE, device_address, true);   //send control byte and read from the register from the MCU   I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);   //wait while checking for MCU to complete the transaction   while(I2CMasterBusy(I2C0_BASE));   //Get the data from the MCU register and return to caller   return( (uint32_t)I2CMasterDataGet(I2C0_BASE)); }
开发者ID:thrasher8390,项目名称:TIVA_Hardware,代码行数:26,


示例8: I2CMasterSlaveAddrSet

unsigned long I2CController::nolock_write8(uint8_t addr, uint8_t data, bool sendStartCondition, bool sendStopCondition){	unsigned long ret;	I2CMasterSlaveAddrSet(_base, addr, 0);	I2CMasterDataPut(_base, data);	if (sendStartCondition) {		I2CMasterControl(_base, sendStopCondition ? I2C_MASTER_CMD_SINGLE_SEND : I2C_MASTER_CMD_BURST_SEND_START);		ret = I2CMasterErr(_base);		if (ret != I2C_MASTER_ERR_NONE) {			return ret;		}	} else {		I2CMasterControl(_base, sendStopCondition ? I2C_MASTER_CMD_BURST_SEND_FINISH : I2C_MASTER_CMD_BURST_SEND_CONT);		ret = I2CMasterErr(_base);		if (ret != I2C_MASTER_ERR_NONE) {			return ret;		}	}	ret = waitFinish();	if (ret != I2C_MASTER_ERR_NONE) {		return ret;	}	return 0;}
开发者ID:HubertD,项目名称:openstella,代码行数:28,


示例9: BSP_DACReadRegister

/***********************************************************************************************************                     BSP_DACReadRegister (CPU_INT08U ucRegister, CPU_INT08U *pucData)** Description : Read a register in the TLV320AIC3107 DAC.** Argument(s) : ucRegister is the offset to the register to write.*               pucData is a pointer to the returned data.** Return(s)   : True on success or false on error.** Caller(s)   : Sound driver.** Note(s)     : ***********************************************************************************************************/static  CPU_BOOLEAN  BSP_DACReadRegister (CPU_INT08U ucRegister, CPU_INT08U *pucData){    // Set the slave address and "WRITE"/false.    I2CMasterSlaveAddrSet(DAC_I2C_MASTER_BASE, TI_TLV320AIC3107_ADDR, false);    // Write the first byte to the controller (register)    I2CMasterDataPut(DAC_I2C_MASTER_BASE, ucRegister);    // Continue the transfer.    I2CMasterControl(DAC_I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START);    // Wait until the current byte has been transferred.    while(I2CMasterIntStatus(DAC_I2C_MASTER_BASE, false) == 0)    {    }    if(I2CMasterErr(DAC_I2C_MASTER_BASE) != I2C_MASTER_ERR_NONE)    {        I2CMasterIntClear(DAC_I2C_MASTER_BASE);        return(false);    }    // Wait until the current byte has been transferred.    while(I2CMasterIntStatus(DAC_I2C_MASTER_BASE, false))    {        I2CMasterIntClear(DAC_I2C_MASTER_BASE);    }    // Set the slave address and "READ"/true.    I2CMasterSlaveAddrSet(DAC_I2C_MASTER_BASE, TI_TLV320AIC3107_ADDR, true);    // Read Data Byte.    I2CMasterControl(DAC_I2C_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);    // Wait until the current byte has been transferred.    while(I2CMasterIntStatus(DAC_I2C_MASTER_BASE, false) == 0)    {    }    if(I2CMasterErr(DAC_I2C_MASTER_BASE) != I2C_MASTER_ERR_NONE)    {        I2CMasterIntClear(DAC_I2C_MASTER_BASE);        return(false);    }    // Wait until the current byte has been transferred.    while(I2CMasterIntStatus(DAC_I2C_MASTER_BASE, false))    {        I2CMasterIntClear(DAC_I2C_MASTER_BASE);    }	*pucData  = I2CMasterDataGet(DAC_I2C_MASTER_BASE);    return(true);}
开发者ID:gouravmodi1991,项目名称:6154_Embedded_Operating_System,代码行数:73,


示例10: EEPROMI2CRead

/** * /brief   This function reads data from EEPROM. * * /param   data    Address where data is to be read. * /param   length  Length of data to be read * /param   offset  Address of the byte from which data to be read. * * /return  None. * * /note    This muxing depends on the profile in which the EVM is configured. *          EEPROMI2CSetUp Shall be called Before this API is used */void EEPROMI2CRead(unsigned char *data, unsigned int length,                   unsigned short offset){    unsigned int idx = 0;    /* First send the register offset - TX operation */    I2CSetDataCount(I2C_BASE_ADDR, 2);    StatusClear();    I2CMasterControl(I2C_BASE_ADDR, I2C_CFG_MST_TX);    I2CMasterStart(I2C_BASE_ADDR);    /* Wait for the START to actually occir on the bus */    while (0 == I2CMasterBusBusy(I2C_BASE_ADDR));    I2CMasterDataPut(I2C_BASE_ADDR, (unsigned char)((offset >> 8) & 0xFF));    /* Wait for the Tx register to be empty */    while (0 == I2CMasterIntRawStatusEx(I2C_BASE_ADDR,                                        I2C_INT_TRANSMIT_READY));    /* Push offset out and tell CPLD from where we intend to read the data */    I2CMasterDataPut(I2C_BASE_ADDR, (unsigned char)(offset & 0xFF));    I2CMasterIntClearEx(I2C_BASE_ADDR, I2C_INT_TRANSMIT_READY);    while(0 == (I2CMasterIntRawStatus(I2C_BASE_ADDR) & I2C_INT_ADRR_READY_ACESS));    StatusClear();    I2CSetDataCount(I2C_BASE_ADDR, length);    /* Now that we have sent the register offset, start a RX operation*/    I2CMasterControl(I2C_BASE_ADDR, I2C_CFG_MST_RX);    /* Repeated start condition */    I2CMasterStart(I2C_BASE_ADDR);    while (length--)    {        while (0 == I2CMasterIntRawStatusEx(I2C_BASE_ADDR,                                            I2C_INT_RECV_READY));        data[idx++] = (unsigned char)I2CMasterDataGet(I2C_BASE_ADDR);        I2CMasterIntClearEx(I2C_BASE_ADDR, I2C_INT_RECV_READY);    }    I2CMasterStop(I2C_BASE_ADDR);    while(0 == (I2CMasterIntRawStatus(I2C_BASE_ADDR) & I2C_INT_STOP_CONDITION));    I2CMasterIntClearEx(I2C_BASE_ADDR, I2C_INT_STOP_CONDITION);}
开发者ID:KonstantinVoip,项目名称:starterwarefree-code,代码行数:66,


示例11: i2c_tx_single

void i2c_tx_single(unsigned char SlaveAddr, unsigned char dest, unsigned char data){    I2CMasterSlaveAddrSet( I2C1_MASTER_BASE, SlaveAddr, I2C_SEND );        I2CMasterDataPut( I2C1_MASTER_BASE, dest );    I2CMasterControl( I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START );    while(I2CMasterBusy(I2C1_MASTER_BASE));        I2CMasterDataPut( I2C1_MASTER_BASE, data );    I2CMasterControl( I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH );    while(I2CMasterBusy(I2C1_MASTER_BASE));}
开发者ID:lusher00,项目名称:balancing_robot,代码行数:12,


示例12: LED_CONTROL

//used to control the ledsvoid LED_CONTROL(int LED_NUMBER, int LED_COMMAND){	data_handler(LED_NUMBER,LED_COMMAND);	// Slave address of TCA6507 is 0x45 (binary 1001 101)	// false=write / true=read	I2CMasterSlaveAddrSet(I2C0_MASTER_BASE, 0x45, false);// the for loop is there to make the code more compact and removes some redundant commands.	int COUNTER;		for (COUNTER=0;COUNTER!=5;COUNTER++)		{			if(COUNTER == 2)			{				//puts the command-byte in the dataput getting ready to sending it.				I2CMasterDataPut(I2C0_MASTER_BASE, COMMAND_BYTE_INCREMENT);				//starts sending the data.				I2CMasterControl(I2C0_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_START);			}			else if(COUNTER == 3)			{				//gets the first led_current_setting containing the byte for select0 ready to transmitting.				I2CMasterDataPut(I2C0_MASTER_BASE,led_current_setting[0] );				//keeps sending data.				I2CMasterControl(I2C0_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_CONT);			}			else if(COUNTER == 4)			{				//gets the second led_current_setting containing the byte for select1 ready to transmitting.				I2CMasterDataPut(I2C0_MASTER_BASE,led_current_setting[1] );				//keeps sending data.				I2CMasterControl(I2C0_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_CONT);			}			else if(COUNTER == 5)			{				//gets the third led_current_setting containing the byte for select2 ready to transmitting.				I2CMasterDataPut(I2C0_MASTER_BASE,led_current_setting[2] );				//transmitting the final byte and a stop command.				I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH );			}			// Wait for I2C to finish.			while(I2CMasterBusy(I2C0_MASTER_BASE));			//a short delay.			SysCtlDelay(80000);		}}
开发者ID:BetteLars,项目名称:EAL_Embedded,代码行数:53,


示例13: i2c_rx_single

unsigned long i2c_rx_single(unsigned char SlaveAddr, unsigned char dest){    I2CMasterSlaveAddrSet( I2C1_MASTER_BASE, SlaveAddr, I2C_SEND );    I2CMasterDataPut( I2C1_MASTER_BASE, dest );    I2CMasterControl( I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND );    while (I2CMasterBusy( I2C1_MASTER_BASE ));        I2CMasterSlaveAddrSet( I2C1_MASTER_BASE, SlaveAddr, I2C_RECEIVE );    I2CMasterControl( I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE );    while(I2CMasterBusy( I2C1_MASTER_BASE ));        return I2CMasterDataGet(I2C1_MASTER_BASE);}
开发者ID:lusher00,项目名称:balancing_robot,代码行数:13,


示例14: I2CTransmit

//This will setup the com for a device, declare the regiester to write to and then write to that regiester//Note I2C waits for a response bit before continuing. If there is no device on the other end the masterbusy loop will NEVER exitvoid I2CTransmit(unsigned char device, unsigned char regiester, unsigned char value){	I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, device, false);	//Set Device to transmit to	I2CMasterDataPut(I2C1_MASTER_BASE,regiester);	//Put on regiester to prep writting	I2CMasterControl(I2C1_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_START);	//Send start bit and the first thing	while(I2CMasterBusy(I2C1_MASTER_BASE));	//Wait till data sent	I2CMasterDataPut(I2C1_MASTER_BASE,value);	//Put more data on	I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);	//Send data and finish bit	while(I2CMasterBusy(I2C1_MASTER_BASE));	//Wait till done}
开发者ID:arduic,项目名称:GitHub,代码行数:15,


示例15: Accel_RegRead

//*****************************************************************************//// Reads a single gyro register.  This routine is blocking.//// /param ui8RegisterAddress is the register address// /return read data////*****************************************************************************uint8_tAccel_RegRead(uint8_t ui8RegisterAddress){    uint8_t ui8Data = 0;    if (VERBOSE) UARTprintf("GryroRegRead(0x%x)/n", ui8RegisterAddress);    // Set the slave device address for WRITE    //   false = this I2C Master is initiating a writes to the slave.    //   true  = this I2C Master is initiating reads from the slave.    I2CMasterSlaveAddrSet(I2C1_BASE, ACCEL_SLAVE_ADDRESS, false);    //    // Transaction #1: Send the register address    //    // Set the Gyro Register address to write    I2CMasterDataPut(I2C1_BASE, ui8RegisterAddress);    // Start, send device address, write one byte (register address), and end the transaction    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_SEND);    // Wait for completion    while(I2CMasterBusy(I2C1_BASE))    {    	//spin wait    }    //TODO: Check I2CMasterErr(I2C1_BASE)    //    // Transaction #2: Read the register data    //    // Set the slave device address for READ    //   false = this I2C Master is initiating a writes to the slave.    //   true  = this I2C Master is initiating reads from the slave.    I2CMasterSlaveAddrSet(I2C1_BASE, ACCEL_SLAVE_ADDRESS, true);    // Start, send device address, read one byte (register data), and end the transaction    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);    // Wait for completion    while(I2CMasterBusy(I2C1_BASE))    {        //spin wait    }    //TODO: Check I2CMasterErr(I2C1_BASE)    ui8Data = I2CMasterDataGet(I2C1_BASE);    return ui8Data;}
开发者ID:kylevedder,项目名称:GyroProject,代码行数:59,


示例16: BSP_DACWriteRegister

/***********************************************************************************************************                        BSP_DACWriteRegister (CPU_INT08U ucRegister, CPU_INT32U ulData)** Description : Write a register in the TLV320AIC3107 DAC.** Argument(s) : ucRegister is the offset to the register to write.*               ulData is the data to be written to the DAC register.** Return(s)   : True on success or false on error.** Caller(s)   : Sound driver.** Note(s)     : This function will write the register passed in ucAddr with the value*               passed in to ulData.  The data in ulData is actually 9 bits and the*               value in ucAddr is interpreted as 7 bits.**********************************************************************************************************/static  CPU_BOOLEAN  BSP_DACWriteRegister (CPU_INT08U ucRegister, CPU_INT32U ulData){    // Set the slave address.    I2CMasterSlaveAddrSet(DAC_I2C_MASTER_BASE, TI_TLV320AIC3107_ADDR, false);    // Write the first byte to the controller (register)    I2CMasterDataPut(DAC_I2C_MASTER_BASE, ucRegister);    // Continue the transfer.    I2CMasterControl(DAC_I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START);    // Wait until the current byte has been transferred.    while(I2CMasterIntStatus(DAC_I2C_MASTER_BASE, false) == 0)    {    }    if(I2CMasterErr(DAC_I2C_MASTER_BASE) != I2C_MASTER_ERR_NONE)    {        I2CMasterIntClear(DAC_I2C_MASTER_BASE);        return(false);    }    // Wait until the current byte has been transferred.    while(I2CMasterIntStatus(DAC_I2C_MASTER_BASE, false))    {        I2CMasterIntClear(DAC_I2C_MASTER_BASE);    }    // Write the data byte to the controller.    I2CMasterDataPut(DAC_I2C_MASTER_BASE, ulData);    // End the transfer.    I2CMasterControl(DAC_I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);    // Wait until the current byte has been transferred.    while(I2CMasterIntStatus(DAC_I2C_MASTER_BASE, false) == 0)    {    }    if(I2CMasterErr(DAC_I2C_MASTER_BASE) != I2C_MASTER_ERR_NONE)    {        return(false);    }    while(I2CMasterIntStatus(DAC_I2C_MASTER_BASE, false))    {        I2CMasterIntClear(DAC_I2C_MASTER_BASE);    }    return(true);}
开发者ID:gouravmodi1991,项目名称:6154_Embedded_Operating_System,代码行数:69,


示例17: CHANGE_BRIGHTNESS_VALUES

//used to control the brightness value.void CHANGE_BRIGHTNESS_VALUES(int value0,int value1){	// Slave address of TCA6507 is 0x45 (binary 1001 101)		// false=write / true=read		I2CMasterSlaveAddrSet(I2C0_MASTER_BASE, 0x45, false);		int COUNTER;		for (COUNTER=0;COUNTER!=4;COUNTER++)		{			//ensure that the user input value is a legal value if not it skips out of the function.			if(value0||value1 > 15 )			{				COUNTER=4;			}			else if(value0||value1 <  1 )			{				COUNTER=4;			}			else if(COUNTER == 2)			{				//puts the command-byte in the dataput getting ready to sending it.				I2CMasterDataPut(I2C0_MASTER_BASE, COMMAND_BYTE_MAXIMUM_INTENSITY);				//starts sending the data.				I2CMasterControl(I2C0_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_START);			}			else if(COUNTER == 3)				{					//value0 and value1 is send through the same byte where value0 is the first 4bit and value1 is the last 4bit.					I2CMasterDataPut(I2C0_MASTER_BASE,NUMBER_HEX[value0]+(10*NUMBER_HEX[value1]));					//transmitting the final byte and a stop command.					I2CMasterControl(I2C0_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH );				}			// Wait for I2C to finish.			while(I2CMasterBusy(I2C0_MASTER_BASE));			//a short delay.			SysCtlDelay(80000);		}}
开发者ID:BetteLars,项目名称:EAL_Embedded,代码行数:51,


示例18: byteAccelRead

unsigned long byteAccelRead(int reg){		short temp;		I2CMasterSlaveAddrSet(I2C_MASTER_BASE, 0x1D, false);		I2CMasterDataPut(I2C_MASTER_BASE, reg);		I2CMasterControl(I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START);		while(I2CMasterBusy(I2C_MASTER_BASE));		I2CMasterSlaveAddrSet(I2C_MASTER_BASE, 0x1D, true);		I2CMasterControl(I2C_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);		while(I2CMasterBusy(I2C_MASTER_BASE));		return I2CMasterDataGet(I2C_MASTER_BASE);		}
开发者ID:richardszeto,项目名称:Embedded_Systems,代码行数:15,


示例19: i2c3_master_interrupt

void i2c3_master_interrupt(void) {	unsigned long status = I2CMasterIntStatusEx(I2C3_MASTER_BASE, false);	if (status & I2C_MASTER_INT_TIMEOUT) {		i2c_flag = 2;		I2CMasterIntClearEx(I2C3_MASTER_BASE, I2C_MASTER_INT_TIMEOUT);	}	if (status & I2C_MASTER_INT_DATA) {		err = I2CMasterErr(I2C3_MASTER_BASE);		if (err != I2C_MASTER_ERR_NONE)			i2c_flag = 2;		if (what_we_re_doing == sending) {			sent_bytes++;			if (sent_bytes < sizeof(data)-1) {				//Continuing				 I2CMasterDataPut(I2C3_MASTER_BASE, ((unsigned char *)&data)[sent_bytes]);				 I2CMasterControl(I2C3_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);			}			else if (sent_bytes == sizeof(data)-1) {				//Last byte remaining				 I2CMasterDataPut(I2C3_MASTER_BASE, ((unsigned char *)&data)[sent_bytes]);				 I2CMasterControl(I2C3_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);			}			else {				//Transaction is done				i2c_flag = 1;			}		}		else if (what_we_re_doing == receiving) {			unsigned char *p = (unsigned char *)&data_recv + received_bytes;			*p = I2CMasterDataGet(I2C3_MASTER_BASE);			received_bytes++;			if (received_bytes < sizeof(data_recv) - 1) {				I2CMasterControl(I2C3_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);			}			else if (received_bytes == sizeof(data_recv) - 1) {				I2CMasterControl(I2C3_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);			}			else {				//Transaction is done				i2c_flag = 1;			}		}		I2CMasterIntClearEx(I2C3_MASTER_BASE, I2C_MASTER_INT_DATA);	}}
开发者ID:ARENIBDelta,项目名称:some_i2c_examples,代码行数:48,


示例20: OSRAMWriteArray

//*****************************************************************************////! /internal//!//! Write a sequence of bytes to the SSD0303 controller.//!//! This function continues a transfer to the SSD0303 controller by writing a//! sequence of bytes over the I2C bus.  This must only be called after calling//! OSRAMWriteFirst(), but before calling OSRAMWriteFinal().//!//! The data is written in a polled fashion; this function will not return//! until the entire byte sequence has been written to the controller.//!//! /return None.////*****************************************************************************static voidOSRAMWriteArray(const unsigned char *pucBuffer, unsigned long ulCount){    //    // Loop while there are more bytes left to be transferred.    //    while(ulCount != 0) {        //        // Wait until the current byte has been transferred.        //        while(I2CMasterIntStatus(I2C_MASTER_BASE, false) == 0) {        }        //        // Provide the required inter-byte delay.        //        OSRAMDelay(g_ulDelay);        //        // Write the next byte to the controller.        //        I2CMasterDataPut(I2C_MASTER_BASE, *pucBuffer++);        ulCount--;        //        // Continue the transfer.        //        I2CMasterControl(I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);    }}
开发者ID:peterliu2,项目名称:FreeRTOS,代码行数:46,


示例21: nolock_read8

unsigned long I2CController::nolock_read(uint8_t addr, uint8_t *buf, int count, bool sendStartCondition, bool sendStopCondition){	unsigned long ret;	if (count<1) return 0;	ret = nolock_read8(addr, buf, sendStartCondition, (sendStopCondition && count==1));	if (ret != I2C_MASTER_ERR_NONE) {		return ret;	}	for (uint8_t i=1; i<count; i++) {		I2CMasterControl(_base, ((i==(count-1)) && sendStopCondition) ? I2C_MASTER_CMD_BURST_RECEIVE_FINISH : I2C_MASTER_CMD_BURST_RECEIVE_CONT);		ret = I2CMasterErr(_base);		if (ret != I2C_MASTER_ERR_NONE) {			return ret;		}		ret = waitFinish();		if (ret != I2C_MASTER_ERR_NONE) {			return ret;		}		buf[i] = I2CMasterDataGet(_base);		ret = I2CMasterErr(_base);		if (ret != I2C_MASTER_ERR_NONE) {			return ret;		}	}	return 0;}
开发者ID:HubertD,项目名称:openstella,代码行数:30,


示例22: accelWrite

void accelWrite (int reg,char data){		// Sets the slave address		I2CMasterSlaveAddrSet(I2C_MASTER_BASE, 0x1D, false);		// Sends the register we want		I2CMasterDataPut(I2C_MASTER_BASE, reg);		I2CMasterControl(I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START);		while(I2CMasterBusy(I2C_MASTER_BASE));				// Set the register value		I2CMasterDataPut(I2C_MASTER_BASE, data);		I2CMasterControl(I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);		while(I2CMasterBusy(I2C_MASTER_BASE));}
开发者ID:richardszeto,项目名称:Embedded_Systems,代码行数:16,


示例23: OSRAM96x16x1WriteByte

//*****************************************************************************////! /internal//!//! Write a byte to the SSD0303 controller.//!//! /param ucChar is the byte to be transmitted to the controller.//!//! This function continues a transfer to the SSD0303 controller by writing//! another byte over the I2C bus.  This must only be called after calling//! OSRAM96x16x1WriteFirst(), but before calling OSRAM96x16x1WriteFinal().//!//! The data is written in a polled faashion; this function will not return//! until the byte has been written to the controller.//!//! /return None.////*****************************************************************************static voidOSRAM96x16x1WriteByte(unsigned char ucChar){    //    // Wait until the current byte has been transferred.    //    while(I2CMasterIntStatus(I2C0_MASTER_BASE, false) == 0)    {    }    //    // Provide the required inter-byte delay.    //    SysCtlDelay(g_ulDelay);    //    // Write the next byte to the controller.    //    I2CMasterDataPut(I2C0_MASTER_BASE, ucChar);    //    // Continue the transfer.    //    I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);}
开发者ID:weng-frank,项目名称:RAS_LM3S811,代码行数:43,


示例24: OSRAMWriteFinal

//*****************************************************************************////! /internal//!//! Finish a transfer to the SSD0303 controller.//!//! /param ucChar is the final byte to be written to the controller.//!//! This function will finish a transfer to the SSD0303 controller via the I2C//! bus.  This must only be called after calling OSRAMWriteFirst().//!//! The data is written in a polled fashion; this function will not return//! until the byte has been written to the controller.//!//! /return None.////*****************************************************************************static voidOSRAMWriteFinal(unsigned char ucChar){    //    // Wait until the current byte has been transferred.    //    while(I2CMasterIntStatus(I2C_MASTER_BASE, false) == 0) {    }    //    // Provide the required inter-byte delay.    //    OSRAMDelay(g_ulDelay);    //    // Write the final byte to the controller.    //    I2CMasterDataPut(I2C_MASTER_BASE, ucChar);    //    // Finish the transfer.    //    I2CMasterControl(I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);    //    // Wait until the final byte has been transferred.    //    while(I2CMasterIntStatus(I2C_MASTER_BASE, false) == 0) {    }    //    // Provide the required inter-byte delay.    //    OSRAMDelay(g_ulDelay);}
开发者ID:peterliu2,项目名称:FreeRTOS,代码行数:52,


示例25: twe_I2CMasterVerify

/** * Verifies that a transmission from the master has completed successfully * * /param ui32base Base address of the I2C peripheral  * * /param burst Set to true if burst mode was used for the transmission * * /param receive Set to true if a receive transmission is to be verified * Set to false if a send transmission is to be verified * * /note Waits until a transmission is complete and then checks that no errors have occurred * * /note If an error occurs the I2C transmission is stopped, the error LED is lit and the * program enters an infinite loop to hold the state. **/void twe_I2CMasterVerify(uint32_t ui32base, bool burst, bool receive) {	while(I2CMasterBusy(ui32base)) {} // Wait until the transfer is complete	//uint32_t errorStatus = I2CMasterErr(ui32Base);	if(I2CMasterErr(ui32base) != I2C_MASTER_ERR_NONE) {		// An error has occured		if(burst && !receive) {			I2CMasterControl(ui32base, I2C_MASTER_CMD_BURST_SEND_ERROR_STOP);		}		else if(burst && !receive) {			I2CMasterControl(ui32base, I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP);		}		while(1) {} // Capture state	}}
开发者ID:IMEMS,项目名称:gtbelib,代码行数:31,


示例26: Display96x16x1WriteArray

//*****************************************************************************////! /internal//!//! Write a sequence of bytes to the SSD0303 or SD1300 controller.//!//! This function continues a transfer to the display controller by writing a//! sequence of bytes over the I2C bus.  This must only be called after calling//! Display96x16x1WriteFirst(), but before calling Display96x16x1WriteFinal().//!//! The data is written in a polled fashion; this function will not return//! until the entire byte sequence has been written to the controller.//!//! /return None.////*****************************************************************************static voidDisplay96x16x1WriteArray(const unsigned char *pucBuffer, unsigned long ulCount){    //    // Loop while there are more bytes left to be transferred.    //    while(ulCount != 0)    {        //        // Wait until the current byte has been transferred.        //        while(I2CMasterIntStatus(I2C0_MASTER_BASE, false) == 0)        {        }        //        // Clear the I2C interrupt.        //        I2CMasterIntClear(I2C0_MASTER_BASE);        //        // Write the next byte to the controller.        //        I2CMasterDataPut(I2C0_MASTER_BASE, *pucBuffer++);        ulCount--;        //        // Continue the transfer.        //        I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);    }}
开发者ID:Razofiter,项目名称:Luminary-Micro-Library,代码行数:48,


示例27: Display96x16x1WriteByte

//*****************************************************************************////! /internal//!//! Write a byte to the SSD0303 or SSD1300 controller.//!//! /param ucChar is the byte to be transmitted to the controller.//!//! This function continues a transfer to the display controller by writing//! another byte over the I2C bus.  This must only be called after calling//! Display96x16x1WriteFirst(), but before calling Display96x16x1WriteFinal().//!//! The data is written in a polled faashion; this function will not return//! until the byte has been written to the controller.//!//! /return None.////*****************************************************************************static voidDisplay96x16x1WriteByte(unsigned char ucChar){    //    // Wait until the current byte has been transferred.    //    while(I2CMasterIntStatus(I2C0_MASTER_BASE, false) == 0)    {    }    //    // Clear the I2C interrupt.    //    I2CMasterIntClear(I2C0_MASTER_BASE);    //    // Write the next byte to the controller.    //    I2CMasterDataPut(I2C0_MASTER_BASE, ucChar);    //    // Continue the transfer.    //    I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);}
开发者ID:Razofiter,项目名称:Luminary-Micro-Library,代码行数:43,


示例28: I2CRead

//Read from device using address and put the read values into buff. num=num of bytes to readvoid I2CRead(unsigned char device, unsigned char regiester, unsigned char num, unsigned long *buff){	//All commented code could likely be delted currently saving for record / emergency	/*I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, device, false);	//Set Device to transmit to	I2CMasterDataPut(I2C1_MASTER_BASE,regiester);	//Put on regiester to prep writting	I2CMasterControl(I2C1_MASTER_BASE,I2C_MASTER_CMD_SINGLE_SEND);	//while(I2CMasterBusBusy(I2C1_MASTER_BASE));	//Wait till data sent	while(I2CMasterBusy(I2C1_MASTER_BASE));		//this is good	short i=0;	for (i=0; i<num; i++){		I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, device, true);	//Set device to RECIEVE FROM		/*I2CMasterDataPut(I2C1_MASTER_BASE,regiester+i);	//Put on regiester to prep writting		I2CMasterControl(I2C1_MASTER_BASE,I2C_MASTER_CMD_SINGLE_SEND);		//while(I2CMasterBusBusy(I2C1_MASTER_BASE));	//Wait till data sent		while(I2CMasterBusy(I2C1_MASTER_BASE));	 */	/*if(i==0){			I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);		}else if(i==(num-1)){			I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);		}else{			I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);		}		//while(I2CMasterIntStatus(I2C1_MASTER_BASE, false) == 0);		while(I2CMasterBusy(I2C1_MASTER_BASE));		buff[i] = I2CMasterDataGet(I2C1_MASTER_BASE);		//I2CMasterIntClear(I2C1_MASTER_BASE);	}	//buff[0]=0x02;	 */	short i=0;	//Initalize i because CCS doesn't like initalizing inside for loop :P	for(i=0; i<num; i++){		I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, device, false);	//Set device to write to		I2CMasterDataPut(I2C1_MASTER_BASE,regiester+i);	//Put on regiester to prep writting		I2CMasterControl(I2C1_MASTER_BASE,I2C_MASTER_CMD_SINGLE_SEND);	//Make a single send there is no bursting through		while(I2CMasterBusy(I2C1_MASTER_BASE));		//wait for the transmission to end via checking the master's state NOT THE BUS		I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, device, true);	//Set device to RECIEVE FROM		I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);	//Set a single read because it will only return this address		while(I2CMasterBusy(I2C1_MASTER_BASE));		//Wait for the master to stop recieving data		buff[i] = I2CMasterDataGet(I2C1_MASTER_BASE);	//Place the data recieved (that is in the FIFO) into the buffer to return	}}
开发者ID:arduic,项目名称:GitHub,代码行数:47,



注:本文中的I2CMasterControl函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ I2CRead函数代码示例
C++ I2CMasterBaseValid函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。