Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMA400 CC1310 SPI interface

    BMA400 CC1310 SPI interface



    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 ?

    13 REPLIES 13

    Community Moderator
    Community Moderator

    Hello ffatih, 


    Here is our github BMA400 example source.

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

    Here is the interface functions in below file.


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

    Community Moderator
    Community Moderator

    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 🙂 


    Hi Minhwan,

    I thought I implemented functions. now I am trying to read chip id from bma400. I referenced Accelerometer.c. 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);
            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.