HPM SDK
HPMicro Software Development Kit
hpm_ffa_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #ifndef HPM_FFA_DRV_H
8 #define HPM_FFA_DRV_H
9 
10 #include "hpm_common.h"
11 #include "hpm_ffa_regs.h"
12 
21 /***********************************************************************************************************************
22  *
23  * Definitions
24  *
25  **********************************************************************************************************************/
29 #define FFA_OPCMD_FIR (0U) /* !< FIR operation command index */
30 #define FFA_OPCMD_FFT (2U) /* !< FFT operation command index */
31 
35 #define FFA_DATA_TYPE_REAL_Q31 (0U) /* !< FFA Data type: Real Q31 */
36 #define FFA_DATA_TYPE_REAL_Q15 (1U) /* !< FFA Data type: Real Q15 */
37 #define FFA_DATA_TYPE_COMPLEX_Q31 (2U) /* !< FFA Data type: Complex Q31 */
38 #define FFA_DATA_TYPE_COMPLEX_Q15 (3U) /* !< FFA Data type: Complex Q15 */
39 
43 typedef int32_t ffa_q31_t;
44 
48 typedef int16_t ffa_q15_t;
49 
53 typedef struct {
57 
61 typedef struct {
65 
69 typedef struct {
70  uint16_t is_ifft; /* !< Is Inverse FFT transform */
71  uint8_t src_data_type; /* !< Source data type */
72  uint8_t dst_data_type; /* !< Destination date type */
73  uint32_t num_points; /* !< Number of points */
74  const void *src; /* !< Source data buffer */
75  void *dst; /* !< Destination Data buffer */
76  uint32_t interrupt_mask; /* !< Interrupt mask */
77 } fft_xfer_t;
78 
82 typedef struct {
83  uint16_t data_type; /* !< Data type */
84  uint16_t coef_taps; /* !< Coefficient taps */
85  uint32_t input_taps; /* !< Input data taps */
86  const void *src; /* !< Source data buffer */
87  const void *coeff; /* !< Coefficient data buffer */
88  void *dst; /* !< Destination data buffer */
89  uint32_t interrupt_mask; /* !< Interrupt mask */
90 } fir_xfer_t;
91 
95 enum {
98  status_ffa_write_error = MAKE_STATUS(status_group_ffa, 2), /* !< FFA write error */
99  status_ffa_read_next_error = MAKE_STATUS(status_group_ffa, 3), /* !< FFA read next data error */
101 };
102 
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106 
112 static inline void ffa_enable(FFA_Type *ptr)
113 {
114  ptr->CTRL = (ptr->CTRL & ~FFA_CTRL_SFTRST_MASK) | FFA_CTRL_EN_MASK;
115 }
116 
122 static inline void ffa_disable(FFA_Type *ptr)
123 {
124  ptr->CTRL = (ptr->CTRL & ~FFA_CTRL_EN_MASK) | FFA_CTRL_SFTRST_MASK;
125 }
126 
133 static inline uint32_t ffa_get_status(FFA_Type *ptr)
134 {
135  return ptr->STATUS;
136 }
137 
144 static inline void ffa_enable_interrupt(FFA_Type *ptr, uint32_t mask)
145 {
146  ptr->INT_EN |= mask;
147 }
148 
155 static inline void ffa_disable_interrupt(FFA_Type *ptr, uint32_t mask)
156 {
157  ptr->INT_EN &= ~mask;
158 }
159 
166 void ffa_start_fft(FFA_Type *ptr, fft_xfer_t *fft_xfer);
167 
174 void ffa_start_fir(FFA_Type *ptr, fir_xfer_t *fir_xfer);
175 
184 
193 
194 
195 #ifdef __cplusplus
196 }
197 #endif
204 #endif /* HPM_FFA_DRV_H */
uint32_t hpm_stat_t
Definition: hpm_common.h:119
#define MAKE_STATUS(group, code)
Definition: hpm_common.h:128
@ status_group_ffa
Definition: hpm_common.h:156
static void ffa_enable(FFA_Type *ptr)
Enable FFA module and start an specified FFA operation.
Definition: hpm_ffa_drv.h:112
static uint32_t ffa_get_status(FFA_Type *ptr)
Get FFA status.
Definition: hpm_ffa_drv.h:133
static void ffa_enable_interrupt(FFA_Type *ptr, uint32_t mask)
Enable FFA Interrupt.
Definition: hpm_ffa_drv.h:144
hpm_stat_t ffa_calculate_fir_blocking(FFA_Type *ptr, fir_xfer_t *fir_xfer)
Perform FIR transform in blocking mode.
Definition: hpm_ffa_drv.c:134
void ffa_start_fft(FFA_Type *ptr, fft_xfer_t *fft_xfer)
Start an FFT operation.
Definition: hpm_ffa_drv.c:34
int16_t ffa_q15_t
FFA Q15 data type definition.
Definition: hpm_ffa_drv.h:48
hpm_stat_t ffa_calculate_fft_blocking(FFA_Type *ptr, fft_xfer_t *fft_xfer)
Perform FFT transformation in blocking mode.
Definition: hpm_ffa_drv.c:114
void ffa_start_fir(FFA_Type *ptr, fir_xfer_t *fir_xfer)
Start an FIR operation.
Definition: hpm_ffa_drv.c:64
static void ffa_disable_interrupt(FFA_Type *ptr, uint32_t mask)
Disable FFA interrupt.
Definition: hpm_ffa_drv.h:155
int32_t ffa_q31_t
FFA Q31 data type definition.
Definition: hpm_ffa_drv.h:43
static void ffa_disable(FFA_Type *ptr)
Stop FFA module.
Definition: hpm_ffa_drv.h:122
@ status_ffa_write_error
Definition: hpm_ffa_drv.h:98
@ status_ffa_read_next_error
Definition: hpm_ffa_drv.h:99
@ status_ffa_fft_overflow
Definition: hpm_ffa_drv.h:97
@ status_ffa_read_error
Definition: hpm_ffa_drv.h:100
@ status_ffa_fir_overflow
Definition: hpm_ffa_drv.h:96
#define FFA_CTRL_EN_MASK
Definition: hpm_ffa_regs.h:67
#define FFA_CTRL_SFTRST_MASK
Definition: hpm_ffa_regs.h:57
Definition: hpm_ffa_regs.h:12
__RW uint32_t INT_EN
Definition: hpm_ffa_regs.h:15
__RW uint32_t STATUS
Definition: hpm_ffa_regs.h:14
__RW uint32_t CTRL
Definition: hpm_ffa_regs.h:13
FFA complex Q15 data type definition.
Definition: hpm_ffa_drv.h:61
ffa_q15_t real
Definition: hpm_ffa_drv.h:62
ffa_q15_t image
Definition: hpm_ffa_drv.h:63
FFA complex Q31 data type definition.
Definition: hpm_ffa_drv.h:53
ffa_q31_t image
Definition: hpm_ffa_drv.h:55
ffa_q31_t real
Definition: hpm_ffa_drv.h:54
FFT transform context.
Definition: hpm_ffa_drv.h:69
void * dst
Definition: hpm_ffa_drv.h:75
uint8_t dst_data_type
Definition: hpm_ffa_drv.h:72
uint32_t interrupt_mask
Definition: hpm_ffa_drv.h:76
uint8_t src_data_type
Definition: hpm_ffa_drv.h:71
const void * src
Definition: hpm_ffa_drv.h:74
uint32_t num_points
Definition: hpm_ffa_drv.h:73
uint16_t is_ifft
Definition: hpm_ffa_drv.h:70
FIR transform context.
Definition: hpm_ffa_drv.h:82
uint32_t input_taps
Definition: hpm_ffa_drv.h:85
const void * coeff
Definition: hpm_ffa_drv.h:87
const void * src
Definition: hpm_ffa_drv.h:86
uint16_t data_type
Definition: hpm_ffa_drv.h:83
uint32_t interrupt_mask
Definition: hpm_ffa_drv.h:89
uint16_t coef_taps
Definition: hpm_ffa_drv.h:84
void * dst
Definition: hpm_ffa_drv.h:88