Extended MaximInterface
Dependents: mbed_DS28EC20_GPIO
Diff: Devices/DS2465.hpp
- Revision:
- 7:471901a04573
- Parent:
- 6:a8c83a2e6fa4
--- a/Devices/DS2465.hpp Wed Jan 23 13:11:04 2019 -0600 +++ b/Devices/DS2465.hpp Mon Mar 04 08:10:00 2019 -0600 @@ -47,7 +47,7 @@ public: enum ErrorValue { HardwareError = 1, ArgumentOutOfRangeError }; - /// 1-Wire port adjustment parameters. + /// @brief 1-Wire port adjustment parameters. /// @note See datasheet page 13. enum PortParameter { tRSTL_STD, @@ -80,10 +80,14 @@ explicit Config(uint_least8_t readByte = optionAPU) : readByte_(readByte & 0xF) {} + /// @name 1WS + /// @brief 1-Wire Speed /// @{ - /// 1-Wire Speed + + /// Get 1WS bit. bool get1WS() const { return (readByte_ & option1WS) == option1WS; } + /// Set 1WS bit. Config & set1WS(bool new1WS) { if (new1WS) { readByte_ |= option1WS; @@ -92,12 +96,17 @@ } return *this; } + /// @} + /// @name SPU + /// @brief Strong Pullup /// @{ - /// Strong Pullup + + /// Get SPU bit. bool getSPU() const { return (readByte_ & optionSPU) == optionSPU; } + /// Set SPU bit. Config & setSPU(bool newSPU) { if (newSPU) { readByte_ |= optionSPU; @@ -106,12 +115,17 @@ } return *this; } + /// @} + /// @name PDN + /// @brief 1-Wire Power Down /// @{ - /// 1-Wire Power Down + + /// Get PDN bit. bool getPDN() const { return (readByte_ & optionPDN) == optionPDN; } + /// Set PDN bit. Config & setPDN(bool newPDN) { if (newPDN) { readByte_ |= optionPDN; @@ -120,12 +134,17 @@ } return *this; } + /// @} + /// @name APU + /// @brief Active Pullup /// @{ - /// Active Pullup + + /// Get APU bit. bool getAPU() const { return (readByte_ & optionAPU) == optionAPU; } + /// Set APU bit. Config & setAPU(bool newAPU) { if (newAPU) { readByte_ |= optionAPU; @@ -134,6 +153,7 @@ } return *this; } + /// @} /// Byte representation that is read from the DS2465. @@ -166,14 +186,14 @@ /// Initialize hardware for use. MaximInterface_EXPORT error_code initialize(Config config = Config()); - /// Write a new configuration to the DS2465. + /// @brief Write a new configuration to the DS2465. /// @param[in] config New configuration to write. MaximInterface_EXPORT error_code writeConfig(Config config); - /// Write a new port configuration parameter to the DS2465. + /// @brief Write a new port configuration parameter to the DS2465. /// @param[in] param Parameter to adjust. - /// @param[in] val New parameter value to set. Consult datasheet for value - /// mappings. + /// @param[in] val + /// New parameter value to set. Consult datasheet for value mappings. MaximInterface_EXPORT error_code writePortParameter(PortParameter param, int val); @@ -198,26 +218,31 @@ MaximInterface_EXPORT virtual error_code setSpeed(Speed newSpeed); - /// @note The DS2465 only supports enabling strong pullup following a 1-Wire - /// read or write operation. + /// @copydoc OneWireMaster::setLevel + /// @note + /// The DS2465 only supports enabling strong pullup following a 1-Wire read or + /// write operation. MaximInterface_EXPORT virtual error_code setLevel(Level newLevel); MaximInterface_EXPORT virtual error_code triplet(TripletData & data); // DS2465 Coprocessor Commands - /// Read data from an EEPROM memory page. + /// @brief Read data from an EEPROM memory page. /// @param pageNum Page number to read from. + /// @param[out] data Data that was read. MaximInterface_EXPORT error_code readPage(int pageNum, Page::span data) const; - /// Write data to an EEPROM memory page. + /// @brief Write data to an EEPROM memory page. /// @param pageNum Page number to copy to. + /// @param data Data to write. MaximInterface_EXPORT error_code writePage(int pageNum, Page::const_span data); - /// Write data to an EEPROM memory segment. + /// @brief Write data to an EEPROM memory segment. /// @param pageNum Page number to copy to. /// @param segmentNum Segment number to copy to. + /// @param data Data to write. MaximInterface_EXPORT error_code writeSegment(int pageNum, int segmentNum, Segment::const_span data); @@ -225,12 +250,12 @@ MaximInterface_EXPORT error_code writeMasterSecret(Sha256::Hash::const_span masterSecret); - /// Compute Next Master Secret. + /// @brief Compute Next Master Secret. /// @param data Combined data fields for computation. MaximInterface_EXPORT error_code computeNextMasterSecret(Sha256::AuthenticationData::const_span data); - /// Compute Next Master Secret with page swapping. + /// @brief Compute Next Master Secret with page swapping. /// @param data Combined data fields for computation. /// @param pageNum Page number to swap in. /// @param region Region of the page to swap in. @@ -238,18 +263,18 @@ computeNextMasterSecretWithSwap(Sha256::AuthenticationData::const_span data, int pageNum, PageRegion region); - /// Compute Write MAC. + /// @brief Compute Write MAC. /// @param data Combined data fields for computation. /// @param[out] mac Computed Write MAC. MaximInterface_EXPORT error_code computeWriteMac( Sha256::WriteMacData::const_span data, Sha256::Hash::span mac) const; - /// Compute Write MAC. + /// @brief Compute Write MAC. /// @param data Combined data fields for computation. MaximInterface_EXPORT error_code computeAndTransmitWriteMac(Sha256::WriteMacData::const_span data) const; - /// Compute Write MAC with page swapping. + /// @brief Compute Write MAC with page swapping. /// @param data Combined data fields for computation. /// @param pageNum Page number to swap in. /// @param segmentNum Segment number to swap in. @@ -258,19 +283,19 @@ computeWriteMacWithSwap(Sha256::WriteMacData::const_span data, int pageNum, int segmentNum, Sha256::Hash::span mac) const; - /// Compute Write MAC with page swapping. + /// @brief Compute Write MAC with page swapping. /// @param data Combined data fields for computation. /// @param pageNum Page number to swap in. /// @param segmentNum Segment number to swap in. MaximInterface_EXPORT error_code computeAndTransmitWriteMacWithSwap( Sha256::WriteMacData::const_span data, int pageNum, int segmentNum) const; - /// Compute Slave Secret (S-Secret). + /// @brief Compute Slave Secret (S-Secret). /// @param data Combined data fields for computation. MaximInterface_EXPORT error_code computeSlaveSecret(Sha256::AuthenticationData::const_span data); - /// Compute Slave Secret (S-Secret) with page swapping. + /// @brief Compute Slave Secret (S-Secret) with page swapping. /// @param data Combined data fields for computation. /// @param pageNum Page number to swap in. /// @param region Region of the page to swap in. @@ -278,19 +303,19 @@ computeSlaveSecretWithSwap(Sha256::AuthenticationData::const_span data, int pageNum, PageRegion region); - /// Compute Authentication MAC. + /// @brief Compute Authentication MAC. /// @param data Combined data fields for computation. /// @param[out] mac Computed Auth MAC. MaximInterface_EXPORT error_code computeAuthMac(Sha256::AuthenticationData::const_span data, Sha256::Hash::span mac) const; - /// Compute Authentication MAC. + /// @brief Compute Authentication MAC. /// @param data Combined data fields for computation. MaximInterface_EXPORT error_code computeAndTransmitAuthMac(Sha256::AuthenticationData::const_span data) const; - /// Compute Authentication MAC with page swapping. + /// @brief Compute Authentication MAC with page swapping. /// @param data Combined data fields for computation. /// @param pageNum Page number to swap in. /// @param region Region of the page to swap in. @@ -299,7 +324,7 @@ Sha256::AuthenticationData::const_span data, int pageNum, PageRegion region, Sha256::Hash::span mac) const; - /// Compute Authentication MAC with page swapping. + /// @brief Compute Authentication MAC with page swapping. /// @param data Combined data fields for computation. /// @param pageNum Page number to swap in. /// @param region Region of the page to swap in. @@ -315,29 +340,31 @@ uint_least8_t address_; Config curConfig; - /// Performs a soft reset on the DS2465. + /// @brief Performs a soft reset on the DS2465. /// @note This is not a 1-Wire Reset. error_code resetDevice(); - /// Polls the DS2465 status waiting for the 1-Wire Busy bit (1WB) to be cleared. + /// @brief + /// Polls the DS2465 status waiting for the 1-Wire Busy bit (1WB) to be + /// cleared. /// @param[out] pStatus Optionally retrive the status byte when 1WB cleared. /// @returns Success or TimeoutError if poll limit reached. error_code pollBusy(uint_least8_t * pStatus = NULL) const; - /// Ensure that the desired 1-Wire level is set in the configuration. + /// @brief Ensure that the desired 1-Wire level is set in the configuration. /// @param level Desired 1-Wire level. error_code configureLevel(Level level); - /// Const since only for internal use. + /// @note Const since only for internal use. error_code writeMemory(uint_least8_t addr, span<const uint_least8_t> buf) const; - /// Read memory from the DS2465. + /// @brief Read memory from the DS2465. /// @param addr Address to begin reading from. /// @param[out] buf Buffer to hold read data. error_code readMemory(uint_least8_t addr, span<uint_least8_t> buf) const; - /// Read memory from the DS2465 at the current pointer. + /// @brief Read memory from the DS2465 at the current pointer. /// @param[out] buf Buffer to hold read data. error_code readMemory(span<uint_least8_t> buf) const;