1
|
|
2
|
#include <HDL51001_ccf.h>
|
3
|
#include <uart.h>
|
4
|
#include "math.h"
|
5
|
|
6
|
#define MAX_BLOCKSIZE 32
|
7
|
#define DELTA (0.000001f)
|
8
|
|
9
|
|
10
|
const float testInput[MAX_BLOCKSIZE] =
|
11
|
{
|
12
|
-1.244916875853235400, -4.793533929171324800, 0.360705030233248850, 0.827929644170887320, -3.299532218312426900, 3.427441903227623800, 3.422401784294607700, -0.108308165334010680,
|
13
|
0.941943896490312180, 0.502609575000365850, -0.537345278736373500, 2.088817392965764500, -1.693168684143455700, 6.283185307179590700, -0.392545884746175080, 0.327893095115825040,
|
14
|
3.070147440456292300, 0.170611405884662230, -0.275275082396073010, -2.395492805446796300, 0.847311163536506600, -3.845517018083148800, 2.055818378415868300, 4.672594161978930800,
|
15
|
-1.990923030266425800, 2.469305197656249500, 3.609002606064021000, -4.586736582331667500, -4.147080139136136300, 1.643756718868359500, -1.150866392366494800, 1.985805026477433800
|
16
|
|
17
|
|
18
|
};
|
19
|
|
20
|
|
21
|
void pause(unsigned int a)
|
22
|
{
|
23
|
unsigned int i;
|
24
|
for(i=a;i>0;i--);
|
25
|
}
|
26
|
|
27
|
void main()
|
28
|
{
|
29
|
|
30
|
|
31
|
float diff;
|
32
|
float a = M_PI_2;
|
33
|
int i;
|
34
|
int k=0xAA;
|
35
|
int blockSize = 32;
|
36
|
|
37
|
|
38
|
UART_InitTypeDef UART_InitStructure;
|
39
|
|
40
|
|
41
|
|
42
|
UART_InitStructure.BaudRate = 38400;
|
43
|
UART_InitStructure.TypeParity = 0x00000000;
|
44
|
UART_InitStructure.Parity = 0x00000000;
|
45
|
UART_InitStructure.FlowControl = 0x00000000;
|
46
|
UART_InitStructure.Mode = 0x00000003;
|
47
|
|
48
|
GPIOB->BPS = 0x00000300;
|
49
|
uart_init(UART0, &UART_InitStructure);
|
50
|
|
51
|
|
52
|
while(1)
|
53
|
{
|
54
|
|
55
|
|
56
|
GPIOB->DIR = ((uint32_t)0x60000000);
|
57
|
GPIOB->OUT = ((uint32_t)0x60000000);
|
58
|
|
59
|
for(i=0; i< blockSize; i++)
|
60
|
{
|
61
|
|
62
|
pause(400000);
|
63
|
diff = (sinf(testInput[i])*sinf(testInput[i]) + cosf(testInput[i])*cosf(testInput[i]) - 1.0f);
|
64
|
if(diff >0)
|
65
|
if(diff<DELTA)
|
66
|
UART_SEND_BYTE(k++, UART0);
|
67
|
else
|
68
|
UART_SEND_BYTE(0x00, UART0);
|
69
|
else
|
70
|
if((-diff)<DELTA)
|
71
|
UART_SEND_BYTE(k++, UART0);
|
72
|
else
|
73
|
UART_SEND_BYTE(0x00, UART0);
|
74
|
}
|
75
|
|
76
|
|
77
|
|
78
|
|
79
|
|
80
|
|
81
|
|
82
|
}
|
83
|
}
|