这篇教程C++ I2C_Cmd函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中I2C_Cmd函数的典型用法代码示例。如果您正苦于以下问题:C++ I2C_Cmd函数的具体用法?C++ I2C_Cmd怎么用?C++ I2C_Cmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了I2C_Cmd函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: I2C_Master_Initialise/**************************************************************************************************** * @fn I2C_Master_Initialise * Call this function to set up the I2C master to its initial standby state. * Remember to enable interrupts from the main application after initializing the I2C. * * @param none * * @return none * ***************************************************************************************************/void I2C_Master_Initialise(void){ I2C_InitTypeDef I2C_InitStructure; /* Configure the I2C interface */ I2C_Cmd(I2C_SENSOR_BUS, ENABLE); I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; I2C_InitStructure.I2C_OwnAddress1 = 0; //Don't care in master mode I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_ClockSpeed = I2C_SENSOR_BUS_CLOCK; I2C_Init(I2C_SENSOR_BUS, &I2C_InitStructure); asyncXfer.i2c_txrx_status = I2C_TXRX_STATUS_PASSED; //initialize last comm status /* Note: I2C bus event and error interrupts are enabled when tx is started */}
开发者ID:crankycoder,项目名称:open-sensor-platform,代码行数:28,
示例2: LM75_Init/** * @brief Initializes the LM75_I2C. * @param None * @retval None */void LM75_Init(void){ LM75_LowLevel_Init(); /* I2C DeInit */ I2C_DeInit(LM75_I2C); /* I2C configuration */ I2C_Init(LM75_I2C, LM75_I2C_SPEED, 0x00, I2C_Mode_SMBusHost, I2C_DutyCycle_2, I2C_Ack_Enable, I2C_AcknowledgedAddress_7bit); /*!< Enable SMBus Alert interrupt */ I2C_ITConfig(LM75_I2C, I2C_IT_ERR, ENABLE); /*!< LM75_I2C Init */ I2C_Cmd(LM75_I2C, ENABLE);}
开发者ID:glockwork,项目名称:ev-stm8l151k6-emotor,代码行数:23,
示例3: I2C_Mode_Config/* * 函数名:I2C_Mode_Config * 描述 :I2C 工作模式配置 * 输入 :无 * 输出 :无 * 调用 :内部调用 */static void I2C_Mode_Config(void){ /* Initialize the I2C1 according to the I2C_InitStructure members */ I2C_InitTypeDef I2C_InitStructure; /* I2C 配置 */ I2C_InitStructure.I2C_Mode = I2C_Mode_I2C ; //I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; //I2C_InitStructure.I2C_OwnAddress1 = SlaveAddress; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_ClockSpeed = 350000; /* I2C1 初始化 */ I2C_Init(I2C1, &I2C_InitStructure); /* 使能 I2C1 */ I2C_Cmd(I2C1, ENABLE); /*允许应答模式*/ I2C_AcknowledgeConfig(I2C1, ENABLE);}
开发者ID:LiuHuiGitHub,项目名称:STM32F103C8,代码行数:25,
示例4: P_I2C3_InitI2C//--------------------------------------------------------------// interne Funktion// Init der I2C-Schnittstelle//--------------------------------------------------------------void P_I2C3_InitI2C(void){ I2C_InitTypeDef I2C_InitStructure; // I2C-Konfiguration I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; I2C_InitStructure.I2C_OwnAddress1 = 0x00; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_ClockSpeed = I2C3_CLOCK_FRQ; // I2C enable I2C_Cmd(I2C3, ENABLE); // Init Struktur I2C_Init(I2C3, &I2C_InitStructure);}
开发者ID:duvitech,项目名称:STM32F429i-Disco_OSC,代码行数:22,
示例5: platform_i2c_setup/* I2C Functions */u32 platform_i2c_setup( unsigned id, u32 speed ){ GPIO_InitTypeDef GPIO_InitStruct; I2C_InitTypeDef I2C_InitStruct; // enable APB1 peripheral clock for I2C1 RCC_APB1PeriphClockCmd(i2c_rcc[id], ENABLE); // enable clock for SCL and SDA pins RCC_AHB1PeriphClockCmd(i2c_port_rcc[id], ENABLE); I2C_DeInit(i2c[id]); /* setup SCL and SDA pins * You can connect I2C1 to two different * pairs of pins: * 1. SCL on PB6 and SDA on PB7 * 2. SCL on PB8 and SDA on PB9 */ GPIO_InitStruct.GPIO_Pin = i2c_scl_pin[id] | i2c_sda_pin[id]; // pins to use GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; // set pins to alternate function GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; // set GPIO speed GPIO_InitStruct.GPIO_OType = GPIO_OType_OD; // set output to open drain --> the line has to be only pulled low, not driven high GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; // enable pull up resistors GPIO_Init(i2c_port[id], &GPIO_InitStruct); // init GPIO // Connect I2C1 pins to AF GPIO_PinAFConfig(i2c_port[id], i2c_scl_pinsource[id], i2c_af[id]); // SCL GPIO_PinAFConfig(i2c_port[id], i2c_sda_pinsource[id], i2c_af[id]); // SDA // configure I2C1 I2C_StructInit(&I2C_InitStruct); I2C_InitStruct.I2C_ClockSpeed = speed; //set speed (100kHz or 400kHz) I2C_InitStruct.I2C_Mode = I2C_Mode_I2C; // I2C mode I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2; // 50% duty cycle --> standard I2C_InitStruct.I2C_OwnAddress1 = 0x00; // own address, not relevant in master mode I2C_InitStruct.I2C_Ack = I2C_Ack_Disable; // disable acknowledge when reading (can be changed later on) I2C_InitStruct.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; // set address length to 7 bit addresses I2C_Init(i2c[id], &I2C_InitStruct); // init I2C1 // enable I2C1 I2C_Cmd(i2c[id], ENABLE); return speed;}
开发者ID:ptLong,项目名称:ruuvitracker_fw,代码行数:45,
示例6: i2cInitvoid i2cInit(I2C_TypeDef *I2C){ NVIC_InitTypeDef NVIC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; I2C_InitTypeDef I2C_InitStructure; // Init pins GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD; GPIO_Init(GPIOB, &GPIO_InitStructure); I2Cx = I2C; // clock out stuff to make sure slaves arent stuck i2cUnstick(); // Init I2C I2C_DeInit(I2Cx); I2C_StructInit(&I2C_InitStructure); I2C_ITConfig(I2Cx, I2C_IT_EVT | I2C_IT_ERR, DISABLE); //Enable EVT and ERR interrupts - they are enabled by the first request I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_ClockSpeed = 400000; I2C_Cmd(I2Cx, ENABLE); I2C_Init(I2Cx, &I2C_InitStructure); NVIC_PriorityGroupConfig(0x500); // I2C ER Interrupt NVIC_InitStructure.NVIC_IRQChannel = I2C2_ER_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); // I2C EV Interrupt NVIC_InitStructure.NVIC_IRQChannel = I2C2_EV_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_Init(&NVIC_InitStructure);}
开发者ID:kh4,项目名称:openLRSngRX32_test,代码行数:44,
|