Lines Matching +full:rx +full:- +full:buffer +full:- +full:config

4  * SPDX-License-Identifier: Apache-2.0
165 uint8_t buffer[A6REQ_PAYLOAD_LEN + REQ_HEADER_LEN + 1]; member
170 uint8_t buffer[RECV_RING_BUFFER_LENGTH]; member
174 } rx; member
203 static int fw_upload_read_data(uint8_t *buffer, uint32_t len) in fw_upload_read_data() argument
208 err = k_sem_take(&fw_upload.rx.sem, in fw_upload_read_data()
214 *buffer = fw_upload.rx.buffer[fw_upload.rx.tail]; in fw_upload_read_data()
215 buffer++; in fw_upload_read_data()
216 fw_upload.rx.tail++; in fw_upload_read_data()
217 fw_upload.rx.tail = fw_upload.rx.tail % sizeof(fw_upload.rx.buffer); in fw_upload_read_data()
218 len--; in fw_upload_read_data()
228 k_sem_reset(&fw_upload.rx.sem); in fw_upload_read_to_clear()
229 fw_upload.rx.head = 0; in fw_upload_read_to_clear()
230 fw_upload.rx.tail = 0; in fw_upload_read_to_clear()
264 return -EIO; in fw_upload_wait_for_hdr_sig()
267 static void fw_upload_write_data(const uint8_t *buffer, uint32_t len) in fw_upload_write_data() argument
270 uart_poll_out(uart_dev, buffer[i]); in fw_upload_write_data()
274 static int fw_upload_request_check_crc(uint8_t *buffer, uint8_t request) in fw_upload_request_check_crc() argument
279 crc = fw_upload_crc8(buffer, A6REQ_PAYLOAD_LEN + REQ_HEADER_LEN); in fw_upload_request_check_crc()
280 if (crc != buffer[A6REQ_PAYLOAD_LEN + REQ_HEADER_LEN]) { in fw_upload_request_check_crc()
282 return -EINVAL; in fw_upload_request_check_crc()
285 crc = fw_upload_crc8(buffer, AbREQ_PAYLOAD_LEN + REQ_HEADER_LEN); in fw_upload_request_check_crc()
286 if (crc != buffer[AbREQ_PAYLOAD_LEN + REQ_HEADER_LEN]) { in fw_upload_request_check_crc()
288 return -EINVAL; in fw_upload_request_check_crc()
301 fw_upload.buffer[0] = ack; in fw_upload_send_ack()
302 fw_upload.buffer[1] = fw_upload_crc8(fw_upload.buffer, 1); in fw_upload_send_ack()
303 fw_upload_write_data(fw_upload.buffer, 2); in fw_upload_send_ack()
304 LOG_DBG("ACK = %x, CRC = %x", ack, fw_upload.buffer[1]); in fw_upload_send_ack()
307 fw_upload.buffer[0] = ack; in fw_upload_send_ack()
308 sys_put_le32(fw_upload.offset, &fw_upload.buffer[1]); in fw_upload_send_ack()
309 fw_upload.buffer[5] = fw_upload_crc8(fw_upload.buffer, 5); in fw_upload_send_ack()
310 fw_upload_write_data(fw_upload.buffer, 6); in fw_upload_send_ack()
311 LOG_DBG("ACK = %x, CRC = %x", ack, fw_upload.buffer[5]); in fw_upload_send_ack()
321 uint8_t buffer[10]; in fw_upload_wait_req() local
323 buffer[0] = fw_upload.hdr_sig; in fw_upload_wait_req()
331 return -EINVAL; in fw_upload_wait_req()
334 err = fw_upload_read_data(&buffer[1], len); in fw_upload_wait_req()
340 err = fw_upload_request_check_crc(buffer, fw_upload.hdr_sig); in fw_upload_wait_req()
348 fw_upload.length = sys_get_le16(&buffer[1]); in fw_upload_wait_req()
349 fw_upload.offset = sys_get_le32(&buffer[3]); in fw_upload_wait_req()
350 fw_upload.error = sys_get_le16(&buffer[7]); in fw_upload_wait_req()
351 fw_upload.crc8 = buffer[9]; in fw_upload_wait_req()
358 chip_id = sys_get_le16(&buffer[1]); in fw_upload_wait_req()
359 LOG_DBG("Indicate: %hhd, %hd, %hhd, %hhd", fw_upload.hdr_sig, chip_id, buffer[3], in fw_upload_wait_req()
360 buffer[4]); in fw_upload_wait_req()
363 return -EINVAL; in fw_upload_wait_req()
414 retry--; in fw_upload_change_timeout()
419 return -ENOTSUP; in fw_upload_change_timeout()
424 return -ENOTSUP; in fw_upload_change_timeout()
428 return -EINVAL; in fw_upload_change_timeout()
443 static int fw_upload_change_speed_config(struct change_speed_config *config, uint32_t speed) in fw_upload_change_speed_config() argument
445 config->clk_div_addr = 0x7f00008fU; in fw_upload_change_speed_config()
446 config->uart_clk_div_addr = 0x7f000090U; in fw_upload_change_speed_config()
447 config->mcr_addr = 0x7f000091U; in fw_upload_change_speed_config()
448 config->reinit_addr = 0x7f000092U; in fw_upload_change_speed_config()
449 config->icr_addr = 0x7f000093U; in fw_upload_change_speed_config()
450 config->fcr_addr = 0x7f000094U; in fw_upload_change_speed_config()
452 config->mcr_val = 0x00000022U; in fw_upload_change_speed_config()
453 config->reinit_val = 0x00000001U; in fw_upload_change_speed_config()
454 config->icr_val = 0x000000c7U; in fw_upload_change_speed_config()
455 config->fcr_val = 0x000000c7U; in fw_upload_change_speed_config()
459 config->clk_div_val = clk_div_map[i].uartClkDivisor; in fw_upload_change_speed_config()
460 config->uart_clk_div_val = clk_div_map[i].uartDivisio; in fw_upload_change_speed_config()
464 return -ENOTSUP; in fw_upload_change_speed_config()
469 uint8_t buffer[4]; in fw_upload_wait_length() local
475 err = fw_upload_read_data(buffer, sizeof(buffer)); in fw_upload_wait_length()
480 len = sys_get_le16(buffer); in fw_upload_wait_length()
481 len_comp = sys_get_le16(buffer); in fw_upload_wait_length()
521 static void fw_upload_get_hdr_start(uint8_t *buffer) in fw_upload_get_hdr_start() argument
531 buffer[count++] = fw_upload.hdr_sig; in fw_upload_get_hdr_start()
540 err = fw_upload_read_data(&buffer[count], 4); in fw_upload_get_hdr_start()
546 static int fw_upload_len_valid(uint8_t *buffer, uint16_t *length) in fw_upload_len_valid() argument
551 len = sys_get_le16(&buffer[1]); in fw_upload_len_valid()
552 len_comp = sys_get_le16(&buffer[3]); in fw_upload_len_valid()
558 return -EINVAL; in fw_upload_len_valid()
562 static int fw_upload_get_last_5bytes(uint8_t *buffer) in fw_upload_get_last_5bytes() argument
579 payload_len = fw_upload_get_payload_length(buffer); in fw_upload_get_last_5bytes()
590 return -EINVAL; in fw_upload_get_last_5bytes()
608 static int fw_upload_write_hdr_and_payload(uint16_t len_to_send, uint8_t *buffer, bool new_speed) in fw_upload_write_hdr_and_payload() argument
618 payload_len = fw_upload_get_payload_length(buffer); in fw_upload_write_hdr_and_payload()
626 fw_upload_write_data(buffer, sending_len); in fw_upload_write_hdr_and_payload()
636 fw_upload_write_data(&buffer[CMD_HDR_LEN], sending_len); in fw_upload_write_hdr_and_payload()
652 fw_upload_write_data(buffer, len_to_send - 1); in fw_upload_write_hdr_and_payload()
657 fw_upload_write_data(&buffer[CMD_HDR_LEN], len_to_send - 1); in fw_upload_write_hdr_and_payload()
662 LOG_DBG("Resending send buffer..."); in fw_upload_write_hdr_and_payload()
663 fw_upload_write_data(buffer, len_to_send); in fw_upload_write_hdr_and_payload()
668 fw_upload_write_data(&buffer[CMD_HDR_LEN], len_to_send); in fw_upload_write_hdr_and_payload()
674 err = fw_upload_get_last_5bytes(buffer); in fw_upload_write_hdr_and_payload()
690 struct uart_config config; in fw_upload_uart_reconfig() local
693 config.baudrate = speed; in fw_upload_uart_reconfig()
694 config.data_bits = UART_CFG_DATA_BITS_8; in fw_upload_uart_reconfig()
695 config.flow_ctrl = flow_control ? UART_CFG_FLOW_CTRL_RTS_CTS : UART_CFG_FLOW_CTRL_NONE; in fw_upload_uart_reconfig()
696 config.parity = UART_CFG_PARITY_NONE; in fw_upload_uart_reconfig()
697 config.stop_bits = UART_CFG_STOP_BITS_1; in fw_upload_uart_reconfig()
702 err = uart_configure(uart_dev, &config); in fw_upload_uart_reconfig()
750 return -ETIME; in fw_upload_change_speed()
772 return -EINVAL; in fw_upload_change_speed()
825 LOG_DBG("Send UA RT config"); in fw_upload_change_speed()
858 if ((fw_upload.fw_length - fw_upload.current_length) < len) { in fw_upload_v1_send_data()
859 len = fw_upload.fw_length - fw_upload.current_length; in fw_upload_v1_send_data()
870 if ((data_len > (sizeof(fw_upload.send_buffer) - len)) || in fw_upload_v1_send_data()
874 return -EINVAL; in fw_upload_v1_send_data()
902 start = fw_upload.offset - fw_upload.cmd7_change_timeout_len - in fw_upload_v3_send_data()
906 return -EINVAL; in fw_upload_v3_send_data()
910 fw_upload.length = fw_upload.fw_length - start; in fw_upload_v3_send_data()
960 return -ETIME; in fw_uploading()
1022 return -ENOTSUP; in fw_uploading()
1025 return -EINVAL; in fw_uploading()
1037 err = uart_poll_in(uart_dev, &fw_upload.rx.buffer[fw_upload.rx.head]); in bt_nxp_ctlr_uart_isr()
1039 fw_upload.rx.head++; in bt_nxp_ctlr_uart_isr()
1040 fw_upload.rx.head = fw_upload.rx.head % sizeof(fw_upload.rx.buffer); in bt_nxp_ctlr_uart_isr()
1046 k_sem_give(&fw_upload.rx.sem); in bt_nxp_ctlr_uart_isr()
1047 count--; in bt_nxp_ctlr_uart_isr()
1058 return -ENODEV; in bt_nxp_ctlr_init()
1077 LOG_ERR("Error: failed to configure sdio_reset %s pin %d", sdio_reset.port->name, in bt_nxp_ctlr_init()
1079 return -EIO; in bt_nxp_ctlr_init()
1086 sdio_reset.port->name, sdio_reset.pin); in bt_nxp_ctlr_init()
1098 LOG_ERR("Error: failed to configure w_disable %s pin %d", w_disable.port->name, in bt_nxp_ctlr_init()
1100 return -EIO; in bt_nxp_ctlr_init()
1107 w_disable.port->name, w_disable.pin); in bt_nxp_ctlr_init()
1137 fw_upload.rx.head = 0; in bt_nxp_ctlr_init()
1138 fw_upload.rx.tail = 0; in bt_nxp_ctlr_init()
1140 k_sem_init(&fw_upload.rx.sem, 0, sizeof(fw_upload.rx.buffer)); in bt_nxp_ctlr_init()
1149 LOG_ERR("Fail to config uart"); in bt_nxp_ctlr_init()
1175 return -EINVAL; in bt_hci_transport_setup()
1192 LOG_ERR("Fail to allocate buffer"); in bt_hci_baudrate_update()
1193 return -ENOBUFS; in bt_hci_baudrate_update()
1196 /* Add new baudrate to the buffer */ in bt_hci_baudrate_update()
1216 return -EINVAL; in bt_h4_vnd_setup()
1220 return -ENODEV; in bt_h4_vnd_setup()