Lines Matching +full:bias +full:- +full:high +full:- +full:impedance

4  * SPDX-License-Identifier: Apache-2.0
45 /* User-defined CMD_PROP_RADIO_DIV_SETUP structures */
54 /* Radio register overrides for CC13x2R (note: CC26x2 does not support sub-GHz radio)
55 * from SmartRF Studio (200kbps, 50kHz deviation, 2-GFSK, 311.8kHz Rx BW),
73 /* Rx: Set RSSI offset to adjust reported RSSI by -1 dB (default: -2),
74 * trimmed for external bias and differential configuration
77 /* Rx: Set anti-aliasing filter bandwidth to 0x8 (in ADI0, set IFAMPCTL3[7:4]=0x8) */
86 /* CC1352P overrides from SmartRF Studio (200kbps, 50kHz deviation, 2-GFSK, 311.8kHz Rx BW) */
92 /* Rx: Set RSSI offset to adjust reported RSSI by -1 dB (default: -2),
93 * trimmed for external bias and differential configuration.
96 /* Rx: Set anti-aliasing filter bandwidth to 0x6 (in ADI0, set IFAMPCTL3[7:4]=0x8) */
112 /* The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings */
118 /* Set TXRX pin to 0 in RX and high impedance in idle/TX. */
125 /* The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings */
131 /* Set TXRX pin to 0 in RX/TX and high impedance in idle. */
150 .modType = 1, /* 2-GFSK - non-standard modulation */
151 .deviation = 200, /* +/- 200*250 = 50kHz deviation (modulation index 0.5) */
157 .rxBw = 0x59, /* 310.8 kHz RX bandwidth, see TRM, section 25.10.5.2, table 25-183 */
160 .nSwBits = 24, /* 24-bit (1 byte preamble + 16 bit SFD) */
187 { -20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) },
188 { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 3) },
189 { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 5) },
190 { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) },
213 { -20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) },
214 { -15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 3) },
215 { -10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 5) },
216 { -5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) },
257 /* See IEEE 802.15.4-2020, section 10.1.3.3. */ in drv_channel_frequency()
266 *frequency = 906 + 2 * (channel - 1); in drv_channel_frequency()
271 return channel <= 26 ? -ENOTSUP : -EINVAL; in drv_channel_frequency()
293 * https://github.com/zephyrproject-rtos/zephyr/issues/50336#issuecomment-1251122582. in drv_channel_frequency()
305 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in drv_power_down()
307 (void)RF_yield(drv_data->rf_handle); in drv_power_down()
316 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in cmd_prop_tx_adv_callback()
321 op->commandNo, op->status, drv_data->cmd_prop_tx_adv.status, e); in cmd_prop_tx_adv_callback()
337 if (drv_data->rx_entry[i].status == DATA_ENTRY_FINISHED) { in drv_rx_done()
338 len = drv_data->rx_data[i][0]; in drv_rx_done()
339 sdu = drv_data->rx_data[i] + 1; in drv_rx_done()
340 status = drv_data->rx_data[i][len--]; in drv_rx_done()
341 rssi = drv_data->rx_data[i][len--]; in drv_rx_done()
345 /* append CRC-16/CCITT */ in drv_rx_done()
357 drv_data->iface, len, AF_UNSPEC, 0, K_NO_WAIT); in drv_rx_done()
369 drv_data->rx_entry[i].status = DATA_ENTRY_PENDING; in drv_rx_done()
378 if (ieee802154_handle_ack(drv_data->iface, pkt) == NET_OK) { in drv_rx_done()
383 if (net_recv_data(drv_data->iface, pkt)) { in drv_rx_done()
388 } else if (drv_data->rx_entry[i].status == in drv_rx_done()
391 drv_data->rx_entry[i].status = DATA_ENTRY_PENDING; in drv_rx_done()
400 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in cmd_prop_rx_adv_callback()
404 op->commandNo, op->status, e); in cmd_prop_rx_adv_callback()
410 if (e & RF_EventRxEntryDone || op->status == PROP_ERROR_RXBUF) { in cmd_prop_rx_adv_callback()
414 if (op->status == PROP_ERROR_RXBUF in cmd_prop_rx_adv_callback()
415 || op->status == PROP_ERROR_RXFULL in cmd_prop_rx_adv_callback()
416 || op->status == PROP_ERROR_RXOVF) { in cmd_prop_rx_adv_callback()
417 LOG_DBG("RX Error %x", op->status); in cmd_prop_rx_adv_callback()
420 if (k_sem_take(&drv_data->lock, LOCK_TIMEOUT)) { in cmd_prop_rx_adv_callback()
425 k_sem_give(&drv_data->lock); in cmd_prop_rx_adv_callback()
453 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in ieee802154_cc13xx_cc26xx_subg_cca()
458 if (k_sem_take(&drv_data->lock, LOCK_TIMEOUT)) { in ieee802154_cc13xx_cc26xx_subg_cca()
459 return -EWOULDBLOCK; in ieee802154_cc13xx_cc26xx_subg_cca()
462 if (!drv_data->is_up) { in ieee802154_cc13xx_cc26xx_subg_cca()
463 ret = -ENETDOWN; in ieee802154_cc13xx_cc26xx_subg_cca()
467 drv_data->cmd_prop_cs.status = IDLE; in ieee802154_cc13xx_cc26xx_subg_cca()
469 was_rx_on = drv_data->cmd_prop_rx_adv.status == ACTIVE; in ieee802154_cc13xx_cc26xx_subg_cca()
473 ret = -EIO; in ieee802154_cc13xx_cc26xx_subg_cca()
478 events = RF_runCmd(drv_data->rf_handle, (RF_Op *)&drv_data->cmd_prop_cs, RF_PriorityNormal, in ieee802154_cc13xx_cc26xx_subg_cca()
482 ret = -EIO; in ieee802154_cc13xx_cc26xx_subg_cca()
486 switch (drv_data->cmd_prop_cs.status) { in ieee802154_cc13xx_cc26xx_subg_cca()
488 /* Do not re-enable RX when the channel is idle as in ieee802154_cc13xx_cc26xx_subg_cca()
496 ret = -EBUSY; in ieee802154_cc13xx_cc26xx_subg_cca()
499 ret = -EIO; in ieee802154_cc13xx_cc26xx_subg_cca()
503 /* Re-enable RX if we found it on initially in ieee802154_cc13xx_cc26xx_subg_cca()
513 k_sem_give(&drv_data->lock); in ieee802154_cc13xx_cc26xx_subg_cca()
520 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in drv_start_rx()
523 if (drv_data->cmd_prop_rx_adv.status == ACTIVE) { in drv_start_rx()
524 return -EALREADY; in drv_start_rx()
531 __ASSERT_NO_MSG(drv_data->rx_entry[i].pNextEntry != NULL); in drv_start_rx()
532 __ASSERT_NO_MSG(drv_data->rx_entry[i].status == DATA_ENTRY_PENDING); in drv_start_rx()
537 drv_data->cmd_prop_rx_adv.status = IDLE; in drv_start_rx()
538 cmd_handle = RF_postCmd(drv_data->rf_handle, in drv_start_rx()
539 (RF_Op *)&drv_data->cmd_prop_rx_adv, RF_PriorityNormal, in drv_start_rx()
543 return -EIO; in drv_start_rx()
546 drv_data->rx_cmd_handle = cmd_handle; in drv_start_rx()
554 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in drv_stop_rx()
557 if (drv_data->cmd_prop_rx_adv.status != ACTIVE) { in drv_stop_rx()
558 return -EALREADY; in drv_stop_rx()
562 status = RF_cancelCmd(drv_data->rf_handle, drv_data->rx_cmd_handle, RF_ABORT_GRACEFULLY); in drv_stop_rx()
568 return -EIO; in drv_stop_rx()
575 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in ieee802154_cc13xx_cc26xx_subg_set_channel()
586 if (k_sem_take(&drv_data->lock, LOCK_TIMEOUT)) { in ieee802154_cc13xx_cc26xx_subg_set_channel()
587 return -EWOULDBLOCK; in ieee802154_cc13xx_cc26xx_subg_set_channel()
590 was_rx_on = drv_data->cmd_prop_rx_adv.status == ACTIVE; in ieee802154_cc13xx_cc26xx_subg_set_channel()
594 ret = -EIO; in ieee802154_cc13xx_cc26xx_subg_set_channel()
600 drv_data->cmd_fs.status = IDLE; in ieee802154_cc13xx_cc26xx_subg_set_channel()
601 drv_data->cmd_fs.frequency = freq; in ieee802154_cc13xx_cc26xx_subg_set_channel()
602 drv_data->cmd_fs.fractFreq = fract; in ieee802154_cc13xx_cc26xx_subg_set_channel()
603 events = RF_runCmd(drv_data->rf_handle, (RF_Op *)&drv_data->cmd_fs, in ieee802154_cc13xx_cc26xx_subg_set_channel()
605 if (events != RF_EventLastCmdDone || drv_data->cmd_fs.status != DONE_OK) { in ieee802154_cc13xx_cc26xx_subg_set_channel()
607 ret = -EIO; in ieee802154_cc13xx_cc26xx_subg_set_channel()
612 /* Re-enable RX if we found it on initially. */ in ieee802154_cc13xx_cc26xx_subg_set_channel()
614 } else if (!drv_data->is_up) { in ieee802154_cc13xx_cc26xx_subg_set_channel()
618 k_sem_give(&drv_data->lock); in ieee802154_cc13xx_cc26xx_subg_set_channel()
632 return -ENOTSUP; in ieee802154_cc13xx_cc26xx_subg_filter()
638 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in ieee802154_cc13xx_cc26xx_subg_set_txpower()
647 return -EINVAL; in ieee802154_cc13xx_cc26xx_subg_set_txpower()
651 status = RF_setTxPower(drv_data->rf_handle, power_table_value); in ieee802154_cc13xx_cc26xx_subg_set_txpower()
654 return -EIO; in ieee802154_cc13xx_cc26xx_subg_set_txpower()
657 if (k_sem_take(&drv_data->lock, LOCK_TIMEOUT)) { in ieee802154_cc13xx_cc26xx_subg_set_txpower()
658 return -EWOULDBLOCK; in ieee802154_cc13xx_cc26xx_subg_set_txpower()
661 if (!drv_data->is_up) { in ieee802154_cc13xx_cc26xx_subg_set_txpower()
665 k_sem_give(&drv_data->lock); in ieee802154_cc13xx_cc26xx_subg_set_txpower()
676 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in ieee802154_cc13xx_cc26xx_subg_tx()
680 if (buf->len > (CC13XX_CC26XX_TX_BUF_SIZE - IEEE802154_PHY_SUN_FSK_PHR_LEN)) { in ieee802154_cc13xx_cc26xx_subg_tx()
681 return -EINVAL; in ieee802154_cc13xx_cc26xx_subg_tx()
686 NET_ERR("TX mode %d not supported - sending directly instead.", mode); in ieee802154_cc13xx_cc26xx_subg_tx()
689 if (k_sem_take(&drv_data->lock, K_FOREVER)) { in ieee802154_cc13xx_cc26xx_subg_tx()
690 return -EIO; in ieee802154_cc13xx_cc26xx_subg_tx()
693 if (!drv_data->is_up) { in ieee802154_cc13xx_cc26xx_subg_tx()
694 ret = -ENETDOWN; in ieee802154_cc13xx_cc26xx_subg_tx()
698 if (drv_data->cmd_prop_rx_adv.status == ACTIVE) { in ieee802154_cc13xx_cc26xx_subg_tx()
701 ret = -EIO; in ieee802154_cc13xx_cc26xx_subg_tx()
707 drv_data->tx_data[0] = buf->len + IEEE802154_FCS_LENGTH; in ieee802154_cc13xx_cc26xx_subg_tx()
711 * TODO: Zero-copy TX, see discussion in #49775. in ieee802154_cc13xx_cc26xx_subg_tx()
713 memcpy(&drv_data->tx_data[IEEE802154_PHY_SUN_FSK_PHR_LEN], buf->data, buf->len); in ieee802154_cc13xx_cc26xx_subg_tx()
714 drv_data->cmd_prop_tx_adv.pktLen = buf->len + IEEE802154_PHY_SUN_FSK_PHR_LEN; in ieee802154_cc13xx_cc26xx_subg_tx()
716 drv_data->cmd_prop_tx_adv.status = IDLE; in ieee802154_cc13xx_cc26xx_subg_tx()
717 events = RF_runCmd(drv_data->rf_handle, (RF_Op *)&drv_data->cmd_prop_tx_adv, in ieee802154_cc13xx_cc26xx_subg_tx()
721 ret = -EIO; in ieee802154_cc13xx_cc26xx_subg_tx()
725 if (drv_data->cmd_prop_tx_adv.status != PROP_DONE_OK) { in ieee802154_cc13xx_cc26xx_subg_tx()
726 LOG_DBG("Transmit failed (0x%x)", drv_data->cmd_prop_tx_adv.status); in ieee802154_cc13xx_cc26xx_subg_tx()
727 ret = -EIO; in ieee802154_cc13xx_cc26xx_subg_tx()
733 k_sem_give(&drv_data->lock); in ieee802154_cc13xx_cc26xx_subg_tx()
737 /* driver-allocated attribute memory - constant across all driver instances */
747 * ensure SUN-FSK timing, see the TODO in in ieee802154_cc13xx_cc26xx_subg_attr_get()
757 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in ieee802154_cc13xx_cc26xx_subg_start()
760 if (k_sem_take(&drv_data->lock, LOCK_TIMEOUT)) { in ieee802154_cc13xx_cc26xx_subg_start()
761 return -EIO; in ieee802154_cc13xx_cc26xx_subg_start()
764 if (drv_data->is_up) { in ieee802154_cc13xx_cc26xx_subg_start()
765 ret = -EALREADY; in ieee802154_cc13xx_cc26xx_subg_start()
774 drv_data->is_up = true; in ieee802154_cc13xx_cc26xx_subg_start()
777 k_sem_give(&drv_data->lock); in ieee802154_cc13xx_cc26xx_subg_start()
784 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in drv_abort_commands()
787 status = RF_flushCmd(drv_data->rf_handle, RF_CMDHANDLE_FLUSH_ALL, 0); in drv_abort_commands()
793 return -EIO; in drv_abort_commands()
800 * Stops the sub-GHz interface and yields the radio (tells RF module to power
805 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in ieee802154_cc13xx_cc26xx_subg_stop_if()
808 if (k_sem_take(&drv_data->lock, LOCK_TIMEOUT)) { in ieee802154_cc13xx_cc26xx_subg_stop_if()
809 return -EIO; in ieee802154_cc13xx_cc26xx_subg_stop_if()
812 if (!drv_data->is_up) { in ieee802154_cc13xx_cc26xx_subg_stop_if()
813 ret = -EALREADY; in ieee802154_cc13xx_cc26xx_subg_stop_if()
827 drv_data->is_up = false; in ieee802154_cc13xx_cc26xx_subg_stop_if()
830 k_sem_give(&drv_data->lock); in ieee802154_cc13xx_cc26xx_subg_stop_if()
839 return -ENOTSUP; in ieee802154_cc13xx_cc26xx_subg_configure()
849 if (i < CC13XX_CC26XX_NUM_RX_BUF - 1) { in drv_setup_rx_buffers()
850 drv_data->rx_entry[i].pNextEntry = in drv_setup_rx_buffers()
851 (uint8_t *) &drv_data->rx_entry[i + 1]; in drv_setup_rx_buffers()
853 drv_data->rx_entry[i].pNextEntry = in drv_setup_rx_buffers()
854 (uint8_t *) &drv_data->rx_entry[0]; in drv_setup_rx_buffers()
857 drv_data->rx_entry[i].config.type = DATA_ENTRY_TYPE_PTR; in drv_setup_rx_buffers()
858 drv_data->rx_entry[i].config.lenSz = 1; in drv_setup_rx_buffers()
859 drv_data->rx_entry[i].length = sizeof(drv_data->rx_data[0]); in drv_setup_rx_buffers()
860 drv_data->rx_entry[i].pData = drv_data->rx_data[i]; in drv_setup_rx_buffers()
863 drv_data->rx_queue.pCurrEntry = (uint8_t *)&drv_data->rx_entry[0]; in drv_setup_rx_buffers()
864 drv_data->rx_queue.pLastEntry = NULL; in drv_setup_rx_buffers()
874 drv_data->tx_data[1] = BIT(3) | /* FCS Type: 2-octet FCS */ in drv_setup_tx_buffer()
877 drv_data->cmd_prop_tx_adv.pPkt = drv_data->tx_data; in drv_setup_tx_buffer()
884 /* TODO: Do multi-protocol devices need more than one IEEE MAC? */ in drv_data_init()
892 sys_memcpy_swap(&drv_data->mac, mac, sizeof(drv_data->mac)); in drv_data_init()
897 /* Setup TX buffer (TRM 25.10.2.1.1, table 25-171) */ in drv_data_init()
900 k_sem_init(&drv_data->lock, 1, 1); in drv_data_init()
906 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in ieee802154_cc13xx_cc26xx_subg_iface_init()
908 net_if_set_link_addr(iface, drv_data->mac, sizeof(drv_data->mac), in ieee802154_cc13xx_cc26xx_subg_iface_init()
911 drv_data->iface = iface; in ieee802154_cc13xx_cc26xx_subg_iface_init()
934 struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; in ieee802154_cc13xx_cc26xx_subg_init()
939 /* No need for locking - initialization is exclusive. */ in ieee802154_cc13xx_cc26xx_subg_init()
949 drv_data->rf_handle = RF_open(&drv_data->rf_object, in ieee802154_cc13xx_cc26xx_subg_init()
952 if (drv_data->rf_handle == NULL) { in ieee802154_cc13xx_cc26xx_subg_init()
954 return -EIO; in ieee802154_cc13xx_cc26xx_subg_init()
961 drv_data->cmd_fs.status = IDLE; in ieee802154_cc13xx_cc26xx_subg_init()
962 drv_data->cmd_fs.frequency = freq; in ieee802154_cc13xx_cc26xx_subg_init()
963 drv_data->cmd_fs.fractFreq = fract; in ieee802154_cc13xx_cc26xx_subg_init()
964 events = RF_runCmd(drv_data->rf_handle, (RF_Op *)&drv_data->cmd_fs, in ieee802154_cc13xx_cc26xx_subg_init()
966 if (events != RF_EventLastCmdDone || drv_data->cmd_fs.status != DONE_OK) { in ieee802154_cc13xx_cc26xx_subg_init()
968 return -EIO; in ieee802154_cc13xx_cc26xx_subg_init()
996 /* Last preamble byte and SFD for uncoded 2-FSK SUN PHY, phySunFskSfd = 0,
997 * see IEEE 802.15.4, section 19.2.3.2, table 19-2.
1006 .lenOffset = -4,
1029 /* see IEEE 802.15.4, section 11.3, table 11-1 and section 10.2.8 */
1046 TRIG_REL_START, /* workaround for CC13_RF_ROM_FW_CPE--BUG00016 */
1048 /* Last preamble byte and SFD for uncoded 2-FSK SUN PHY, phySunFskSfd = 0,
1049 * see IEEE 802.15.4, section 19.2.3.2, table 19-2.