Lines Matching +full:2 +full:- +full:byte
1 /* uart_h5.c - UART based Bluetooth driver */
4 * Copyright (c) 2015-2016 Intel Corporation
6 * SPDX-License-Identifier: Apache-2.0
73 #define H5_TX_ACK_PEND 2
80 #define H5_HDR_LEN(hdr) ((((hdr)[1] >> 4) & 0x0f) + ((hdr)[2] << 4))
87 ((hdr)[2] |= (len) >> 4))
120 /* Third byte may change */
126 #define SIGNAL_COUNT 2
142 static int h5_unslip_byte(uint8_t *byte) in h5_unslip_byte() argument
146 if (*byte != SLIP_ESC) { in h5_unslip_byte()
151 count = uart_fifo_read(h5_dev, byte, sizeof(*byte)); in h5_unslip_byte()
154 switch (*byte) { in h5_unslip_byte()
156 *byte = SLIP_DELIMITER; in h5_unslip_byte()
159 *byte = SLIP_ESC; in h5_unslip_byte()
162 LOG_ERR("Invalid escape byte %x\n", *byte); in h5_unslip_byte()
163 return -EIO; in h5_unslip_byte()
189 number_removed--; in process_unack()
190 /* Similar to (n - 1) % 8 with unsigned conversion */ in process_unack()
191 next_seq = (next_seq - 1) & 0x07; in process_unack()
213 unack_queue_len--; in process_unack()
214 number_removed--; in process_unack()
235 printk("%s zero-length signal packet\n", str); in hexdump()
239 while (length--) { in hexdump()
264 static uint8_t h5_slip_byte(uint8_t byte) in h5_slip_byte() argument
266 switch (byte) { in h5_slip_byte()
270 return 2; in h5_slip_byte()
274 return 2; in h5_slip_byte()
276 uart_poll_out(h5_dev, byte); in h5_slip_byte()
305 hdr[3] = ~((hdr[0] + hdr[1] + hdr[2]) & 0xff); in h5_send()
345 h5.tx_seq = (h5.tx_seq - 1) & 0x07; in retx_timeout()
346 unack_queue_len--; in retx_timeout()
398 hexdump("=> ", buf->data, buf->len); in h5_process_complete_packet()
412 uint8_t byte; in bt_uart_isr() local
429 /* Only the UART RX path is interrupt-enabled */ in bt_uart_isr()
433 ret = uart_fifo_read(h5_dev, &byte, sizeof(byte)); in bt_uart_isr()
440 if (byte == SLIP_DELIMITER) { in bt_uart_isr()
449 if (byte == SLIP_DELIMITER) { in bt_uart_isr()
454 if (h5_unslip_byte(&byte) < 0) { in bt_uart_isr()
459 memcpy(&hdr[sizeof(hdr) - remaining], &byte, 1); in bt_uart_isr()
460 remaining--; in bt_uart_isr()
518 if (h5_unslip_byte(&byte) < 0) { in bt_uart_isr()
527 h5.rx_buf = get_evt_buf(byte); in bt_uart_isr()
536 if (buf_tailroom < sizeof(byte)) { in bt_uart_isr()
537 LOG_ERR("Not enough space in buffer %zu/%zu", sizeof(byte), in bt_uart_isr()
543 net_buf_add_mem(h5.rx_buf, &byte, sizeof(byte)); in bt_uart_isr()
544 remaining--; in bt_uart_isr()
550 if (byte != SLIP_DELIMITER) { in bt_uart_isr()
586 LOG_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); in h5_queue()
600 return -1; in h5_queue()
636 h5_send(buf->data, type, buf->len); in tx_thread()
653 conf[2] = h5.tx_win & 0x07; in h5_set_txwin()
665 hexdump("=> ", buf->data, buf->len); in rx_thread()
667 if (!memcmp(buf->data, sync_req, sizeof(sync_req))) { in rx_thread()
673 } else if (!memcmp(buf->data, sync_rsp, sizeof(sync_rsp))) { in rx_thread()
681 } else if (!memcmp(buf->data, conf_req, 2)) { in rx_thread()
691 } else if (!memcmp(buf->data, conf_rsp, 2)) { in rx_thread()
693 if (buf->len > 2) { in rx_thread()
695 h5.tx_win = (buf->data[2] & 0x07); in rx_thread()
700 LOG_ERR("Not handled yet %x %x", buf->data[0], buf->data[1]); in rx_thread()
774 return -ENODEV; in bt_uart_init()