Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BHI160b Shuttle Board with STM32

    belaya
    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.

    install_Sensor_callback.png

    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.

    enable_virtual_sensor.png

    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 */
    	    if(bhy_install_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?

    Vincent
    Community Moderator

    Re: BHI160b Shuttle Board with STM32

    what is the value for following parameter in your code? 

    ROTATION_VECTOR_SAMPLE_RATE

     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)

    Vincent
    Community Moderator

    Re: BHI160b Shuttle Board with STM32

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

    BHY_META_EVENT_TYPE_ERROR = 4,
    BHY_META_EVENT_TYPE_SENSOR_ERROR = 11,

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

    belaya
    Established Member

    Re: BHI160b Shuttle Board with STM32

    Thats how i defined the sample rate in main.c

    #define ROTATION_VECTOR_SAMPLE_RATE    100

    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)
      {
        Error_Handler();
      }

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

    Vincent
    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.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist