Skip to content

Commit cd0e41d

Browse files
committed
[ISSUE-XXXX]: code formatting cleanup
1 parent 1ef9900 commit cd0e41d

41 files changed

Lines changed: 254 additions & 75 deletions

Some content is hidden

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

examples/0blink/ledblink.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ const uint64_t gu64tckSchedulePeriod = (CLK_FREQ_HZ / SCHEDULE_FREQ_HZ);
3535
// ==================== Local Data ================
3636
static volatile bool gbLedOn = false;
3737

38-
// Implementation
38+
// ============== Implementation ==============
39+
// -------------- Internal functions --------------
3940

4041
static void _ledblink_init() {
4142
gpio_pin_enable(LEDBLINK_GPIO);
@@ -52,7 +53,7 @@ static void _ledblink_cycle(uint64_t u64Ticks) {
5253
}
5354
}
5455

55-
// ====================== Interface functions =========================
56+
// -------------- Interface functions --------------
5657

5758
void prog_init_pro_pre() {
5859
_ledblink_init();

examples/0button/buttonisr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const uint64_t gu64tckSchedulePeriod = (CLK_FREQ_HZ / SCHEDULE_FREQ_HZ);
4141
// ==================== Local Data ================
4242
static const char acMessage[] = "Button pressed.\n";
4343

44-
// ================ Local function definitions =================
44+
// ============== Implementation ==============
45+
// -------------- Internal functions --------------
4546
IRAM_ATTR static void _button_isr(void *pvParam) {
4647
bool bButtonEvent = gsGPIO.STATUS & (1 << BUTTON_GPIO);
4748
if (bButtonEvent) {
@@ -88,7 +89,7 @@ static void _button_cycle(uint64_t u64Ticks) {
8889
}
8990
}
9091

91-
// ====================== Interface functions =========================
92+
// -------------- Interface functions --------------
9293

9394
void prog_init_pro_pre() {
9495
gsUART0.CLKDIV.u20ClkDiv = APB_FREQ_HZ / 115200;

examples/0hello/hello.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ const uint64_t gu64tckSchedulePeriod = (CLK_FREQ_HZ / SCHEDULE_FREQ_HZ);
3939
// ==================== Local Data ================
4040
static UART_Type *gpsUART0 = &gsUART0;
4141

42-
// Implementation
42+
// ============== Implementation ==============
43+
// -------------- Internal functions --------------
4344

4445
static void _uart_init() {
45-
gpsUART0->CLKDIV.u20ClkDiv = APB_FREQ_HZ / UART_FREQ_HZ;
46+
gpsUART0->CLKDIV.raw = UART_HZ2CLKDIV(UART_FREQ_HZ, APB_FREQ_HZ);
4647
}
4748

4849
static void _print_cycle(uint64_t u64Ticks) {
@@ -70,7 +71,7 @@ static void _print_cycle(uint64_t u64Ticks) {
7071
}
7172
}
7273

73-
// ====================== Interface functions =========================
74+
// -------------- Interface functions --------------
7475

7576
void prog_init_pro_pre() {
7677
_uart_init();

examples/0ledctrl/ledctrl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ const uint64_t gu64tckSchedulePeriod = (CLK_FREQ_HZ / SCHEDULE_FREQ_HZ);
4040
static UART_Type *gpsUART0 = &gsUART0;
4141
static UART_Type *gpsUART0M = &gsUART0Mapped;
4242

43-
// Implementation
43+
// ============== Implementation ==============
44+
// -------------- Internal functions --------------
4445

4546
static void _led_init() {
4647
gpio_pin_enable(LED1_GPIO);
4748
gpio_pin_enable(LED2_GPIO);
4849
}
4950

5051
static void _uart_init() {
51-
gpsUART0->CLKDIV.u20ClkDiv = APB_FREQ_HZ / UART_FREQ_HZ;
52+
gpsUART0->CLKDIV.raw = UART_HZ2CLKDIV(UART_FREQ_HZ, APB_FREQ_HZ);
5253
}
5354

5455
static void _ledctrl_cycle(uint64_t u64Ticks) {
@@ -78,7 +79,7 @@ static void _ledctrl_cycle(uint64_t u64Ticks) {
7879
}
7980
}
8081

81-
// ====================== Interface functions =========================
82+
// -------------- Internface functions --------------
8283

8384
void prog_init_pro_pre() {
8485
_led_init();

examples/0uart/uartprint.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,11 @@ const uint64_t gu64tckSchedulePeriod = (CLK_FREQ_HZ / SCHEDULE_FREQ_HZ);
3232
static UART_Type *gpsUART0 = &gsUART0;
3333
static UART_Type *gpsUART0M = &gsUART0Mapped;
3434

35-
// Implementation
35+
// ============== Implementation ==============
36+
// -------------- Internal functions --------------
3637

3738
static void _uart_init() {
38-
#define UART0_CLKDIV_INT HZ2APBTICKS(UART0_FREQ_HZ)
39-
#define UART0_CLKDIV_REM (APB_FREQ_HZ - (UART0_CLKDIV_INT * UART0_FREQ_HZ))
40-
#define UART0_CLKDIV_FRAG ((16U * UART0_CLKDIV_REM) / UART0_FREQ_HZ)
41-
// version A)
42-
gsUART0.CLKDIV.u20ClkDiv = UART0_CLKDIV_INT;
43-
gsUART0.CLKDIV.u4ClkDivFrag = UART0_CLKDIV_FRAG;
44-
// version B)
45-
// gsUART0.CLKDIV.raw = UART0_CLKDIV_INT | (UART0_CLKDIV_FRAG << 20); // this line results in shorter binary file
46-
#undef UART0_CLKDIV_FRAG
47-
#undef UART0_CLKDIV_REM
48-
#undef UART0_CLKDIV_INT
39+
gpsUART0->CLKDIV.raw = UART_HZ2CLKDIV(UART0_FREQ_HZ, APB_FREQ_HZ);
4940
}
5041

5142
static void _uart_cycle(uint64_t u64tckNow) {
@@ -106,7 +97,7 @@ static void _uart_cycle(uint64_t u64tckNow) {
10697
}
10798
}
10899

109-
// ====================== Interface functions =========================
100+
// -------------- Interface functions --------------
110101

111102
void prog_init_pro_pre() {
112103
_uart_init();

examples/0udma/uarttx.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 SZIGETI János
2+
* Copyright 2025 SZIGETI János
33
*
44
* This file is part of Bilis ESP32 Basic, which is released under GNU General Public License.version 3.
55
* See LICENSE or <https://www.gnu.org/licenses/> for full license details.
@@ -74,27 +74,16 @@ static volatile uint64_t gu64TckUdmaTxTotalEof;
7474
static char gacTestPattern[TEST_PATTERN_LENGTH];
7575
static UdmaDescriptor gsUdmaDesc;
7676

77-
// Implementation
78-
79-
// ==================== Local Functions ================
77+
// ============== Implementation ==============
78+
// -------------- Internal functions --------------
8079
static void _pattern_init() {
8180
for (int i = 0; i < TEST_PATTERN_LENGTH; ++i) {
8281
gacTestPattern[i] = '0' + (i % 10);
8382
}
8483
}
8584

8685
static void _uart_init() {
87-
#define UART_CLKDIV_INT HZ2APBTICKS(UART_FREQ_HZ)
88-
#define UART_CLKDIV_REM (APB_FREQ_HZ - (UART_CLKDIV_INT * UART_FREQ_HZ))
89-
#define UART_CLKDIV_FRAG ((16U * UART_CLKDIV_REM) / UART_FREQ_HZ)
90-
// version A)
91-
gpsUART->CLKDIV.u20ClkDiv = UART_CLKDIV_INT;
92-
gpsUART->CLKDIV.u4ClkDivFrag = UART_CLKDIV_FRAG;
93-
// version B)
94-
// gpsUART->CLKDIV.raw = UART_CLKDIV_INT | (UART_CLKDIV_FRAG << 20); // this line results in shorter binary file
95-
#undef UART_CLKDIV_FRAG
96-
#undef UART_CLKDIV_REM
97-
#undef UART_CLKDIV_INT
86+
gpsUART->CLKDIV.raw = UART_HZ2CLKDIV(UART_FREQ_HZ, APB_FREQ_HZ);
9887
uart_init_udma(geUart, geUdma);
9988
gpsUHCI->INT_ENA = (1 << UHCI_INT_OUTTOTALEOF) | (1 << UHCI_INT_OUTDONE);
10089

@@ -173,7 +162,7 @@ IRAM_ATTR static void _uhci_isr(void *pvParam) {
173162
}
174163
}
175164

176-
// ====================== Interface functions =========================
165+
// -------------- Interface functions --------------
177166

178167
void prog_init_pro_pre() {
179168
_uart_init();

examples/1rmtblink/rmtblink.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ static const uint16_t gu16usBlinkLenBase = 25000U;
5555
static const uint16_t gu8BlinkLenMul = (BLINKLEN_MS * 1000) / (2 * gu16usBlinkLenBase); // BLINKLEN=200 => 4.
5656
static const uint8_t gu8BlinkMax = 8;
5757

58-
// ==================== Implementation ================
58+
// ============== Implementation ==============
59+
// -------------- Internal functions --------------
5960

6061
static void _rmt_config_channel(ERmtChannel eChannel, bool bLevel, bool bHoldLevel) {
6162
// rmt channel config
@@ -104,7 +105,7 @@ static void _rmtblink_cycle(uint64_t u64Ticks) {
104105
}
105106
}
106107

107-
// ====================== Interface functions =========================
108+
// -------------- Interface functions --------------
108109

109110
void prog_init_pro_pre() {
110111
_rmtblink_init();

examples/1rmtdht/rmtdht.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// =================== Hard constants =================
2525
// #1: Timings
2626
#define RMTDHT_PERIOD_MS 2000U ///< Higher than 8 * 0.2s, so RMT blinks will not overlap.
27+
#define UART_FREQ_HZ 115200U
2728

2829
// #2: Channels / wires / addresses
2930
#define RMTDHT_GPIO 21U
@@ -33,6 +34,7 @@
3334
// ============= Local types ===============
3435

3536
// ================ Local function declarations =================
37+
void _done_rx(void *pvParam, SDht22Data *psParam);
3638
static void _rmtdht_init();
3739
static void _rmtdht_cycle(uint64_t u64Ticks);
3840

@@ -44,7 +46,8 @@ const uint64_t gu64tckSchedulePeriod = (CLK_FREQ_HZ / SCHEDULE_FREQ_HZ);
4446
// ==================== Local Data ================
4547
static SDht22Descriptor gsDht22Desc;
4648

47-
// ==================== Implementation ================
49+
// ============== Implementation ==============
50+
// -------------- Internal functions --------------
4851

4952
void _done_rx(void *pvParam, SDht22Data *psParam) {
5053
uart_printf(&gsUART0, "INVALID: %02X %02X %02X %02X %02X\n",
@@ -87,10 +90,10 @@ static void _rmtdht_cycle(uint64_t u64Ticks) {
8790
}
8891
}
8992

90-
// ====================== Interface functions =========================
93+
// -------------- Interface functions --------------
9194

9295
void prog_init_pro_pre() {
93-
gsUART0.CLKDIV.u20ClkDiv = APB_FREQ_HZ / 115200;
96+
gsUART0.CLKDIV.raw = UART_HZ2CLKDIV(UART_FREQ_HZ, APB_FREQ_HZ);
9497

9598
_rmtdht_init();
9699
}

examples/1rmtmorse/rmtmorse.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#define CARRIER_HI_TCK 40000U
4242
#define CARRIER_LO_TCK 40000U
4343

44+
#define UART_FREQ_HZ 115200U
45+
4446
// #2: Channels / wires / addresses
4547
#define RMTMORSE_GPIO 2U
4648
#define RMTMORSE_CH RMT_CH0
@@ -79,7 +81,8 @@ const uint16_t gau16msPhaseLen[] = {
7981
};
8082
const char acMessage[] = MESSAGE;
8183

82-
// ==================== Implementation ================
84+
// ============== Implementation ==============
85+
// -------------- Internal functions --------------
8386

8487
/**
8588
* Transforms a single morse phase into a single RMT (pre)entry using the timings
@@ -156,7 +159,7 @@ static void _rmtmorse_init() {
156159
_rmt_config_channel(RMTMORSE_CH, 0, 0);
157160

158161
// we do some logging, hence set UART0 speed
159-
gsUART0.CLKDIV.u20ClkDiv = APB_FREQ_HZ / 115200;
162+
gsUART0.CLKDIV.raw = UART_HZ2CLKDIV(UART_FREQ_HZ, APB_FREQ_HZ);
160163
}
161164

162165
static void _rmtmorse_cycle(uint64_t u64Ticks) {
@@ -208,7 +211,7 @@ static void _rmtmorse_cycle(uint64_t u64Ticks) {
208211
}
209212
}
210213

211-
// ====================== Interface functions =========================
214+
// -------------- Interface functions --------------
212215

213216
void prog_init_pro_pre() {
214217
_rmtmorse_init();

examples/1rmtmusic/rmtmusic.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#define UPDATE_PERIOD_MS 250U ///< Period of the control cycle (_rmtmusic_cycle())
3434

35+
#define UART_FREQ_HZ 115200U
36+
3537
// #2: Channels / wires / addresses
3638
#define RMTMUSIC_GPIO 2U
3739
#define RMTMUSIC_CH RMT_CH0
@@ -111,7 +113,8 @@ static uint32_t gau32RotationLen[ARRAY_SIZE(gasVarShift) + 1]; ///< This array w
111113

112114
static SMusicRmtStateDesc gsMusicState; ///< ISR parameter
113115

114-
// ==================== Implementation ================
116+
// ============== Implementation ==============
117+
// -------------- Internal functions --------------
115118

116119
/**
117120
* Transforms a single ON / OFF signal given as (u32Period, bLevel) pair
@@ -261,7 +264,7 @@ static void _rmtmusic_init() {
261264
_rmt_config_channel(RMTMUSIC_CH, 0, 0);
262265

263266
// we do some logging, hence set UART0 speed
264-
gsUART0.CLKDIV.u20ClkDiv = APB_FREQ_HZ / 115200;
267+
gsUART0.CLKDIV.raw = UART_HZ2CLKDIV(UART_FREQ_HZ, APB_FREQ_HZ);
265268

266269
// register ISR and enable it
267270
rmt_isr_init();
@@ -305,7 +308,7 @@ static void _rmtmusic_cycle(uint64_t u64Ticks) {
305308
}
306309
}
307310

308-
// ====================== Interface functions =========================
311+
// -------------- Interface functions --------------
309312

310313
void prog_init_pro_pre() {
311314

0 commit comments

Comments
 (0)