How to handle multiple devices of the same kind in device driver code?

Hi, I’m writing a RIOT device driver for the ST A3G4250D sensor. How can I set up my code to work with multiple ST A3G4250D devices?


that’s cool! Looking forward for your PR :slight_smile:

You could orient your code e.g. on the SHT3x driver. Basically, you have “device handle”, which is a struct containing all the state. The functions operate on this device handle. Because no state is store elsewhere but in the device handle, the driver will be able to handle as many devices as you can allocate device handles (practically CPU time, I/O pins, busses etc. are typically the limiting factor, not memory for device handles).

You can open a PR early on and add an WIP: in front of the title, if you gave questions while the driver is not yet completed. Feel free to mention me in such a PR if you have any questions.