1+ =======
12MCP9600
23=======
34
45Contributed by Matteo Golin.
56
6- The MCP9600 is a thermocouple EMF to temperature converter made by Microchip. It is also sold as a `breakout board module
7- by Adafruit <https://learn.adafruit.com/adafruit-mcp9600-i2c-thermocouple-amplifier> `_.
7+ The MCP9600 is a thermocouple EMF to temperature converter made by Microchip. It
8+ is also sold as a `breakout board module by Adafruit
9+ <https://learn.adafruit.com/adafruit-mcp9600-i2c-thermocouple-amplifier> `_.
810
911Application Programming Interface
1012==================================
@@ -15,26 +17,63 @@ The header file for the MCP9600 driver interface can be included using:
1517
1618 #include <nuttx/sensors/mcp9600.h>
1719
18- The MCP9600 registration function allows the driver to be registered as a POSIX
19- character driver.
20+ The MCP9600 registration function allows the driver to be registered as a
21+ :doc: `UORB </components/drivers/special/sensors/sensors_uorb >` sensor.
22+
23+ The MCP9600 measures three types of temperature:
24+ * Hot junction temperature
25+ * Cold junction temperature
26+ * Temperature delta
27+
28+ Registering this sensor will create three UORB temperature topics, each with
29+ their own unique device number. You must specify the unique device numbers for
30+ each topic in the registration function:
31+
32+ .. code-block :: c
33+
34+ /* Registers sensor_temp1, sensor_temp2 and sensor_temp 3, where 1 is the
35+ * hot junction topic, 2 is the cold junction topic and 3 is the delta
36+ */
2037
21- The standard POSIX `read() ` operation will return the device information in
22- plain-text, which is useful when debugging/testing the driver using `cat ` from
23- the shell.
38+ int err;
39+ err = mcp9600_register(i2c_master, 0x60, 1, 2, 3);
40+ if (err < 0) {
41+ syslog(LOG_ERR, "Could not register MCP9600: %d\n", err);
42+ }
2443
25- The `write() ` operation is not implemented for this sensor.
2644
27- Specific operations the sensor offers can be performed via the POSIX ` ioctl `
28- operation. The supported commands are:
45+ This sensor offers some additional control commands for features that are not
46+ accessible with the standard UORB interface.
2947
48+ * :c:macro: `SNIOC_SET_THERMO `
3049 * :c:macro: `SNIOC_WHO_AM_I `
3150 * :c:macro: `SNIOC_READ_RAW_DATA `
3251 * :c:macro: `SNIOC_CHECK_STATUS_REG `
3352 * :c:macro: `SNIOC_CONFIGURE `
3453 * :c:macro: `SNIOC_WRITECONF `
35- * :c:macro: `SNIOC_READTEMP `
36- * :c:macro: `SNIOC_SHUTDOWN `
37- * :c:macro: `SNIOC_START `
54+
55+ ``SNIOC_SET_THERMO ``
56+ --------------------
57+
58+ This command configures the thermocouple type of the MCP9600. The device
59+ supports the following thermocouple types:
60+
61+ * K
62+ * J
63+ * T
64+ * N
65+ * E
66+ * S
67+ * B
68+ * R
69+
70+ .. code-block :: c
71+
72+ int err;
73+ err = orb_ioctl(sensor, SNIOC_SET_THERMO, SENSOR_THERMO_TYPE_J);
74+ if (err < 0) {
75+ syslog(LOG_ERR, "Failed to set thermocouple type: %d\n", err);
76+ }
3877
3978 ``SNIOC_WHO_AM_I ``
4079------------------
@@ -46,7 +85,7 @@ type ``struct mcp9600_devinfo_s *``.
4685.. code-block :: c
4786
4887 struct mcp9600_devinfo_s devinfo;
49- err = ioctl (sensor, SNIOC_WHO_AM_I, &devinfo);
88+ err = orb_ioctl (sensor, SNIOC_WHO_AM_I, &devinfo);
5089
5190 uint8_t revision_minor = MCP9600_REV_MINOR(devinfo.revision);
5291 uint8_t revision_major = MCP9600_REV_MAJOR(devinfo.revision);
@@ -64,7 +103,7 @@ configured resolution; consult the data sheet.
64103.. code-block :: c
65104
66105 int32_t raw;
67- err = ioctl (sensor, SNIOC_READ_RAW_DATA, &raw);
106+ err = orb_ioctl (sensor, SNIOC_READ_RAW_DATA, &raw);
68107
69108 ``SNIOC_CHECK_STATUS_REG ``
70109--------------------------
@@ -75,7 +114,7 @@ this command must be a pointer to type ``struct mcp9600_status_s``.
75114.. code-block :: c
76115
77116 struct mcp9600_status_s status;
78- err = ioctl (sensor, SNIOC_CHECK_STATUS_REG, &status);
117+ err = orb_ioctl (sensor, SNIOC_CHECK_STATUS_REG, &status);
79118
80119 ``SNIOC_CONFIGURE ``
81120-------------------
@@ -93,7 +132,7 @@ mcp9600_devconf_s``.
93132 .resolution = MCP9600_ADC_RES_18,
94133 /* More fields ... */
95134 };
96- err = ioctl (sensor, SNIOC_CONFIGURE, &conf);
135+ err = orb_ioctl (sensor, SNIOC_CONFIGURE, &conf);
97136
98137 ``SNIOC_WRITECONF ``
99138-------------------
@@ -111,36 +150,4 @@ mcp9600_alertconf_s``.
111150 .limit = 40 / 0.25,
112151 /* More fields ... */
113152 };
114- err = ioctl(sensor, SNIOC_WRITECONF, &conf);
115-
116- ``SNIOC_READTEMP ``
117- ------------------
118-
119- This command lets you read the three different types of temperature that the
120- MCP9600 can measure. The argument to this command must be a pointer to type
121- ``struct mcp9600_temp_s ``.
122-
123- .. code-block :: c
124-
125- struct mcp9600_temp_s temps;
126- err = ioctl(sensor, SNIOC_READTEMP, &temps);
127-
128- printf("Temperature: %d C\n", temps.hot_junc);
129-
130- ``SNIOC_SHUTDOWN ``
131- ------------------
132-
133- This command shuts down the sensor. It takes no arguments.
134-
135- .. code-block :: c
136-
137- err = ioctl(sensor, SNIOC_SHUTDOWN, NULL);
138-
139- ``SNIOC_START ``
140- ---------------
141-
142- This command starts the sensor in normal mode. It takes no arguments.
143-
144- .. code-block :: c
145-
146- err = ioctl(sensor, SNIOC_START, NULL);
153+ err = orb_ioctl(sensor, SNIOC_WRITECONF, &conf);
0 commit comments