
-
main.cpp@2:5de273c2a2a4, 2014-12-30 (annotated)
- Committer:
- frada
- Date:
- Tue Dec 30 18:47:41 2014 +0000
- Revision:
- 2:5de273c2a2a4
- Parent:
- 1:608e44287bb8
-
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frada | 0:495602973870 | 1 | #include "mbed.h" |
frada | 1:608e44287bb8 | 2 | #include "ADS7828.h" |
frada | 0:495602973870 | 3 | |
frada | 1:608e44287bb8 | 4 | DigitalOut myled(LED_GREEN); |
frada | 1:608e44287bb8 | 5 | Serial pc(USBTX, USBRX); |
frada | 1:608e44287bb8 | 6 | ADS7828 ADC(I2C_SDA, I2C_SCL, 100000, 0x00); |
frada | 0:495602973870 | 7 | |
frada | 0:495602973870 | 8 | int main() { |
frada | 2:5de273c2a2a4 | 9 | int data; |
frada | 1:608e44287bb8 | 10 | |
frada | 1:608e44287bb8 | 11 | pc.baud(115200); |
frada | 1:608e44287bb8 | 12 | pc.printf("Hello, World!\r\n"); |
frada | 0:495602973870 | 13 | |
frada | 0:495602973870 | 14 | while(1) { |
frada | 0:495602973870 | 15 | myled != myled; |
frada | 1:608e44287bb8 | 16 | |
frada | 2:5de273c2a2a4 | 17 | data = ADC.readRawValue(MODE_SE | MODE_INTERNAL_REF_ON_ADC_ON, CH0_SE); |
frada | 1:608e44287bb8 | 18 | if (data == -1) |
frada | 1:608e44287bb8 | 19 | pc.printf("Error reading data from ADC!\r\n"); |
frada | 1:608e44287bb8 | 20 | else |
frada | 2:5de273c2a2a4 | 21 | pc.printf("Conversion result: 0x%04x = %.3f V\r\n", data, 2.5F/4096*data); |
frada | 1:608e44287bb8 | 22 | |
frada | 0:495602973870 | 23 | wait(0.2); |
frada | 0:495602973870 | 24 | } |
frada | 0:495602973870 | 25 | } |