Extended MaximInterface
Dependents: mbed_DS28EC20_GPIO
Diff: Devices/DS1920.hpp
- Revision:
- 8:211d1b8f730c
- Parent:
- 7:471901a04573
--- a/Devices/DS1920.hpp Tue Jul 24 08:33:31 2018 +0000 +++ b/Devices/DS1920.hpp Wed Apr 03 12:33:10 2019 +0000 @@ -35,11 +35,12 @@ #include <MaximInterface/Links/SelectRom.hpp> #include <MaximInterface/Links/Sleep.hpp> +#include <MaximInterface/Utilities/array_span.hpp> #include <MaximInterface/Utilities/Export.h> namespace MaximInterface { -/// DS1920 1-Wire Temperature iButton +/// @brief DS1920 1-Wire Temperature iButton /// @details The iButton® temperature logger (DS1920) provides /// direct-to-digital 9-bit temperature readings over a range of /// -55°C to +100°C in 0.5° increments. The iButton communicates with @@ -54,19 +55,20 @@ enum ErrorValue { CrcError = 1, DataError }; /// Holds the contents of the device scratchpad. - typedef array<uint_least8_t, 8> Scratchpad; + typedef array_span<uint_least8_t, 8> Scratchpad; - DS1920(const Sleep & sleep, OneWireMaster & master, - const SelectRom & selectRom) + DS1920(Sleep & sleep, OneWireMaster & master, const SelectRom & selectRom) : selectRom(selectRom), master(&master), sleep(&sleep) {} - void setSleep(const Sleep & sleep) { this->sleep = &sleep; } + void setSleep(Sleep & sleep) { this->sleep = &sleep; } + void setMaster(OneWireMaster & master) { this->master = &master; } + void setSelectRom(const SelectRom & selectRom) { this->selectRom = selectRom; } - /// Write Scratchpad Command + /// @brief Write Scratchpad Command /// @details If the result of a temperature measurement is higher /// than TH or lower than TL, an alarm flag inside the device is /// set. This flag is updated with every temperature measurement. @@ -77,21 +79,21 @@ MaximInterface_EXPORT error_code writeScratchpad(uint_least8_t th, uint_least8_t tl); - /// Read Scratchpad Command + /// @brief Read Scratchpad Command /// @param[out] scratchpad Contents of scratchpad. - MaximInterface_EXPORT error_code readScratchpad(Scratchpad & scratchpad); + MaximInterface_EXPORT error_code readScratchpad(Scratchpad::span scratchpad); - /// Copy Scratchpad Command + /// @brief Copy Scratchpad Command /// @details This command copies from the scratchpad into the /// EEPROM of the DS1920, storing the temperature trigger bytes /// in nonvolatile memory. MaximInterface_EXPORT error_code copyScratchpad(); - /// Convert Temperature Command + /// @brief Convert Temperature Command /// @details This command begins a temperature conversion. MaximInterface_EXPORT error_code convertTemperature(); - /// Recall Command + /// @brief Recall Command /// @details This command recalls the temperature trigger values /// stored in EEPROM to the scratchpad. MaximInterface_EXPORT error_code recallEeprom(); @@ -104,8 +106,9 @@ const Sleep * sleep; }; -/// Reads the current temperature as an integer value. -/// @param[out] temperature Temperature in degrees Celsius multiplied by 16. +/// @brief Reads the current temperature as an integer value. +/// @param ds1920 Device to read. +/// @param[out] temperature Temperature in degrees Celsius multiplied by 2. MaximInterface_EXPORT error_code readTemperature(DS1920 & ds1920, int & temperature);