Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (681 Bytes)

1
#include <serial.h>
2
#include <stdint.h>
3
#include <stdlib.h>
4
#include "fp_math.h"
5

    
6
#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
int main(int argc, char** argv) { 
16
        int32_t i, x, y;
17
        char buf[128];
18

    
19
        usb_init();
20
        
21
        for(i=0; i < 10000; i++) { 
22

    
23
                //Random number / sign
24
                x = random();
25
                x = ((rand() >> 2) & 1) ? x : -x;
26
                
27
                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
        }
42
        
43
        usb_putc(EXIT);
44

    
45
        while(1);
46
}
47