Good morning
Doing the BLE fundamentals course and cant seem to build lesson 4 ex 3. Have picked up this thread BLE Fundamentals lesson 4 exercise 3 failure to build - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com) with no solution.
using the latest tool chain, nrf52840DK 2.02.
The errors in the function below im receiving are
C:/ncs/v2.6.0/zephyr/include/zephyr/toolchain/gcc.h:87:36: error: static assertion failed: "pointer type mismatch in CONTAINER_OF"
87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
in this line
static void uart_cb(const struct device *dev, struct uart_event *evt, void *user_data) { ARG_UNUSED(dev); static size_t aborted_len; struct uart_data_t *buf; static uint8_t *aborted_buf; static bool disable_req; switch (evt->type) { case UART_TX_DONE: LOG_DBG("UART_TX_DONE"); if ((evt->data.tx.len == 0) || (!evt->data.tx.buf)) { return; } if (aborted_buf) { buf = CONTAINER_OF(aborted_buf, struct uart_data_t, data); aborted_buf = NULL; aborted_len = 0; } else { buf = CONTAINER_OF(evt->data.tx.buf, struct uart_data_t, data); } k_free(buf); buf = k_fifo_get(&fifo_uart_tx_data, K_NO_WAIT); if (!buf) { return; } if (uart_tx(uart, buf->data, buf->len, SYS_FOREVER_MS)) { LOG_WRN("Failed to send data over UART"); } break; case UART_RX_RDY: LOG_DBG("UART_RX_RDY"); buf = CONTAINER_OF(evt->data.rx.buf, struct uart_data_t, data); buf->len += evt->data.rx.len; if (disable_req) { return; } if ((evt->data.rx.buf[buf->len - 1] == '\n') || (evt->data.rx.buf[buf->len - 1] == '\r')) { disable_req = true; uart_rx_disable(uart); } break; case UART_RX_DISABLED: LOG_DBG("UART_RX_DISABLED"); disable_req = false; buf = k_malloc(sizeof(*buf)); if (buf) { buf->len = 0; } else { LOG_WRN("Not able to allocate UART receive buffer"); k_work_reschedule(&uart_work, UART_WAIT_FOR_BUF_DELAY); return; } uart_rx_enable(uart, buf->data, sizeof(buf->data), UART_WAIT_FOR_RX); break; case UART_RX_BUF_REQUEST: LOG_DBG("UART_RX_BUF_REQUEST"); buf = k_malloc(sizeof(*buf)); if (buf) { buf->len = 0; uart_rx_buf_rsp(uart, buf->data, sizeof(buf->data)); } else { LOG_WRN("Not able to allocate UART receive buffer"); } break; case UART_RX_BUF_RELEASED: LOG_DBG("UART_RX_BUF_RELEASED"); buf = CONTAINER_OF(evt->data.rx_buf.buf, struct uart_data_t, data); if (buf->len > 0) { /* STEP 9.1 - Push the data received from the UART peripheral into the fifo_uart_rx_data FIFO */ k_fifo_put(&fifo_uart_rx_data, buf); } else { k_free(buf); } break; case UART_TX_ABORTED: LOG_DBG("UART_TX_ABORTED"); if (!aborted_buf) { aborted_buf = (uint8_t *)evt->data.tx.buf; } aborted_len += evt->data.tx.len; buf = CONTAINER_OF(aborted_buf, struct uart_data_t, data); uart_tx(uart, &buf->data[aborted_len], buf->len - aborted_len, SYS_FOREVER_MS); break; default: break; } }
I have tried to build the solution as well with the same outcome
Thanks in advance for any assistance.