keil/include/drivers/mk_uwb.h
@@ -1,5 +1,5 @@
/*
 * Copyright (c) 2019-2023 Beijing Hanwei Innovation Technology Ltd. Co. and
 * Copyright (c) 2019-2025 Beijing Hanwei Innovation Technology Ltd. Co. and
 * its subsidiaries and affiliates (collectly called MKSEMI).
 *
 * All rights reserved.
@@ -48,6 +48,14 @@
 * @addtogroup MK8000_UWB
 * @{
 */
#ifndef RANGING_EN
#if defined(FIRA_RANGING_EN) || defined(CCC_RANGING_EN) || defined(CUSTOM_RANGING_EN) || defined(UL_TDOA_EN)
#define RANGING_EN (1)
#else
#define RANGING_EN (0)
#endif
#endif
/* Receiver antenna mode: Port Num in use (2 bits) | Ant Num in use (2 bits) | Index (2 bits) | Main Rx Ant (2 bits) */
// 4-Antennas, for high band (CH5/CH9)
@@ -161,6 +169,25 @@
    ANT_LAYOUT_VERTICAL,
};
/**
 * @brief Enumeration for UWB transmission modes.
 */
enum UWB_TX_MODE_T
{
    TX_MODE_IMMEDIATE = 0, /*!< Immediate transmission mode */
    TX_MODE_DEFER = 1,     /*!< Deferred transmission mode */
    TX_MODE_CSMACA = 2,    /*!< CSMA-CA transmission mode */
};
/**
 * @brief Enumeration for UWB reception modes.
 */
enum UWB_RX_MODE_T
{
    RX_MODE_IMMEDIATE = 0, /*!< Immediate reception mode */
    RX_MODE_DEFER = 1,     /*!< Deferred reception mode */
};
#ifdef __cplusplus
extern "C" {
#endif
@@ -188,6 +215,20 @@
void uwb_channel_switch(uint8_t ch_num);
/**
 * @brief Set UWB pulse shape.
 * @param[in] pulse_shape           Pulse shape (0x0 - Symmetrical pulse, 0x1/0x2 -  Precursor-Free)
 * @note This API is used for CCC pulse shape setting
 */
void uwb_pulse_shape_set(uint8_t pulse_shape);
/**
 * @brief Set UWB pulse width.
 * @param[in] width                 Pulse width (0x0 - 2ns(500M), 0x3 - 0.92ns(900M), 0x2 - 0.75ns(1.3G))
 * @note This API is used for UWB pulse width setting, it will change the setting of pulse shaping
 */
void uwb_pulse_width_set(uint8_t width);
/**
 * @brief Set UWB TX power.
 * @param[in] tx_power_level        TX power level
 */
@@ -212,9 +253,8 @@
 * @param[in] mode              Work mode, PHY_TX or PHY_RX or both.
 * @param[in] tx_power_level    TX power level
 * @param[in] ppdu_params       PHY protocol data unit parameters @ref UWB_CONFIG_T
 * @return default PHY parameter set address
 */
void *uwb_configure(uint8_t mode, uint8_t tx_power_level, const struct UWB_CONFIG_T *ppdu_params);
void uwb_configure(uint8_t mode, uint8_t tx_power_level, struct UWB_CONFIG_T *ppdu_params);
/**
 * @brief Switch the PHY parameter sets.
@@ -227,7 +267,7 @@
 * @brief UWB transmit a packet.
 * @param[in] pkt_data          Pointer to packet data to be sent
 * @param[in] pkt_len           Packet length
 * @param[in] scheduled_mode    Scheduled sending mode
 * @param[in] scheduled_mode    Transmission scheduling mode @ref UWB_TX_MODE_T
 * @param[in] tgt_time          Target time to send packet, if target time equals 0 means send immediately.
 * @return programmed TX event number, the maximum TX event number depends on configuration from mac_init()
 */
@@ -235,18 +275,28 @@
/**
 * @brief Receive a UWB packet.
 * @param[in] scheduled_mode    Scheduled receiving mode
 * @param[in] scheduled_mode    Reception scheduling mode @ref UWB_RX_MODE_T
 * @param[in] tgt_time          Target time to receive packet
 * @param[in] timeout_us        Maximum receive window, input value <= 3,441,480 us
 * @param[in] timeout           Maximum receive window, unit: PHY timer count 1/124.8M
 * @return programmed RX event number, the maximum RX event number depends on configuration from mac_init()
 */
int uwb_rx(uint8_t scheduled_mode, uint32_t target_time, uint32_t timeout_us);
int uwb_rx(uint8_t scheduled_mode, uint32_t target_time, uint32_t timeout);
/**
 * @brief UWB loopback.
 * @param[in] pkt_data          Pointer to packet data to be sent
 * @param[in] pkt_len           Packet length
 * @param[in] scheduled_mode    Transmission scheduling mode @ref UWB_TX_MODE_T
 * @param[in] tgt_time          Target time to send packet, if target time equals 0 means send immediately.
 * @return programmed TX event number, the maximum TX event number depends on configuration from mac_init()
 */
int uwb_loopback(uint8_t *pkt_data, uint16_t pkt_len, uint8_t scheduled_mode, uint32_t target_time);
/**
 * @brief Force switch off UWB Rx.
 * @param[in] int_rpt_dis       Discard current RX interrupt report
 */
void uwb_rx_force_off(uint8_t int_rpt_dis);
void uwb_rx_force_off(bool int_rpt_dis);
/**
 * @brief Configure UWB transceiver work at TX carrier only mode.
@@ -276,6 +326,23 @@
 */
void uwb_blocking_trx_stop(void);
/**
 * @brief Update UWB loopback time, the result is the avarage value of the count times
 * @note This API will change UWB configuration, please call uwb_configure() to restore the configuration.
 * @param[in] count             Loopback count, one loopback test time is around 2ms
 * @param[in] ppdu_params       PHY protocol data unit parameters @ref UWB_CONFIG_T
 */
void uwb_loopback_time_update(uint16_t count, struct UWB_CONFIG_T *ppdu_params);
/**
 * @brief Find a suitable Vdd core voltage value and measure the UWB TX and RX loopback time for antenna delay calibration
 * @note This API should be called after power_init(), suggests to do loopback calibration before antenna delay calibration.
 * @param[in] wr_nvm_en         Enable calibration result written into NVM
 * @param[in] count             Loopback count, one loopback test time is around 2ms
 * @param[in] ppdu_params       PHY protocol data unit parameters @ref UWB_CONFIG_T
 */
void uwb_loopback_calibration(uint8_t wr_nvm_en, uint16_t count, struct UWB_CONFIG_T *ppdu_params);
#ifdef __cplusplus
}
#endif