Skip to content

Commit 4005887

Browse files
authored
Merge pull request #7008 from 0xc0170/fix_drivers
AStyle : drivers/hal/platform folders update
2 parents 2353e7b + ffcb6ec commit 4005887

File tree

123 files changed

+3762
-2684
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+3762
-2684
lines changed

.astyleignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ features/filesystem/fat/ChaN
99
features/frameworks
1010
features/FEATURE_BLE/targets
1111
features/unsupported/
12+
features/FEATURE_COMMON_PAL/
13+
hal/storage_abstraction
14+
FEATURE_NANOSTACK/coap-service
15+
FEATURE_NANOSTACK/sal-stack-nanostack
1216
rtos/TARGET_CORTEX/rtx5
1317
targets
1418
tools

drivers/AnalogIn.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class AnalogIn {
5757
*
5858
* @param pin AnalogIn pin to connect to
5959
*/
60-
AnalogIn(PinName pin) {
60+
AnalogIn(PinName pin)
61+
{
6162
lock();
6263
analogin_init(&_adc, pin);
6364
unlock();
@@ -67,7 +68,8 @@ class AnalogIn {
6768
*
6869
* @returns A floating-point value representing the current input voltage, measured as a percentage
6970
*/
70-
float read() {
71+
float read()
72+
{
7173
lock();
7274
float ret = analogin_read(&_adc);
7375
unlock();
@@ -79,7 +81,8 @@ class AnalogIn {
7981
* @returns
8082
* 16-bit unsigned short representing the current input voltage, normalised to a 16-bit value
8183
*/
82-
unsigned short read_u16() {
84+
unsigned short read_u16()
85+
{
8386
lock();
8487
unsigned short ret = analogin_read_u16(&_adc);
8588
unlock();
@@ -99,22 +102,26 @@ class AnalogIn {
99102
* if(volume > 0.25) { ... }
100103
* @endcode
101104
*/
102-
operator float() {
105+
operator float()
106+
{
103107
// Underlying call is thread safe
104108
return read();
105109
}
106110

107-
virtual ~AnalogIn() {
111+
virtual ~AnalogIn()
112+
{
108113
// Do nothing
109114
}
110115

111116
protected:
112117

113-
virtual void lock() {
118+
virtual void lock()
119+
{
114120
_mutex->lock();
115121
}
116122

117-
virtual void unlock() {
123+
virtual void unlock()
124+
{
118125
_mutex->unlock();
119126
}
120127

drivers/AnalogOut.h

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class AnalogOut {
5757
*
5858
* @param pin AnalogOut pin to connect to
5959
*/
60-
AnalogOut(PinName pin) {
60+
AnalogOut(PinName pin)
61+
{
6162
analogout_init(&_dac, pin);
6263
}
6364

@@ -68,7 +69,8 @@ class AnalogOut {
6869
* 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
6970
* Values outside this range will be saturated to 0.0f or 1.0f.
7071
*/
71-
void write(float value) {
72+
void write(float value)
73+
{
7274
lock();
7375
analogout_write(&_dac, value);
7476
unlock();
@@ -79,7 +81,8 @@ class AnalogOut {
7981
* @param value 16-bit unsigned short representing the output voltage,
8082
* normalised to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v)
8183
*/
82-
void write_u16(unsigned short value) {
84+
void write_u16(unsigned short value)
85+
{
8386
lock();
8487
analogout_write_u16(&_dac, value);
8588
unlock();
@@ -95,7 +98,8 @@ class AnalogOut {
9598
* @note
9699
* This value may not match exactly the value set by a previous write().
97100
*/
98-
float read() {
101+
float read()
102+
{
99103
lock();
100104
float ret = analogout_read(&_dac);
101105
unlock();
@@ -105,7 +109,8 @@ class AnalogOut {
105109
/** An operator shorthand for write()
106110
* \sa AnalogOut::write()
107111
*/
108-
AnalogOut& operator= (float percent) {
112+
AnalogOut &operator= (float percent)
113+
{
109114
// Underlying write call is thread safe
110115
write(percent);
111116
return *this;
@@ -114,7 +119,8 @@ class AnalogOut {
114119
/** An operator shorthand for write()
115120
* \sa AnalogOut::write()
116121
*/
117-
AnalogOut& operator= (AnalogOut& rhs) {
122+
AnalogOut &operator= (AnalogOut &rhs)
123+
{
118124
// Underlying write call is thread safe
119125
write(rhs.read());
120126
return *this;
@@ -123,22 +129,26 @@ class AnalogOut {
123129
/** An operator shorthand for read()
124130
* \sa AnalogOut::read()
125131
*/
126-
operator float() {
132+
operator float()
133+
{
127134
// Underlying read call is thread safe
128135
return read();
129136
}
130137

131-
virtual ~AnalogOut() {
138+
virtual ~AnalogOut()
139+
{
132140
// Do nothing
133141
}
134142

135143
protected:
136144

137-
virtual void lock() {
145+
virtual void lock()
146+
{
138147
_mutex.lock();
139148
}
140149

141-
virtual void unlock() {
150+
virtual void unlock()
151+
{
142152
_mutex.unlock();
143153
}
144154

drivers/BusIn.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,47 @@
1818

1919
namespace mbed {
2020

21-
BusIn::BusIn(PinName p0, PinName p1, PinName p2, PinName p3, PinName p4, PinName p5, PinName p6, PinName p7, PinName p8, PinName p9, PinName p10, PinName p11, PinName p12, PinName p13, PinName p14, PinName p15) {
21+
BusIn::BusIn(PinName p0, PinName p1, PinName p2, PinName p3, PinName p4, PinName p5, PinName p6, PinName p7, PinName p8, PinName p9, PinName p10, PinName p11, PinName p12, PinName p13, PinName p14, PinName p15)
22+
{
2223
PinName pins[16] = {p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15};
2324

2425
// No lock needed in the constructor
2526
_nc_mask = 0;
26-
for (int i=0; i<16; i++) {
27+
for (int i = 0; i < 16; i++) {
2728
_pin[i] = (pins[i] != NC) ? new DigitalIn(pins[i]) : 0;
2829
if (pins[i] != NC) {
2930
_nc_mask |= (1 << i);
3031
}
3132
}
3233
}
3334

34-
BusIn::BusIn(PinName pins[16]) {
35+
BusIn::BusIn(PinName pins[16])
36+
{
3537
// No lock needed in the constructor
3638
_nc_mask = 0;
37-
for (int i=0; i<16; i++) {
39+
for (int i = 0; i < 16; i++) {
3840
_pin[i] = (pins[i] != NC) ? new DigitalIn(pins[i]) : 0;
3941
if (pins[i] != NC) {
4042
_nc_mask |= (1 << i);
4143
}
4244
}
4345
}
4446

45-
BusIn::~BusIn() {
47+
BusIn::~BusIn()
48+
{
4649
// No lock needed in the destructor
47-
for (int i=0; i<16; i++) {
50+
for (int i = 0; i < 16; i++) {
4851
if (_pin[i] != 0) {
4952
delete _pin[i];
5053
}
5154
}
5255
}
5356

54-
int BusIn::read() {
57+
int BusIn::read()
58+
{
5559
int v = 0;
5660
lock();
57-
for (int i=0; i<16; i++) {
61+
for (int i = 0; i < 16; i++) {
5862
if (_pin[i] != 0) {
5963
v |= _pin[i]->read() << i;
6064
}
@@ -63,30 +67,35 @@ int BusIn::read() {
6367
return v;
6468
}
6569

66-
void BusIn::mode(PinMode pull) {
70+
void BusIn::mode(PinMode pull)
71+
{
6772
lock();
68-
for (int i=0; i<16; i++) {
73+
for (int i = 0; i < 16; i++) {
6974
if (_pin[i] != 0) {
7075
_pin[i]->mode(pull);
7176
}
7277
}
7378
unlock();
7479
}
7580

76-
void BusIn::lock() {
81+
void BusIn::lock()
82+
{
7783
_mutex.lock();
7884
}
7985

80-
void BusIn::unlock() {
86+
void BusIn::unlock()
87+
{
8188
_mutex.unlock();
8289
}
8390

84-
BusIn::operator int() {
91+
BusIn::operator int()
92+
{
8593
// Underlying read is thread safe
8694
return read();
8795
}
8896

89-
DigitalIn& BusIn::operator[] (int index) {
97+
DigitalIn &BusIn::operator[](int index)
98+
{
9099
// No lock needed since _pin is not modified outside the constructor
91100
MBED_ASSERT(index >= 0 && index <= 16);
92101
MBED_ASSERT(_pin[index]);

drivers/BusIn.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ class BusIn : private NonCopyable<BusIn> {
6262
PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
6363
PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
6464

65-
65+
6666
/** Create an BusIn, connected to the specified pins
6767
*
6868
* @param pins An array of pins to connect to bus bit
6969
*/
70-
BusIn(PinName pins[16]);
70+
BusIn(PinName pins[16]);
7171

7272
virtual ~BusIn();
7373

@@ -90,7 +90,8 @@ class BusIn : private NonCopyable<BusIn> {
9090
* @returns
9191
* Binary mask of connected pins
9292
*/
93-
int mask() {
93+
int mask()
94+
{
9495
// No lock needed since _nc_mask is not modified outside the constructor
9596
return _nc_mask;
9697
}
@@ -103,10 +104,10 @@ class BusIn : private NonCopyable<BusIn> {
103104
/** Access to particular bit in random-iterator fashion
104105
* @param index Position of bit
105106
*/
106-
DigitalIn & operator[] (int index);
107+
DigitalIn &operator[](int index);
107108

108109
protected:
109-
DigitalIn* _pin[16];
110+
DigitalIn *_pin[16];
110111

111112
/* Mask of bus's NC pins
112113
* If bit[n] is set to 1 - pin is connected

0 commit comments

Comments
 (0)