//FIR_filters.h
// FIR Filters header
// Mark Wickert April 2015

#define ARM_MATH_CM4
#include <s6e2cc.h>
#include "arm_math.h"


/*
Structures to hold FIR filter state information. Two direct form FIR 
types are implemented at present: (1) float32_t and (2) int16_t.
Each type requires both an initialization function and a filtering
function. The functions feature both sample-based and frame-based
capability.

More FIR implementation types can/should be added, say for a folded design,
use of intrinsics in the fixed point version. The use of a circular buffer
in all versions.
*/

struct FIR_struct_float32
{
  int16_t M_taps;
  float32_t *state;
  float32_t *b_coeff;
};

struct FIR_struct_int16
{
  int16_t M_taps;
  int16_t circ_idx;
  int16_t *state;
  int16_t *b_coeff;
};

void FIR_init_float32(struct FIR_struct_float32 *FIR, float32_t *state, 
	                    float32_t *b_coeff, int16_t Nb);
void FIR_filt_float32(struct FIR_struct_float32 *FIR, float32_t *x_in, 
	                    float32_t *x_out, int16_t Nframe);
void FIR_init_int16(struct FIR_struct_int16 *FIR, int16_t *state, 
	                  int16_t *b_coeff, int16_t Nb);
void FIR_filt_int16(struct FIR_struct_int16 *FIR, int16_t *x_in, 
	                  int16_t *x_out, int16_t Nframe, int16_t scale);
void FIR_filt_int16_cb(struct FIR_struct_int16 *FIR, int16_t *x_in, 
	                  int16_t *x_out, int16_t Nframe, int16_t scale);
void FIR_filt_int16_folded(struct FIR_struct_int16 *FIR, int16_t *x_in, 
	                  int16_t *x_out, int16_t Nframe, int16_t scale);
