summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/defs.h
blob: 362fe3bbb575fa41cac78fd77c24e836749caffb (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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#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 AV carriers per HP10 carrier. */
#define PHY_HP10_CARRIER_FACTOR 8

/** Number of OFDM carrier for HP10. */
#define PHY_HP10_CARRIER_NB \
    ((PHY_CARRIER_OFFSET + PHY_CARRIER_NB - 1) / PHY_HP10_CARRIER_FACTOR \
     - PHY_HP10_CARRIER_OFFSET + 1)

/** Number of first OFDM carrier for HP10. */
#define PHY_HP10_CARRIER_OFFSET \
    CEIL_DIV (PHY_CARRIER_OFFSET, PHY_HP10_CARRIER_FACTOR)

/** 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)

/** Number of words in HP10 extended tonemask. */
#define PHY_HP10_TONEMASK_WORDS 6

/** Delay to find a preamble, defined by the hardware, not precise.
 * At this time, we got confirmation from HW.
 * False alarm is not possible anymore. */
#define PHY_PREAMBLE_CONFIRMATION_DELAY_TCK ((192 + 9 * 384) / 3)

/** 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)

/** Hardware delay after short MPDU to activate RX again. */
#define PHY_RX_ACTIVATE_DELAY_AFTER_SHORT_TCK (60 * 25)

/** Hardware delay after RX BURST MPDU BIFS to activate RX again. */
#define PHY_RX_ACTIVATE_DELAY_AFTER_BURST_TCK (0 * 25)

/** Hardware delay for RX between sample on medium and DSP analysis. */
#define PHY_RX_HARDWARE_DELAY_TCK (12 + 3)

/** Hardware delay for TX between start command and first sample on medium. */
#define PHY_TX_HARDWARE_DELAY_TCK (54 / 3 + 8)

/** Hardware delay for PRP TX between start command and first sample on
 * medium. */
#define PHY_PRP_HARDWARE_DELAY_TCK (14 / 3 + 8)

/** Hardware delay for preamble or PRS creation, include a margin for software
 * execution. */
#define PHY_PREPARE_DELAY_TCK (90 * 25)

/** 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

/** Combo parameters for want_conf & stop_tx_on_prp_lost. */
#define PHY_WANT_CONF 2
#define PHY_STOP_ON_PRP_LOST 1

/** Events. */
enum phy_event_t
{
    PHY_EVENT_RX_FC = 1,
    PHY_EVENT_ACCESS = 2,
    PHY_EVENT_ACCESS_CONF = 4,
    PHY_EVENT_PBDMA = 8,
};
typedef enum phy_event_t phy_event_t;

#endif /* hal_phy_defs_h */