Lines Matching +full:write +full:- +full:cmd

4  * SPDX-License-Identifier: Apache-2.0
46 return gpio_pin_get_dt(&spi->cfg->dr) > 0; in eswifi_spi_cmddata_ready()
56 } while (!eswifi_spi_cmddata_ready(spi) && --max_retries); in eswifi_spi_wait_cmddata_ready()
58 return max_retries ? 0 : -ETIMEDOUT; in eswifi_spi_wait_cmddata_ready()
63 struct eswifi_spi_data *spi = eswifi->bus_data; in eswifi_spi_write()
73 status = spi_write_dt(&spi->cfg->bus, &spi_tx); in eswifi_spi_write()
75 LOG_ERR("SPI write error %d", status); in eswifi_spi_write()
85 struct eswifi_spi_data *spi = eswifi->bus_data; in eswifi_spi_read()
95 status = spi_read_dt(&spi->cfg->bus, &spi_rx); in eswifi_spi_read()
105 static int eswifi_spi_request(struct eswifi_dev *eswifi, char *cmd, size_t clen, in eswifi_spi_request() argument
108 struct eswifi_spi_data *spi = eswifi->bus_data; in eswifi_spi_request()
113 LOG_DBG("cmd=%p (%u byte), rsp=%p (%u byte)", cmd, clen, rsp, rlen); in eswifi_spi_request()
116 * CMD/DATA protocol: in eswifi_spi_request()
117 * 1. Module raises data-ready when ready for **command phase** in eswifi_spi_request()
118 * 2. Host announces command start by lowering chip-select in eswifi_spi_request()
119 * 3. Host write the command (possibly several spi transfers) in eswifi_spi_request()
120 * 4. Host announces end of command by raising chip-select in eswifi_spi_request()
121 * 5. Module lowers data-ready signal in eswifi_spi_request()
122 * 6. Module raises data-ready to signal start of the **data phase** in eswifi_spi_request()
123 * 7. Host lowers chip-select in eswifi_spi_request()
124 * 8. Host fetch data as long as data-ready pin is up in eswifi_spi_request()
125 * 9. Module lowers data-ready to signal the end of the data Phase in eswifi_spi_request()
126 * 10. Host raises chip-select in eswifi_spi_request()
129 * All commands to the eS-WiFi module must be post-padded with in eswifi_spi_request()
131 * All data from eS-WiFi module are post-padded with 0x15(NAK) to an in eswifi_spi_request()
135 if (!cmd) { in eswifi_spi_request()
139 /* CMD/DATA READY signals the Command Phase */ in eswifi_spi_request()
142 LOG_ERR("CMD ready timeout\n"); in eswifi_spi_request()
146 if (clen % 2) { /* Add post-padding if necessary */ in eswifi_spi_request()
147 /* cmd is a string so cmd[clen] is 0x00 */ in eswifi_spi_request()
148 cmd[clen] = 0x0a; in eswifi_spi_request()
152 eswifi_spi_write(eswifi, cmd, clen); in eswifi_spi_request()
155 spi_release_dt(&spi->cfg->bus); in eswifi_spi_request()
158 /* CMD/DATA READY signals the Data Phase */ in eswifi_spi_request()
166 to_read = MIN(rlen - offset, to_read); in eswifi_spi_request()
180 spi_release_dt(&spi->cfg->bus); in eswifi_spi_request()
191 char cmd[] = "MR\r"; in eswifi_spi_read_msg() local
200 ret = eswifi_at_cmd_rsp(eswifi, cmd, &rsp); in eswifi_spi_read_msg()
207 if (strncmp(rsp, startstr, sizeof(endstr) - 1)) { in eswifi_spi_read_msg()
214 msg_len = ret - (sizeof(startstr) - 1) - (sizeof(endstr) - 1); in eswifi_spi_read_msg()
216 eswifi_async_msg(eswifi, rsp + sizeof(endstr) - 1, msg_len); in eswifi_spi_read_msg()
241 if (!gpio_is_ready_dt(&cfg->dr)) { in eswifi_spi_init()
242 LOG_ERR("device %s is not ready", cfg->dr.port->name); in eswifi_spi_init()
243 return -ENODEV; in eswifi_spi_init()
245 gpio_pin_configure_dt(&cfg->dr, GPIO_INPUT); in eswifi_spi_init()
248 if (!spi_is_ready_dt(&cfg->bus)) { in eswifi_spi_init()
250 return -ENODEV; in eswifi_spi_init()
253 spi->cfg = cfg; in eswifi_spi_init()
255 eswifi->bus_data = spi; in eswifi_spi_init()
259 k_thread_create(&spi->poll_thread, eswifi_spi_poll_stack, in eswifi_spi_init()