01-19-2021 11:50 AM
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 ?
Solved! Go to Solution.
01-20-2021 12:51 AM
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,
02-01-2021 01:51 PM
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.
02-01-2021 04:45 PM
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,
02-18-2021 02:21 PM - edited 02-19-2021 12:26 PM
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.