Fixes memory link on ACK packet and fixes for bootloader
This commit is contained in:
parent
fe70ee1c86
commit
954bfcf3dc
|
@ -1,5 +1,4 @@
|
|||
set(CONF_FILE c3.conf)
|
||||
set(BOARD nrf52_sparkfun)
|
||||
|
||||
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
|
||||
project(NONE)
|
||||
|
|
8
c3.conf
8
c3.conf
|
@ -6,10 +6,7 @@ CONFIG_UART_CONSOLE=n
|
|||
CONFIG_GPIO=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
CONFIG_UART_NRF5_BAUD_RATE=1000000
|
||||
CONFIG_UART_NRF5_FLOW_CONTROL=n
|
||||
CONFIG_CLOCK_CONTROL_NRF5_K32SRC_RC=y
|
||||
CONFIG_CLOCK_CONTROL_NRF5_K32SRC_250PPM=y
|
||||
CONFIG_UART_NRF5_BAUD_RATE=115200
|
||||
CONFIG_MAIN_STACK_SIZE=512
|
||||
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
|
||||
CONFIG_BT=y
|
||||
|
@ -18,3 +15,6 @@ CONFIG_BT_MAX_CONN=16
|
|||
CONFIG_BT_TINYCRYPT_ECC=n
|
||||
CONFIG_BT_CTLR_DTM_HCI=y
|
||||
CONFIG_BT_CTLR_ASSERT_HANDLER=y
|
||||
|
||||
# Bootloader stuff
|
||||
CONFIG_TEXT_SECTION_OFFSET=0x200
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
&uart0 {
|
||||
compatible = "nordic,nrf-uart";
|
||||
current-speed = <115200>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
};
|
||||
};
|
|
@ -3,3 +3,10 @@
|
|||
current-speed = <115200>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
};
|
||||
};
|
||||
|
|
66
src/main.c
66
src/main.c
|
@ -403,7 +403,6 @@ void bt_uart_isr(struct device *unused)
|
|||
bt_uart_drain(hci_uart_dev);
|
||||
break;
|
||||
}
|
||||
SYS_LOG_DBG("ALLOC %p", buf);
|
||||
}
|
||||
|
||||
if (!uart_fifo_read(hci_uart_dev, &byte, sizeof(byte))) {
|
||||
|
@ -463,7 +462,7 @@ static void unproc_thread(void) {
|
|||
rx_buf = net_buf_alloc(&acl_tx_pool, K_NO_WAIT);
|
||||
if (!rx_buf) {
|
||||
SYS_LOG_WRN("No available data buffers");
|
||||
return;
|
||||
goto next;
|
||||
}
|
||||
bt_buf_set_type(rx_buf, BT_BUF_ACL_OUT);
|
||||
break;
|
||||
|
@ -471,21 +470,26 @@ static void unproc_thread(void) {
|
|||
rx_buf = net_buf_alloc(&cmd_tx_pool, K_NO_WAIT);
|
||||
if (!rx_buf) {
|
||||
SYS_LOG_WRN("No available data buffers");
|
||||
return;
|
||||
goto next;
|
||||
}
|
||||
bt_buf_set_type(rx_buf, BT_BUF_CMD);
|
||||
break;
|
||||
case HCI_3WIRE_LINK_PKT:
|
||||
case HCI_3WIRE_ACK_PKT:
|
||||
SYS_LOG_DBG("ACK PACKET");
|
||||
h5.rx_ack = H5_HDR_ACK(hdr);
|
||||
goto next;
|
||||
break;
|
||||
case HCI_3WIRE_LINK_PKT:
|
||||
rx_buf = net_buf_alloc(&h5_pool, K_NO_WAIT);
|
||||
if (!rx_buf) {
|
||||
SYS_LOG_WRN("No available signal buffers");
|
||||
return;
|
||||
}
|
||||
SYS_LOG_DBG("ALLOC %p", rx_buf);
|
||||
break;
|
||||
default:
|
||||
SYS_LOG_ERR("Wrong packet type from host: %u", H5_HDR_PKT_TYPE(hdr));
|
||||
return;
|
||||
goto next;
|
||||
}
|
||||
|
||||
int byte;
|
||||
|
@ -539,7 +543,6 @@ static void unproc_thread(void) {
|
|||
break;
|
||||
}
|
||||
next:
|
||||
SYS_LOG_DBG("UNREF: %p", buf);
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
}
|
||||
|
@ -551,12 +554,12 @@ static void tx_thread(void)
|
|||
while (true) {
|
||||
struct net_buf *buf;
|
||||
|
||||
SYS_LOG_DBG("link_state %u", h5.link_state);
|
||||
|
||||
switch (h5.link_state) {
|
||||
case UNINIT:
|
||||
h5_send_sync();
|
||||
k_sleep(250);
|
||||
case INIT:
|
||||
/* FIXME: send conf */
|
||||
h5_send_config();
|
||||
k_sleep(250);
|
||||
break;
|
||||
case ACTIVE:
|
||||
|
@ -647,47 +650,6 @@ static int h5_open(struct device *unused)
|
|||
void bt_ctlr_assert_handle(char *file, u32_t line)
|
||||
{
|
||||
printk("Assert %s:%u", file, line);
|
||||
/*u32_t len = 0, pos = 0;
|
||||
|
||||
// Disable interrupts, this is unrecoverable
|
||||
(void)irq_lock();
|
||||
|
||||
uart_irq_rx_disable(hci_uart_dev);
|
||||
uart_irq_tx_disable(hci_uart_dev);
|
||||
|
||||
if (file) {
|
||||
while (file[len] != '\0') {
|
||||
if (file[len] == '/') {
|
||||
pos = len + 1;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
file += pos;
|
||||
len -= pos;
|
||||
}
|
||||
|
||||
uart_poll_out(hci_uart_dev, H4_EVT); */
|
||||
/* Vendor-Specific debug event */
|
||||
/*uart_poll_out(hci_uart_dev, 0xff);
|
||||
0xAA + strlen + \0 + 32-bit line number
|
||||
uart_poll_out(hci_uart_dev, 1 + len + 1 + 4);
|
||||
uart_poll_out(hci_uart_dev, 0xAA);
|
||||
|
||||
if (len) {
|
||||
while (*file != '\0') {
|
||||
uart_poll_out(hci_uart_dev, *file);
|
||||
file++;
|
||||
}
|
||||
uart_poll_out(hci_uart_dev, 0x00);
|
||||
}
|
||||
|
||||
uart_poll_out(hci_uart_dev, line >> 0 & 0xff);
|
||||
uart_poll_out(hci_uart_dev, line >> 8 & 0xff);
|
||||
uart_poll_out(hci_uart_dev, line >> 16 & 0xff);
|
||||
uart_poll_out(hci_uart_dev, line >> 24 & 0xff);*/
|
||||
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_CTLR_ASSERT_HANDLER */
|
||||
|
||||
|
@ -738,9 +700,9 @@ void main(void)
|
|||
// Adds controller output to host output queue
|
||||
bt_enable_raw(&h5.host_queue);
|
||||
|
||||
while (1) {
|
||||
struct net_buf *buf;
|
||||
struct net_buf *buf = NULL;
|
||||
|
||||
while (true) {
|
||||
buf = net_buf_get(&h5.host_queue, K_FOREVER);
|
||||
|
||||
if (packet_is_sync(buf)) {
|
||||
|
|
Loading…
Reference in New Issue