|
1 | 1 | /* |
2 | | - * Copyright 2024 SZIGETI János |
| 2 | + * Copyright 2025 SZIGETI János |
3 | 3 | * |
4 | 4 | * This file is part of Bilis ESP32 Basic, which is released under GNU General Public License.version 3. |
5 | 5 | * See LICENSE or <https://www.gnu.org/licenses/> for full license details. |
@@ -74,27 +74,16 @@ static volatile uint64_t gu64TckUdmaTxTotalEof; |
74 | 74 | static char gacTestPattern[TEST_PATTERN_LENGTH]; |
75 | 75 | static UdmaDescriptor gsUdmaDesc; |
76 | 76 |
|
77 | | -// Implementation |
78 | | - |
79 | | -// ==================== Local Functions ================ |
| 77 | +// ============== Implementation ============== |
| 78 | +// -------------- Internal functions -------------- |
80 | 79 | static void _pattern_init() { |
81 | 80 | for (int i = 0; i < TEST_PATTERN_LENGTH; ++i) { |
82 | 81 | gacTestPattern[i] = '0' + (i % 10); |
83 | 82 | } |
84 | 83 | } |
85 | 84 |
|
86 | 85 | 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); |
98 | 87 | uart_init_udma(geUart, geUdma); |
99 | 88 | gpsUHCI->INT_ENA = (1 << UHCI_INT_OUTTOTALEOF) | (1 << UHCI_INT_OUTDONE); |
100 | 89 |
|
@@ -173,7 +162,7 @@ IRAM_ATTR static void _uhci_isr(void *pvParam) { |
173 | 162 | } |
174 | 163 | } |
175 | 164 |
|
176 | | -// ====================== Interface functions ========================= |
| 165 | +// -------------- Interface functions -------------- |
177 | 166 |
|
178 | 167 | void prog_init_pro_pre() { |
179 | 168 | _uart_init(); |
|
0 commit comments