33#ifdef LIBOPENCM3_CORDIC_H
35#ifndef LIBOPENCM3_CORDIC_COMMON_V1_H
36#define LIBOPENCM3_CORDIC_COMMON_V1_H
42#define CORDIC_CSR MMIO32(CORDIC_BASE + 0x00)
44#define CORDIC_WDATA MMIO32(CORDIC_BASE + 0x04)
46#define CORDIC_RDATA MMIO32(CORDIC_BASE + 0x08)
55#define CORDIC_CSR_RRDY (0x1 << 31)
57#define CORDIC_CSR_ARGSIZE (0x1 << 22)
59#define CORDIC_CSR_RESSIZE (0x1 << 21)
61#define CORDIC_CSR_NARGS (0x1 << 20)
63#define CORDIC_CSR_NRES (0x1 << 19)
65#define CORDIC_CSR_DMAWEN (0x1 << 18)
67#define CORDIC_CSR_DMAREN (0x1 << 17)
69#define CORDIC_CSR_IEN (0x1 << 16)
73#define CORDIC_CSR_SCALE_1 (0x0)
74#define CORDIC_CSR_SCALE_2 (0x1)
75#define CORDIC_CSR_SCALE_4 (0x2)
76#define CORDIC_CSR_SCALE_8 (0x3)
77#define CORDIC_CSR_SCALE_16 (0x4)
78#define CORDIC_CSR_SCALE_32 (0x5)
79#define CORDIC_CSR_SCALE_64 (0x6)
80#define CORDIC_CSR_SCALE_128 (0x7)
82#define CORDIC_CSR_SCALE_SHIFT (8)
83#define CORDIC_CSR_SCALE_MASK (0x7 << CORDIC_CSR_SCALE_SHIFT)
87#define CORDIC_CSR_PRECISION_ITER_04 (0x1)
88#define CORDIC_CSR_PRECISION_ITER_08 (0x2)
89#define CORDIC_CSR_PRECISION_ITER_12 (0x3)
90#define CORDIC_CSR_PRECISION_ITER_16 (0x4)
91#define CORDIC_CSR_PRECISION_ITER_20 (0x5)
92#define CORDIC_CSR_PRECISION_ITER_24 (0x6)
93#define CORDIC_CSR_PRECISION_ITER_28 (0x7)
94#define CORDIC_CSR_PRECISION_ITER_32 (0x8)
95#define CORDIC_CSR_PRECISION_ITER_36 (0x9)
96#define CORDIC_CSR_PRECISION_ITER_40 (0xA)
97#define CORDIC_CSR_PRECISION_ITER_44 (0xB)
98#define CORDIC_CSR_PRECISION_ITER_48 (0xC)
99#define CORDIC_CSR_PRECISION_ITER_52 (0xD)
100#define CORDIC_CSR_PRECISION_ITER_56 (0xE)
101#define CORDIC_CSR_PRECISION_ITER_60 (0xF)
103#define CORDIC_CSR_PRECISION_SHIFT (4)
104#define CORDIC_CSR_PRECISION_MASK (0xF << CORDIC_CSR_PRECISION_SHIFT)
108#define CORDIC_CSR_FUNC_COS (0x0)
109#define CORDIC_CSR_FUNC_SIN (0x1)
110#define CORDIC_CSR_FUNC_PHASE (0x2)
111#define CORDIC_CSR_FUNC_MODULUS (0x3)
112#define CORDIC_CSR_FUNC_ATAN (0x4)
113#define CORDIC_CSR_FUNC_COSH (0x5)
114#define CORDIC_CSR_FUNC_SINH (0x6)
115#define CORDIC_CSR_FUNC_ATANH (0x7)
116#define CORDIC_CSR_FUNC_COSINE (0x8)
117#define CORDIC_CSR_FUNC_SQRT (0x9)
119#define CORDIC_CSR_FUNC_SHIFT (0)
120#define CORDIC_CSR_FUNC_MASK (0xF << CORDIC_CSR_FUNC_SHIFT)
int32_t cordic_sin_32bit(int32_t x)
Compute 32 bit sine using CORDIC (blocking)
void cordic_configure_for_cos_16bit(void)
Configure cordic for 16 bit cosine.
void cordic_write_16bit_arguments(uint16_t argument1, uint16_t argument2)
Write two 16 bit arguments.
void cordic_configure_for_sin_16bit(void)
Configure cordic for 16 bit sine.
void cordic_set_number_of_arguments_2(void)
Set number of CORDIC arguments to two 32 bit arguments.
void cordic_configure_for_cos_32bit(void)
Configure cordic for 32 bit cosine.
void cordic_set_result_width_16bit(void)
Set CORDIC to 16 bit result data width.
int16_t cordic_cos_16bit(int16_t x)
Compute 16 bit cosine using CORDIC (blocking)
void cordic_set_number_of_results_2(void)
Set number of CORDIC results to two 32 bit results.
void cordic_enable_interrupt(void)
Enable interrupt when result is ready.
int32_t cordic_cos_32bit(int32_t x)
Compute 32 bit cosine using CORDIC (blocking)
void cordic_set_precision(uint8_t precision)
Set precision for CORDIC operations.
void cordic_cos_32bit_async(int32_t x)
Compute 32 bit cosine using CORDIC (non blocking)
void cordic_disable_dma_write(void)
Disable DMA for writes to CORDIC_WDATA.
void cordic_set_scaling_factor(uint8_t n)
Set scaling factor for CORDIC operations.
bool cordic_is_result_ready(void)
Read CORDIC result ready flag.
void cordic_set_number_of_results_1(void)
Set number of CORDIC results to one 32 bit result or two 16 bit results.
int16_t cordic_sin_16bit(int16_t x)
Compute 16 bit sine using CORDIC (blocking)
void cordic_enable_dma_read(void)
Enable DMA for read from CORDIC_RDATA.
uint16_t cordic_read_16bit_result(void)
Read single 16 bit result.
void cordic_write_32bit_argument(uint32_t argument)
Write single 32 bit argument.
void cordic_read_16bit_results(uint16_t *result1, uint16_t *result2)
Read two 16 bit results.
void cordic_configure_for_sin_32bit(void)
Configure cordic for 32 bit sine.
void cordic_set_argument_width_16bit(void)
Set CORDIC to 16 bit argument data width.
void cordic_set_function(uint8_t function)
Set CORDIC operation type.
void cordic_sin_16bit_async(int16_t x)
Compute 16 bit sine using CORDIC (non blocking)
void cordic_sin_32bit_async(int32_t x)
Compute 32 bit sine using CORDIC (non blocking)
void cordic_write_16bit_argument(uint16_t argument)
Write single 16 bit argument.
void cordic_disable_dma_read(void)
Disable DMA for read from CORDIC_RDATA.
void cordic_enable_dma_write(void)
Enable DMA for writes to CORDIC_WDATA.
void cordic_set_argument_width_32bit(void)
Set CORDIC to 32 bit argument data width.
void cordic_set_number_of_arguments_1(void)
Set number of CORDIC arguments to one 32 bit argument or two 16 bit arguments.
void cordic_cos_16bit_async(int16_t x)
Compute 16 bit cosine using CORDIC (non blocking)
void cordic_set_result_width_32bit(void)
Set CORDIC to 32 bit result data width.
uint32_t cordic_read_32bit_result(void)
Read 32 bit result.