Library for the MAX11300
Dependents: MAX_IOT_KIT MAX_IOT_KIT
Fork of MAX11300 by
The MAX11300/01/11/12 are configurable mixed signal integrated circuits. The MAX11300/11 offer a SPI interface while the MAX11301/12 offer an I2C interface. The MAX11300/01 are 20 port devices while the MAX11311/12 are 12 port devices.
This library supports the family of parts by providing member functions that can manipulate the GPIO, ADC, DAC, and analog switches of the device, after it has been configured. For configuration of the device, this library requires a header file that can be generated by the MAX11300/01/11/12 Configuration Software. The configuration software can be found at the following link.
Include the generated MAX113XXHex.h file into your project and update the #include in MAX113XX_Pixi.h.
Diff: MAX113XX_Pixi.cpp
- Revision:
- 11:31e7ca030b8f
- Parent:
- 10:6efe114ef882
- Child:
- 12:8054ee101bad
--- a/MAX113XX_Pixi.cpp Mon May 08 17:49:57 2017 +0000 +++ b/MAX113XX_Pixi.cpp Mon May 08 19:24:55 2017 +0000 @@ -57,6 +57,23 @@ port_cfg_17_DESIGNVALUE, port_cfg_18_DESIGNVALUE, port_cfg_19_DESIGNVALUE}; + +static const uint16_t deviceDesignVals[15] = { + device_control_DESIGNVALUE, + interrupt_mask_DESIGNVALUE, + gpi_irqmode_7_to_0_DESIGNVALUE, + gpi_irqmode_15_to_8_DESIGNVALUE, + gpi_irqmode_19_to_16_DESIGNVALUE, + 0, //reserved + dac_preset_data_1_DESIGNVALUE, + dac_preset_data_2_DESIGNVALUE, + tmp_mon_cfg_DESIGNVALUE, + tmp_mon_int_hi_thresh_DESIGNVALUE, + tmp_mon_int_lo_thresh_DESIGNVALUE, + tmp_mon_ext1_hi_thresh_DESIGNVALUE, + tmp_mon_ext1_lo_thresh_DESIGNVALUE, + tmp_mon_ext2_hi_thresh_DESIGNVALUE, + tmp_mon_ext2_lo_thresh_DESIGNVALUE}; #endif //12 port devices... @@ -81,7 +98,8 @@ MAX113XX_Pixi::MAX113XX_Pixi(Device_e device, PinName cnvt): m_device(device), m_cnvt(cnvt, 1) { -} +} + //********************************************************************* MAX113XX_Pixi::CmdResult_e MAX113XX_Pixi::gpioWrite(Ports_e port, @@ -242,7 +260,15 @@ MAX113XX_Pixi::Device_e device, PinName cnvt): MAX113XX_Pixi(device, cnvt), m_spiBus(spiBus), m_cs(cs, 1) { - + if((m_device == MAX11300) || (m_device == MAX11301)) //20 port device + { + blockWrite(device_control, deviceDesignVals, 15); + blockWrite(port_cfg_00, portConfigDesignVals, 20); + wait(0.1); + } + else //12 port device + { + } } //********************************************************************* @@ -279,19 +305,30 @@ void MAX113XX_SPI::blockWrite(uint8_t reg, const uint16_t *data, const uint8_t num_reg) { + m_cs = 0; + m_spiBus.write(MAX113XXAddr_SPI_Write(reg)); for(uint8_t idx = 0; idx < num_reg; idx++) { - writeRegister((reg + idx), data[idx]); + m_spiBus.write(((0xFF00 & data[idx]) >> 8)); + m_spiBus.write((0x00FF & data[idx])); } + m_cs = 1; } //********************************************************************* void MAX113XX_SPI::blockRead(uint8_t reg, uint16_t *data, const uint8_t num_reg) { - for(uint8_t idx = 0; idx < num_reg; idx++) + uint16_t temp; + m_cs = 0; + m_spiBus.write(MAX113XXAddr_SPI_Read(reg)); + for(uint8_t idx = 0; idx < num_reg; idx ++) { - data[idx] = readRegister((reg + idx)); + temp = 0; + temp |= (m_spiBus.write(0xFF) << 8); + temp |= m_spiBus.write(0xFF); + data[idx] = temp; } + m_cs = 1; } @@ -299,7 +336,15 @@ MAX113XX_I2C::MAX113XX_I2C(I2C &i2cBus, MAX113XX_Pixi::Device_e device, PinName cnvt): MAX113XX_Pixi(device, cnvt), m_i2cBus(i2cBus) { - + if((m_device == MAX11300) || (m_device == MAX11301)) //20 port device + { + blockWrite(device_control, deviceDesignVals, 15); + blockWrite(port_cfg_00, portConfigDesignVals, 20); + wait(0.1); + } + else //12 port device + { + } } //*********************************************************************