1 // Copyright (C) 2022 Beken Corporation 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 #pragma once 16 #include <common/bk_include.h> 17 #include <driver/fft_types.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /* @brief Overview about this API header 24 * 25 */ 26 27 /** 28 * @brief FFT API 29 * @defgroup bk_api_fft FFT API group 30 * @{ 31 */ 32 33 34 /** 35 * @brief Get the fft module working status 36 * 37 * @return 38 * - TRUE: fft is busying 39 * - FALSE: fft is not busying 40 */ 41 bool bk_fft_is_busy(void); 42 43 /** 44 * @brief Enable fft module to process fft/ifft function 45 * 46 * This API process fft/ifft function : 47 * - Set fft work mode: fft/ifft 48 * - Configure the fft/ifft parameters 49 * - start trigger 50 * - enable interrupts 51 * 52 * Usage example: 53 * 54 * //init fft driver 55 * bk_fft_driver_init(); 56 * 57 * fft_conf.inbuf = os_malloc(4*1024); 58 * os_memset(fft_conf.inbuf, 0, 4*1024); 59 * 60 * fft_conf.mode = FFT_WORK_MODE_FFT; 61 * fft_conf.size = 1024; 62 * 63 * //start fft 64 * bk_fft_enable(&fft_conf); 65 * 66 * //wait fft complete 67 * while(fft_busy_flag) 68 * bk_fft_is_busy(&fft_busy_flag); 69 * CLI_LOGI("fft complete\r\n"); 70 * //read output data 71 * bk_fft_output_read(data_proc_i, data_proc_q, 2 * 1024); 72 * 73 * @param fft_conf fft/ifft parameters 74 * 75 * @return 76 * - BK_OK: succeed 77 * - others: other errors. 78 */ 79 bk_err_t bk_fft_enable(fft_input_t *fft_conf); 80 81 /** 82 * @brief Init fft module driver 83 * 84 * This API init fft driver : 85 * - power on 86 * - enable interrupts 87 * 88 * @return 89 * - BK_OK: succeed 90 * - others: other errors. 91 */ 92 bk_err_t bk_fft_driver_init(void); 93 94 /** 95 * @brief Deinit fft module driver 96 * 97 * This API deinit fft driver : 98 * - Power down clock 99 * - disable interrupts 100 * 101 * @return 102 * - BK_OK: succeed 103 * - others: other errors. 104 */ 105 bk_err_t bk_fft_driver_deinit(void); 106 107 /** 108 * @brief Read fft data 109 * 110 * This API read fft data after processing complete 111 * 112 113 * @param i_output save fft data 114 * @param q_output save fft data 115 * @param size read size if i_output 116 * 117 * @return 118 * - BK_OK: succeed 119 * - others: other errors. 120 */ 121 bk_err_t bk_fft_output_read(int16_t *i_output, int16_t *q_output, uint32_t size); 122 123 /** 124 * @} 125 */ 126 127 #ifdef __cplusplus 128 } 129 #endif 130