summaryrefslogtreecommitdiff
path: root/mac/common/src/ntb.c
blob: b7e0851bfb9cb539475f54f4ac6ba0c833abb22a (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/common/src/ntb.c
 * \brief   « brief description »
 * \ingroup « module »
 *
 * « long description »
 */
#include "common/std.h"

#include "hal/phy/phy.h"
#include "mac/common/ntb.h"

u32
phy_date (phy_t *ctx) __attribute__((weak));

mac_ntb_t ntb_global;

/**
 * Initialize the ntb context.
 *
 * \param  phy  the phy context.
 * \param  mac_config  the mac config context.
 */
void
mac_ntb_init (phy_t *phy, mac_config_t *mac_config)
{
    dbg_assert(phy);
    dbg_assert(mac_config);

    ntb_global.phy = phy;
    ntb_global.mac_config = mac_config;
}

/**
 * Uninitialize the ntb context.
 */
void
mac_ntb_uninit (void)
{
    /* TODO maybe. */
}

/**
 * Get the ntb date
 *
 * \return  the ntb date
 */
u32
mac_ntb (void)
{
    dbg_assert (ntb_global.phy);
    dbg_assert (ntb_global.mac_config);

    return phy_date (ntb_global.phy) + ntb_global.mac_config->ntb_offset_tck;
}

/**
 * Create a phy_date weak function to do not have to include the phy on test
 * when it is not necessary.
 *
 * \param  phy  the phy context.
 * \return  the phy date.
 */
u32
phy_date (phy_t *phy)
{
    return 42;
}