MAX5842
Published 01 Sep 2009, by
Simon Ford

No tags
« Back to documentation index
Show/hide line numbers
main.cpp Source File
main.cpp
00001
00002
00003
00004
00005
00006
00007 #include "mbed.h"
00008
00009 AnalogIn result(p16);
00010 DigitalOut led(LED1);
00011
00012 I2C max5842(p9, p10);
00013
00014 int main() {
00015
00016 max5842.frequency(400000);
00017
00018
00019
00020 const int addr = 0x3C;
00021
00022
00023
00024
00025 char power_up[2] = {0xF0, 0x3C};
00026 max5842.write(addr, power_up, 2);
00027
00028
00029
00030 char data[2] = {0x08, 0x00};
00031 max5842.write(addr, data, 2);
00032
00033 while(1) {
00034 printf("res = %f\n", result.read());
00035 led = !led;
00036 wait(0.25);
00037 }
00038 }