keil/include/components/uwb/inc/uwb_api.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.
@@ -49,15 +49,6 @@
 * @{
 */
/** Fira Certification */
#ifndef FIRA_TEST_EN
#define FIRA_TEST_EN (1)
#endif
#ifndef MCTT_TEST_EN
#define MCTT_TEST_EN (0)
#endif
#ifndef DYNAMIC_UPDATE_MAIN_ANTENNA_EN
#define DYNAMIC_UPDATE_MAIN_ANTENNA_EN (0)
#endif
@@ -89,7 +80,8 @@
#define SESSION_TYPE_RANGING_ONLY (0x03)
#define SESSION_TYPE_IN_BAND_DATA (0x04)
#define SESSION_TYPE_RANGING_WITH_DATA (0x05)
// 0xA0-0x9F Reserved for Vendor Specific use case
#define SESSION_TYPE_CCC_RANGING (0xA0)
// 0xA1-0x9F Reserved for Vendor Specific use case
// device test mode, 0xD1-0xDF RFU
#define SESSION_TYPE_DEVICE_TEST_MODE (0xD0)
// 0xE0-0xFE  Vendor Specific use
@@ -97,8 +89,6 @@
#define SESSION_TYPE_VENDOR_ALONE_RADAR (0xFE)
#define FREQ_OFFSET_SAMPLES_NUM 5
#define INITIATION_NUM (4)
// In Fira spec the number of controlees 1~8
#ifndef RESPONDER_NUM_MAX
@@ -145,6 +135,8 @@
#define UWB_MODE_VENDOR_RX 9
#define UWB_MODE_VENDOR_CARRIER_TX 10
#define UWB_MODE_TEST_SS_TWR 11
#define UWB_MODE_TEST_DS_TWR 12
#define UWB_MODE_PDOA_CAL 13
/** UWB status */
enum UWB_STATUS_T
@@ -211,6 +203,8 @@
{
    DEV_TYPE_CONTROLEE = 0,
    DEV_TYPE_CONTROLLER = 1,
    DEV_TYPE_DEVICE = 0xA0,
    DEV_TYPE_VEHICLE = 0xA1,
};
/** UWB device role */
@@ -278,7 +272,8 @@
    /* MKSEMI parameters */
    SFD5_NON_STD_LEN8 = 5,   // non-std 8
    SFD6_NON_STD_LEN16 = 6,  // non-std 16
    SFD7_STD_LONG_LEN64 = 7, // 15.4a long
    SFD7_NON_STD_LEN64 = 7,  // non-std 64
    SFD8_STD_LONG_LEN64 = 8, // 15.4a long
};
/** UWB PSDU data rate */
@@ -350,7 +345,7 @@
/** UWB MAC address mode */
enum MAC_ADDRESS_MODE_T
{
    ARRD_SHORT_USE_SHORT = 0, // MAC address is 2 bytes and 2 bytes to be used in MAC header
    ADDR_SHORT_USE_SHORT = 0, // MAC address is 2 bytes and 2 bytes to be used in MAC header
    ADDR_LONG_USE_SHORT = 1,  // MAC address is 8 bytes and 2 bytes to be used in MAC header (Not supported)
    ADDR_LONG_USE_LONG = 2,   // MAC address is 8 bytes and 8 bytes to be used in MAC header
};
@@ -375,6 +370,7 @@
{
    SP0 = 0,
    SP1 = 1,
    SP2 = 2,
    SP3 = 3,
};
@@ -388,6 +384,7 @@
    RANGING_FLOW_SIMPLE = 4,
    RANGING_FLOW_CONTENTION = 5,
    RANGING_FLOW_DATA_TRANSFER = 6,
    RANGING_FLOW_ALIRO = 7,
};
/** UWB ranging stage */
@@ -501,11 +498,7 @@
    uint16_t max_rr_retry; // 0x2A
    uint8_t res4[2];
#if FIRA_TEST_EN
    uint32_t uwb_initiation_time; // 0x2B
#else
    uint64_t uwb_initiation_time; // 0x2B
#endif
    uint32_t uwb_initiation_time;    // 0x2B
    uint8_t hopping_mode;            // 0x2C
    uint8_t stride_length;           // 0x2D
    uint8_t result_report_config;    // 0x2E
@@ -560,14 +553,22 @@
    /* Reserved for Vendor Specific use 0xA0-0xDF */
    /* Additional configuration applicable only for CCC */
    uint32_t hop_mode_key;      // 0xA0
    uint16_t ranging_proto_ver; // 0xA3
    uint16_t uwb_cfg_id;        // 0xA4
    uint8_t pulseshape_combo;   // 0xA5
    uint32_t hop_mode_key;                  // 0xA0
    uint8_t ccc_responder_slot_idx;         // 0xA2
    uint8_t pulseshape_combo;               // 0xA5
    uint16_t ranging_proto_ver;             // 0xA3
    uint16_t uwb_cfg_id;                    // 0xA4
    uint16_t ursk_ttl;                      // 0xA6
    uint32_t last_sts_index_used;           // 0xA8
    uint8_t responder_participation_config; // 0xA7
    /* Additional configuration applicable only for aliro */
    uint8_t ranging_round_num; // 0xA9
    uint8_t hopping_offset;    // 0xAA
    /* Reserved for Vendor Specific Use */
    uint8_t tx_power_level;    // 0xF2
    uint8_t rx_ant_id;         // 0xF3
    uint8_t rx_main_ant;       // 0xF3
    uint8_t per_payload_check; // 0xF4
    /* Coded in us with bit 15 == 0 */
    /* Coded in ms when bit 15 == 1 */
@@ -593,7 +594,7 @@
    uint8_t uwb_radar_pulse_period; // 0xF7   Octet[2]
    /* UWB radar rx filter gain level
     * 0 ~ 21 (default = 15) */
    uint8_t uwb_radar_rx_gain_level; // 0xF7   Octet[3]
    uint8_t uwb_radar_filter_gain_level; // 0xF7   Octet[3]
    /* UWB radar lna gain level 0 ~ 5
     * (defalut = 5) */
    uint8_t uwb_radar_lna_gain_level; // 0xF7   Octet[4]
@@ -601,7 +602,7 @@
    uint8_t uwb_radar_tx_power_level; // 0xF7   Octet[5]
    /* UWB radar tx pulse width
     * 0x00: 2ns (Bandwidth 500M)
     * 0x01: 0.92ns (Bandwidth 900M)
     * 0x03: 0.92ns (Bandwidth 900M)
     * 0x02: 0.75ns (Bandwidth 1.3G)
     * (defalut = 0x02) */
    uint8_t uwb_radar_bandwidth; // 0xF7   Octet[6]
@@ -741,8 +742,8 @@
    uint8_t *data;
};
/** UWB ranging measurement report */
struct RANGING_MEASUREMENT_T
/** UWB two-way ranging measurement report */
struct TWR_MEASUREMENT_T
{
    uint8_t mac_addr[8];
    uint8_t status;
@@ -759,8 +760,7 @@
    uint8_t aoa_dst_azimuth_fom;
    uint8_t aoa_dst_elevation_fom;
    uint8_t slot_idx;
    uint8_t rfu[12];
    uint8_t reserved;
    uint32_t rfu[3];
};
/** UWB ranging data report */
@@ -770,11 +770,41 @@
    uint32_t session_id;
    // unit: ms
    uint32_t ranging_interval;
    uint8_t rcr_ind;
    uint8_t ranging_type;
    uint8_t rfu;
    uint8_t mac_addr_mode;
    uint8_t measurements_num;
    struct RANGING_MEASUREMENT_T measurements[MEASUREMENT_NUM_MAX];
    struct TWR_MEASUREMENT_T measurements[MEASUREMENT_NUM_MAX];
};
/** CCC ranging measurement report */
struct CCC_MEASUREMENT_T
{
    uint8_t status;
    uint8_t slot_index;
    uint16_t rr_index;
    uint32_t sts_index;
    uint16_t distance;
    uint8_t anchor_fom;
    uint8_t initiator_fom;
    int16_t aoa_azimuth;
    int16_t aoa_elevation;
    uint8_t aoa_azimuth_fom;
    uint8_t aoa_elevation_fom;
};
/** UWB ranging data report */
struct CCC_RANGE_DATA_T
{
    uint32_t sequence_num;
    uint32_t session_id;
    // unit: ms
    uint32_t ranging_interval;
    uint8_t ranging_type;
    uint8_t rfu;
    uint8_t mac_addr_mode;
    uint8_t measurements_num;
    struct CCC_MEASUREMENT_T measurements[MEASUREMENT_NUM_MAX];
};
/** UWB test environment variable */
@@ -786,6 +816,13 @@
    uint8_t *tx_pkt_data;
    uint32_t trx_count_packet; /* This variable used to count how many packets were received or sent */
    uint32_t sync_time;        /* This variable is used to record the timestamp of the synchronization moment (unit:8ns) */
};
/** UWB data transfer report */
struct DATA_TRANSFER_T
{
    uint16_t length;
    uint8_t data[256];
};
/** UWB operations handler */
@@ -801,7 +838,9 @@
    uint8_t (*session_responder_num_get)(void);
    uint16_t (*session_responder_addr_get)(uint8_t idx);
    uint8_t (*session_dynamic_update_responder_list)(uint8_t action, uint16_t addr);
    void (*session_set_ccc_ursk)(const uint8_t *ursk);
    void (*session_initiator_addr_set)(uint16_t short_addr);
    void (*session_controller_addr_set)(uint16_t short_addr);
    bool (*session_set_ccc_ursk)(uint32_t session_id, const uint8_t *ursk);
    void (*vendor_session_start)(void);
    void (*vendor_session_stop)(void);
    void (*vendor_session_configure)(void);
@@ -810,7 +849,7 @@
/** UWB application configuration */
struct UWB_APP_CFG_T
{
    struct UWB_CONFIG_T ppdu_params;
    struct UWB_CONFIG_T *ppdu_params;
    struct APP_CFG_PARAM_T session_param;
    struct TEST_CFG_PARAM_T test_param;
@@ -843,6 +882,7 @@
extern "C" {
#endif
extern struct UWB_CONFIG_T uwb_ppdu_params;
extern struct UWB_APP_CFG_T uwb_app_config;
extern struct TEST_ENV_T test_env;
extern struct TEST_PER_RX_T uci_test_rx_per;
@@ -853,6 +893,7 @@
typedef void (*test_per_rx_report_cb_t)(struct TEST_PER_RX_T *report);
typedef void (*test_rx_report_cb_t)(struct TEST_RX_T *report);
typedef void (*test_ss_twr_report_cb_t)(uint8_t *, uint32_t);
typedef void (*test_ds_twr_report_cb_t)(uint8_t *, uint32_t);
typedef void (*vendor_rx_report_cb_t)(const uint16_t *data_len, const uint8_t *data);
typedef uint8_t (*vendor_user_defined_data_process_cb_t)(uint16_t cmd_len, const uint8_t *p_cmd);
@@ -1002,6 +1043,11 @@
uint8_t uwbapi_test_config_get(struct TEST_CFG_PARAM_T *param);
/**
 * @brief Configure STS for the test session.
 */
void uwbapi_test_sts_config(void);
/**
 * @brief Start periodic TX test.
 * @param[in] psdu_len          the length of packet to be sent periodically.
 * @param[in] psdu_data         the packet data to be sent periodically, including FCS.
@@ -1040,6 +1086,13 @@
 * @return UWB Status code @ref UWB_STATUS_T
 */
uint8_t uwbapi_test_ss_twr(test_ss_twr_report_cb_t func);
/**
 * @brief Start DS-TWR test, This API can be used to measure single DS-TWR ToF using SP0/SP3 packets.
 * @param[in] func          callback function to report result.
 * @return UWB Status code @ref UWB_STATUS_T
 */
uint8_t uwbapi_test_ds_twr(test_ds_twr_report_cb_t func);
/**
 * @brief Stop the test session.
@@ -1159,11 +1212,12 @@
/**
 * @brief Set URSK for CCC work mode
 * @param[in] session_id session id
 * @param[in] ursk URSK data.
 * @param[in] len URSK length.
 * @return UWB Status code @ref UWB_STATUS_T
 */
uint8_t uwbapi_vendor_set_ccc_ursk(const uint8_t *ursk, uint16_t len);
uint8_t uwbapi_vendor_set_ccc_ursk(uint32_t session_id, const uint8_t *ursk, uint16_t len);
/**
 * @}
@@ -1186,6 +1240,13 @@
 * @param[in] op            processing handler list.
 */
void uwbs_handler_init(struct UWB_OP_T *op);
/**
 * @brief Change the UWB parameter configuration.
 * @note This API should be called after session stop, and take effect after session start.
 * @param[in] ppdu_params       Point to the UWB configuration parameters.
 */
void uwbs_ppdu_params_change(struct UWB_CONFIG_T *ppdu_params);
/**
 * @brief Configure UWB transceiver work at TX or RX mode.
@@ -1268,6 +1329,36 @@
void uwbs_pan_id_set(uint16_t pan_id);
/**
 * @brief Get Imm-Ack cfg value
 * @return immack cfg value
 */
uint8_t uwbs_immack_cfg_get(void);
/**
 * @brief Set Imm-Ack cfg value
 * @param[in] immack_cfg        cfg value for immack. 1 to open it and 0 to close it
 */
void uwbs_immack_cfg_set(uint8_t immack_cfg);
/**
 * @brief Get current immack sn value
 * @return current immack sn value
 */
uint8_t uwbs_immack_sn_get(void);
/**
 * @brief Set the packet sn within the frame control field
 * @param[in] pkt_sn
 */
void uwbs_immack_sn_set(uint8_t pkt_sn);
/**
 * @brief Set the timeout value for immack wait time at tx side
 * @param[in] timeout_us   timeout with us unit
 */
void uwbs_immack_waitack_timeout_set(uint16_t timeout_us);
/**
 * @brief Enable or disable UWBS security.
 * @param[in] en        Enable or disable
 */
@@ -1280,6 +1371,12 @@
uint8_t uwbs_ccc_uwb_config_id_set(uint16_t uwb_cfg_id);
/**
 * @brief Set pulse shape combination for CCC.
 * @param[in] pulseshape_combo  pulse shape combination
 */
uint8_t uwbs_ccc_pulseshape_combo_set(uint8_t pulseshape_combo);
/**
 * @brief Clear RSSI statistical result in PER test procedure.
 */
void uwbs_clear_rssi(void);