Library for interfacing with the MAX4822 relay driver.

Dependents:   MAXREFDES130_131_Demo MAXREFDES130_Demo

Committer:
j3
Date:
Thu Jul 28 18:42:58 2016 +0000
Revision:
0:074983020f27
Child:
1:0263f798de82
init commit, skeleton library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 0:074983020f27 1 /**********************************************************************
j3 0:074983020f27 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 0:074983020f27 3 *
j3 0:074983020f27 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 0:074983020f27 5 * copy of this software and associated documentation files (the "Software"),
j3 0:074983020f27 6 * to deal in the Software without restriction, including without limitation
j3 0:074983020f27 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 0:074983020f27 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 0:074983020f27 9 * Software is furnished to do so, subject to the following conditions:
j3 0:074983020f27 10 *
j3 0:074983020f27 11 * The above copyright notice and this permission notice shall be included
j3 0:074983020f27 12 * in all copies or substantial portions of the Software.
j3 0:074983020f27 13 *
j3 0:074983020f27 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 0:074983020f27 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 0:074983020f27 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 0:074983020f27 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 0:074983020f27 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 0:074983020f27 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 0:074983020f27 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 0:074983020f27 21 *
j3 0:074983020f27 22 * Except as contained in this notice, the name of Maxim Integrated
j3 0:074983020f27 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 0:074983020f27 24 * Products, Inc. Branding Policy.
j3 0:074983020f27 25 *
j3 0:074983020f27 26 * The mere transfer of this software does not imply any licenses
j3 0:074983020f27 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 0:074983020f27 28 * trademarks, maskwork rights, or any other form of intellectual
j3 0:074983020f27 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 0:074983020f27 30 * ownership rights.
j3 0:074983020f27 31 **********************************************************************/
j3 0:074983020f27 32
j3 0:074983020f27 33 #include "MAX4822.h"
j3 0:074983020f27 34
j3 0:074983020f27 35 //*********************************************************************
j3 0:074983020f27 36 MAX4822::MAX4822(SPI & spi_bus, PinName cs, PinName set, PinName reset):
j3 0:074983020f27 37 m_spi(spi_bus), m_cs(cs), m_set(set, 1), m_reset(reset, 0), m_num_devices(1)
j3 0:074983020f27 38 {
j3 0:074983020f27 39 }
j3 0:074983020f27 40
j3 0:074983020f27 41 //*********************************************************************
j3 0:074983020f27 42 MAX4822::~MAX4822()
j3 0:074983020f27 43 {
j3 0:074983020f27 44 }
j3 0:074983020f27 45
j3 0:074983020f27 46 //*********************************************************************
j3 0:074983020f27 47 MAX4822::CmdResult MAX4822::set_num_devices(uint8_t n)
j3 0:074983020f27 48 {
j3 0:074983020f27 49 MAX4822::CmdResult result = OpFailure;
j3 0:074983020f27 50
j3 0:074983020f27 51 if(n)
j3 0:074983020f27 52 {
j3 0:074983020f27 53 m_num_devices = n;
j3 0:074983020f27 54 result = MAX4822::Success;
j3 0:074983020f27 55 }
j3 0:074983020f27 56
j3 0:074983020f27 57 return result;
j3 0:074983020f27 58 }
j3 0:074983020f27 59
j3 0:074983020f27 60 //*********************************************************************
j3 0:074983020f27 61 MAX4822::CmdResult MAX4822::set_all_relays(uint8_t n)
j3 0:074983020f27 62 {
j3 0:074983020f27 63 MAX4822::CmdResult result = OpFailure;
j3 0:074983020f27 64
j3 0:074983020f27 65 return result;
j3 0:074983020f27 66 }
j3 0:074983020f27 67
j3 0:074983020f27 68 //*********************************************************************
j3 0:074983020f27 69 MAX4822::CmdResult MAX4822::reset_all_relays(uint8_t n)
j3 0:074983020f27 70 {
j3 0:074983020f27 71 MAX4822::CmdResult result = OpFailure;
j3 0:074983020f27 72
j3 0:074983020f27 73 return result;
j3 0:074983020f27 74 }
j3 0:074983020f27 75
j3 0:074983020f27 76 //*********************************************************************
j3 0:074983020f27 77 MAX4822::CmdResult MAX4822::set_relay(RelayChannel r, uint8_t n)
j3 0:074983020f27 78 {
j3 0:074983020f27 79 MAX4822::CmdResult result = OpFailure;
j3 0:074983020f27 80
j3 0:074983020f27 81 return result;
j3 0:074983020f27 82 }
j3 0:074983020f27 83
j3 0:074983020f27 84 //*********************************************************************
j3 0:074983020f27 85 MAX4822::CmdResult MAX4822::reset_relay(RelayChannel r, uint8_t n)
j3 0:074983020f27 86 {
j3 0:074983020f27 87 MAX4822::CmdResult result = OpFailure;
j3 0:074983020f27 88
j3 0:074983020f27 89 return result;
j3 0:074983020f27 90 }