-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic application multi-sensor #98
Comments
Hi! You need separate descriptors for each i2c device. |
@UncleRus oky so i work with detected device so i can create instance with malloc bcs number of device is detected with i2ccannser now i create max : // /****************************************************/ |
Yes you can create device descriptors dynamically, e.g. i2c_dev_t *bh1750; // pointer to device descriptor
...
bh1750 = malloc(sizeof(i2c_dev_t)); // allocate memory for descriptor
memset(bh1750, 0, sizeof(i2c_dev_t))); // fill it with zeroes
... // init descriptor, init device, use it
free(bh1750); // free allocated memory |
Ah yes yes but for sensor i don't think I free memory bcs I use all time read_bh1750 and I don't initialize device for each read So it's don't give problem if I don't use free(p) ? |
hi,
i am working on application multi-sensor using esp-idf-lib so i connect all my sensor with mux TCA9548A and i want to now if i need to create instance i2c_dev_t dev for each sensor or i can use one for all same sensor ?
The text was updated successfully, but these errors were encountered: