Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions mcux/middleware/wifi_nxp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ else()
set(MCUX_SDK_DIR ${ZEPHYR_HAL_NXP_MODULE_DIR}/mcux/mcux-sdk-ng)
endif()

if(CONFIG_NXP_WIFI_CSI_AMI)
add_library(libcsi STATIC IMPORTED)
if(CONFIG_NXP_LIBCSI_CM33)
set_target_properties(libcsi PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libcsi/zephyr/cm33/libcsi.a)
elseif(CONFIG_NXP_LIBCSI_CM7_20M)
set_target_properties(libcsi PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libcsi/zephyr/cm7/cm7f_sta_20_only/libcsi.a)
else()
set_target_properties(libcsi PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libcsi/zephyr/cm7/cm7f/libcsi.a)
endif()
target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/libcsi/incl)
zephyr_include_directories(
libcsi/incl
)
target_link_libraries(app PRIVATE libcsi)
endif()

zephyr_compile_definitions_ifdef(CONFIG_NXP_88W8987
SD8987
)
Expand Down
4 changes: 4 additions & 0 deletions mcux/middleware/wifi_nxp/incl/nxp_wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ extern "C" {
#define CONFIG_CSI 1
#endif

#if CONFIG_NXP_WIFI_CSI_AMI
#define CONFIG_CSI_AMI 1
#endif

#if CONFIG_NXP_WIFI_RESET
#define CONFIG_WIFI_RESET 1
#endif
Expand Down
3 changes: 3 additions & 0 deletions mcux/middleware/wifi_nxp/incl/wifidriver/wifi_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ enum wifi_event
/* Recv csi data */
WIFI_EVENT_CSI,
WIFI_EVENT_CSI_STATUS,
#if CONFIG_CSI_AMI
WIFI_EVENT_CSI_PROC,
#endif
#endif
#if (CONFIG_11MC) || (CONFIG_11AZ)
/* Event to trigger or stop ftm*/
Expand Down
33 changes: 33 additions & 0 deletions mcux/middleware/wifi_nxp/incl/wlcmgr/wlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,22 @@ enum wlan_csi_opt
CSI_FILTER_OPT_CLEAR,
CSI_FILTER_OPT_DUMP,
};

#if CONFIG_CSI_AMI
typedef struct _wlan_csi_proc_cfg
{
/** peer mac address */
uint8_t peer_mac[MLAN_MAC_ADDR_LENGTH];
/** Number of CSI to process */
uint8_t num_csi;
/** CSI bandwidth: 20/40/80 */
uint8_t packet_bandwidth;
/** CSI format: legacy/HT/VHT/HE */
uint8_t packet_format;
/** Reference Update */
uint8_t reference_update;
} wlan_csi_proc_cfg;
#endif
#endif

#if CONFIG_NET_MONITOR
Expand Down Expand Up @@ -6777,6 +6793,23 @@ int wlan_register_csi_user_callback(int (*csi_data_recv_callback)(void *buffer,
* \return WM_SUCCESS if successful
*/
int wlan_unregister_csi_user_callback(void);


#if CONFIG_CSI_AMI
/** This function set Ambient Motion Index configuration.
*
* \param[in] cfg: Ambient Motion Index configuration..
*/
void wlan_set_ami_cfg(wlan_csi_proc_cfg *cfg);

/** Use this API to start or stop caculate Ambient Motion Index.
*
* \param[in] start: start/stop
* 1: start
* 0: stop
*/
void wlan_start_stop_ami(uint8_t start);
#endif
#endif

#if (CONFIG_11K) || (CONFIG_11V) || (CONFIG_11R) || (CONFIG_ROAMING)
Expand Down
58 changes: 58 additions & 0 deletions mcux/middleware/wifi_nxp/libcsi/incl/event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2025 NXP
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/

/*! \file event.h
* \brief This file provides essential macro definitions and data structures for processing CSI event data.
*/

#ifndef _LIB_CSI_EVENT_H_
#define _LIB_CSI_EVENT_H_

#include <ctype.h>
#include <stdlib.h>
#include "wls_structure_defs.h"

#define PI_ALPHA_FACTOR 0.1f
#define KALMAN_N0 0.2f
#define KALMAN_P0 0.5f
#define KALMAN_ALPHA 0.005f

typedef enum {
AMI_FILTER_NOT_SET = 0, // Filter not set
AMI_FILTER_SET, // Filter manually set via configuration
AMI_FILTER_AUTO_SET, // Filter auto set from the first packet
} ami_filter_set_status_t;

typedef enum {
AMI_REF_UNINIT = 0, // AMI reference not initialized
AMI_REF_INITIALIZED // AMI reference initialized
} ami_reference_status_t;

typedef enum {
AMI_STOP = 0, // AMI calculation stopped
AMI_START // AMI calculation started
} ami_start_status_t;

/** Structure for CSI config data*/
typedef struct wls_csi_cfg
{
/** Channel number for FTM session*/
t_u8 channel;
/** Indicate whether CSI filter has been set */
ami_filter_set_status_t csiFilterSet;
/** Indicate whether start to caculate Ambient Motion Index.
* AMI_STOP - stop. AMI_START - start */
ami_start_status_t start;
/** Indicates whether AMI reference has been initialized */
ami_reference_status_t ami_reference_init;
/**CSI processing config*/
hal_wls_processing_input_params_t wls_processing_input;
/**CSI filter parameters*/
csi_filter_param_t gcsi_filter_param;
} wls_csi_cfg_t, ami_cfg_t;

#endif /* _LIB_CSI_EVENT_H */
55 changes: 55 additions & 0 deletions mcux/middleware/wifi_nxp/libcsi/incl/range_kalman.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2025 NXP
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/

/*! \file range_kalman.h
* \brief This file contains Kalman filter for WLS range measurements.
*/

#ifndef RANGE_KALMAN
#define RANGE_KALMAN

#define RANGE_RUN_FLT
#ifdef RANGE_RUN_FLT
// range is in meters, range_rate in meters/second
// time is in seconds
typedef struct {
// input
unsigned long long time;
float range_measurement;
// state
float last_range; // also output <--
float last_range_rate;
float R0_11, R0_22, R0_12;
unsigned long long last_time;
// model parameters
float measurement_var;
float drive_var;
} range_kalman_state;

void range_kalman_init(range_kalman_state* in, float range, unsigned long long time, float range_drive_var, float range_measurement_var, float range_rate_init);
#else
// range format u16.8 in meters
// time format is u64.0 in milliseconds
typedef struct {
// input
unsigned long long time;
unsigned int range_measurement;
// state
unsigned short last_range; // also output <--
signed short last_range_rate;
unsigned long long last_time;
unsigned short R0_11, R0_22;
signed int R0_12;
// model parameters
unsigned int measurement_var;
unsigned int drive_var;
} range_kalman_state;
#endif

int range_kalman(range_kalman_state* in);

#endif
30 changes: 30 additions & 0 deletions mcux/middleware/wifi_nxp/libcsi/incl/wls_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2025 NXP
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/

/*! \file wls_api.h
* \brief This file contains header file file for WLS processing fixed-point version API.
*/

/************************************************************************
* Header file for WLS processing fixed-point version API
************************************************************************/
#ifndef WLS_API_H
#define WLS_API_H

#include "wls_structure_defs.h"
#include "event.h"
#ifdef DFW_CSI_PROC
#include "dsp_cmd.h"
#endif

int wls_process_csi(unsigned int *bufferMemory, unsigned int *fftInBuffer, hal_wls_packet_params_t *packetparams, hal_wls_processing_input_params_t *inputVals, unsigned int *resArray);
int wls_unpack_csi(unsigned int *bufferMemory, unsigned int *outBuffer, hal_wls_packet_params_t *packetparams, hal_wls_processing_input_params_t *inputVals, unsigned int *totalpower, unsigned int *pktInfoPtr);
int wls_calculate_toa(unsigned int *pktInfoPtr, int bufferSpacing, unsigned int *fftInBuffer, unsigned int *fftBuffer, unsigned int *totalpower, hal_wls_packet_params_t *packetparams, hal_wls_processing_input_params_t *inputVals);

void wls_intialize_reference(unsigned int *headerBuffer, unsigned int *pktInfoPtr, csi_filter_param_t *csi_filter_param_ptr, int bufferSpacing, unsigned int *fftInBuffer, float *fftRefBuffer);
float wls_update_cross_corr_ami_calc(unsigned int *headerBuffer, unsigned int *pktInfoPtr, csi_filter_param_t *csi_filter_param_ptr, int bufferSpacing, unsigned int *fftInBuffer, float *fftRefBuffer, unsigned int *tempBuffer);
#endif
Loading