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.
Fork of mbed-dev by
Diff: drivers/AnalogIn.h
- Revision:
- 187:0387e8f68319
- Parent:
- 167:e84263d55307
--- a/drivers/AnalogIn.h Fri Jun 22 16:45:37 2018 +0100
+++ b/drivers/AnalogIn.h Thu Sep 06 13:40:20 2018 +0100
@@ -57,7 +57,8 @@
*
* @param pin AnalogIn pin to connect to
*/
- AnalogIn(PinName pin) {
+ AnalogIn(PinName pin)
+ {
lock();
analogin_init(&_adc, pin);
unlock();
@@ -67,7 +68,8 @@
*
* @returns A floating-point value representing the current input voltage, measured as a percentage
*/
- float read() {
+ float read()
+ {
lock();
float ret = analogin_read(&_adc);
unlock();
@@ -79,7 +81,8 @@
* @returns
* 16-bit unsigned short representing the current input voltage, normalised to a 16-bit value
*/
- unsigned short read_u16() {
+ unsigned short read_u16()
+ {
lock();
unsigned short ret = analogin_read_u16(&_adc);
unlock();
@@ -99,22 +102,26 @@
* if(volume > 0.25) { ... }
* @endcode
*/
- operator float() {
+ operator float()
+ {
// Underlying call is thread safe
return read();
}
- virtual ~AnalogIn() {
+ virtual ~AnalogIn()
+ {
// Do nothing
}
protected:
- virtual void lock() {
+ virtual void lock()
+ {
_mutex->lock();
}
- virtual void unlock() {
+ virtual void unlock()
+ {
_mutex->unlock();
}
