aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/fx3/b200/b200_ad9361.c
blob: ebb0dda70c1e925bb964bee0898848deca4a470b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Copyright 2013-2014 Ettus Research LLC
//

#include "cyu3error.h"
#include "cyu3i2c.h"
#include "cyu3spi.h"
#include "cyu3os.h"
#include "cyu3pib.h"
#include "cyu3system.h"
#include "cyu3usb.h"
#include "cyu3utils.h"
#include "pib_regs.h"
#include "b200_vrq.h"
#include <stdint.h>

#define true CyTrue
#define false CyFalse

typedef CyBool_t bool;

/* Fast sqrt() - precision can be improved by increasing 
 * the number of iterations 
 */
float ad9361_sqrt(const float number)
{
    uint32_t i;
    float x2, y;

    x2 = number * 0.5F;
    y = number;
    i = *(uint32_t *) &y;
    i = 0x5f3759df - ( i >> 1 );
    y = *(float *) &i;
    y = y * (1.5F - (x2 * y * y));

    return number * y;
}

void ad9361_msleep(const unsigned millis)
{
    CyU3PThreadSleep(millis);
}

#define AD9361_MIN(a, b) CY_U3P_MIN(a, b)
#define AD9361_MAX(a, b) CY_U3P_MAX(a, b)

#define AD9361_CEIL_INT(a)  ((int)(a+1)) 
#define AD9361_FLOOR_INT(a) ((int)(a))

#define AD9361_CLOCKING_MODE 0

#define AD9361_RX_BAND_EDGE0 2.2e9
#define AD9361_RX_BAND_EDGE1 4e9
#define AD9361_TX_BAND_EDGE 2.5e9

#include "../ad9361/lib/ad9361_impl.c"