![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
d
Dependencies: mbed DS1621 4dGENIE
main.cpp@0:c8f90c6586ea, 2021-02-16 (annotated)
- Committer:
- __joss__
- Date:
- Tue Feb 16 14:15:44 2021 +0000
- Revision:
- 0:c8f90c6586ea
s
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
__joss__ | 0:c8f90c6586ea | 1 | #include "mbed.h" |
__joss__ | 0:c8f90c6586ea | 2 | #include "ds1621.h" |
__joss__ | 0:c8f90c6586ea | 3 | |
__joss__ | 0:c8f90c6586ea | 4 | #define DS1621_ADDR 0x90 |
__joss__ | 0:c8f90c6586ea | 5 | |
__joss__ | 0:c8f90c6586ea | 6 | Serial pc(USBTX, USBRX); |
__joss__ | 0:c8f90c6586ea | 7 | I2C i2c_ds(p28, p27); |
__joss__ | 0:c8f90c6586ea | 8 | DS1621 ds(&i2c_ds, DS1621_ADDR); |
__joss__ | 0:c8f90c6586ea | 9 | float temp, Htemp; |
__joss__ | 0:c8f90c6586ea | 10 | |
__joss__ | 0:c8f90c6586ea | 11 | int main() { |
__joss__ | 0:c8f90c6586ea | 12 | ds.StartConversion(1); |
__joss__ | 0:c8f90c6586ea | 13 | //ds.SetConfig(0x01); //1shot |
__joss__ | 0:c8f90c6586ea | 14 | ds.SetConfig(0x00); //polarity |
__joss__ | 0:c8f90c6586ea | 15 | while(1) { |
__joss__ | 0:c8f90c6586ea | 16 | ds.GetTemp(READ_TEMPERATURE, &temp); |
__joss__ | 0:c8f90c6586ea | 17 | pc.printf("%f \n\r", temp); |
__joss__ | 0:c8f90c6586ea | 18 | wait(1.0); |
__joss__ | 0:c8f90c6586ea | 19 | pc.printf("\n\r"); |
__joss__ | 0:c8f90c6586ea | 20 | } |
__joss__ | 0:c8f90c6586ea | 21 | } |