Library for the MAX11300
Dependents: MAXREFDES130_131_Demo MAXREFDES130_Demo MAX11300_test
Diff: MAX11300.h
- Revision:
- 0:bfae6930d2ff
- Child:
- 1:90e0ff21a740
diff -r 000000000000 -r bfae6930d2ff MAX11300.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MAX11300.h Tue Jul 26 00:33:40 2016 +0000 @@ -0,0 +1,168 @@ +/********************************************************************** +* Copyright (C) 2016 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. +**********************************************************************/ + + +#ifndef MAX11300_H +#define MAX11300_H + +#include "mbed.h" +#include "MAX11300Hex.h" + +/** +@brief MAX11300 - PIXI, 20-Port Programmable Mixed-Signal I/O with +12-Bit ADC, 12-Bit DAC, Analog Switches, and GPIO + +The MAX11300 integrates a PIXI™, 12-bit, multichannel, analog-to-digital +converter (ADC) and a 12-bit, multichannel, buffered digital-to-analog +converter (DAC) in a single integrated circuit (IC). This device offers +20 mixed-signal high-voltage, bipolar ports, which are configurable as an +ADC analog input, a DAC analog output, a general-purpose input port (GPI), +a general-purpose output port (GPO), or an analog switch terminal. +One internal and two external temperature sensors track junction and +environmental temperature, respectively. Adjacent pairs of ports are +configurable as a logic-level translator for open-drain devices or an +analog switch. + +Use configuration software found at +https://www.maximintegrated.com/en/products/analog/data-converters/analog-to-digital-converters/MAX11300.html/tb_tab2 +to generate MAX11300hex.h file +*/ +class MAX11300 +{ + public: + + ///MAX11300 Ports + enum MAX11300_Ports + { + PORT0, + PORT1, + PORT2, + PORT3, + PORT4, + PORT5, + PORT6, + PORT7, + PORT8, + PORT9, + PORT10, + PORT11, + PORT12, + PORT13, + PORT14, + PORT15, + PORT16, + PORT17, + PORT18, + PORT19 + }; + + ///MAX11300 Port Modes + enum MAX11300_Port_Modes + { + ///HIGH_Z + MODE_0, + ///Digital input with programmable threshold, GPI + MODE_1, + ///Bidirectional level translator terminal + MODE_2, + ///Register-driven digital output with DAC-controlled level, GPO + MODE_3, + ///Unidirectional path output with DAC-controlled level, GPO + MODE_4, + ///Analog output for DAC + MODE_5, + ///Analog output for DAC with ADC monitoring + MODE_6, + ///Positive analog input to single-ended ADC + MODE_7, + ///Positive analog input to differential ADC + MODE_8, + ///Negative analog input to differential ADC + MODE_9, + ///Analog output for DAC and negative analog input to differential ADC + MODE_10, + ///Terminal to GPI-controlled analog switch + MODE_11, + ///Terminal to register-controlled analog switch + MODE_12 + }; + + enum CmdResult + { + ///Failed operation + OpFailure, + ///Successful operation + Success + }; + + ///@brief MAX11300 Constructor + ///@param[in] spi_bus - reference to SPI bus for this device + ///@param[in] cs - pin to be used for chip select + ///@param[in] interrupt - pin to be used as interrupt input, default = NC + ///@param[in] cnvrt - pin to be used for convert, default = NC + MAX11300(SPI & spi_bus, PinName cs, PinName interrupt = NC, PinName cnvt = NC); + + ///@brief MAX11300 Destructor + ~MAX11300(); + + void write_register(MAX11300RegAddress_t reg, uint16_t data); + + uint16_t read_register(MAX11300RegAddress_t reg); + + void block_write(MAX11300RegAddress_t reg, uint16_t * data, uint8_t num_bytes); + + void block_read(MAX11300RegAddress_t reg, uint16_t * data, uint8_t num_bytes); + + CmdResult gpio_write(MAX11300_Ports port, uint8_t state); + + CmdResult gpio_read(MAX11300_Ports port, uint8_t & state); + + CmdResult adc_read(MAX11300_Ports port, uint16_t & data); + + CmdResult dac_write(MAX11300_Ports port, uint16_t data); + + CmdResult asw_cntrl(MAX11300_Ports port, uint8_t state); + + private: + + SPI & m_spi_bus; + DigitalOut m_cs; + DigitalIn m_int; + DigitalOut m_cnvt; + + void init(void); + void config_process_1(void); + void config_process_2(void); + void config_process_3(void); +}; + +#endif /* MAX11300_H */ \ No newline at end of file