Lines Matching +full:data +full:- +full:bits

2  * SPDX-License-Identifier: Apache-2.0
22 uint8_t *data; member
58 struct sy1xx_uart_config *config = (struct sy1xx_uart_config *)dev->config; in sy1xx_uart_configure()
60 if (uart_cfg->baudrate == 0) { in sy1xx_uart_configure()
61 return -1; in sy1xx_uart_configure()
66 * and then will restart from 0, so we must give div - 1 as in sy1xx_uart_configure()
69 uint32_t divider = sy1xx_soc_get_peripheral_clock() / uart_cfg->baudrate - 1; in sy1xx_uart_configure()
75 * [3]: stop bits 0 = 1 stop bit in sy1xx_uart_configure()
76 * 1 = 2 stop bits in sy1xx_uart_configure()
77 * [2:1]: bits 00 = 5 bits in sy1xx_uart_configure()
78 * 01 = 6 bits in sy1xx_uart_configure()
79 * 10 = 7 bits in sy1xx_uart_configure()
80 * 11 = 8 bits in sy1xx_uart_configure()
84 /* default: both tx and rx enabled; 8N1 configuration; 1 stop bits */ in sy1xx_uart_configure()
85 volatile uint32_t setup = 0x0306 | uart_cfg->parity; in sy1xx_uart_configure()
88 SY1XX_UDMA_WRITE_REG(config->base, SY1XX_UDMA_SETUP_REG, setup); in sy1xx_uart_configure()
95 .data = (uint8_t *)dummy_data, in sy1xx_uart_configure()
104 * - < 0: Error
105 * - 0: OK
106 * - > 0: Busy
110 struct sy1xx_uart_config *config = (struct sy1xx_uart_config *)dev->config; in sy1xx_uart_read()
111 struct sy1xx_uart_data *data = (struct sy1xx_uart_data *)dev->data; in sy1xx_uart_read() local
114 return -1; in sy1xx_uart_read()
117 uint32_t max_read_size = request->data_len; in sy1xx_uart_read()
119 request->data_len = 0; in sy1xx_uart_read()
122 return -3; in sy1xx_uart_read()
128 int32_t remaining_bytes = SY1XX_UDMA_READ_REG(config->base, SY1XX_UDMA_RX_SIZE_REG); in sy1xx_uart_read()
129 int32_t bytes_transferred = (DEVICE_MAX_BUFFER_SIZE - remaining_bytes); in sy1xx_uart_read()
132 /* copy data to the user buffer */ in sy1xx_uart_read()
136 request->data[i] = data->read[i]; in sy1xx_uart_read()
140 request->data_len = bytes_transferred; in sy1xx_uart_read()
143 SY1XX_UDMA_CANCEL_RX(config->base); in sy1xx_uart_read()
146 SY1XX_UDMA_START_RX(config->base, (int32_t)data->read, DEVICE_MAX_BUFFER_SIZE, 0); in sy1xx_uart_read()
148 /* return: some data received */ in sy1xx_uart_read()
161 * - < 0: Error
162 * - 0: OK
163 * - > 0: Busy
167 struct sy1xx_uart_config *config = (struct sy1xx_uart_config *)dev->config; in sy1xx_uart_write()
168 struct sy1xx_uart_data *data = (struct sy1xx_uart_data *)dev->data; in sy1xx_uart_write() local
171 return -1; in sy1xx_uart_write()
174 if (request->data_len == 0) { in sy1xx_uart_write()
175 return -1; in sy1xx_uart_write()
178 if (request->data_len > DEVICE_MAX_BUFFER_SIZE) { in sy1xx_uart_write()
179 /* more data than possible requested */ in sy1xx_uart_write()
180 return -2; in sy1xx_uart_write()
183 if (0 == SY1XX_UDMA_IS_FINISHED_TX(config->base)) { in sy1xx_uart_write()
188 uint32_t remaining_bytes = SY1XX_UDMA_GET_REMAINING_TX(config->base); in sy1xx_uart_write()
191 SY1XX_UDMA_CANCEL_TX(config->base); in sy1xx_uart_write()
192 return -3; in sy1xx_uart_write()
195 /* copy the data to transmission buffer */ in sy1xx_uart_write()
196 for (uint32_t i = 0; i < request->data_len; i++) { in sy1xx_uart_write()
197 data->write[i] = request->data[i]; in sy1xx_uart_write()
201 SY1XX_UDMA_START_TX(config->base, (uint32_t)data->write, request->data_len, 0); in sy1xx_uart_write()
214 .data = c, in sy1xx_uart_poll_in()
221 return -1; in sy1xx_uart_poll_in()
231 .data = &c, in sy1xx_uart_poll_out()
250 struct sy1xx_uart_config *config = (struct sy1xx_uart_config *)dev->config; in sy1xx_uart_init()
251 struct sy1xx_uart_data *data = (struct sy1xx_uart_data *)dev->data; in sy1xx_uart_init() local
254 data->write[i] = 0xa5; in sy1xx_uart_init()
255 data->read[i] = 0xb4; in sy1xx_uart_init()
259 sy1xx_udma_enable_clock(SY1XX_UDMA_MODULE_UART, config->inst); in sy1xx_uart_init()
283 SY1XX_PAD_CONFIG_ADDR_UART + (config->inst * 4 + 0)); in sy1xx_uart_init()
291 SY1XX_UDMA_CANCEL_RX(config->base); in sy1xx_uart_init()
292 SY1XX_UDMA_CANCEL_TX(config->base); in sy1xx_uart_init()