08-18-2020 11:30 PM
Hello I am working the BMA400 accelerometer. I have been using the BMA400 API on Git (https://github.com/BoschSensortec/BMA400-API) as reference point. I have run into an issue regarding the null_ptr_check() function. Below is an example.
I figured this function is suppose to check if any (or some )of "dev"'s parameters are NULL. If it succeeds it will return BMA400_OK. However, when I run this the return is -1 or BMA400_E_NULL_PTR.
I guess I did something wrong in the interface setting for the BMA400, but I am not sure. My set_interface function looks like the last picture. I assume that the function pointers for dev->read and dev->write should be replaced with my I2C functions. And the example on Git had dev->delay_ms pointing to a delay function too. I took that out and replaced the calls in the API with _delay_ms from util/delay. I think that's okay though. I am pretty sure the I2C read/write commands work, I just don't know why the null_ptr_check fails.
I appriecate any help!
Ken.
Solved! Go to Solution.
08-19-2020 03:23 AM
08-19-2020 04:20 PM
Thanks for replying BSTRobin,
I have defined the structures for the bma400 like this above main().
I don't know if it cannot be done this way. I assume you can create the instances like this.
08-19-2020 04:24 PM
In main(), the following is used to test the BMA400.
However, it seems to fail at the first startup test, bma400_init(&bma) when checking for null.
08-19-2020 07:11 PM
I think I found it, the delay_ms function pointer must be set in the set_interface call. This solution works, since I use calls to _delay_ms from util for the delays that bma400 structure needs.