avr-fw-modules/core/src/fp_sin_lookup.c

44 lines
807 B
C
Executable File

#include "hwo/fixpoint.h"
#if ((RAMEND - RAMSTART) >= 102400) // Only with more than 100kB SRAM for now...
/* Lookup auf sinus tabelle... */
extern uint32_t __sin090[90<<8];
fixpoint_t fp_sin_lookup(fixpoint_t arc090)
{
int32_t index = (arc090 >> 8); // Lookup Table has index format fixpoint 24.8
if (index < 0)
return 0;
if (index > (90<<8))
return 0;
return __sin090[ index ];
};
/* Reverse Lookup auf SINUS Tabelle */
fixpoint_t fp_sin_lookup_reverse(fixpoint_t sin)
{
int32_t hi = 0,
index = 0;
for (hi = 0; __sin090[ hi<<8 ] <= sin ; hi++);
index = hi << 8;
while (__sin090[ index-- ] <= sin);
return (index << 8);
};
#else
fixpoint_t fp_sin_lookup(fixpoint_t arc090)
{
return fp_make(0);
};
fixpoint_t fp_sin_lookup_reverse(fixpoint_t sin)
{
return fp_make(0);
};
#endif