Ai-Thinker-Open / GPRS_C_SDK

Ai-Thinker A9/A9G GPRS (with GPS(A9G)) module C development SDK
https://ai-thinker-open.github.io/GPRS_C_SDK_DOC
MIT License
446 stars 232 forks source link

A9G GPRS_C_SDK with accelerometer LIS3DSH #508

Open lorenzopeluso opened 2 years ago

lorenzopeluso commented 2 years ago

Hi all.

I've soldered the LIS3DSH on my A9G device.

I'am trying to interact with accelerometer but without success.

First of all, which I2C interface (1, 2, 3) I should initialize in order to read from accelerometer?

My code (to read chipID):

I2C_Config_t i2cConfig1; i2cConfig1.freq = I2C_FREQ_100K;

if(!I2C_Init(I2C2, i2cConfig2)) Trace(1, "ERROR");

I2C_ReadMem(I2C1, 0x19, 0x02, 1, &accId1, 1, I2C_DEFAULT_TIME_OUT); Trace(1,"accelerator id shold be 0x19, read:0X%02x",accId1);

The result is:

"accelerator id shold be 0x19, read:0Xfd"

Thanks a lot for any suggestion or sample code.

Cheers, Lorenzo.

breadcrumb3000 commented 2 years ago

See the demo: https://github.com/Ai-Thinker-Open/GPRS_C_SDK/blob/master/demo/i2c/src/demo_i2c.c