Bosch Sensortec Community

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

    BMA400 CC1310 SPI interface

    ffatih
    Member

    BMA400 CC1310 SPI interface

    Hello,

    I have a custom board with Texas Instruments' CC1310, I want to send this board's coordinates via RF with bma400's help. RF part is ok, there are files on github as reference but I want to know if there is an example code for TI MCU's. I want to move quickly that's why I need help about that topic. If there is no sample doc as I want, how can I adapt files on github to my project ?

    Tags (3)
    12 REPLIES 12
    Minhwan
    Community Moderator

    Re: BMA400 CC1310 SPI interface

    Hello ffatih, 

     

    Here is our github BMA400 example source. 

    https://github.com/BoschSensortec/BMA400-API

    What you have to do is to change spi function for your system. 

    Here is the interface functions in below file.  

    https://github.com/BoschSensortec/BMA400-API/blob/master/examples/common/common.c

    And, 

    You have to change your own function to coines_read_spi(dev_addr, reg_addr, reg_data, (uint16_t)len);. 

    Your spi write and read function should support multiple read and write functions. 

    Please let me know if you have any questions. 

    Thanks, 

     

    ffatih
    Member

    Re: BMA400 CC1310 SPI interface

    Thanks for first answer, I have another question. In int8_t bma400_interface_init(struct bma400_dev *bma400, uint8_t intf) function, and in SPI side there is dev_addr = COINES_SHUTTLE_PIN_7; definition.

    I know I need I2C slave address in slave communication but what is that dev_addr ? It is used almost everywhere with bma400->intf_ptr = &dev_addr; that pointer so I have to know what it represents in CC1310 side.

    Minhwan
    Community Moderator

    Re: BMA400 CC1310 SPI interface

    Hello ffaith, 

     

    You are right. 

    If you are using only one SPI slave device, you are not going to use it.

    Typically, we set intf_ptr value as GPIO pin number so that it will select proper slave when you are using multiple slaves 🙂 

    Thanks, 

    ffatih
    Member

    Re: BMA400 CC1310 SPI interface

    Hi Minhwan,

    I thought I implemented functions. now I am trying to read chip id from bma400. I referenced Accelerometer.c. https://github.com/BoschSensortec/BMA400-API/tree/master/examples/accelerometer I did my mcu's spi initializing etc. I see data on clk,cs,mosi but can't see datas on miso.

     

     

    struct bma400_dev bma;
    
    void AccelTaskFunction(void)
    {
        rslt = bma400_interface_init(&bma, BMA400_SPI_INTF);
        bma400_check_rslt("bma400_interface_init", rslt);
    
        rslt = bma400_soft_reset(&bma);
        bma400_check_rslt("bma400_soft_reset", rslt);
    
        rslt = bma400_init(&bma);
        bma400_check_rslt("bma400_init", rslt);
    }

     

     

    I am powering bma400 with 3.3V .

    I did some changes in functions. If I did sth wrong in functions please tell me . I deleted sth because I think they are dependent on coines board.
    bma400_interface_init returns 0, so it is okay. soft_reset function also returns 0 but I don't see any data on miso line. bma400_init returns -3 which means BMA400_E_DEV_NOT_FOUND. What does cause this problem ?

     

     

    int8_t bma400_interface_init(struct bma400_dev *bma400, uint8_t intf)
    {
        int8_t rslt = BMA400_OK;
    
        if (bma400 != NULL)
        {
    
            if(intf == BMA400_SPI_INTF)
            {
    //            dev_addr = COINES_SHUTTLE_PIN_7;
                bma400->read = bma400_spi_read;
                bma400->write = bma400_spi_write;
                bma400->intf = BMA400_SPI_INTF;
    //            coines_config_spi_bus(COINES_SPI_BUS_0, COINES_SPI_SPEED_7_5_MHZ, COINES_SPI_MODE0);
            }
    
            bma400->intf_ptr = &dev_addr;
            bma400->delay_us = bma400_delay_us;
            bma400->read_write_len = READ_WRITE_LENGTH;
    
            usleep(100000); // 100 ms wait
    //        coines_delay_msec(100);
    
    //        coines_set_shuttleboard_vdd_vddio_config(3300, 3300);
    
    //        coines_delay_msec(200);
        }
        else
        {
            rslt = BMA400_E_NULL_PTR;
        }
    
        return rslt;
    }

     

     


    I think I modified  coines_read_spi(dev_addr, reg_addr, reg_data, (uint16_t)len) and coines_write_spi(dev_addr, reg_addr, (uint8_t *)reg_data, (uint16_t)len) functions correctly. I am sending reg_addr first, then I reg_data. After that I wait for response. What is wrong with my functions ?
    I am calling bma400_init(&bma) function in background loop, and datas as below in logic analyzer.
    miso8000.jpg



     

    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