
Demo for the MAX11301WING
Dependencies: MAX113XX_Pixi max32630fthr
Fork of MAX11301_Demo by
main.cpp@2:5362460b01ef, 2017-08-17 (annotated)
- Committer:
- coreyharris
- Date:
- Thu Aug 17 20:04:52 2017 +0000
- Revision:
- 2:5362460b01ef
- Parent:
- 1:c161bde4496f
- Child:
- 3:b3fbff9ab12e
Added comments;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
coreyharris | 0:6727152ebfbb | 1 | #include "mbed.h" |
coreyharris | 0:6727152ebfbb | 2 | #include "max32630fthr.h" |
coreyharris | 0:6727152ebfbb | 3 | #include "MAX113XX_Pixi.h" |
coreyharris | 0:6727152ebfbb | 4 | #include "MAX11301Hex.h" |
coreyharris | 0:6727152ebfbb | 5 | |
coreyharris | 0:6727152ebfbb | 6 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
coreyharris | 0:6727152ebfbb | 7 | |
coreyharris | 0:6727152ebfbb | 8 | int main() |
coreyharris | 0:6727152ebfbb | 9 | { |
coreyharris | 1:c161bde4496f | 10 | Serial pc(USBTX, USBRX); // Use USB debug probe for serial link |
coreyharris | 1:c161bde4496f | 11 | pc.baud(115200); // Baud rate = 115200 |
coreyharris | 0:6727152ebfbb | 12 | |
coreyharris | 1:c161bde4496f | 13 | I2C i2cBus(I2C1_SDA, I2C1_SCL); // I2C bus, P3_4 = SDA, P3_5 = SCL |
coreyharris | 0:6727152ebfbb | 14 | |
coreyharris | 0:6727152ebfbb | 15 | MAX113XX_I2C * pixi; |
coreyharris | 0:6727152ebfbb | 16 | pixi = new MAX113XX_I2C(i2cBus, MAX113XX_I2C::MAX11301, 0x38, P5_5); |
coreyharris | 0:6727152ebfbb | 17 | |
coreyharris | 1:c161bde4496f | 18 | |
coreyharris | 1:c161bde4496f | 19 | uint16_t adcData, idx; |
coreyharris | 0:6727152ebfbb | 20 | float adcVoltage; |
coreyharris | 0:6727152ebfbb | 21 | while(1) { |
coreyharris | 1:c161bde4496f | 22 | |
coreyharris | 1:c161bde4496f | 23 | for(idx = 0; idx <= 0xFFF; idx++) { |
coreyharris | 2:5362460b01ef | 24 | pixi->dacWrite(MAX113XX_Pixi::PORT0, idx); // Write idx to PORT0 |
coreyharris | 2:5362460b01ef | 25 | pixi->singleEndedADCRead(MAX113XX_Pixi::PORT9, adcData); // Read value from PORT9 |
coreyharris | 2:5362460b01ef | 26 | adcVoltage = -5 + 2.442e-3 * adcData; // Convert ADC val to a voltage |
coreyharris | 0:6727152ebfbb | 27 | pc.printf("ADC Voltage is %1.3f V, Count is 0x%x \r\n", adcVoltage, idx); |
coreyharris | 0:6727152ebfbb | 28 | } |
coreyharris | 0:6727152ebfbb | 29 | |
coreyharris | 1:c161bde4496f | 30 | pc.printf("\r\n\r\nSweep complete, starting new sweep\r\n\r\n"); |
coreyharris | 1:c161bde4496f | 31 | wait(2.0); |
coreyharris | 0:6727152ebfbb | 32 | } |
coreyharris | 0:6727152ebfbb | 33 | } |
coreyharris | 0:6727152ebfbb | 34 |