High Speed Analog In STM32L152RET
Embed:
(wiki syntax)
Show/hide line numbers
HSAnalogIn.h
00001 #include "mbed.h" 00002 00003 class HSAnalogIn 00004 { 00005 private: 00006 int BDCin; 00007 int myPin=0; 00008 int gruppe=0; 00009 00010 void warte(int zeit) 00011 { 00012 for (int i=0;i<zeit*5;i++) 00013 { 00014 asm("nop\n\t"); 00015 } 00016 } 00017 00018 public: 00019 HSAnalogIn(int Pin); 00020 00021 00022 00023 float read(); 00024 00025 /** Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF] 00026 * 00027 * @returns 00028 * 16-bit unsigned short representing the current input voltage, normalized to a 16-bit value 00029 */ 00030 unsigned short read_u16(); 00031 00032 /** An operator shorthand for read() 00033 * 00034 * The float() operator can be used as a shorthand for read() to simplify common code sequences 00035 * 00036 * Example: 00037 * @code 00038 * float x = volume.read(); 00039 * float x = volume; 00040 * 00041 * if(volume.read() > 0.25) { ... } 00042 * if(volume > 0.25) { ... } 00043 * @endcode 00044 */ 00045 00046 operator float() 00047 { 00048 // Underlying call is thread safe 00049 return read(); 00050 } 00051 00052 virtual ~HSAnalogIn() 00053 { 00054 // Do nothing 00055 } 00056 00057 };
Generated on Mon Aug 1 2022 00:30:30 by
1.7.2