Skip to content

Commit 9447ee9

Browse files
authored
[FL-2630] Wireless UART (#45)
* HTTP: websocket mockup * PSRAM: 2M, store some global objects there * Web interface: UART console and refactoring * Simple-UART: get config * Network: websocket for web uart * Web interface: UART history, receive indicator * Build: artifacts * Web interface: UART config * Simple UART: proxy config * Web interface: cleanup API and fix README * software uart logs: more precise timings * software uart logs: enlarge buffer * uart: network socket * app: network uart * Web interface: UART send * Web interface: update dependencies * UART Rx: 1Mb stream buffer * HTTP Server: cleanup websocket fns * Web interface: smart nbsp in terminal * Web interface: add keypress to non-interactive elements with on:click * bundle * Web interface: fix first nbsp on line * Web interface: firmware version * Attempts to fix build: 1 * Attempts to fix build: 2 * Attempts to fix build: 3 * Web interface: mobile friendly uart terminal * Web interface: mobile friendly input
1 parent 41acbe3 commit 9447ee9

Some content is hidden

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

41 files changed

+2099
-521
lines changed

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Black Magic Probe for ESP32-S2
1+
# Black Magic Probe / DapLink for ESP32-S2
22

3-
WiFi/USB capable version of the famous Black Magic Probe debugger.
3+
WiFi/USB capable version of the famous BlackMagicProbe (or DapLink) debugger.
44

55
# Clone the Repository
66

@@ -32,22 +32,26 @@ Run:
3232
idf.py -p <port> flash
3333
```
3434

35-
## Test with ESP-IDF
36-
37-
Connect to the dev board with:
38-
```shell
39-
idf.py -p <port> monitor
40-
```
41-
42-
You should not see errors in the logs if the firmware is installed and running correctly.
43-
4435
## Web interface development
4536

4637
Web interface is located in `components/svelte-portal` and written in Svelte. To build it, you need to install Node.js and run `npm install` in `components/svelte-portal` directory. Then you can run `npm run dev` to start development server or `npm run build` to build production version.
4738

48-
Typical workflow is to fix the board's IP address in `components/svelte-portal/src/App.svelte` and then run `npm run dev`. After that, you can open `http://localhost:5000` in your browser and see changes in the web interface in real time with live reload.
39+
Typical workflow is to fix the board's IP address in `components/svelte-portal/src/lib/Api.svelte` and then run `npm run dev`. After that, you can open `http://localhost:5000` in your browser and see changes in the web interface in real time with live reload.
40+
41+
If you want to change local ip or port, you need to run `export HOST={ip} PORT={port}` before `npm run dev`.
42+
43+
```shell
44+
export HOST=127.0.0.1 PORT=3000
45+
npm run dev
46+
```
4947

5048
When you're done, you need to run `npm run build`, `idf.py build` and then `idf.py -p <port> flash`. You can then open `http://blackmagic.local` in your browser and see the changes in the web interface.
49+
```shell
50+
npm run build
51+
idf.py build
52+
idf.py -p <port> flash
53+
```
54+
5155

5256
## Schematic
5357

components/simple-uart/simple-uart.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ typedef struct {
1717
uart_isr rx_isr;
1818
} uart_context_t;
1919

20+
typedef struct {
21+
uint32_t baud_rate;
22+
uart_stop_bits_t stop_bits;
23+
uart_parity_t parity;
24+
uart_word_length_t data_bits;
25+
} UartInnerConfig;
26+
2027
#define UART_CONTEX_INIT_DEF(uart_num) \
2128
{ \
2229
.hal.dev = UART_LL_GET_HW(uart_num), .uart_index = uart_num, .isr_context = NULL, \
@@ -31,6 +38,11 @@ static uart_context_t uart_context[UART_NUM_MAX] = {
3138
#endif
3239
};
3340

41+
static UartInnerConfig uart_config[UART_NUM_MAX] = {
42+
{0},
43+
{0},
44+
};
45+
3446
#define UART_HAL(uart_num) &(uart_context[uart_num].hal)
3547

3648
/***********************************************/
@@ -173,17 +185,37 @@ static void simple_uart_isr(void* arg) {
173185
}
174186

175187
void simple_uart_set_baud_rate(uint8_t uart_num, uint32_t baud_rate) {
188+
uart_config[uart_num].baud_rate = baud_rate;
176189
uart_hal_set_baudrate(UART_HAL(uart_num), baud_rate);
177190
}
178191

179192
void simple_uart_set_stop_bits(uint8_t uart_num, uart_stop_bits_t stop_bits) {
193+
uart_config[uart_num].stop_bits = stop_bits;
180194
uart_hal_set_stop_bits(UART_HAL(uart_num), stop_bits);
181195
}
182196

183197
void simple_uart_set_parity(uint8_t uart_num, uart_parity_t parity) {
198+
uart_config[uart_num].parity = parity;
184199
uart_hal_set_parity(UART_HAL(uart_num), parity);
185200
}
186201

187202
void simple_uart_set_data_bits(uint8_t uart_num, uart_word_length_t data_bits) {
203+
uart_config[uart_num].data_bits = data_bits;
188204
uart_hal_set_data_bit_num(UART_HAL(uart_num), data_bits);
205+
}
206+
207+
uint32_t simple_uart_get_baud_rate(uint8_t uart_num) {
208+
return uart_config[uart_num].baud_rate;
209+
}
210+
211+
uart_stop_bits_t simple_uart_get_stop_bits(uint8_t uart_num) {
212+
return uart_config[uart_num].stop_bits;
213+
}
214+
215+
uart_parity_t simple_uart_get_parity(uint8_t uart_num) {
216+
return uart_config[uart_num].parity;
217+
}
218+
219+
uart_word_length_t simple_uart_get_data_bits(uint8_t uart_num) {
220+
return uart_config[uart_num].data_bits;
189221
}

components/simple-uart/simple-uart.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,36 @@ void simple_uart_set_parity(uint8_t uart_num, uart_parity_t parity);
8787
* @param uart_num
8888
* @param data_bits
8989
*/
90-
void simple_uart_set_data_bits(uint8_t uart_num, uart_word_length_t data_bits);
90+
void simple_uart_set_data_bits(uint8_t uart_num, uart_word_length_t data_bits);
91+
92+
/**
93+
* @brief Get the UART baud rate
94+
*
95+
* @param uart_num
96+
* @return uint32_t
97+
*/
98+
uint32_t simple_uart_get_baud_rate(uint8_t uart_num);
99+
100+
/**
101+
* @brief Get the UART stop bits
102+
*
103+
* @param uart_num
104+
* @return uart_stop_bits_t
105+
*/
106+
uart_stop_bits_t simple_uart_get_stop_bits(uint8_t uart_num);
107+
108+
/**
109+
* @brief Get the UART parity
110+
*
111+
* @param uart_num
112+
* @return uart_parity_t
113+
*/
114+
uart_parity_t simple_uart_get_parity(uint8_t uart_num);
115+
116+
/**
117+
* @brief Get the UART data bits
118+
*
119+
* @param uart_num
120+
* @return uart_word_length_t
121+
*/
122+
uart_word_length_t simple_uart_get_data_bits(uint8_t uart_num);

components/soft-uart/soft-uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct SoftUart {
1414
#define wait_cycles(cycles) \
1515
for(uint32_t start = cycle_count_get(); cycle_count_get() - start < cycles;)
1616

17-
static uint32_t cycle_count_get() {
17+
static inline uint32_t __attribute__((always_inline)) cycle_count_get() {
1818
uint32_t ccount;
1919
__asm__ __volatile__("esync; rsr %0,ccount" : "=a"(ccount));
2020
return ccount;

0 commit comments

Comments
 (0)