Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / fp_math / main.c @ 1602

History | View | Annotate | Download (681 Bytes)

1 1579 justin
#include <serial.h>
2
#include <stdint.h>
3 1602 justin
#include <stdlib.h>
4 1579 justin
#include "fp_math.h"
5
6 1602 justin
#define X_IN 0
7
#define Y_OUT 1
8
9
#define FP_COS 2
10
#define FP_SIN 3
11
#define FP_TAN 4
12
13
#define EXIT 5
14
15 1579 justin
int main(int argc, char** argv) {
16 1602 justin
        int32_t i, x, y;
17 1579 justin
        char buf[128];
18 1602 justin
19
        usb_init();
20 1579 justin
21 1602 justin
        for(i=0; i < 10000; i++) {
22
23
                //Random number / sign
24
                x = random();
25
                x = ((rand() >> 2) & 1) ? x : -x;
26 1579 justin
27 1602 justin
                usb_putc(X_IN);
28
                for(i=0; i < 32; i += 8)
29
                        usb_putc((x >> i)  & 0xFF);
30
31
                y = fp_cos(x);
32
33
                usb_putc(Y_OUT);
34
                for(i=0; i < 32; i += 8)
35
                        usb_putc((y >> i)  & 0xFF);
36
37
                usb_putc(FP_COS);
38
39
                //sprintf(buf, "%ld = cos(%ld)\n\r", y, x);
40
                //usb_puts(buf);
41 1579 justin
        }
42 1602 justin
43
        usb_putc(EXIT);
44
45
        while(1);
46 1579 justin
}