コード例 #1
0
void range_finder_init()
{
	/* MCU Configuration----------------------------------------------------------*/


	    /* Initialize all configured peripherals */
	    MX_I2C1_Init();

	    tca9545_init();
	    tca9545_set(Channel_0);

	    /* these almost just redo what already done just above by CubeMx Init */
	    XNUCLEO6180XA1_GPIO_Init();
	    XNUCLEO6180XA1_I2C1_Init(&hi2c1);

	    tca9545Channel_e channel;

	    for(channel = Channel_0; channel <= Channel_3; channel++)
	    {
	        tca9545_set(channel);
	        MyDev_Init(myDev);           // your code init device variable
	        MyDev_SetChipEnable(myDev);  // your code assert chip enable
	        MyDev_uSleep(1000);          // your code sleep at least 1 msec
	        VL6180x_InitData(myDev);
	        VL6180x_Prepare(myDev);
	    }
}
コード例 #2
0
/**
 * All in one device init
 * @param myDev  The device
 * @return     0 on success may @a #CALIBRATION_WARNING <0 on errir
 */
int Sample_Init(VL6180xDev_t myDev){
    int status, init_status;
    MyDev_Init(myDev);           // your code
    MyDev_SetChipEnable(myDev);  // your code
    MyDev_uSleep(2000);          // your code sleep at least 1msec prior to do i2c to device
    init_status = VL6180x_InitData(myDev);
    if(init_status == 0 || init_status == CALIBRATION_WARNING ){
        status = VL6180x_Prepare(myDev);
        if( !status )
            status=init_status; // if prepare is successfull return potential init warning
    }
    return status;
}
コード例 #3
0
/**
 * @brief  Simplest polling ALS
 * that may be your main()
 */
void Sample_SimpleAls(void) {
#if VL6180x_ALS_SUPPORT
    VL6180xDev_t myDev;
    VL6180x_AlsData_t Als;

    MyDev_Init(myDev);           // your code init device variable
    MyDev_SetChipEnable(myDev);  // your code assert chip enable
    MyDev_uSleep(1000);          // your code sleep at least 1 msec
    VL6180x_InitData(myDev);
    VL6180x_Prepare(myDev);
    do {
        VL6180x_AlsPollMeasurement(myDev, &Als);
        if (Als.errorStatus == 0 )
            MyDev_ShowLux(myDev, Als.lux); // your code display range in mm
        else
            MyDev_ShowErr(myDev, Als.errorStatus); // your code display error code
    } while (!MyDev_UserSayStop(myDev)); // your code to stop looping
#endif
}