zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.11k stars 6.21k forks source link

drivers: sensor: mcp9600: Support extra functionality from the IC #66259

Open naNEQ opened 7 months ago

naNEQ commented 7 months ago

Introduction

The MCP9600 IC has some advanced functionality, such as an internal digital filter, a burst mode etc., that is currently inaccessible from the drivers. My proposal is to enable access to set of features (or part of). For reference, the datasheet of the part can be found here.

Problem description

I wouldn't say there is any problem here that we try to solve. It can be seen as an improvement of the current driver.

Proposed change

Once this change is implemented, the application can configure and use the more advanced features of the IC, such as the internal digital filter that is applied on each temperature sample, or the burst mode, where the IC samples for certain period and then goes to sleep mode to conserve power.

Detailed RFC

We can include the following features:

As a lower priority, we could also support the following:

Proposed change (Detailed)

What needs to be done is to create a new mcp9600.h header file in the include/zephyr/drivers/sensor directory, with the necessary function (and perhaps struct) declarations. The ccs811 has implemented similar additional functionality.

The modify the existing mcp9600.c file to implement the extra functions.

Dependencies

Just to be clear, I don't propose any modifications to the generic sensor API. Only the mcp9600 driver will be affected. Therefore I don't see any special dependencies.

Concerns and Unresolved Questions

n/a

Alternatives

n/a

aasinclair commented 5 months ago

Hi @naNEQ .

Adding additional functionality to an existing driver is always welcome, and doesn't need an RFC.

For this specific example, one time configuration (e.g. thermocouple type, adc resolution) can be specified in devicetree and set at init. Reading status can be done with either a custom channel ID, or get_attr, depending on what fits best.

naNEQ commented 5 months ago

Hi @aasinclair,

that makes a lot of sense and also great for the tips. I suggest then to close this issue, and any further discussions can be taken later on, upon a potential merge request.