FFT API Reference#
Overview#
The current SDK exposes FFT to user applications through the RT-Smart HAL wrapper in drv_fft.h. The older public API described as kd_mpi_fft* and mpi_fft_api.h is no longer the application-facing interface in the current tree.
The current flow is:
Open the device with
drv_fft_open().Fill a
drv_fft_cfg_tconfiguration.Run FFT or IFFT through
drv_fft_run(),drv_fft_fft(), ordrv_fft_ifft().Close the instance with
drv_fft_close().
The HAL hides MMZ allocation, cache maintenance, and ioctl details from applications.
Header#
Header file:
drv_fft.h
Public Types#
drv_fft_cfg_t#
typedef struct {
uint32_t point;
k_fft_mode_e mode;
k_fft_input_mode_e input_mode;
k_fft_out_mode_e output_mode;
uint16_t shift;
uint32_t timeout_ms;
} drv_fft_cfg_t;
k_fft_mode_e#
typedef enum {
FFT_MODE = 0,
IFFT_MODE,
} k_fft_mode_e;
k_fft_input_mode_e#
typedef enum {
RIRI = 0,
RRRR,
RR_II,
} k_fft_input_mode_e;
k_fft_out_mode_e#
typedef enum {
RIRI_OUT = 0,
RR_II_OUT,
} k_fft_out_mode_e;
Public Functions#
drv_fft_open#
int drv_fft_open(drv_fft_inst_t **inst);
Opens /dev/fft and returns an FFT instance handle.
drv_fft_close#
void drv_fft_close(drv_fft_inst_t **inst);
Closes the instance and clears the caller’s handle.
drv_fft_run#
int drv_fft_run(drv_fft_inst_t *inst, const drv_fft_cfg_t *cfg,
const short *in_real, const short *in_imag,
short *out_real, short *out_imag);
Runs one FFT or IFFT according to cfg->mode.
drv_fft_fft#
int drv_fft_fft(drv_fft_inst_t *inst, const drv_fft_cfg_t *cfg,
const short *in_real, const short *in_imag,
short *out_real, short *out_imag);
Convenience wrapper that forces FFT_MODE.
drv_fft_ifft#
int drv_fft_ifft(drv_fft_inst_t *inst, const drv_fft_cfg_t *cfg,
const short *in_real, const short *in_imag,
short *out_real, short *out_imag);
Convenience wrapper that forces IFFT_MODE.
Notes#
Supported point sizes are
64, 128, 256, 512, 1024, 2048, 4096.in_imagmay beNULLonly wheninput_mode == RRRR.timeout_ms = 0disables timeout reporting and is the default used by current samples.Return values follow negative errno-style error codes on failure.
Examples#
HAL roundtrip test:
src/rtsmart/examples/peripheral/fft/test_fft.cAudio spectrum display demo:
src/rtsmart/examples/mpp/sample_fft_display/main.c
