Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BHI160b Shuttle Board with STM32

    Established Member

    Re: BHI160b Shuttle Board with STM32

    Bevor i checked the bhy_enable_virtual_sensor i checked this line before.

    	    if(bhy_install_sensor_callback(VS_TYPE_ROTATION_VECTOR, VS_WAKEUP, sensors_callback_rotation_vector))
    	        //DEBUG("Fail to install sensor callback\n");

    I placed 4 Breakpoints on the return values like this.


    So the return value after bhy_install_sensor_callback is BHY_SUCCESS.

    After i installed the callback i want to enable the virtual sensor like this.

    	    if(bhy_enable_virtual_sensor(VS_TYPE_ROTATION_VECTOR, VS_WAKEUP, ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
    	        //DEBUG("Fail to enable sensor id=%d\n", VS_TYPE_ROTATION_VECTOR);

    In the Debug session i jumped into this function and checked its return value.


    The return value is 18.

    I tried to implement also the meta event callback. For that i have some questions.

    Can i implement more that one callback function on the sensor?

    If yes, i implemented the function after the sensor Install and callback. Is this working like that?

    	    /* install the meta event callback */
    	        //DEBUG("Fail to enable sensor id=%d\n", VS_TYPE_ROTATION_VECTOR);

    I am not sure which BHY_META_EVENT i have to install to get the current sensor status. I checked the selftest_example in the git repository.

    They installed the meta event callback like this:

        bhy_install_meta_event_callback(BHY_META_EVENT_TYPE_INITIALIZED, meta_event_callback);
        bhy_install_meta_event_callback(BHY_META_EVENT_TYPE_SELF_TEST_RESULTS, meta_event_callback);

    but none of these callbacks gives me the current sensor status? So which one do i have to use?

    Community Moderator

    Re: BHI160b Shuttle Board with STM32

    what is the value for following parameter in your code? 


     It shows a enable sensor error (expect return value is also 0 for this funciton).  then you don't really enable any virtual sensor, so no data in FIFO,  no interrupt fired. 

    Enable virtual sensor is just mapping the settings into coresponding register content, then do a burst write into sensor. 

    Following are the error code we defined in the BHY driver.  you got -18 (all error is minus).  so you should have several write parameter pages error in calling our API code. 

    Thus,  i ask to check both sample rate and your write function again. 

    If you have logic analyzer plotter is better to understanding the issue.

    #define BHY_NULL_PTR ((void *) 0)
    #define BHY_NULL ((u8)0)
    #define BHY_COMM_RES ((s8)-1)
    #define BHY_OUT_OF_RANGE ((s8)-2)
    #define BHY_SUCCESS ((u8)0)
    #define BHY_ERROR ((s8)-3)

    Community Moderator

    Re: BHI160b Shuttle Board with STM32

    According to the meta event,  i want the following meta event type to be checked:


    Or you can try to print the content with meta event id in the FIFO for reference. 

    Established Member

    Re: BHI160b Shuttle Board with STM32

    Thats how i defined the sample rate in main.c


    It seems like that my read and write function is not working properly. I refered to the code from a different topic. But i dont know how he initialized the I2C interface. That how i did it:

      hi2c1.Instance = I2C1;
      hi2c1.Init.ClockSpeed = 100000;
      hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
      hi2c1.Init.OwnAddress1 = 0;
      hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
      hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
      hi2c1.Init.OwnAddress2 = 0;
      hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
      hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
      if (HAL_I2C_Init(&hi2c1) != HAL_OK)

    Actually i also dont know how long i should set my delay on the i2c transmit/receive function...

    Community Moderator

    Re: BHI160b Shuttle Board with STM32

    The interface initialize looks OK from my side.

    And i found one thing in your HW connection:  J1 pin 17 is SDA.  in your previous conent,  you connect it to SCL.

    If the FW download is successfully,  actually i will expect a good write function of the platform.

    Can you check exactly which function got error code returned then we can know exactly which step you got issue? 

    If possible,  you can just put your logic analyzer data log and shared to us for double check.