Lines Matching +full:settling +full:- +full:time

1 /* ieee802154_cc1200.c - TI CC1200 driver */
8 * SPDX-License-Identifier: Apache-2.0
65 LOG_DBG("Settling"); in cc1200_print_status()
80 const struct cc1200_config *config = dev->config; in z_cc1200_access_reg()
118 return (spi_transceive_dt(&config->bus, &tx, &rx) == 0); in z_cc1200_access_reg()
124 return (spi_write_dt(&config->bus, &tx) == 0); in z_cc1200_access_reg()
129 struct cc1200_context *cc1200 = dev->data; in get_mac()
132 sys_rand_get(&cc1200->mac_addr[4], 4U); in get_mac()
134 cc1200->mac_addr[7] = (cc1200->mac_addr[7] & ~0x01) | 0x02; in get_mac()
136 cc1200->mac_addr[4] = CONFIG_IEEE802154_CC1200_MAC4; in get_mac()
137 cc1200->mac_addr[5] = CONFIG_IEEE802154_CC1200_MAC5; in get_mac()
138 cc1200->mac_addr[6] = CONFIG_IEEE802154_CC1200_MAC6; in get_mac()
139 cc1200->mac_addr[7] = CONFIG_IEEE802154_CC1200_MAC7; in get_mac()
142 cc1200->mac_addr[0] = 0x00; in get_mac()
143 cc1200->mac_addr[1] = 0x12; in get_mac()
144 cc1200->mac_addr[2] = 0x4b; in get_mac()
145 cc1200->mac_addr[3] = 0x00; in get_mac()
147 return cc1200->mac_addr; in get_mac()
174 if (atomic_get(&cc1200->tx) == 1) { in gpio0_int_handler()
175 if (atomic_get(&cc1200->tx_start) == 0) { in gpio0_int_handler()
176 atomic_set(&cc1200->tx_start, 1); in gpio0_int_handler()
178 atomic_set(&cc1200->tx, 0); in gpio0_int_handler()
181 k_sem_give(&cc1200->tx_sync); in gpio0_int_handler()
183 if (atomic_get(&cc1200->rx) == 1) { in gpio0_int_handler()
184 k_sem_give(&cc1200->rx_lock); in gpio0_int_handler()
185 atomic_set(&cc1200->rx, 0); in gpio0_int_handler()
187 atomic_set(&cc1200->rx, 1); in gpio0_int_handler()
194 const struct cc1200_config *cfg = dev->config; in enable_gpio0_interrupt()
197 gpio_pin_interrupt_configure_dt(&cfg->interrupt, mode); in enable_gpio0_interrupt()
202 const struct cc1200_config *cfg = dev->config; in setup_gpio_callback()
203 struct cc1200_context *cc1200 = dev->data; in setup_gpio_callback()
205 gpio_init_callback(&cc1200->rx_tx_cb, gpio0_int_handler, BIT(cfg->interrupt.pin)); in setup_gpio_callback()
207 if (gpio_add_callback(cfg->interrupt.port, &cc1200->rx_tx_cb) != 0) { in setup_gpio_callback()
208 return -EIO; in setup_gpio_callback()
237 /* See Section 9.12 - RF programming
258 * losing precision. A factor - growing as much as Xtal decrease - is then
264 * pre-computed part or else.
268 struct cc1200_context *ctx = dev->data; in rf_evaluate_freq_setting()
275 rf = ctx->rf_settings->chan_center_freq0 + in rf_evaluate_freq_setting()
276 ((chan * (uint32_t)ctx->rf_settings->channel_spacing) / 10U); in rf_evaluate_freq_setting()
309 rf -= hz; in rf_evaluate_freq_setting()
321 struct cc1200_context *cc1200 = dev->data; in rf_install_settings()
324 (void *)rf_settings->registers, in rf_install_settings()
327 (uint8_t *)rf_settings->registers in rf_install_settings()
335 cc1200->rf_settings = rf_settings; in rf_install_settings()
344 return -EIO; in rf_calibrate()
349 /* We need to re-enable RX as SCAL shuts off the freq synth */ in rf_calibrate()
354 return -EIO; in rf_calibrate()
416 if (!read_rxfifo(dev, buf->data, len) || in read_rxfifo_content()
453 struct cc1200_context *cc1200 = dev->data; in cc1200_rx()
460 k_sem_take(&cc1200->rx_lock, K_FOREVER); in cc1200_rx()
473 pkt = net_pkt_rx_alloc_with_buffer(cc1200->iface, pkt_len, in cc1200_rx()
480 if (!read_rxfifo_content(dev, pkt->buffer, pkt_len)) { in cc1200_rx()
490 if (ieee802154_handle_ack(cc1200->iface, pkt) == NET_OK) { in cc1200_rx()
497 if (net_recv_data(cc1200->iface, pkt) < 0) { in cc1200_rx()
502 log_stack_usage(&cc1200->rx_thread); in cc1200_rx()
528 struct cc1200_context *cc1200 = dev->data; in cc1200_cca()
530 if (atomic_get(&cc1200->rx) == 0) { in cc1200_cca()
541 return -EBUSY; in cc1200_cca()
546 struct cc1200_context *cc1200 = dev->data; in cc1200_set_channel()
550 * channel counts it doesn't make sense to validate (aka -EINVAL) a in cc1200_set_channel()
554 return -ENOTSUP; in cc1200_set_channel()
565 if (atomic_get(&cc1200->rx) != 0) { in cc1200_set_channel()
566 return -EIO; in cc1200_set_channel()
574 return -EIO; in cc1200_set_channel()
587 dbm = ((dbm + 18) * 2) - 1; in cc1200_set_txpower()
590 return -EINVAL; in cc1200_set_txpower()
598 return -EIO; in cc1200_set_txpower()
609 struct cc1200_context *cc1200 = dev->data; in cc1200_tx()
610 uint8_t *frame = frag->data; in cc1200_tx()
611 uint8_t len = frag->len; in cc1200_tx()
616 return -ENOTSUP; in cc1200_tx()
623 * depending on len value, this will also take more time. in cc1200_tx()
637 LOG_ERR("Cannot fill-in TX fifo"); in cc1200_tx()
641 atomic_set(&cc1200->tx, 1); in cc1200_tx()
642 atomic_set(&cc1200->tx_start, 0); in cc1200_tx()
650 k_sem_take(&cc1200->tx_sync, K_MSEC(100)); in cc1200_tx()
651 if (atomic_get(&cc1200->tx_start) == 1) { in cc1200_tx()
653 k_sem_take(&cc1200->tx_sync, K_MSEC(100)); in cc1200_tx()
659 if (atomic_get(&cc1200->tx) == 1 && in cc1200_tx()
663 atomic_set(&cc1200->tx_start, 0); in cc1200_tx()
670 atomic_set(&cc1200->tx, 0); in cc1200_tx()
675 return status ? 0 : -EIO; in cc1200_tx()
685 return -EIO; in cc1200_start()
701 return -EIO; in cc1200_stop()
707 /* driver-allocated attribute memory - constant across all driver instances as
730 return -EIO; in power_on_and_setup()
734 return -EIO; in power_on_and_setup()
741 return -EIO; in power_on_and_setup()
745 return -EIO; in power_on_and_setup()
753 const struct cc1200_config *config = dev->config; in cc1200_init()
754 struct cc1200_context *cc1200 = dev->data; in cc1200_init()
756 atomic_set(&cc1200->tx, 0); in cc1200_init()
757 atomic_set(&cc1200->tx_start, 0); in cc1200_init()
758 atomic_set(&cc1200->rx, 0); in cc1200_init()
759 k_sem_init(&cc1200->rx_lock, 0, 1); in cc1200_init()
760 k_sem_init(&cc1200->tx_sync, 0, 1); in cc1200_init()
763 if (!gpio_is_ready_dt(&config->interrupt)) { in cc1200_init()
765 config->interrupt.port->name); in cc1200_init()
766 return -ENODEV; in cc1200_init()
768 gpio_pin_configure_dt(&config->interrupt, GPIO_INPUT); in cc1200_init()
770 if (!spi_is_ready_dt(&config->bus)) { in cc1200_init()
771 LOG_ERR("SPI bus %s is not ready", config->bus.bus->name); in cc1200_init()
772 return -ENODEV; in cc1200_init()
778 return -EIO; in cc1200_init()
781 k_thread_create(&cc1200->rx_thread, cc1200->rx_stack, in cc1200_init()
785 k_thread_name_set(&cc1200->rx_thread, "cc1200_rx"); in cc1200_init()
795 struct cc1200_context *cc1200 = dev->data; in cc1200_iface_init()
802 cc1200->iface = iface; in cc1200_iface_init()