summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/defs.h
blob: 40e3234013605cc923e1186fea433a3beda88493 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#ifndef hal_phy_defs_h
#define hal_phy_defs_h
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hal/phy/defs.h
 * \brief   HAL Phy types and defines.
 * \ingroup hal_phy
 */

/** DSP clock is supposed to be 150 MHz, but it is 75 MHz on prototype. */
#include "common/module.h"
#if defined (__sparc__) && MODULE_INCLUDED (hal_phy)
# include "config/phy/dsp.h"
# define PHY_DSP_CLOCK_MHZ (CONFIG_PHY_DSP_150MHZ ? 150 : 75)
#else
# define PHY_DSP_CLOCK_MHZ 150
#endif

/** Number of OFDM carrier, defined by the hardware. */
#define PHY_CARRIER_NB 1155

/** Number of first OFDM carrier, defined by the hardware. */
#define PHY_CARRIER_OFFSET 74

/** Carrier min and max used. */
#define PHY_CARRIER_MIN PHY_CARRIER_OFFSET
#define PHY_CARRIER_MAX (PHY_CARRIER_OFFSET + PHY_CARRIER_NB - 1)

/** Total number of OFDM carrier, also counting unusable ones. */
#define PHY_ALL_CARRIER_NB 1536

/** Number of OFDM carrier for HP10, defined by the hardware. */
#define PHY_HP10_CARRIER_NB 144

/** Number of first OFDM carrier for HP10, defined by the hardware. */
#define PHY_HP10_CARRIER_OFFSET 10

/** Number of words needed to define a tonemask. */
#define PHY_TONEMASK_WORDS ((PHY_CARRIER_NB + 32 - 1) / 32)

/** Number of bytes needed to define a tonemask. */
#define PHY_TONEMASK_SIZE (PHY_TONEMASK_WORDS * 4)

/** Number of words needed to define a tonemap. */
#define PHY_TONEMAP_WORDS ((PHY_CARRIER_NB + 8 - 1) / 8)

/** Number of bytes needed to define a tonemap. */
#define PHY_TONEMAP_SIZE (PHY_TONEMAP_WORDS * 4)

/** Delay to detect a preamble, defined by the hardware, not precise. */
#if defined (__sparc__)
# define PHY_PREAMBLE_DETECTION_DELAY_TCK ((192 + 9 * 384) / 3)
#else
# define PHY_PREAMBLE_DETECTION_DELAY_TCK (20 * 25)
#endif

/** Delay for FC 1.0 preparation.
 * 7900: FC 1.0 creation cycles.
 * 1600: last FC 1.0 IFFT cycles.
 * 1152: hybrid preamble.
 * 372: preamble/FC overlapping. */
#define PHY_FC_10_PREPARATION_DELAY_TCK \
    (((7900 + 1600) / (PHY_DSP_CLOCK_MHZ / 25)) - 1152 + 372 / 3 + 1)

/** Delay for MAFADESE start. */
#define PHY_START_MAFADESE_DELAY_TCK (1400 / 3)

/** Noise energy type.*/
typedef unsigned int phy_noise_energy_t;

/** Spectrum type.*/
typedef unsigned int phy_spectrum_t;

/** Number of noise storable in a block */
#define PHY_NOISE_NB_PER_BLK (BLK_SIZE/(sizeof(phy_noise_energy_t)))

/** Number of spectrum storable in a block */
#define PHY_SPECTRUM_NB_PER_BLK (BLK_SIZE/(sizeof(phy_spectrum_t)))

/** Modulation mode. */
enum phy_mod_t
{
    PHY_MOD_ROBO,       /*< ROBO mode. */
    PHY_MOD_HS_ROBO,    /*< HIGH-SPEED ROBO mode. */
    PHY_MOD_MINI_ROBO,  /*< MINI ROBO mode. */
    PHY_MOD_TM,         /*< Tone map modulation. */
    PHY_MOD_NONE,       /*< Invalid mode. */
    PHY_MOD_ROBO_NB = PHY_MOD_TM, /*< Number of ROBO modes. */
};
typedef enum phy_mod_t phy_mod_t;

/** Forward Error Correction puncturing rate. */
enum phy_fecrate_t
{
    PHY_FEC_RATE_1_2,   /*< FEC rate 1/2. */
    PHY_FEC_RATE_16_21, /*< FEC rate 16/21. */
    PHY_FEC_RATE_NONE,   /*< Invalid FEC rate. */
    PHY_FEC_RATE_NB = PHY_FEC_RATE_NONE /*< Number of FEC Fate. */
};
typedef enum phy_fecrate_t phy_fecrate_t;

/** PB size. */
enum phy_pb_size_t
{
    PHY_PB_SIZE_136,    /*< PB size 136 bytes, only one PB. */
    PHY_PB_SIZE_520,    /*< PB size 520 bytes. */
    PHY_PB_SIZE_NONE    /*< Invalid PB size. */
};
typedef enum phy_pb_size_t phy_pb_size_t;

/** FC mode. */
enum phy_fc_mode_t
{
    PHY_FC_MODE_HYBRID_1,       /*< Hybrid FC, 1 symbol. */
    PHY_FC_MODE_HYBRID_2,       /*< Hybrid FC, 2 symbol. */
    PHY_FC_MODE_AV_1,           /*< AV FC, 1 symbol. */
    PHY_FC_MODE_AV_2,           /*< AV FC, 2 symbol. */
    PHY_FC_MODE_NB,             /*< Number of defined FC mode. */
    PHY_FC_MODE_NONE = PHY_FC_MODE_NB   /*< Invalid FC mode. */
};
typedef enum phy_fc_mode_t phy_fc_mode_t;

/** Is it a hybrid mode. */
#define PHY_FC_MODE_IS_HYBRID(m) (!((m) & 0x2))

/** Is there two symbols. */
#define PHY_FC_MODE_IS_TWO_SYMBOLS(m) ((m) & 0x1)

/** Make FC mode. */
#define PHY_FC_MODE(hybrid, fc_symb_nb) (((hybrid) ? 0 : 2) \
                                         | ((fc_symb_nb == 1) ? 0 : 1))

/** Guard interval length. */
enum phy_gil_t
{
    PHY_GIL_417,        /*< Guard interval 417 samples. */
    PHY_GIL_567,        /*< Guard interval 567 samples. */
    PHY_GIL_3534,       /*< Guard interval 3534 samples. */
    PHY_GIL_NB,         /*< Number of defined guard intervals. */
    PHY_GIL_NONE = PHY_GIL_NB   /*< Invalid guard interval. */
};
typedef enum phy_gil_t phy_gil_t;

/** Build combo parameters for phy_tx_param and phy_rx_prepare family
 * functions. */
#define PHY_COMBO_PARAMS(mod, fecrate, pb_size) \
    BF_FILL (PHY_COMBO_PARAMS, (MOD, (mod)), (FECRATE, (fecrate)), \
             (PB_SIZE, (pb_size)))
#define PHY_COMBO_PARAMS__MOD 3, 2
#define PHY_COMBO_PARAMS__FECRATE 1, 1
#define PHY_COMBO_PARAMS__PB_SIZE 0, 0

#endif /* hal_phy_defs_h */