Skip to content

Commit 516477b

Browse files
committed
refactor(style): Apply style changes
1 parent 33d9c77 commit 516477b

File tree

757 files changed

+24465
-21417
lines changed

Some content is hidden

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

757 files changed

+24465
-21417
lines changed

cores/esp32/Arduino.h

+81-68
Original file line numberDiff line numberDiff line change
@@ -41,107 +41,111 @@
4141
#include "binary.h"
4242
#include "extra_attr.h"
4343

44-
#define PI 3.1415926535897932384626433832795
45-
#define HALF_PI 1.5707963267948966192313216916398
46-
#define TWO_PI 6.283185307179586476925286766559
44+
#define PI 3.1415926535897932384626433832795
45+
#define HALF_PI 1.5707963267948966192313216916398
46+
#define TWO_PI 6.283185307179586476925286766559
4747
#define DEG_TO_RAD 0.017453292519943295769236907684886
4848
#define RAD_TO_DEG 57.295779513082320876798154814105
49-
#define EULER 2.718281828459045235360287471352
49+
#define EULER 2.718281828459045235360287471352
5050

51-
#define SERIAL 0x0
51+
#define SERIAL 0x0
5252
#define DISPLAY 0x1
5353

5454
#define LSBFIRST 0
5555
#define MSBFIRST 1
5656

5757
//Interrupt Modes
58-
#define RISING 0x01
59-
#define FALLING 0x02
60-
#define CHANGE 0x03
61-
#define ONLOW 0x04
62-
#define ONHIGH 0x05
63-
#define ONLOW_WE 0x0C
58+
#define RISING 0x01
59+
#define FALLING 0x02
60+
#define CHANGE 0x03
61+
#define ONLOW 0x04
62+
#define ONHIGH 0x05
63+
#define ONLOW_WE 0x0C
6464
#define ONHIGH_WE 0x0D
6565

66-
#define DEFAULT 1
66+
#define DEFAULT 1
6767
#define EXTERNAL 0
6868

6969
#ifndef __STRINGIFY
7070
#define __STRINGIFY(a) #a
7171
#endif
7272

7373
// can't define max() / min() because of conflicts with C++
74-
#define _min(a, b) ((a) < (b) ? (a) : (b))
75-
#define _max(a, b) ((a) > (b) ? (a) : (b))
76-
#define _abs(x) ((x) > 0 ? (x) : -(x)) // abs() comes from STL
74+
#define _min(a, b) ((a) < (b) ? (a) : (b))
75+
#define _max(a, b) ((a) > (b) ? (a) : (b))
76+
#define _abs(x) ((x) > 0 ? (x) : -(x)) // abs() comes from STL
7777
#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
78-
#define _round(x) ((x) >= 0 ? (long)((x) + 0.5) : (long)((x)-0.5)) // round() comes from STL
79-
#define radians(deg) ((deg)*DEG_TO_RAD)
80-
#define degrees(rad) ((rad)*RAD_TO_DEG)
81-
#define sq(x) ((x) * (x))
78+
#define _round(x) ((x) >= 0 ? (long) ((x) + 0.5) : (long) ((x) - 0.5)) // round() comes from STL
79+
#define radians(deg) ((deg) * DEG_TO_RAD)
80+
#define degrees(rad) ((rad) * RAD_TO_DEG)
81+
#define sq(x) ((x) * (x))
8282

8383
// ESP32xx runs FreeRTOS... disabling interrupts can lead to issues, such as Watchdog Timeout
84-
#define sei() portENABLE_INTERRUPTS()
85-
#define cli() portDISABLE_INTERRUPTS()
86-
#define interrupts() sei()
84+
#define sei() portENABLE_INTERRUPTS()
85+
#define cli() portDISABLE_INTERRUPTS()
86+
#define interrupts() sei()
8787
#define noInterrupts() cli()
8888

89-
#define clockCyclesPerMicrosecond() ((long int)getCpuFrequencyMhz())
89+
#define clockCyclesPerMicrosecond() ((long int) getCpuFrequencyMhz())
9090
#define clockCyclesToMicroseconds(a) ((a) / clockCyclesPerMicrosecond())
91-
#define microsecondsToClockCycles(a) ((a)*clockCyclesPerMicrosecond())
91+
#define microsecondsToClockCycles(a) ((a) * clockCyclesPerMicrosecond())
9292

93-
#define lowByte(w) ((uint8_t)((w)&0xff))
94-
#define highByte(w) ((uint8_t)((w) >> 8))
93+
#define lowByte(w) ((uint8_t) ((w) & 0xff))
94+
#define highByte(w) ((uint8_t) ((w) >> 8))
9595

96-
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
97-
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
98-
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
99-
#define bitToggle(value, bit) ((value) ^= (1UL << (bit)))
96+
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
97+
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
98+
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
99+
#define bitToggle(value, bit) ((value) ^= (1UL << (bit)))
100100
#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit))
101101

102102
// avr-libc defines _NOP() since 1.6.2
103103
#ifndef _NOP
104-
#define _NOP() \
105-
do { __asm__ volatile("nop"); } while (0)
104+
#define _NOP() \
105+
do { \
106+
__asm__ volatile("nop"); \
107+
} while (0)
106108
#endif
107109

108110
#define bit(b) (1UL << (b))
109111
#define _BV(b) (1UL << (b))
110112

111113
#define digitalPinToTimer(pin) (0)
112-
#define analogInPinToBit(P) (P)
114+
#define analogInPinToBit(P) (P)
113115
#if SOC_GPIO_PIN_COUNT <= 32
114-
#define digitalPinToPort(pin) (0)
116+
#define digitalPinToPort(pin) (0)
115117
#define digitalPinToBitMask(pin) (1UL << digitalPinToGPIONumber(pin))
116-
#define portOutputRegister(port) ((volatile uint32_t*)GPIO_OUT_REG)
117-
#define portInputRegister(port) ((volatile uint32_t*)GPIO_IN_REG)
118-
#define portModeRegister(port) ((volatile uint32_t*)GPIO_ENABLE_REG)
118+
#define portOutputRegister(port) ((volatile uint32_t *) GPIO_OUT_REG)
119+
#define portInputRegister(port) ((volatile uint32_t *) GPIO_IN_REG)
120+
#define portModeRegister(port) ((volatile uint32_t *) GPIO_ENABLE_REG)
119121
#elif SOC_GPIO_PIN_COUNT <= 64
120-
#define digitalPinToPort(pin) ((digitalPinToGPIONumber(pin) > 31) ? 1 : 0)
122+
#define digitalPinToPort(pin) ((digitalPinToGPIONumber(pin) > 31) ? 1 : 0)
121123
#define digitalPinToBitMask(pin) (1UL << (digitalPinToGPIONumber(pin) & 31))
122-
#define portOutputRegister(port) ((volatile uint32_t*)((port) ? GPIO_OUT1_REG : GPIO_OUT_REG))
123-
#define portInputRegister(port) ((volatile uint32_t*)((port) ? GPIO_IN1_REG : GPIO_IN_REG))
124-
#define portModeRegister(port) ((volatile uint32_t*)((port) ? GPIO_ENABLE1_REG : GPIO_ENABLE_REG))
124+
#define portOutputRegister(port) ((volatile uint32_t *) ((port) ? GPIO_OUT1_REG : GPIO_OUT_REG))
125+
#define portInputRegister(port) ((volatile uint32_t *) ((port) ? GPIO_IN1_REG : GPIO_IN_REG))
126+
#define portModeRegister(port) ((volatile uint32_t *) ((port) ? GPIO_ENABLE1_REG : GPIO_ENABLE_REG))
125127
#else
126128
#error SOC_GPIO_PIN_COUNT > 64 not implemented
127129
#endif
128130

129-
#define NOT_A_PIN -1
130-
#define NOT_A_PORT -1
131+
#define NOT_A_PIN -1
132+
#define NOT_A_PORT -1
131133
#define NOT_AN_INTERRUPT -1
132-
#define NOT_ON_TIMER 0
134+
#define NOT_ON_TIMER 0
133135

134136
// some defines generic for all SoC moved from variants/board_name/pins_arduino.h
135137
#define NUM_DIGITAL_PINS SOC_GPIO_PIN_COUNT // All GPIOs
136138
#if SOC_ADC_PERIPH_NUM == 1
137139
#define NUM_ANALOG_INPUTS (SOC_ADC_CHANNEL_NUM(0)) // Depends on the SoC (ESP32C6, ESP32H2, ESP32C2, ESP32P4)
138140
#elif SOC_ADC_PERIPH_NUM == 2
139-
#define NUM_ANALOG_INPUTS (SOC_ADC_CHANNEL_NUM(0) + SOC_ADC_CHANNEL_NUM(1)) // Depends on the SoC (ESP32, ESP32S2, ESP32S3, ESP32C3)
141+
#define NUM_ANALOG_INPUTS \
142+
(SOC_ADC_CHANNEL_NUM(0) + SOC_ADC_CHANNEL_NUM(1)) // Depends on the SoC (ESP32, ESP32S2, ESP32S3, ESP32C3)
140143
#endif
141-
#define EXTERNAL_NUM_INTERRUPTS NUM_DIGITAL_PINS // All GPIOs
144+
#define EXTERNAL_NUM_INTERRUPTS NUM_DIGITAL_PINS // All GPIOs
142145
#define analogInputToDigitalPin(p) (((p) < NUM_ANALOG_INPUTS) ? (analogChannelToDigitalPin(p)) : -1)
143-
#define digitalPinToInterrupt(p) ((((uint8_t)digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS) ? digitalPinToGPIONumber(p) : NOT_AN_INTERRUPT)
144-
#define digitalPinHasPWM(p) (((uint8_t)digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS)
146+
#define digitalPinToInterrupt(p) \
147+
((((uint8_t) digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS) ? digitalPinToGPIONumber(p) : NOT_AN_INTERRUPT)
148+
#define digitalPinHasPWM(p) (((uint8_t) digitalPinToGPIONumber(p)) < NUM_DIGITAL_PINS)
145149

146150
typedef bool boolean;
147151
typedef uint8_t byte;
@@ -170,15 +174,15 @@ long map(long, long, long, long, long);
170174
extern "C" {
171175
#endif
172176

173-
void init(void);
174-
void initVariant(void);
175-
void initArduino(void);
177+
void init(void);
178+
void initVariant(void);
179+
void initArduino(void);
176180

177-
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
178-
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
181+
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
182+
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
179183

180-
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
181-
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
184+
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
185+
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
182186

183187
#ifdef __cplusplus
184188
}
@@ -212,29 +216,38 @@ uint16_t makeWord(uint8_t h, uint8_t l);
212216
#define word(...) makeWord(__VA_ARGS__)
213217

214218
size_t getArduinoLoopTaskStackSize(void);
215-
#define SET_LOOP_TASK_STACK_SIZE(sz) \
216-
size_t getArduinoLoopTaskStackSize() { return sz; }
219+
#define SET_LOOP_TASK_STACK_SIZE(sz) \
220+
size_t getArduinoLoopTaskStackSize() \
221+
{ \
222+
return sz; \
223+
}
217224

218225
bool shouldPrintChipDebugReport(void);
219-
#define ENABLE_CHIP_DEBUG_REPORT \
220-
bool shouldPrintChipDebugReport(void) { return true; }
226+
#define ENABLE_CHIP_DEBUG_REPORT \
227+
bool shouldPrintChipDebugReport(void) \
228+
{ \
229+
return true; \
230+
}
221231

222232
// allows user to bypass esp_spiram_test()
223233
bool esp_psram_extram_test(void);
224-
#define BYPASS_SPIRAM_TEST(bypass) \
225-
bool testSPIRAM(void) { \
226-
if (bypass) return true; \
227-
else return esp_psram_extram_test(); \
234+
#define BYPASS_SPIRAM_TEST(bypass) \
235+
bool testSPIRAM(void) \
236+
{ \
237+
if (bypass) \
238+
return true; \
239+
else \
240+
return esp_psram_extram_test(); \
228241
}
229242

230243
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
231244
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
232245

233-
extern "C" bool getLocalTime(struct tm* info, uint32_t ms = 5000);
234-
extern "C" void configTime(long gmtOffset_sec, int daylightOffset_sec,
235-
const char* server1, const char* server2 = nullptr, const char* server3 = nullptr);
236-
extern "C" void configTzTime(const char* tz,
237-
const char* server1, const char* server2 = nullptr, const char* server3 = nullptr);
246+
extern "C" bool getLocalTime(struct tm *info, uint32_t ms = 5000);
247+
extern "C" void configTime(long gmtOffset_sec, int daylightOffset_sec, const char *server1,
248+
const char *server2 = nullptr, const char *server3 = nullptr);
249+
extern "C" void configTzTime(const char *tz, const char *server1, const char *server2 = nullptr,
250+
const char *server3 = nullptr);
238251

239252
void setToneChannel(uint8_t channel = 0);
240253
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);

cores/esp32/Client.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
#include "Stream.h"
2424
#include "IPAddress.h"
2525

26-
class Client : public Stream {
26+
class Client : public Stream
27+
{
2728
public:
2829
virtual int connect(IPAddress ip, uint16_t port) = 0;
2930
virtual int connect(const char *host, uint16_t port) = 0;
@@ -37,8 +38,10 @@ class Client : public Stream {
3738
virtual void stop() = 0;
3839
virtual uint8_t connected() = 0;
3940
virtual operator bool() = 0;
41+
4042
protected:
41-
uint8_t *rawIPAddress(IPAddress &addr) {
43+
uint8_t *rawIPAddress(IPAddress &addr)
44+
{
4245
return addr.raw_address();
4346
}
4447
};

0 commit comments

Comments
 (0)