
Demo for the MAX11301WING
Dependencies: MAX113XX_Pixi max32630fthr
Fork of MAX11301_Demo by
main.cpp@5:2edbaf7fcf7b, 2017-08-28 (annotated)
- Committer:
- coreyharris
- Date:
- Mon Aug 28 20:46:58 2017 +0000
- Revision:
- 5:2edbaf7fcf7b
- Parent:
- 4:4899e8165b98
- Child:
- 6:fe500943de11
Changed the Pixi object declaration
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
coreyharris | 5:2edbaf7fcf7b | 1 | /******************************************************************************* |
coreyharris | 5:2edbaf7fcf7b | 2 | * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. |
coreyharris | 5:2edbaf7fcf7b | 3 | * |
coreyharris | 5:2edbaf7fcf7b | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
coreyharris | 5:2edbaf7fcf7b | 5 | * copy of this software and associated documentation files (the "Software"), |
coreyharris | 5:2edbaf7fcf7b | 6 | * to deal in the Software without restriction, including without limitation |
coreyharris | 5:2edbaf7fcf7b | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
coreyharris | 5:2edbaf7fcf7b | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
coreyharris | 5:2edbaf7fcf7b | 9 | * Software is furnished to do so, subject to the following conditions: |
coreyharris | 5:2edbaf7fcf7b | 10 | * |
coreyharris | 5:2edbaf7fcf7b | 11 | * The above copyright notice and this permission notice shall be included |
coreyharris | 5:2edbaf7fcf7b | 12 | * in all copies or substantial portions of the Software. |
coreyharris | 5:2edbaf7fcf7b | 13 | * |
coreyharris | 5:2edbaf7fcf7b | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
coreyharris | 5:2edbaf7fcf7b | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
coreyharris | 5:2edbaf7fcf7b | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
coreyharris | 5:2edbaf7fcf7b | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
coreyharris | 5:2edbaf7fcf7b | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
coreyharris | 5:2edbaf7fcf7b | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
coreyharris | 5:2edbaf7fcf7b | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
coreyharris | 5:2edbaf7fcf7b | 21 | * |
coreyharris | 5:2edbaf7fcf7b | 22 | * Except as contained in this notice, the name of Maxim Integrated |
coreyharris | 5:2edbaf7fcf7b | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
coreyharris | 5:2edbaf7fcf7b | 24 | * Products, Inc. Branding Policy. |
coreyharris | 5:2edbaf7fcf7b | 25 | * |
coreyharris | 5:2edbaf7fcf7b | 26 | * The mere transfer of this software does not imply any licenses |
coreyharris | 5:2edbaf7fcf7b | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
coreyharris | 5:2edbaf7fcf7b | 28 | * trademarks, maskwork rights, or any other form of intellectual |
coreyharris | 5:2edbaf7fcf7b | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
coreyharris | 5:2edbaf7fcf7b | 30 | * ownership rights. |
coreyharris | 5:2edbaf7fcf7b | 31 | ******************************************************************************* |
coreyharris | 5:2edbaf7fcf7b | 32 | */ |
coreyharris | 5:2edbaf7fcf7b | 33 | |
coreyharris | 5:2edbaf7fcf7b | 34 | |
coreyharris | 0:6727152ebfbb | 35 | #include "mbed.h" |
coreyharris | 0:6727152ebfbb | 36 | #include "max32630fthr.h" |
coreyharris | 0:6727152ebfbb | 37 | #include "MAX113XX_Pixi.h" |
coreyharris | 0:6727152ebfbb | 38 | #include "MAX11301Hex.h" |
coreyharris | 0:6727152ebfbb | 39 | |
coreyharris | 0:6727152ebfbb | 40 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
coreyharris | 0:6727152ebfbb | 41 | |
coreyharris | 0:6727152ebfbb | 42 | int main() |
coreyharris | 0:6727152ebfbb | 43 | { |
coreyharris | 1:c161bde4496f | 44 | Serial pc(USBTX, USBRX); // Use USB debug probe for serial link |
coreyharris | 1:c161bde4496f | 45 | pc.baud(115200); // Baud rate = 115200 |
coreyharris | 0:6727152ebfbb | 46 | |
coreyharris | 1:c161bde4496f | 47 | I2C i2cBus(I2C1_SDA, I2C1_SCL); // I2C bus, P3_4 = SDA, P3_5 = SCL |
coreyharris | 0:6727152ebfbb | 48 | |
coreyharris | 5:2edbaf7fcf7b | 49 | MAX113XX_I2C pixi(i2cBus, MAX113XX_I2C::MAX11301, 0x38, P5_5); |
coreyharris | 3:b3fbff9ab12e | 50 | |
coreyharris | 5:2edbaf7fcf7b | 51 | pixi.dacWrite(MAX113XX_Pixi::PORT0, 0x000); // Pixi PORT0 is -5V |
coreyharris | 5:2edbaf7fcf7b | 52 | pixi.dacWrite(MAX113XX_Pixi::PORT1, 0xFFF); // Pixi PORT1 is +5V |
coreyharris | 1:c161bde4496f | 53 | |
coreyharris | 5:2edbaf7fcf7b | 54 | uint16_t adcData; |
coreyharris | 0:6727152ebfbb | 55 | float adcVoltage; |
coreyharris | 0:6727152ebfbb | 56 | while(1) { |
coreyharris | 0:6727152ebfbb | 57 | |
coreyharris | 5:2edbaf7fcf7b | 58 | pixi.singleEndedADCRead(MAX113XX_Pixi::PORT9, adcData); // Read value from PORT9 |
coreyharris | 5:2edbaf7fcf7b | 59 | adcVoltage = -5 + 2.442e-3 * adcData; // Convert ADC val to a voltage |
coreyharris | 4:4899e8165b98 | 60 | pc.printf("ADC Read is : %i,\tVoltage is %1.3f V \r\n", adcData, adcVoltage); |
coreyharris | 5:2edbaf7fcf7b | 61 | wait(0.05); |
coreyharris | 5:2edbaf7fcf7b | 62 | |
coreyharris | 0:6727152ebfbb | 63 | } |
coreyharris | 0:6727152ebfbb | 64 | } |
coreyharris | 0:6727152ebfbb | 65 |