Device interface library for multiple platforms including Mbed.

Dependents:   DeepCover Embedded Security in IoT MaximInterface MAXREFDES155#

Maxim Interface is a library framework focused on providing flexible and expressive hardware interfaces. Both communication interfaces such as I2C and 1-Wire and device interfaces such as DS18B20 are supported. Modern C++ concepts are used extensively while keeping compatibility with C++98/C++03 and requiring no external dependencies. The embedded-friendly design does not depend on exceptions or RTTI.

The full version of the project is hosted on GitLab: https://gitlab.com/iabenz/MaximInterface

Revision:
8:5ea891c7d1a1
Parent:
7:9cd16581b578
diff -r 9cd16581b578 -r 5ea891c7d1a1 MaximInterfaceCore/RomCommands.hpp
--- a/MaximInterfaceCore/RomCommands.hpp	Mon Jul 22 11:44:07 2019 -0500
+++ b/MaximInterfaceCore/RomCommands.hpp	Mon Sep 16 11:13:37 2019 -0500
@@ -1,5 +1,5 @@
 /*******************************************************************************
-* Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
+* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
@@ -33,8 +33,8 @@
 /// @file
 /// @brief ROM Commands for enumerating and selecting 1-Wire devices.
 
-#ifndef MaximInterfaceCore_RomCommands
-#define MaximInterfaceCore_RomCommands
+#ifndef MaximInterfaceCore_RomCommands_hpp
+#define MaximInterfaceCore_RomCommands_hpp
 
 #include <stdint.h>
 #include "Algorithm.hpp"
@@ -63,7 +63,7 @@
   explicit SearchRomState(RomId::element familyCode)
       : romId(), lastDiscrepancy(64), lastFamilyDiscrepancy(0),
         lastDevice(false) {
-    setFamilyCode(romId, familyCode);
+    romId.front() = familyCode;
   }
 };
 
@@ -73,23 +73,22 @@
 MaximInterfaceCore_EXPORT void skipCurrentFamily(SearchRomState & searchState);
 
 /// Verify that the device with the specified ROM ID is present.
-MaximInterfaceCore_EXPORT error_code verifyRom(OneWireMaster & master,
-                                               RomId::const_span romId);
+MaximInterfaceCore_EXPORT Result<void> verifyRom(OneWireMaster & master,
+                                                 RomId::const_span romId);
 
 /// @brief Use Read ROM command to read ROM ID from device on bus.
 /// @note
 /// Only use this command with a single-drop bus.
 /// Data collisions will occur if there is more than one device on the bus.
 /// @param master 1-Wire master for operation.
-/// @param[out] romId ROM ID read from device.
-MaximInterfaceCore_EXPORT error_code readRom(OneWireMaster & master,
-                                             RomId::span romId);
+/// @returns ROM ID read from device.
+MaximInterfaceCore_EXPORT Result<RomId::array> readRom(OneWireMaster & master);
 
 /// @brief Issue Skip ROM command on bus.
 /// @note
 /// Only use this command with a single-drop bus.
 /// Data collisions will occur if there is more than one device on the bus.
-MaximInterfaceCore_EXPORT error_code skipRom(OneWireMaster & master);
+MaximInterfaceCore_EXPORT Result<void> skipRom(OneWireMaster & master);
 
 /// @brief Use the Match ROM command to select the device by its known ID.
 /// @note
@@ -97,8 +96,8 @@
 /// Overdrive timing.
 /// @param master 1-Wire master for operation.
 /// @param[in] romId ROM ID of device to select.
-MaximInterfaceCore_EXPORT error_code matchRom(OneWireMaster & master,
-                                              RomId::const_span romId);
+MaximInterfaceCore_EXPORT Result<void> matchRom(OneWireMaster & master,
+                                                RomId::const_span romId);
 
 /// @brief Issue Overdrive Skip ROM command on bus.
 /// @note
@@ -107,20 +106,20 @@
 /// @note
 /// Only use this command with a single-drop bus.
 /// Data collisions will occur if there is more than one device on the bus.
-MaximInterfaceCore_EXPORT error_code overdriveSkipRom(OneWireMaster & master);
+MaximInterfaceCore_EXPORT Result<void> overdriveSkipRom(OneWireMaster & master);
 
 /// @brief
 /// Use the Overdrive Match ROM command to select the device by its known ID.
 /// @param master 1-Wire master for operation.
 /// @param[in] romId ROM ID of device to select.
-MaximInterfaceCore_EXPORT error_code overdriveMatchRom(OneWireMaster & master,
-                                                       RomId::const_span romId);
+MaximInterfaceCore_EXPORT Result<void>
+overdriveMatchRom(OneWireMaster & master, RomId::const_span romId);
 
 /// @brief Perform a Resume ROM command on bus.
 /// @details
 /// Resumes communication with the last device selected through a Match ROM or
 /// Search ROM operation.
-MaximInterfaceCore_EXPORT error_code resumeRom(OneWireMaster & master);
+MaximInterfaceCore_EXPORT Result<void> resumeRom(OneWireMaster & master);
 
 /// @brief Find device on the 1-Wire bus.
 /// @details
@@ -128,8 +127,8 @@
 /// sequence. Begin with a new search state and continue using the same search
 /// state until the last device flag is set which indicates that all devices
 /// have been discovered.
-MaximInterfaceCore_EXPORT error_code searchRom(OneWireMaster & master,
-                                               SearchRomState & searchState);
+MaximInterfaceCore_EXPORT Result<void> searchRom(OneWireMaster & master,
+                                                 SearchRomState & searchState);
 
 } // namespace MaximInterfaceCore