MAX14661 Library Demo

Dependencies:   max14661 mbed

MAX14661 Component Page

Committer:
j3
Date:
Thu Mar 19 22:02:40 2015 +0000
Revision:
1:a06b939860a6
Parent:
0:3c97a1a20098
updated lib

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 0:3c97a1a20098 1 /**********************************************************************
j3 0:3c97a1a20098 2 *
j3 0:3c97a1a20098 3 * Demo MAX14661 Library
j3 0:3c97a1a20098 4 *
j3 0:3c97a1a20098 5 ***********************************************************************
j3 0:3c97a1a20098 6 * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved.
j3 0:3c97a1a20098 7 *
j3 0:3c97a1a20098 8 * Permission is hereby granted, free of charge, to any person obtaining a
j3 0:3c97a1a20098 9 * copy of this software and associated documentation files (the "Software"),
j3 0:3c97a1a20098 10 * to deal in the Software without restriction, including without limitation
j3 0:3c97a1a20098 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 0:3c97a1a20098 12 * and/or sell copies of the Software, and to permit persons to whom the
j3 0:3c97a1a20098 13 * Software is furnished to do so, subject to the following conditions:
j3 0:3c97a1a20098 14 *
j3 0:3c97a1a20098 15 * The above copyright notice and this permission notice shall be included
j3 0:3c97a1a20098 16 * in all copies or substantial portions of the Software.
j3 0:3c97a1a20098 17 *
j3 0:3c97a1a20098 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 0:3c97a1a20098 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 0:3c97a1a20098 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 0:3c97a1a20098 21 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 0:3c97a1a20098 22 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 0:3c97a1a20098 23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 0:3c97a1a20098 24 * OTHER DEALINGS IN THE SOFTWARE.
j3 0:3c97a1a20098 25 *
j3 0:3c97a1a20098 26 * Except as contained in this notice, the name of Maxim Integrated
j3 0:3c97a1a20098 27 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 0:3c97a1a20098 28 * Products, Inc. Branding Policy.
j3 0:3c97a1a20098 29 *
j3 0:3c97a1a20098 30 * The mere transfer of this software does not imply any licenses
j3 0:3c97a1a20098 31 * of trade secrets, proprietary technology, copyrights, patents,
j3 0:3c97a1a20098 32 * trademarks, maskwork rights, or any other form of intellectual
j3 0:3c97a1a20098 33 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 0:3c97a1a20098 34 * ownership rights.
j3 0:3c97a1a20098 35 **********************************************************************/
j3 0:3c97a1a20098 36
j3 0:3c97a1a20098 37
j3 0:3c97a1a20098 38 #include "mbed.h"
j3 0:3c97a1a20098 39 #include "max14661.h"
j3 0:3c97a1a20098 40
j3 0:3c97a1a20098 41
j3 1:a06b939860a6 42 Max14661 mux(D14, D15, Max14661::MAX14661_I2C_ADRS0);
j3 0:3c97a1a20098 43
j3 0:3c97a1a20098 44
j3 0:3c97a1a20098 45 int main(void)
j3 0:3c97a1a20098 46 {
j3 0:3c97a1a20098 47 uint16_t bankA = 0;
j3 1:a06b939860a6 48 uint16_t bankB = mux.SW03;
j3 0:3c97a1a20098 49 uint8_t data[4];
j3 0:3c97a1a20098 50
j3 0:3c97a1a20098 51 printf("\r\nMAX14661 Library Demo\r\n");
j3 0:3c97a1a20098 52
j3 0:3c97a1a20098 53 mux.set_switches(bankA, bankB);
j3 0:3c97a1a20098 54
j3 0:3c97a1a20098 55 mux.rd_dir_registers(data);
j3 0:3c97a1a20098 56 for(uint8_t idx = 0; idx < 4; idx++)
j3 0:3c97a1a20098 57 {
j3 0:3c97a1a20098 58 printf("\r\nDirect Register %d = %d", idx, data[idx]);
j3 0:3c97a1a20098 59 }
j3 0:3c97a1a20098 60 printf("\r\n");
j3 0:3c97a1a20098 61
j3 1:a06b939860a6 62 mux.wrt_cmd_registers(mux.DISABLE_BANK, mux.DISABLE_BANK);
j3 0:3c97a1a20098 63
j3 0:3c97a1a20098 64 mux.rd_dir_registers(data);
j3 0:3c97a1a20098 65 for(uint8_t idx = 0; idx < 4; idx++)
j3 0:3c97a1a20098 66 {
j3 0:3c97a1a20098 67 printf("\r\nDirect Register %d = %d", idx, data[idx]);
j3 0:3c97a1a20098 68 }
j3 0:3c97a1a20098 69 printf("\r\n");
j3 0:3c97a1a20098 70
j3 0:3c97a1a20098 71 return 0;
j3 0:3c97a1a20098 72 }