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/AnalogOut.h
- Revision:
- 187:0387e8f68319
- Parent:
- 167:e84263d55307
--- a/drivers/AnalogOut.h Fri Jun 22 16:45:37 2018 +0100
+++ b/drivers/AnalogOut.h Thu Sep 06 13:40:20 2018 +0100
@@ -57,7 +57,8 @@
*
* @param pin AnalogOut pin to connect to
*/
- AnalogOut(PinName pin) {
+ AnalogOut(PinName pin)
+ {
analogout_init(&_dac, pin);
}
@@ -68,7 +69,8 @@
* 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
* Values outside this range will be saturated to 0.0f or 1.0f.
*/
- void write(float value) {
+ void write(float value)
+ {
lock();
analogout_write(&_dac, value);
unlock();
@@ -79,7 +81,8 @@
* @param value 16-bit unsigned short representing the output voltage,
* normalised to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v)
*/
- void write_u16(unsigned short value) {
+ void write_u16(unsigned short value)
+ {
lock();
analogout_write_u16(&_dac, value);
unlock();
@@ -95,7 +98,8 @@
* @note
* This value may not match exactly the value set by a previous write().
*/
- float read() {
+ float read()
+ {
lock();
float ret = analogout_read(&_dac);
unlock();
@@ -105,7 +109,8 @@
/** An operator shorthand for write()
* \sa AnalogOut::write()
*/
- AnalogOut& operator= (float percent) {
+ AnalogOut &operator= (float percent)
+ {
// Underlying write call is thread safe
write(percent);
return *this;
@@ -114,7 +119,8 @@
/** An operator shorthand for write()
* \sa AnalogOut::write()
*/
- AnalogOut& operator= (AnalogOut& rhs) {
+ AnalogOut &operator= (AnalogOut &rhs)
+ {
// Underlying write call is thread safe
write(rhs.read());
return *this;
@@ -123,22 +129,26 @@
/** An operator shorthand for read()
* \sa AnalogOut::read()
*/
- operator float() {
+ operator float()
+ {
// Underlying read call is thread safe
return read();
}
- virtual ~AnalogOut() {
+ virtual ~AnalogOut()
+ {
// Do nothing
}
protected:
- virtual void lock() {
+ virtual void lock()
+ {
_mutex.lock();
}
- virtual void unlock() {
+ virtual void unlock()
+ {
_mutex.unlock();
}
