summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/bitloading.h
blob: d82a828979895cf8787d12cf36825e236a7bb95c (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
78
79
80
81
82
83
#ifndef ce_rx_bitloading_bitloading_h
#define ce_rx_bitloading_bitloading_h
/* Cesar project {{{
 *
 * Copyright (C) 2009 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    ce/rx/bitloading/bitloading.h
 * \brief   CE RX bit-loading (public declaration).
 * \ingroup ce_rx
 *
 * This module is responsible to manage the bit-loading state and data per
 * station.
 *
 * Basically, a structure is added to the sta_t with some information (like
 * the state of the bit-loading).
 */

#include "lib/blk.h"

/**
 * Bit-loading data per station.
 */
typedef struct ce_rx_bitloading_t
{
    /** State of the bit loading. */
    u32 fsm;
    /** Mean of the noise NRJ (on multiple blk) per intervals. */
    blk_t *noise_nrj;
    /** Number of allocated block for the noise NRJ. */
    u8 noise_nrj_blk_count;
    /** Mean count. */
    u32 mean_count;
    /** Get SNR for statistics for the CP. */
    bool get_snr;
} ce_rx_bitloading_t;

BEGIN_DECLS

/**
 * Initialize bit-loading data.
 * \param  bt  the bit-loading data & state structure.
 * @note the structure must be already allocated.
 */
extern inline void
ce_rx_bitloading_init (ce_rx_bitloading_t *bt)
{
    /* Check parameter. */
    dbg_assert (bt);
    /* Initialize. */
    bt->fsm = 0;
    bt->noise_nrj_blk_count = 0;
    bt->noise_nrj = NULL;
    bt->get_snr = false;
}

/**
 * Un-initialize bit-loading data.
 * \param  bt  the bit-loading data & state structure.
 * @note this function does not delete the structure itself, just clean the
 * structure.
 */
extern inline void
ce_rx_bitloading_uninit (ce_rx_bitloading_t *bt)
{
    /* Check parameter. */
    dbg_assert (bt);
    /* Clean if needed. */
    if (bt->noise_nrj_blk_count)
    {
        blk_release_desc_range_nb (bt->noise_nrj, bt->noise_nrj_blk_count);
        bt->noise_nrj_blk_count = 0;
        bt->noise_nrj = NULL;
    }
    /* Letting the FSM in its current state. */
}

END_DECLS

#endif /* ce_rx_bitloading_bitloading_h */