summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/spoc/spoc.h
blob: 5cc7e19ce18a10d548b3f96e2ef745f506d73ef0 (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
#ifndef hal_phy_spoc_spoc_h
#define hal_phy_spoc_spoc_h
/* Cesar project {{{
 *
 * Copyright (C) 2009 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hal/phy/spoc/spoc.h
 * \brief   SPOC public interface.
 * \ingroup hal_phy
 */
#include "hal/phy/phy.h"

/** M matrix coefficients number. */
#define PHY_SPOC_M_MATRIX_COEF_NB 41

/** CG vector coefficients numbers. */
#define PHY_SPOC_CG_VECTOR_COEF_NB 21

/** SPOC coefficients first part, fit in a 512 byte block. */
struct phy_spoc_coeff_t
{
    /** Frequency error, Q30 format. */
    s32 rho_q30;
    /** TX M matrix alpha coefficients. */
    s32 tx_alpha[PHY_SPOC_M_MATRIX_COEF_NB];
    /** TX M matrix beta coefficients. */
    s32 tx_beta[PHY_SPOC_M_MATRIX_COEF_NB];
    /** CG vector PR1 coefficients. */
    s32 tx_prebegin[PHY_SPOC_CG_VECTOR_COEF_NB];
    /** CG vector PR2 coefficients. */
    s32 tx_preend[PHY_SPOC_CG_VECTOR_COEF_NB];
    /** Pointer to second part. */
    struct phy_spoc_coeff_part2_t *part2;
};
typedef struct phy_spoc_coeff_t phy_spoc_coeff_t;

/** SPOC coefficients second part, fit in a 512 byte block. */
struct phy_spoc_coeff_part2_t
{
    /** CG vector FC 1.0 coefficients. */
    s32 tx_fc10[PHY_SPOC_CG_VECTOR_COEF_NB];
    /** CG vector FC AV coefficients. */
    s32 tx_av[PHY_SPOC_CG_VECTOR_COEF_NB];
    /** Rho inverse. */
    s32 rx_inv_rho;
    /** RX M matrix alpha coefficients. */
    s32 rx_alpha[PHY_SPOC_M_MATRIX_COEF_NB];
    /** RX M matrix beta coefficients. */
    s32 rx_beta[PHY_SPOC_M_MATRIX_COEF_NB];
};
typedef struct phy_spoc_coeff_part2_t phy_spoc_coeff_part2_t;

BEGIN_DECLS

/**
 * Compute CG vector for the given alpha factor.
 * \param  rho_q30  frequency error, Q30 format
 * \param  alpha  the alpha factor
 * \param  cg_vector  CG vector result
 */
void
phy_spoc_compute_cg_vector (s32 rho_q30, int alpha, s32 *cg_vector);

/**
 * Compute SPOC M matrix approximation coefficients.
 * \param  rho_q30  frequency error, Q30 format
 * \param  reg_alpha  alpha coefficients result
 * \param  reg_beta  beta coefficients result
 */
void
phy_spoc_compute_m_matrix (s32 rho_q30, s32 *reg_alpha, s32 *reg_beta);

/**
 * Compute all SPOC coefficients.
 * \param  rho_q30  frequency error, Q30 format
 * \param  coeff  coefficients structure
 */
void
phy_spoc_compute_all (s32 rho_q30, phy_spoc_coeff_t *coeff);

/**
 * Initialise SPOC initial state.
 * \param  ctx  phy context
 * \param  rho_q30  initial frequency error, Q30 format
 */
void
phy_spoc_init (phy_t *ctx, s32 rho_q30);

/**
 * Set SPOC coefficients for TX.
 * \param  ctx  phy context
 * \param  coeff  coefficients structure
 *
 * PRS and preamble should be regenerated before next TX (this is less
 * important for PRS).
 */
void
phy_spoc_tx_set (phy_t *ctx, phy_spoc_coeff_t *coeff);

/**
 * Set SPOC coefficients for RX.
 * \param  ctx  phy context
 * \param  coeff  coefficients structure
 */
void
phy_spoc_rx_set (phy_t *ctx, phy_spoc_coeff_t *coeff);

END_DECLS

#endif /* hal_phy_spoc_spoc_h */