示例#1
0
 /**
 * @brief  mpu6050_init
 * @param  void
 * @retval 成功为0
 * @note 初始化mpu6050    频率为100*1000HZ
 */
int16_t mpu6050_init(void)
{
    
    I2C_QuickInit(I2C0_SCL_PB02_SDA_PB03,100*1000);
    
    
    int result=0;
    
    result=mpu_init();
	if(!result)
	{	 		 
	
		PrintChar("mpu initialization complete......\n ");		//mpu initialization complete	 	  

		if(!mpu_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL))		//mpu_set_sensor
			PrintChar("mpu_set_sensor complete ......\n");
		else
			PrintChar("mpu_set_sensor come across error ......\n");

		if(!mpu_configure_fifo(INV_XYZ_GYRO | INV_XYZ_ACCEL))	//mpu_configure_fifo
			PrintChar("mpu_configure_fifo complete ......\n");
		else
			PrintChar("mpu_configure_fifo come across error ......\n");

		if(!mpu_set_sample_rate(DEFAULT_MPU_HZ))	   	  		//mpu_set_sample_rate
		 PrintChar("mpu_set_sample_rate complete ......\n");
		else
		 	PrintChar("mpu_set_sample_rate error ......\n");

		if(!dmp_load_motion_driver_firmware())   	  			//dmp_load_motion_driver_firmvare
			PrintChar("dmp_load_motion_driver_firmware complete ......\n");
		else
			PrintChar("dmp_load_motion_driver_firmware come across error ......\n");

		if(!dmp_set_orientation(inv_orientation_matrix_to_scalar(gyro_orientation))) 	  //dmp_set_orientation
		 	PrintChar("dmp_set_orientation complete ......\n");
		else
		 	PrintChar("dmp_set_orientation come across error ......\n");

		if(!dmp_enable_feature(DMP_FEATURE_6X_LP_QUAT | DMP_FEATURE_TAP |
		    DMP_FEATURE_ANDROID_ORIENT | DMP_FEATURE_SEND_RAW_ACCEL | DMP_FEATURE_SEND_CAL_GYRO |
		    DMP_FEATURE_GYRO_CAL))		   	 					 //dmp_enable_feature
		 	PrintChar("dmp_enable_feature complete ......\n");
		else
		 	PrintChar("dmp_enable_feature come across error ......\n");

		if(!dmp_set_fifo_rate(DEFAULT_MPU_HZ))   	 			 //dmp_set_fifo_rate
		 	PrintChar("dmp_set_fifo_rate complete ......\n");
		else
		 	PrintChar("dmp_set_fifo_rate come across error ......\n");

		run_self_test();		//自检

		if(!mpu_set_dmp_state(1))
		 	PrintChar("mpu_set_dmp_state complete ......\n");
		else
		 	PrintChar("mpu_set_dmp_state come across error ......\n");
	}
    return 0;
}
示例#2
0
void SCCB_Init(void)
{
    I2C_QuickInit(I2C0_SCL_PB00_SDA_PB01, 100*1000);
    /* 只是复位 全部做默认设置 */
    /* Yandld: 如果是默认出厂配置, 则无需配置SCCB */
    OV7620_Reset();
    DelayMs(10);
    /* 默认配置如下 */
    /* 0x12,0x64
       0x06,0xA0
       0x03,0x80 */
}
示例#3
0
文件: i2c.c 项目: rainfd/CH-K-Lib
/**
 * \brief i2c bus scan test
 * @param[in] MAP  I2C引脚配置缩略图,详见i2c.h
 * \retval None
 */
void I2C_Scan(uint32_t MAP)
{
    uint8_t i;
    uint8_t ret;
    uint32_t instance;
    instance = I2C_QuickInit(MAP, 100*1000);
    for(i = 1; i < 127; i++)
    {
        ret = I2C_Probe(instance , i);
        if(!ret)
        {
            LIB_TRACE("ADDR:0x%2X(7BIT) | 0x%2X(8BIT) found!\r\n", i, i<<1);
        }
    }
}
示例#4
0
int SCCB_Init(uint32_t I2C_MAP)
{
    int r;
    uint32_t instance;
    instance = I2C_QuickInit(I2C_MAP, 50*1000);
    r = ov7725_probe(instance);
    if(r)
    {
        return 1;
    }
    r = ov7725_set_image_size(IMAGE_SIZE);
    if(r)
    {
        printf("OV7725 set image error\r\n");
        return 1;
    }
    return 0;
}
示例#5
0
文件: main.c 项目: jeenter/CH-K-Lib
int main(void)
{
    int i;
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PA01_TX_PA02, 115200);
    
     /** print message before mode change*/
    printf("i2s MAPSK64 test\r\n");
    I2C_QuickInit(I2C0_SCL_PE24_SDA_PE25, 100*1000);
   // I2C_Scan(I2C0_SCL_PE24_SDA_PE25);
    wm8960_init(0);
    wm8960_format_config(44100, 16);
   // wm8960_set_volume(kWolfsonModuleHP, 0x2FFF);
    
    
    I2S_InitTypeDef Init;
    Init.instance = 0;
    Init.isStereo = true;
    Init.isMaster = true;
    Init.protocol = kSaiBusI2SLeft;
    Init.sampleBit = 16;
    Init.sampleRate = 44100;
    Init.chl = 0;
    I2S_Init(&Init);
    
    /* pinmux */
    PORT_PinMuxConfig(HW_GPIOE, 6, kPinAlt4);
    PORT_PinMuxConfig(HW_GPIOE, 7, kPinAlt4);
    PORT_PinMuxConfig(HW_GPIOE, 12, kPinAlt4); 
    PORT_PinMuxConfig(HW_GPIOE, 11, kPinAlt4); 
    PORT_PinMuxConfig(HW_GPIOE, 10, kPinAlt4); 
    
    while(1)
    {
        I2S_SendData(0, 16, 0, (uint8_t*)music_44100_16_2, sizeof(music_44100_16_2));
        printf("complete\r\n");
      //  DelayMs(500);
    }
}
示例#6
0
void MB85RC64_Init(uint32_t I2CMAP)
{
    gInstance = I2C_QuickInit(BOARD_I2C_MAP, 100*1000);
}