Hello World example for using the max14724 library

Dependencies:   ard2pmod max14724 mbed

This is untested.

Files at this revision

API Documentation at this revision

Comitter:
wt8008
Date:
Mon Apr 27 17:38:32 2015 +0000
Commit message:
Initial Import

Changed in this revision

ard2pmod.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
max14724.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 080c891e3e3a ard2pmod.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ard2pmod.lib	Mon Apr 27 17:38:32 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Maxim-Integrated/code/ard2pmod/#abb327ca5580
diff -r 000000000000 -r 080c891e3e3a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 27 17:38:32 2015 +0000
@@ -0,0 +1,88 @@
+/***********************************************************************
+* Copyright (C) 2015 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*
+* Except as contained in this notice, the name of Maxim Integrated
+* Products, Inc. shall not be used except as stated in the Maxim Integrated
+* Products, Inc. Branding Policy.
+*
+* The mere transfer of this software does not imply any licenses
+* of trade secrets, proprietary technology, copyrights, patents,
+* trademarks, maskwork rights, or any other form of intellectual
+* property whatsoever. Maxim Integrated Products, Inc. retains all
+* ownership rights.
+**********************************************************************/
+
+// Tested with FRDM-K64F
+#include "mbed.h"
+
+#include "max14724.h"
+#include "ard2pmod.h"
+
+int main() {
+    
+    uint8_t data[4];
+    
+    Serial pc(USBTX, USBRX);
+    pc.printf("\r\n\r\nMAX14724 Hello World!\r\n");
+    
+    Ard2Pmod a2p(Ard2Pmod::PMOD_TYPE_1_GPIO); // Configure ard2pmod multiplexer for GPIO (all switches open)
+    a2p.set_switches((Ard2Pmod::SW11 | Ard2Pmod::SW09), (Ard2Pmod::SW13 | Ard2Pmod::SW10)); // Manually configure mux for custom I2C mapping
+    a2p.rd_dir_registers(data); // Verify Ard2Pmod configuration with sucessful I2C read.
+    pc.printf("Ad2Pmd mux data: 0x%02X 0x%02X 0x%02X 0x%02X\r\n", data[0], data[1], data[2], data[3]);
+    
+    Max14724 max14724(ARD2PMOD_SDA, ARD2PMOD_SCL, Max14724::MAX14724_I2C_ADRS1);
+    
+    //wait(2); // turn on delay
+    
+    // Write MAX14724 Switches Indirectly    
+    max14724.rd_dir_registers(data);
+    pc.printf("DIR Registers: 0x%02X 0x%02X 0x%02X 0x%02X\r\n", data[0], data[1], data[2], data[3]);
+    
+    max14724.wrt_shadow_registers(Max14724::SW01, Max14724::SW02, Max14724::SW03, Max14724::SW04);
+    pc.printf("Write Shadow Registers\r\n");
+    
+    max14724.rd_dir_registers(data);
+    pc.printf("DIR Registers: 0x%02X 0x%02X 0x%02X 0x%02X\r\n", data[0], data[1], data[2], data[3]);
+    
+    max14724.rd_shadow_registers(data);
+    pc.printf("Shadow Registers: 0x%02X 0x%02X 0x%02X 0x%02X\r\n", data[0], data[1], data[2], data[3]);
+    
+    max14724.wrt_cmd_registers(Max14724::COPY_SHADOW, Max14724::COPY_SHADOW, Max14724::COPY_SHADOW, Max14724::COPY_SHADOW);
+    pc.printf("Write Command Registers\r\n");
+    
+    max14724.rd_dir_registers(data);
+    pc.printf("DIR Registers: 0x%02X 0x%02X 0x%02X 0x%02X\r\n", data[0], data[1], data[2], data[3]);
+    
+    max14724.rd_shadow_registers(data);
+    pc.printf("Shadow Registers: 0x%02X 0x%02X 0x%02X 0x%02X\r\n", data[0], data[1], data[2], data[3]);    
+    
+    // Write MAX14724 Switches Directly
+    max14724.set_switches(Max14724::SW05, Max14724::SW06, Max14724::SW07, Max14724::SW08);
+    pc.printf("Set Switches Directly\r\n");
+    
+    max14724.rd_dir_registers(data);
+    pc.printf("DIR Registers: 0x%02X 0x%02X 0x%02X 0x%02X\r\n", data[0], data[1], data[2], data[3]);
+    
+    max14724.rd_shadow_registers(data);
+    pc.printf("Shadow Registers: 0x%02X 0x%02X 0x%02X 0x%02X\r\n", data[0], data[1], data[2], data[3]);   
+    
+    return 0;
+}
diff -r 000000000000 -r 080c891e3e3a max14724.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max14724.lib	Mon Apr 27 17:38:32 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/wt8008/code/max14724/#5a3720e6e017
diff -r 000000000000 -r 080c891e3e3a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Apr 27 17:38:32 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889
\ No newline at end of file