drivers: add driver for APDS9007 illuminance sensor#8989
drivers: add driver for APDS9007 illuminance sensor#8989Hyungsin wants to merge 1 commit intoRIOT-OS:masterfrom
Conversation
12317bb to
a7a0a9a
Compare
aabadie
left a comment
There was a problem hiding this comment.
This PR looks good. I don't have have the hardware so I can't test.
You need to uncrustify apds9007.c and apds9007_saul.c (opening curly braces of a function should be on next line).
|
Also this PR needs to be rebased. |
79ba77e to
5b05a33
Compare
|
@aabadie, done! |
74e52c2 to
b162ffe
Compare
|
@aabadie. Oops. resolved again :) |
38d6acc to
6f63efd
Compare
|
@PeterKietzmann, @danpetry, yes please! I just came back to the development world and believe that #9013 is almost done. |
|
#9013 was merged, @danpetry disappeared. Is there anyone else with access to this sensor or a Hamilton board? @emmanuelsearch? @jcarrano? @SemjonKerner? |
|
I did find some Hamilton boards, but none with the sensor so far. I'll keep looking. |
|
Yeah, I have a Hamilton. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
|
The board is merged now and the driver is pretty simple. |
cfc0dcb to
c68470f
Compare
done |
57f07b0 to
1237d00
Compare
1237d00 to
1496634
Compare
benpicco
left a comment
There was a problem hiding this comment.
Sorry for the long dormancy, it took the stale bot to bring this back to live.
Some minor things: I'd rename the 'gpio' to shutdown so it matches the data sheet and it's function.
Since it's not needed for basic sensor operation, you should also handle the GPIO_UNDEF case.
I agree that it doesn't make much sense to convert this to lux since that would just mean multiplying it by an unknown factor and introducing inaccuracies.
| * @brief Parameters needed for device initialization | ||
| */ | ||
| typedef struct { | ||
| gpio_t gpio; /**< GPIO pin that sensor is connected to */ |
There was a problem hiding this comment.
The data sheet calls this pin 'shutdown' which also makes sense given it's function.
| dev->p.adcline = params->adcline; | ||
| dev->p.adcres = params->adcres; | ||
|
|
||
| gpio_init(params->gpio, GPIO_OUT); |
There was a problem hiding this comment.
| gpio_init(params->gpio, GPIO_OUT); | |
| if (params->gpio != GPIO_UNDEF) { | |
| gpio_init(params->gpio, GPIO_OUT); | |
| } |
The sensor will still work if the shutdown pin is not connected / connected to ground and some platforms will crash if you try to initialize / access GPIO_UNDEF.
|
|
||
| void apds9007_set_active(const apds9007_t *dev) | ||
| { | ||
| gpio_write(dev->p.gpio, 0); |
| * @{ | ||
| */ | ||
| #ifndef APDS9007_PARAM_GPIO | ||
| #define APDS9007_PARAM_GPIO GPIO_PIN(PA,6) |
There was a problem hiding this comment.
GPIO_UNDEF would also be a good default here.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
This PR provides a driver implementation for APDS9007 illuminance sensor.
APDS9007 gives raw voltage value which is proportional to "lux".
This driver reads this voltage value through ADC, which needs to be converted to "lux" according to passive components. The voltage->lux conversion is out of the scope of this PR.
Note:
APDS9007's illuminance output is 3 to 70,000 lux, which cannot be captured by a 16 bit variable.
But raw voltage output is 0 to 3000 mV, which is durable.
Dependencies
#9013