Fork to see if I can get working

Dependencies:   BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated

Fork of xDotBridge_update_test20180823 by Matt Briggs

Revision:
40:2ec4be320961
Child:
47:a68747642a7a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xDotBridge/inc/DS2408.h	Thu Jan 26 17:36:59 2017 -0700
@@ -0,0 +1,109 @@
+/**
+ * Library for DS2408 on top of OneWire library
+*/
+
+#ifndef XDOT_DS2408_H
+#define XDOT_DS2408_H
+
+#include "../config.h"
+#include "OneWire.h"
+
+/**
+ *  @class DS2408
+ *  @brief This class abstracts communicating with the DS2408 port expander.
+ *  The OneWire library is used for physical layer communication and this class
+ *  simply makes it easy to communicate with this one chip.
+ */
+class DS2408
+{
+public:
+    enum DS2408RegAddr {
+        pioLogicStateReg         = 0x88,
+        pioOutputLatchStateReg   = 0x89,
+        pioActivityStateReg      = 0x8A,
+        condSearchChSelMaskReg   = 0x8B,
+        condSearchChPolMaskReg   = 0x8C,
+        ctrlStatusReg            = 0x8D
+    };
+
+    /**
+    * @brief DS2408 constructor
+    *
+    * @details Just initialized internal variables does not configure device
+    * use init() for that.
+    *
+    * On Entry:
+    *     @param[in] owMaster - reference to 1-wire master
+    *     @param[in] romAddr - 64-bit address of ROM
+    *
+    * On Exit:
+    *
+    * @return
+    */
+    DS2408(OneWire *owMaster, uint8_t romAddr[8]);
+
+    /**
+    * @brief init()
+    *
+    * @details Just a placeholder for now
+    *
+    *
+    * On Entry:
+    *     @param[in] owMaster - reference to 1-wire master
+    *     @param[in] romAddr - 64-bit address of ROM
+    *
+    * On Exit:
+    *
+    * @return Result of operation zero for success
+    */
+    CmdResult init();
+
+    /**
+    * @brief registerRead()
+    *
+    * @details reads state of pio
+    *
+    *
+    * On Exit:
+    *     @param[in]  addr - per datasheet valid registers are from 0x88 to 0x8D.
+    *     Note value will be automatically promoted to 16-bit value.
+    *     @param[out] val - register value
+    *
+    * @return Result of operation zero for success
+    */
+    CmdResult registerRead(uint8_t addr, uint8_t &val);
+
+    /**
+    * @brief pioLogicRead()
+    *
+    * @details Uses regisrterRead to get logic values
+    *
+    *
+    * On Exit:
+    *     @param[out] val - lsb represents the state of the pio
+    *
+    * @return Result of operation zero for success
+    */
+    CmdResult pioLogicRead(uint8_t &val);
+    // TODO implement other register based functions
+
+    /**
+    * @brief pioLogicWrite()
+    *
+    * @details writes to pio.  Note 0 means active pull down and 1 high-Z to
+    * allow PIO to float high.
+    *
+    * On Entry:
+    *    @param[in] val - Value for IO.
+    *
+    * @return CmdResult - result of operation
+    */
+    CmdResult pioLogicWrite(uint8_t val);
+
+private:
+    OneWire *mMaster;
+    uint8_t mRomAddr[8];
+
+};
+
+#endif