feat: 100us count, fft length, sample rate

This commit is contained in:
liuyihui 2023-04-28 18:11:09 +08:00
parent 50ee62911a
commit 824e73237b
9 changed files with 65 additions and 173 deletions

View File

@ -33,10 +33,10 @@ typedef unsigned char uchar;
PORT##port->PCR[pin] |= PORT_PCR_PE(0x1); \
}
#define ticks_ms (uint32_t)(ticks_50us / 20)
#define ticks_ms (uint32_t)(ticks_100us / 10)
extern uint32_t CORCLK;
extern uint32_t BUSCLK;
extern volatile uint32_t ticks_50us;
extern volatile uint32_t ticks_100us;
extern void SysTick_Handler(void);
extern void UART1_IRQHandler(void);

View File

@ -2,7 +2,7 @@
#include "derivative.h"
#define FFT_N 1024
#define FFT_N 256
#define FFT_BIN(num, re) (uint16_t)((float)(num + 0.5) * re)
#define FFT_INDEX(freq, re) (uint16_t)((float)freq / re)

View File

@ -2,8 +2,7 @@
#include "fft.h"
extern const q15_t hanning_28[];
extern const q15_t hanning_200[];
extern const q15_t hanning_117[];
extern const uint16_t bitrevTable[];
extern const q15_t rotCoef[];

View File

@ -3,9 +3,8 @@
#include "derivative.h"
#include "fft/fft.h"
#define FS 20000
#define FS 10000
#define RE FS / FFT_N
#define BUF_M 1024
#define FREQ_BIT1 1100
#define FREQ_SYNC 1200
@ -14,6 +13,6 @@
#define FREQ_BLACK 1500
#define FREQ_WHITE 4000
#define FREQ_RANGE FREQ_WHITE - FREQ_BLACK
#define COLOR_SCALE 64
#define COLOR_SCALE 32
uint8_t decode_sstv();

View File

@ -16,11 +16,11 @@ static inline bool timer_expired_ms(uint32_t *t, uint32_t prd) {
return true; // Expired, return true
}
static inline bool timer_expired_50us(uint32_t *t, uint32_t prd) {
if (ticks_50us + prd < *t) *t = 0; // Time wrapped? Reset timer
if (*t == 0) *t = ticks_50us + prd; // First poll? Set expiration
if (*t > ticks_50us) return false; // Not expired yet, return
*t = (ticks_50us - *t) > prd ? ticks_50us + prd : *t + prd; // Next expiration time
static inline bool timer_expired_100us(uint32_t *t, uint32_t prd) {
if (ticks_100us + prd < *t) *t = 0; // Time wrapped? Reset timer
if (*t == 0) *t = ticks_100us + prd; // First poll? Set expiration
if (*t > ticks_100us) return false; // Not expired yet, return
*t = (ticks_100us - *t) > prd ? ticks_100us + prd : *t + prd; // Next expiration time
return true; // Expired, return true
}
@ -29,7 +29,7 @@ static inline void delay_ms(uint32_t ms) {
while (ticks_ms - start < ms) asm("nop");
}
static inline void delay_50us(uint32_t us) {
uint32_t start = ticks_50us;
while (ticks_50us - start < us) asm("nop");
static inline void delay_100us(uint32_t us) {
uint32_t start = ticks_100us;
while (ticks_100us - start < us) asm("nop");
}

View File

@ -5,10 +5,10 @@
uint32_t CORCLK = CORCLK_DEFAULT;
uint32_t BUSCLK = BUSCLK_DEFAULT;
volatile uint32_t ticks_50us;
volatile uint32_t ticks_100us;
void SysTick_Handler(void) {
ticks_50us++;
ticks_100us++;
if (fADC) {
adc_buf[pADC] = adc0_TR_DATA() - 1550;
pADC = (pADC + 1) % ADC_M;

View File

@ -3,7 +3,6 @@
#include <math.h>
#include <stdlib.h>
#define FFT_N 1024
#define Re(x) 2 * x
#define Im(x) 2 * x + 1
@ -11,10 +10,7 @@ static q15_t res[FFT_N * 2];
static void hanning(q15_t *data, uint16_t len) {
for (uint16_t i = len; i < FFT_N; i++) data[i] = 0;
if (len == 200)
for (uint16_t i = 0; i < len; i++) data[i] = (q15_t)(((q31_t)data[i] * hanning_200[i]) >> 15);
else
for (uint16_t i = 0; i < len; i++) data[i] = (q15_t)(((q31_t)data[i] * hanning_28[i]) >> 15);
for (uint16_t i = 0; i < len; i++) data[i] = (q15_t)(((q31_t)data[i] * hanning_117[i]) >> 15);
}
static inline void bitreversal(q31_t *data) {

View File

@ -1,28 +1,18 @@
#include "fft/table.h"
const q15_t hanning_28[] = {
0, 442, 1743, 3833, 6600, 9895, 13539, 17337, 21083, 24576, 27627, 30073, 31780, 32657,
32657, 31780, 30073, 27627, 24576, 21083, 17337, 13539, 9895, 6600, 3833, 1743, 442, 0,
};
const q15_t hanning_200[] = {
0, 8, 33, 73, 130, 204, 293, 399, 520, 657, 810, 978, 1162, 1361, 1575, 1803,
2047, 2304, 2576, 2861, 3160, 3471, 3796, 4134, 4483, 4845, 5217, 5602, 5996, 6402, 6817, 7241,
7675, 8117, 8568, 9027, 9492, 9965, 10444, 10929, 11420, 11915, 12415, 12919, 13426, 13936, 14449, 14963,
15479, 15996, 16513, 17030, 17547, 18062, 18576, 19087, 19596, 20102, 20604, 21101, 21594, 22082, 22564, 23040,
23509, 23972, 24426, 24873, 25311, 25740, 26160, 26570, 26970, 27360, 27738, 28106, 28461, 28805, 29136, 29454,
29759, 30052, 30330, 30594, 30845, 31081, 31302, 31508, 31700, 31876, 32036, 32181, 32311, 32424, 32522, 32603,
32668, 32717, 32750, 32766, 32766, 32750, 32717, 32668, 32603, 32522, 32424, 32311, 32181, 32036, 31876, 31700,
31508, 31302, 31081, 30845, 30594, 30330, 30052, 29759, 29454, 29136, 28805, 28461, 28106, 27738, 27360, 26970,
26570, 26160, 25740, 25311, 24873, 24426, 23972, 23509, 23040, 22564, 22082, 21594, 21101, 20604, 20102, 19596,
19087, 18576, 18062, 17547, 17030, 16513, 15996, 15479, 14963, 14449, 13936, 13426, 12919, 12415, 11915, 11420,
10929, 10444, 9965, 9492, 9027, 8568, 8117, 7675, 7241, 6817, 6402, 5996, 5602, 5217, 4845, 4483,
4134, 3796, 3471, 3160, 2861, 2576, 2304, 2047, 1803, 1575, 1361, 1162, 978, 810, 657, 520,
399, 293, 204, 130, 73, 33, 8, 0,
const q15_t hanning_117[] = {
0, 24, 96, 216, 383, 597, 858, 1164, 1514, 1909, 2345, 2823, 3341, 3897, 4489,
5117, 5777, 6469, 7190, 7937, 8710, 9505, 10320, 11153, 12001, 12862, 13733, 14613, 15497, 16384,
17271, 18155, 19035, 19906, 20767, 21615, 22448, 23263, 24058, 24831, 25578, 26299, 26991, 27651, 28279,
28871, 29427, 29945, 30423, 30859, 31254, 31604, 31910, 32171, 32385, 32552, 32672, 32744, 32767, 32744,
32672, 32552, 32385, 32171, 31910, 31604, 31254, 30859, 30423, 29945, 29427, 28871, 28279, 27651, 26991,
26299, 25578, 24831, 24058, 23263, 22448, 21615, 20767, 19906, 19035, 18155, 17271, 16384, 15497, 14613,
13733, 12862, 12001, 11153, 10320, 9505, 8710, 7937, 7190, 6469, 5777, 5117, 4489, 3897, 3341,
2823, 2345, 1909, 1514, 1164, 858, 597, 383, 216, 96, 24, 0,
};
/*
Table for bit reversal process, where N = 4096 logN2 = 12, N is the maximum FFT Size supported
Table for bit reversal process, where N = 256 logN2 = 8, N is the maximum FFT Size supported
for (l = 1; l <= N / 4; l++) {
for (i = 0; i < logN2; i++) {
a[i] = l & (1 << i);
@ -33,22 +23,11 @@ const q15_t hanning_200[] = {
y[l] = y[l] >> 1;
}
*/
const uint16_t bitrevTable[256] = {
0x100, 0x80, 0x180, 0x40, 0x140, 0xc0, 0x1c0, 0x20, 0x120, 0xa0, 0x1a0, 0x60, 0x160, 0xe0, 0x1e0, 0x10, 0x110, 0x90,
0x190, 0x50, 0x150, 0xd0, 0x1d0, 0x30, 0x130, 0xb0, 0x1b0, 0x70, 0x170, 0xf0, 0x1f0, 0x8, 0x108, 0x88, 0x188, 0x48,
0x148, 0xc8, 0x1c8, 0x28, 0x128, 0xa8, 0x1a8, 0x68, 0x168, 0xe8, 0x1e8, 0x18, 0x118, 0x98, 0x198, 0x58, 0x158, 0xd8,
0x1d8, 0x38, 0x138, 0xb8, 0x1b8, 0x78, 0x178, 0xf8, 0x1f8, 0x4, 0x104, 0x84, 0x184, 0x44, 0x144, 0xc4, 0x1c4, 0x24,
0x124, 0xa4, 0x1a4, 0x64, 0x164, 0xe4, 0x1e4, 0x14, 0x114, 0x94, 0x194, 0x54, 0x154, 0xd4, 0x1d4, 0x34, 0x134, 0xb4,
0x1b4, 0x74, 0x174, 0xf4, 0x1f4, 0xc, 0x10c, 0x8c, 0x18c, 0x4c, 0x14c, 0xcc, 0x1cc, 0x2c, 0x12c, 0xac, 0x1ac, 0x6c,
0x16c, 0xec, 0x1ec, 0x1c, 0x11c, 0x9c, 0x19c, 0x5c, 0x15c, 0xdc, 0x1dc, 0x3c, 0x13c, 0xbc, 0x1bc, 0x7c, 0x17c, 0xfc,
0x1fc, 0x2, 0x102, 0x82, 0x182, 0x42, 0x142, 0xc2, 0x1c2, 0x22, 0x122, 0xa2, 0x1a2, 0x62, 0x162, 0xe2, 0x1e2, 0x12,
0x112, 0x92, 0x192, 0x52, 0x152, 0xd2, 0x1d2, 0x32, 0x132, 0xb2, 0x1b2, 0x72, 0x172, 0xf2, 0x1f2, 0xa, 0x10a, 0x8a,
0x18a, 0x4a, 0x14a, 0xca, 0x1ca, 0x2a, 0x12a, 0xaa, 0x1aa, 0x6a, 0x16a, 0xea, 0x1ea, 0x1a, 0x11a, 0x9a, 0x19a, 0x5a,
0x15a, 0xda, 0x1da, 0x3a, 0x13a, 0xba, 0x1ba, 0x7a, 0x17a, 0xfa, 0x1fa, 0x6, 0x106, 0x86, 0x186, 0x46, 0x146, 0xc6,
0x1c6, 0x26, 0x126, 0xa6, 0x1a6, 0x66, 0x166, 0xe6, 0x1e6, 0x16, 0x116, 0x96, 0x196, 0x56, 0x156, 0xd6, 0x1d6, 0x36,
0x136, 0xb6, 0x1b6, 0x76, 0x176, 0xf6, 0x1f6, 0xe, 0x10e, 0x8e, 0x18e, 0x4e, 0x14e, 0xce, 0x1ce, 0x2e, 0x12e, 0xae,
0x1ae, 0x6e, 0x16e, 0xee, 0x1ee, 0x1e, 0x11e, 0x9e, 0x19e, 0x5e, 0x15e, 0xde, 0x1de, 0x3e, 0x13e, 0xbe, 0x1be, 0x7e,
0x17e, 0xfe, 0x1fe, 0x1,
const uint16_t bitrevTable[64] = {
0x40, 0x20, 0x60, 0x10, 0x50, 0x30, 0x70, 0x8, 0x48, 0x28, 0x68, 0x18, 0x58, 0x38, 0x78, 0x4,
0x44, 0x24, 0x64, 0x14, 0x54, 0x34, 0x74, 0xc, 0x4c, 0x2c, 0x6c, 0x1c, 0x5c, 0x3c, 0x7c, 0x2,
0x42, 0x22, 0x62, 0x12, 0x52, 0x32, 0x72, 0xa, 0x4a, 0x2a, 0x6a, 0x1a, 0x5a, 0x3a, 0x7a, 0x6,
0x46, 0x26, 0x66, 0x16, 0x56, 0x36, 0x76, 0xe, 0x4e, 0x2e, 0x6e, 0x1e, 0x5e, 0x3e, 0x7e, 0x1,
};
/*
@ -57,117 +36,36 @@ const uint16_t bitrevTable[256] = {
rotCoef[2 * i] = cos(i * 2 * PI / (float)N);
rotCoef[2 * i + 1] = sin(i * 2 * PI / (float)N);
}
where N = 1024 and PI = 3.14159265358979, Cos and Sin values are interleaved fashion
where N = 256 and PI = 3.14159265358979, Cos and Sin values are interleaved fashion
Convert Floating point to int16 round(rotCoef(i) * pow(2, 15))
*/
const q15_t rotCoef[1536] = {
32767, 0, 32766, 201, 32765, 402, 32761, 603, 32757, 804, 32752, 1005, 32745, 1206,
32737, 1407, 32728, 1608, 32717, 1809, 32705, 2009, 32692, 2210, 32678, 2410, 32663, 2611,
32646, 2811, 32628, 3012, 32609, 3212, 32589, 3412, 32567, 3612, 32545, 3811, 32521, 4011,
32495, 4210, 32469, 4410, 32441, 4609, 32412, 4808, 32382, 5007, 32351, 5205, 32318, 5404,
32285, 5602, 32250, 5800, 32213, 5998, 32176, 6195, 32137, 6393, 32098, 6590, 32057, 6786,
32014, 6983, 31971, 7179, 31926, 7375, 31880, 7571, 31833, 7767, 31785, 7962, 31736, 8157,
31685, 8351, 31633, 8545, 31580, 8739, 31526, 8933, 31470, 9126, 31414, 9319, 31356, 9512,
31297, 9704, 31237, 9896, 31176, 10087, 31113, 10278, 31050, 10469, 30985, 10659, 30919, 10849,
30852, 11039, 30783, 11228, 30714, 11417, 30643, 11605, 30571, 11793, 30498, 11980, 30424, 12167,
30349, 12353, 30273, 12539, 30195, 12725, 30117, 12910, 30037, 13094, 29956, 13279, 29874, 13462,
29791, 13645, 29706, 13828, 29621, 14010, 29534, 14191, 29447, 14372, 29358, 14553, 29268, 14732,
29177, 14912, 29085, 15090, 28992, 15269, 28898, 15446, 28803, 15623, 28706, 15800, 28609, 15976,
28510, 16151, 28411, 16325, 28310, 16499, 28208, 16673, 28105, 16846, 28001, 17018, 27896, 17189,
27790, 17360, 27683, 17530, 27575, 17700, 27466, 17869, 27356, 18037, 27245, 18204, 27133, 18371,
27019, 18537, 26905, 18703, 26790, 18868, 26674, 19032, 26556, 19195, 26438, 19357, 26319, 19519,
26198, 19680, 26077, 19841, 25955, 20000, 25832, 20159, 25708, 20317, 25582, 20475, 25456, 20631,
25329, 20787, 25201, 20942, 25072, 21096, 24942, 21250, 24811, 21403, 24680, 21554, 24547, 21705,
24413, 21856, 24279, 22005, 24143, 22154, 24007, 22301, 23870, 22448, 23731, 22594, 23592, 22739,
23452, 22884, 23311, 23027, 23170, 23170, 23027, 23311, 22884, 23452, 22739, 23592, 22594, 23731,
22448, 23870, 22301, 24007, 22154, 24143, 22005, 24279, 21856, 24413, 21705, 24547, 21554, 24680,
21403, 24811, 21250, 24942, 21096, 25072, 20942, 25201, 20787, 25329, 20631, 25456, 20475, 25582,
20317, 25708, 20159, 25832, 20000, 25955, 19841, 26077, 19680, 26198, 19519, 26319, 19357, 26438,
19195, 26556, 19032, 26674, 18868, 26790, 18703, 26905, 18537, 27019, 18371, 27133, 18204, 27245,
18037, 27356, 17869, 27466, 17700, 27575, 17530, 27683, 17360, 27790, 17189, 27896, 17018, 28001,
16846, 28105, 16673, 28208, 16499, 28310, 16325, 28411, 16151, 28510, 15976, 28609, 15800, 28706,
15623, 28803, 15446, 28898, 15269, 28992, 15090, 29085, 14912, 29177, 14732, 29268, 14553, 29358,
14372, 29447, 14191, 29534, 14010, 29621, 13828, 29706, 13645, 29791, 13462, 29874, 13279, 29956,
13094, 30037, 12910, 30117, 12725, 30195, 12539, 30273, 12353, 30349, 12167, 30424, 11980, 30498,
11793, 30571, 11605, 30643, 11417, 30714, 11228, 30783, 11039, 30852, 10849, 30919, 10659, 30985,
10469, 31050, 10278, 31113, 10087, 31176, 9896, 31237, 9704, 31297, 9512, 31356, 9319, 31414,
9126, 31470, 8933, 31526, 8739, 31580, 8545, 31633, 8351, 31685, 8157, 31736, 7962, 31785,
7767, 31833, 7571, 31880, 7375, 31926, 7179, 31971, 6983, 32014, 6786, 32057, 6590, 32098,
6393, 32137, 6195, 32176, 5998, 32213, 5800, 32250, 5602, 32285, 5404, 32318, 5205, 32351,
5007, 32382, 4808, 32412, 4609, 32441, 4410, 32469, 4210, 32495, 4011, 32521, 3811, 32545,
3612, 32567, 3412, 32589, 3212, 32609, 3012, 32628, 2811, 32646, 2611, 32663, 2410, 32678,
2210, 32692, 2009, 32705, 1809, 32717, 1608, 32728, 1407, 32737, 1206, 32745, 1005, 32752,
804, 32757, 603, 32761, 402, 32765, 201, 32766, 0, 32767, -201, 32766, -402, 32765,
-603, 32761, -804, 32757, -1005, 32752, -1206, 32745, -1407, 32737, -1608, 32728, -1809, 32717,
-2009, 32705, -2210, 32692, -2410, 32678, -2611, 32663, -2811, 32646, -3012, 32628, -3212, 32609,
-3412, 32589, -3612, 32567, -3811, 32545, -4011, 32521, -4210, 32495, -4410, 32469, -4609, 32441,
-4808, 32412, -5007, 32382, -5205, 32351, -5404, 32318, -5602, 32285, -5800, 32250, -5998, 32213,
-6195, 32176, -6393, 32137, -6590, 32098, -6786, 32057, -6983, 32014, -7179, 31971, -7375, 31926,
-7571, 31880, -7767, 31833, -7962, 31785, -8157, 31736, -8351, 31685, -8545, 31633, -8739, 31580,
-8933, 31526, -9126, 31470, -9319, 31414, -9512, 31356, -9704, 31297, -9896, 31237, -10087, 31176,
-10278, 31113, -10469, 31050, -10659, 30985, -10849, 30919, -11039, 30852, -11228, 30783, -11417, 30714,
-11605, 30643, -11793, 30571, -11980, 30498, -12167, 30424, -12353, 30349, -12539, 30273, -12725, 30195,
-12910, 30117, -13094, 30037, -13279, 29956, -13462, 29874, -13645, 29791, -13828, 29706, -14010, 29621,
-14191, 29534, -14372, 29447, -14553, 29358, -14732, 29268, -14912, 29177, -15090, 29085, -15269, 28992,
-15446, 28898, -15623, 28803, -15800, 28706, -15976, 28609, -16151, 28510, -16325, 28411, -16499, 28310,
-16673, 28208, -16846, 28105, -17018, 28001, -17189, 27896, -17360, 27790, -17530, 27683, -17700, 27575,
-17869, 27466, -18037, 27356, -18204, 27245, -18371, 27133, -18537, 27019, -18703, 26905, -18868, 26790,
-19032, 26674, -19195, 26556, -19357, 26438, -19519, 26319, -19680, 26198, -19841, 26077, -20000, 25955,
-20159, 25832, -20317, 25708, -20475, 25582, -20631, 25456, -20787, 25329, -20942, 25201, -21096, 25072,
-21250, 24942, -21403, 24811, -21554, 24680, -21705, 24547, -21856, 24413, -22005, 24279, -22154, 24143,
-22301, 24007, -22448, 23870, -22594, 23731, -22739, 23592, -22884, 23452, -23027, 23311, -23170, 23170,
-23311, 23027, -23452, 22884, -23592, 22739, -23731, 22594, -23870, 22448, -24007, 22301, -24143, 22154,
-24279, 22005, -24413, 21856, -24547, 21705, -24680, 21554, -24811, 21403, -24942, 21250, -25072, 21096,
-25201, 20942, -25329, 20787, -25456, 20631, -25582, 20475, -25708, 20317, -25832, 20159, -25955, 20000,
-26077, 19841, -26198, 19680, -26319, 19519, -26438, 19357, -26556, 19195, -26674, 19032, -26790, 18868,
-26905, 18703, -27019, 18537, -27133, 18371, -27245, 18204, -27356, 18037, -27466, 17869, -27575, 17700,
-27683, 17530, -27790, 17360, -27896, 17189, -28001, 17018, -28105, 16846, -28208, 16673, -28310, 16499,
-28411, 16325, -28510, 16151, -28609, 15976, -28706, 15800, -28803, 15623, -28898, 15446, -28992, 15269,
-29085, 15090, -29177, 14912, -29268, 14732, -29358, 14553, -29447, 14372, -29534, 14191, -29621, 14010,
-29706, 13828, -29791, 13645, -29874, 13462, -29956, 13279, -30037, 13094, -30117, 12910, -30195, 12725,
-30273, 12539, -30349, 12353, -30424, 12167, -30498, 11980, -30571, 11793, -30643, 11605, -30714, 11417,
-30783, 11228, -30852, 11039, -30919, 10849, -30985, 10659, -31050, 10469, -31113, 10278, -31176, 10087,
-31237, 9896, -31297, 9704, -31356, 9512, -31414, 9319, -31470, 9126, -31526, 8933, -31580, 8739,
-31633, 8545, -31685, 8351, -31736, 8157, -31785, 7962, -31833, 7767, -31880, 7571, -31926, 7375,
-31971, 7179, -32014, 6983, -32057, 6786, -32098, 6590, -32137, 6393, -32176, 6195, -32213, 5998,
-32250, 5800, -32285, 5602, -32318, 5404, -32351, 5205, -32382, 5007, -32412, 4808, -32441, 4609,
-32469, 4410, -32495, 4210, -32521, 4011, -32545, 3811, -32567, 3612, -32589, 3412, -32609, 3212,
-32628, 3012, -32646, 2811, -32663, 2611, -32678, 2410, -32692, 2210, -32705, 2009, -32717, 1809,
-32728, 1608, -32737, 1407, -32745, 1206, -32752, 1005, -32757, 804, -32761, 603, -32765, 402,
-32766, 201, -32767, 0, -32766, -201, -32765, -402, -32761, -603, -32757, -804, -32752, -1005,
-32745, -1206, -32737, -1407, -32728, -1608, -32717, -1809, -32705, -2009, -32692, -2210, -32678, -2410,
-32663, -2611, -32646, -2811, -32628, -3012, -32609, -3212, -32589, -3412, -32567, -3612, -32545, -3811,
-32521, -4011, -32495, -4210, -32469, -4410, -32441, -4609, -32412, -4808, -32382, -5007, -32351, -5205,
-32318, -5404, -32285, -5602, -32250, -5800, -32213, -5998, -32176, -6195, -32137, -6393, -32098, -6590,
-32057, -6786, -32014, -6983, -31971, -7179, -31926, -7375, -31880, -7571, -31833, -7767, -31785, -7962,
-31736, -8157, -31685, -8351, -31633, -8545, -31580, -8739, -31526, -8933, -31470, -9126, -31414, -9319,
-31356, -9512, -31297, -9704, -31237, -9896, -31176, -10087, -31113, -10278, -31050, -10469, -30985, -10659,
-30919, -10849, -30852, -11039, -30783, -11228, -30714, -11417, -30643, -11605, -30571, -11793, -30498, -11980,
-30424, -12167, -30349, -12353, -30273, -12539, -30195, -12725, -30117, -12910, -30037, -13094, -29956, -13279,
-29874, -13462, -29791, -13645, -29706, -13828, -29621, -14010, -29534, -14191, -29447, -14372, -29358, -14553,
-29268, -14732, -29177, -14912, -29085, -15090, -28992, -15269, -28898, -15446, -28803, -15623, -28706, -15800,
-28609, -15976, -28510, -16151, -28411, -16325, -28310, -16499, -28208, -16673, -28105, -16846, -28001, -17018,
-27896, -17189, -27790, -17360, -27683, -17530, -27575, -17700, -27466, -17869, -27356, -18037, -27245, -18204,
-27133, -18371, -27019, -18537, -26905, -18703, -26790, -18868, -26674, -19032, -26556, -19195, -26438, -19357,
-26319, -19519, -26198, -19680, -26077, -19841, -25955, -20000, -25832, -20159, -25708, -20317, -25582, -20475,
-25456, -20631, -25329, -20787, -25201, -20942, -25072, -21096, -24942, -21250, -24811, -21403, -24680, -21554,
-24547, -21705, -24413, -21856, -24279, -22005, -24143, -22154, -24007, -22301, -23870, -22448, -23731, -22594,
-23592, -22739, -23452, -22884, -23311, -23027, -23170, -23170, -23027, -23311, -22884, -23452, -22739, -23592,
-22594, -23731, -22448, -23870, -22301, -24007, -22154, -24143, -22005, -24279, -21856, -24413, -21705, -24547,
-21554, -24680, -21403, -24811, -21250, -24942, -21096, -25072, -20942, -25201, -20787, -25329, -20631, -25456,
-20475, -25582, -20317, -25708, -20159, -25832, -20000, -25955, -19841, -26077, -19680, -26198, -19519, -26319,
-19357, -26438, -19195, -26556, -19032, -26674, -18868, -26790, -18703, -26905, -18537, -27019, -18371, -27133,
-18204, -27245, -18037, -27356, -17869, -27466, -17700, -27575, -17530, -27683, -17360, -27790, -17189, -27896,
-17018, -28001, -16846, -28105, -16673, -28208, -16499, -28310, -16325, -28411, -16151, -28510, -15976, -28609,
-15800, -28706, -15623, -28803, -15446, -28898, -15269, -28992, -15090, -29085, -14912, -29177, -14732, -29268,
-14553, -29358, -14372, -29447, -14191, -29534, -14010, -29621, -13828, -29706, -13645, -29791, -13462, -29874,
-13279, -29956, -13094, -30037, -12910, -30117, -12725, -30195, -12539, -30273, -12353, -30349, -12167, -30424,
-11980, -30498, -11793, -30571, -11605, -30643, -11417, -30714, -11228, -30783, -11039, -30852, -10849, -30919,
-10659, -30985, -10469, -31050, -10278, -31113, -10087, -31176, -9896, -31237, -9704, -31297, -9512, -31356,
-9319, -31414, -9126, -31470, -8933, -31526, -8739, -31580, -8545, -31633, -8351, -31685, -8157, -31736,
-7962, -31785, -7767, -31833, -7571, -31880, -7375, -31926, -7179, -31971, -6983, -32014, -6786, -32057,
-6590, -32098, -6393, -32137, -6195, -32176, -5998, -32213, -5800, -32250, -5602, -32285, -5404, -32318,
-5205, -32351, -5007, -32382, -4808, -32412, -4609, -32441, -4410, -32469, -4210, -32495, -4011, -32521,
-3811, -32545, -3612, -32567, -3412, -32589, -3212, -32609, -3012, -32628, -2811, -32646, -2611, -32663,
-2410, -32678, -2210, -32692, -2009, -32705, -1809, -32717, -1608, -32728, -1407, -32737, -1206, -32745,
-1005, -32752, -804, -32757, -603, -32761, -402, -32765, -201, -32766};
const q15_t rotCoef[384] = {
32767, 0, 32757, 804, 32728, 1608, 32678, 2410, 32609, 3212, 32521, 4011, 32412, 4808,
32285, 5602, 32137, 6393, 31971, 7179, 31785, 7962, 31580, 8739, 31356, 9512, 31113, 10278,
30852, 11039, 30571, 11793, 30273, 12539, 29956, 13279, 29621, 14010, 29268, 14732, 28898, 15446,
28510, 16151, 28105, 16846, 27683, 17530, 27245, 18204, 26790, 18868, 26319, 19519, 25832, 20159,
25329, 20787, 24811, 21403, 24279, 22005, 23731, 22594, 23170, 23170, 22594, 23731, 22005, 24279,
21403, 24811, 20787, 25329, 20159, 25832, 19519, 26319, 18868, 26790, 18204, 27245, 17530, 27683,
16846, 28105, 16151, 28510, 15446, 28898, 14732, 29268, 14010, 29621, 13279, 29956, 12539, 30273,
11793, 30571, 11039, 30852, 10278, 31113, 9512, 31356, 8739, 31580, 7962, 31785, 7179, 31971,
6393, 32137, 5602, 32285, 4808, 32412, 4011, 32521, 3212, 32609, 2410, 32678, 1608, 32728,
804, 32757, 0, 32767, -804, 32757, -1608, 32728, -2410, 32678, -3212, 32609, -4011, 32521,
-4808, 32412, -5602, 32285, -6393, 32137, -7179, 31971, -7962, 31785, -8739, 31580, -9512, 31356,
-10278, 31113, -11039, 30852, -11793, 30571, -12539, 30273, -13279, 29956, -14010, 29621, -14732, 29268,
-15446, 28898, -16151, 28510, -16846, 28105, -17530, 27683, -18204, 27245, -18868, 26790, -19519, 26319,
-20159, 25832, -20787, 25329, -21403, 24811, -22005, 24279, -22594, 23731, -23170, 23170, -23731, 22594,
-24279, 22005, -24811, 21403, -25329, 20787, -25832, 20159, -26319, 19519, -26790, 18868, -27245, 18204,
-27683, 17530, -28105, 16846, -28510, 16151, -28898, 15446, -29268, 14732, -29621, 14010, -29956, 13279,
-30273, 12539, -30571, 11793, -30852, 11039, -31113, 10278, -31356, 9512, -31580, 8739, -31785, 7962,
-31971, 7179, -32137, 6393, -32285, 5602, -32412, 4808, -32521, 4011, -32609, 3212, -32678, 2410,
-32728, 1608, -32757, 804, -32767, 0, -32757, -804, -32728, -1608, -32678, -2410, -32609, -3212,
-32521, -4011, -32412, -4808, -32285, -5602, -32137, -6393, -31971, -7179, -31785, -7962, -31580, -8739,
-31356, -9512, -31113, -10278, -30852, -11039, -30571, -11793, -30273, -12539, -29956, -13279, -29621, -14010,
-29268, -14732, -28898, -15446, -28510, -16151, -28105, -16846, -27683, -17530, -27245, -18204, -26790, -18868,
-26319, -19519, -25832, -20159, -25329, -20787, -24811, -21403, -24279, -22005, -23731, -22594, -23170, -23170,
-22594, -23731, -22005, -24279, -21403, -24811, -20787, -25329, -20159, -25832, -19519, -26319, -18868, -26790,
-18204, -27245, -17530, -27683, -16846, -28105, -16151, -28510, -15446, -28898, -14732, -29268, -14010, -29621,
-13279, -29956, -12539, -30273, -11793, -30571, -11039, -30852, -10278, -31113, -9512, -31356, -8739, -31580,
-7962, -31785, -7179, -31971, -6393, -32137, -5602, -32285, -4808, -32412, -4011, -32521, -3212, -32609,
-2410, -32678, -1608, -32728, -804, -32757,
};

View File

@ -159,7 +159,7 @@ __attribute__((naked, noreturn)) void _reset(void) {
copy_data();
clock_init();
SysTick_Config(CORCLK / 100000 * 5); // Period of systick timer : 50 us
SysTick_Config(CORCLK / 100000 * 10); // Period of systick timer : 100 us
main();
for (;;) (void)0;