Skip to content

Commit

Permalink
Merge branch 'dev' into pr/40
Browse files Browse the repository at this point in the history
  • Loading branch information
DrZlo13 committed Jun 5, 2024
2 parents ceabc92 + 9447ee9 commit ff7f7b8
Show file tree
Hide file tree
Showing 43 changed files with 2,127 additions and 530 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1

- name: 'Checkout submodules'
run:
git submodule update --init --recursive --depth 1 --jobs "$(getconf _NPROCESSORS_ONLN)";
Expand All @@ -51,7 +51,7 @@ jobs:
- name: 'Setup node'
uses: actions/setup-node@v3
with:
node-version: '17'
node-version: '18'
cache: 'npm'
cache-dependency-path: components/svelte-portal

Expand Down
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Black Magic Probe for ESP32-S2
# Black Magic Probe / DapLink for ESP32-S2

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

# Clone the Repository

Expand Down Expand Up @@ -32,22 +32,26 @@ Run:
idf.py -p <port> flash
```

## Test with ESP-IDF

Connect to the dev board with:
```shell
idf.py -p <port> monitor
```

You should not see errors in the logs if the firmware is installed and running correctly.

## Web interface development

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.

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.
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.

If you want to change local ip or port, you need to run `export HOST={ip} PORT={port}` before `npm run dev`.

```shell
export HOST=127.0.0.1 PORT=3000
npm run dev
```

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.
```shell
npm run build
idf.py build
idf.py -p <port> flash
```


## Schematic

Expand Down
32 changes: 32 additions & 0 deletions components/simple-uart/simple-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ typedef struct {
uart_isr rx_isr;
} uart_context_t;

typedef struct {
uint32_t baud_rate;
uart_stop_bits_t stop_bits;
uart_parity_t parity;
uart_word_length_t data_bits;
} UartInnerConfig;

#define UART_CONTEX_INIT_DEF(uart_num) \
{ \
.hal.dev = UART_LL_GET_HW(uart_num), .uart_index = uart_num, .isr_context = NULL, \
Expand All @@ -33,6 +40,11 @@ static uart_context_t uart_context[UART_NUM_MAX] = {
#endif
};

static UartInnerConfig uart_config[UART_NUM_MAX] = {
{0},
{0},
};

#define UART_HAL(uart_num) &(uart_context[uart_num].hal)

/***********************************************/
Expand Down Expand Up @@ -177,20 +189,40 @@ static void simple_uart_isr(void* arg) {
void simple_uart_set_baud_rate(uint8_t uart_num, uint32_t baud_rate) {
uart_sclk_t src_clk;
uint32_t sclk_freq;
uart_config[uart_num].baud_rate = baud_rate;

uart_hal_get_sclk(&(uart_context[uart_num].hal), &src_clk);
uart_get_sclk_freq(src_clk, &sclk_freq);
uart_hal_set_baudrate(UART_HAL(uart_num), baud_rate, sclk_freq);
}

void simple_uart_set_stop_bits(uint8_t uart_num, uart_stop_bits_t stop_bits) {
uart_config[uart_num].stop_bits = stop_bits;
uart_hal_set_stop_bits(UART_HAL(uart_num), stop_bits);
}

void simple_uart_set_parity(uint8_t uart_num, uart_parity_t parity) {
uart_config[uart_num].parity = parity;
uart_hal_set_parity(UART_HAL(uart_num), parity);
}

void simple_uart_set_data_bits(uint8_t uart_num, uart_word_length_t data_bits) {
uart_config[uart_num].data_bits = data_bits;
uart_hal_set_data_bit_num(UART_HAL(uart_num), data_bits);
}

uint32_t simple_uart_get_baud_rate(uint8_t uart_num) {
return uart_config[uart_num].baud_rate;
}

uart_stop_bits_t simple_uart_get_stop_bits(uint8_t uart_num) {
return uart_config[uart_num].stop_bits;
}

uart_parity_t simple_uart_get_parity(uint8_t uart_num) {
return uart_config[uart_num].parity;
}

uart_word_length_t simple_uart_get_data_bits(uint8_t uart_num) {
return uart_config[uart_num].data_bits;
}
34 changes: 33 additions & 1 deletion components/simple-uart/simple-uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,36 @@ void simple_uart_set_parity(uint8_t uart_num, uart_parity_t parity);
* @param uart_num
* @param data_bits
*/
void simple_uart_set_data_bits(uint8_t uart_num, uart_word_length_t data_bits);
void simple_uart_set_data_bits(uint8_t uart_num, uart_word_length_t data_bits);

/**
* @brief Get the UART baud rate
*
* @param uart_num
* @return uint32_t
*/
uint32_t simple_uart_get_baud_rate(uint8_t uart_num);

/**
* @brief Get the UART stop bits
*
* @param uart_num
* @return uart_stop_bits_t
*/
uart_stop_bits_t simple_uart_get_stop_bits(uint8_t uart_num);

/**
* @brief Get the UART parity
*
* @param uart_num
* @return uart_parity_t
*/
uart_parity_t simple_uart_get_parity(uint8_t uart_num);

/**
* @brief Get the UART data bits
*
* @param uart_num
* @return uart_word_length_t
*/
uart_word_length_t simple_uart_get_data_bits(uint8_t uart_num);
2 changes: 1 addition & 1 deletion components/soft-uart/soft-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct SoftUart {
#define wait_cycles(cycles) \
for(uint32_t start = cycle_count_get(); cycle_count_get() - start < cycles;)

static uint32_t cycle_count_get() {
static inline uint32_t __attribute__((always_inline)) cycle_count_get() {
uint32_t ccount;
__asm__ __volatile__("esync; rsr %0,ccount" : "=a"(ccount));
return ccount;
Expand Down
Loading

0 comments on commit ff7f7b8

Please sign in to comment.