コウスケ スズキ
/
ADlkyori
a
Revision 0:b0beaf8fde48, committed 2022-01-16
- Comitter:
- kosukesuzuki
- Date:
- Sun Jan 16 04:03:52 2022 +0000
- Commit message:
- a
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r b0beaf8fde48 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jan 16 04:03:52 2022 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include <math.h> + +SPI spi(p5,p6,p7); +DigitalOut cs(p8); + +Serial pc(USBTX,USBRX); + +int main(){ + spi.format(7,0); + spi.frequency(1000000); + pc.printf("Starting ADC interaction\r\n"); + double y; + + while(1){ + cs=0; + spi.write(0x60); + + uint8_t high= spi.write(0x00); + uint8_t low = spi.write(0x00); + + low = (high << 5)|(low>>2); + high=high>>3; + + int value=(high<<8)|low; + y = 53.444*(double(value()),-1.736); + pc.printf("sensor 0 value = %.3f[mm]\r\n",y); + + cs = 1; + wait(1); + } + } \ No newline at end of file
diff -r 000000000000 -r b0beaf8fde48 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Jan 16 04:03:52 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file