Lines Matching +full:2 +full:- +full:byte
3 * Copyright (c) 2015-2016 Intel Corporation
5 * SPDX-License-Identifier: Apache-2.0
74 #define H5_TX_ACK_PEND 2
81 #define H5_HDR_LEN(hdr) ((((hdr)[1] >> 4) & 0x0f) + ((hdr)[2] << 4))
88 ((hdr)[2] |= (len) >> 4))
123 /* Third byte may change */
129 #define SIGNAL_COUNT 2
151 static int h5_unslip_byte(uint8_t *byte) in h5_unslip_byte() argument
155 if (*byte != SLIP_ESC) { in h5_unslip_byte()
160 count = uart_fifo_read(h5_dev, byte, sizeof(*byte)); in h5_unslip_byte()
163 switch (*byte) { in h5_unslip_byte()
165 *byte = SLIP_DELIMITER; in h5_unslip_byte()
168 *byte = SLIP_ESC; in h5_unslip_byte()
171 LOG_ERR("Invalid escape byte %x\n", *byte); in h5_unslip_byte()
172 return -EIO; in h5_unslip_byte()
199 number_removed--; in process_unack()
200 /* Similar to (n - 1) % 8 with unsigned conversion */ in process_unack()
201 next_seq = (next_seq - 1) & 0x07; in process_unack()
223 unack_queue_len--; in process_unack()
224 number_removed--; in process_unack()
250 printk("%s zero-length signal packet\n", str); in hexdump()
254 while (length--) { in hexdump()
276 static uint8_t h5_slip_byte(uint8_t byte) in h5_slip_byte() argument
278 switch (byte) { in h5_slip_byte()
282 return 2; in h5_slip_byte()
286 return 2; in h5_slip_byte()
288 uart_poll_out(h5_dev, byte); in h5_slip_byte()
317 hdr[3] = ~((hdr[0] + hdr[1] + hdr[2]) & 0xff); in h5_send()
357 h5.tx_seq = (h5.tx_seq - 1) & 0x07; in retx_timeout()
358 unack_queue_len--; in retx_timeout()
412 hexdump("=> ", buf->data, buf->len); in h5_process_complete_packet()
421 uint8_t byte, type; in bt_uart_isr() local
438 /* Only the UART RX path is interrupt-enabled */ in bt_uart_isr()
442 ret = uart_fifo_read(h5_dev, &byte, sizeof(byte)); in bt_uart_isr()
449 if (byte == SLIP_DELIMITER) { in bt_uart_isr()
458 if (byte == SLIP_DELIMITER) { in bt_uart_isr()
463 if (h5_unslip_byte(&byte) < 0) { in bt_uart_isr()
468 memcpy(&hdr[sizeof(hdr) - remaining], &byte, 1); in bt_uart_isr()
469 remaining--; in bt_uart_isr()
513 if (byte == SLIP_DELIMITER) { in bt_uart_isr()
519 if (h5_unslip_byte(&byte) < 0) { in bt_uart_isr()
525 if (buf_tailroom < sizeof(byte)) { in bt_uart_isr()
526 LOG_ERR("Not enough space in buffer %zu/%zu", sizeof(byte), in bt_uart_isr()
532 net_buf_add_mem(h5.rx_buf, &byte, sizeof(byte)); in bt_uart_isr()
533 remaining--; in bt_uart_isr()
539 if (byte != SLIP_DELIMITER) { in bt_uart_isr()
568 LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); in h5_queue()
588 for (; count; ev++, count--) { in process_events()
589 LOG_DBG("ev->state %u", ev->state); in process_events()
591 switch (ev->state) { in process_events()
602 if (ev->tag == 0) { in process_events()
613 } else if (ev->tag == 2) { in process_events()
618 h5_send(buf->data, type, buf->len); in process_events()
632 LOG_WRN("Unexpected k_poll event state %u", ev->state); in process_events()
649 &h5.tx_queue, 2), in tx_thread()
659 int err, ev_count = 2; in tx_thread()
666 events[2].state = K_POLL_STATE_NOT_READY; in tx_thread()
693 hexdump("=> ", buf->data, buf->len); in rx_thread()
695 if (!memcmp(buf->data, sync_req, sizeof(sync_req))) { in rx_thread()
716 } else if (!memcmp(buf->data, conf_req, 2)) { in rx_thread()
717 if (buf->len > 2) { in rx_thread()
718 uint8_t tx_win = buf->data[2] & 0x07; in rx_thread()
724 conf_rsp[2] = h5.tx_win; in rx_thread()
736 LOG_ERR("Not handled yet %x %x", buf->data[0], buf->data[1]); in rx_thread()
753 LOG_ERR("HCI UART %s is not ready", h5_dev->name); in hci_uart_init()
754 return -EINVAL; in hci_uart_init()