Driver for the NXP PCT2075 digital temperature sensor and thermal watchdog
NXP PCT2075 temperature sensor driver for mbed
This library is a driver for the [NXP PCT2075](http://www.nxp.com/products/sensors/i2c-temperature-voltage-monitors/ic-bus-fm-plus-1-degree-c-accuracy-digital-temperature-sensor-and-thermal-watchdog:PCT2075). It only handles the I2C communication with the sensor, it does not handle the OS interrupt line. The [mbed InterruptIn](https://developer.mbed.org/handbook/InterruptIn) library can be used for this.
example usage
#include <mbed.h> #include <PCT2075.h> Serial s(USBTX, USBRX); // tx, rx InterruptIn TempPinInt(PC4); LowPowerTicker ticker; static volatile bool temp_int = false; static volatile bool tick_int = false; int main( void ) { TempPinInt.mode(PullUp); PCT2075::Configuration config = { PCT2075::OS_FAULT_QUE_1, PCT2075::OS_ACTIVE_LOW, PCT2075::OS_MODE_INTERRUPT, PCT2075::DEVICE_MODE_SHUTDOWN }; temp_sensor.set_configuration(config); temp_sensor.set_idle_time(PCT2075::TIDLE_MAX); temp_sensor.set_hyst_temperature(2000); temp_sensor.set_os_temperature(2500); TempPinInt.fall(&on_fall); ticker.attach(&tick, 2.0); while(true) { sleep(); // wait to be woken up by ticker or temp sensor if (tick_int) { s.printf("Tick\r\n"); config.device_mode = PCT2075::DEVICE_MODE_NORMAL; temp_sensor.set_configuration(config); tick_int = false; } if (temp_int) { config.device_mode = PCT2075::DEVICE_MODE_SHUTDOWN; temp_sensor.set_configuration(config); uint16_t t = temp_sensor.read_temperature(); s.printf("Temperature: %d\r\n", t); temp_int = false; } } }
LICENSE.txt@1:a2b7889eb4e9, 2016-09-23 (annotated)
- Committer:
- Seppe Stas
- Date:
- Fri Sep 23 15:38:34 2016 +0200
- Revision:
- 1:a2b7889eb4e9
- Parent:
- 0:396665cc3ea0
Added library files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
seppestas | 0:396665cc3ea0 | 1 | Copyright (c) 2016 Productize |
seppestas | 0:396665cc3ea0 | 2 | |
seppestas | 0:396665cc3ea0 | 3 | Permission is hereby granted, free of charge, to any person obtaining a |
seppestas | 0:396665cc3ea0 | 4 | copy of this software and associated documentation files (the "Software"), |
seppestas | 0:396665cc3ea0 | 5 | to deal in the Software without restriction, including without limitation |
seppestas | 0:396665cc3ea0 | 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
seppestas | 0:396665cc3ea0 | 7 | and/or sell copies of the Software, and to permit persons to whom the |
seppestas | 0:396665cc3ea0 | 8 | Software is furnished to do so, subject to the following conditions: |
seppestas | 0:396665cc3ea0 | 9 | |
seppestas | 0:396665cc3ea0 | 10 | The above copyright notice and this permission notice shall be included in |
seppestas | 0:396665cc3ea0 | 11 | all copies or substantial portions of the Software. |
seppestas | 0:396665cc3ea0 | 12 | |
seppestas | 0:396665cc3ea0 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
seppestas | 0:396665cc3ea0 | 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
seppestas | 0:396665cc3ea0 | 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
seppestas | 0:396665cc3ea0 | 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
seppestas | 0:396665cc3ea0 | 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
seppestas | 0:396665cc3ea0 | 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
seppestas | 0:396665cc3ea0 | 19 | DEALINGS IN THE SOFTWARE. |