Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 1_P-7100 4_EEPROM_baro_press 0_twe_Tmode 4_sensor-Integration-function2
P7100.cpp
00001 #include "mbed.h" 00002 #include "P7100.h" 00003 00004 P7100::P7100(PinName mosi, PinName miso, PinName sclk, PinName pin) : spi(mosi, miso, sclk), cs(pin) 00005 { 00006 cs = 0; 00007 spi.format(7, 0); //通信形式定義 00008 spi.frequency(1000000); //クロックレート 00009 } 00010 00011 P7100::~P7100() 00012 { 00013 } 00014 00015 float P7100::v_read() 00016 { 00017 uint8_t high, low; //1バイトの符号なし整数 00018 float value, v; //値,電圧 00019 00020 cs = 0; //通信開始 00021 00022 spi.write(0x60); //シングル 00023 //spi.write(0x40); //差動 00024 00025 high = spi.write(0x00); 00026 low = spi.write(0x00); 00027 00028 low = (high << 5) | (low >> 2); 00029 high = high >> 3; 00030 00031 value = (high << 8) | low; 00032 00033 v = value / 4096 * 5.0; //出力電圧 00034 00035 cs = 1; //通信終了 00036 00037 return v; 00038 }
Generated on Wed Aug 3 2022 22:05:14 by
1.7.2