138 lines
9.0 KiB
C
138 lines
9.0 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
#include "os_types.h"
|
|
#include "phy_math_tb.h"
|
|
#include "phy_bb.h"
|
|
|
|
const uint16_t phy_alpha_cal_tbl[] = {
|
|
32767, 32767, 32767, 32768, 32768, 32769, 32769, 32770,
|
|
32771, 32773, 32774, 32775, 32777, 32779, 32780, 32782,
|
|
32785, 32787, 32789, 32792, 32794, 32797, 32800, 32803,
|
|
32806, 32810, 32813, 32817, 32821, 32825, 32829, 32833,
|
|
32837, 32842, 32846, 32851, 32856, 32861, 32866, 32871,
|
|
32877, 32882, 32888, 32894, 32900, 32906, 32912, 32918,
|
|
32925, 32931, 32938, 32945, 32952, 32959, 32967, 32974,
|
|
32982, 32989, 32997, 33005, 33013, 33022, 33030, 33039,
|
|
33047, 33056, 33065, 33074, 33083, 33093, 33102, 33112,
|
|
33122, 33132, 33142, 33152, 33162, 33173, 33183, 33194,
|
|
33205, 33216, 33227, 33238, 33249, 33261, 33273, 33284,
|
|
33296, 33308, 33321, 33333, 33345, 33358, 33371, 33384,
|
|
33397, 33410, 33423, 33436, 33450, 33464, 33477, 33491,
|
|
33506, 33520, 33534, 33549, 33563, 33578, 33593, 33608,
|
|
33623, 33638, 33654, 33669, 33685, 33701, 33717, 33733,
|
|
33749, 33765, 33782, 33798, 33815, 33832, 33849, 33866,
|
|
33884, 33901, 33918, 33936, 33954, 33972, 33990, 34008,
|
|
34027, 34045, 34064, 34082, 34101, 34120, 34139, 34159,
|
|
34178, 34197, 34217, 34237, 34257, 34277, 34297, 34317,
|
|
34338, 34358, 34379, 34400, 34421, 34442, 34463, 34485,
|
|
34506, 34528, 34549, 34571, 34593, 34615, 34638, 34660,
|
|
34682, 34705, 34728, 34751, 34774, 34797, 34820, 34844,
|
|
34867, 34891, 34915, 34939, 34963, 34987, 35011, 35036,
|
|
35060, 35085, 35110, 35135, 35160, 35185, 35210, 35236,
|
|
35261, 35287, 35313, 35339, 35365, 35391, 35417, 35444,
|
|
35471, 35497, 35524, 35551, 35578, 35605, 35633, 35660,
|
|
35688, 35716, 35743, 35771, 35799, 35828, 35856, 35884,
|
|
35913, 35942, 35971, 36000, 36029, 36058, 36087, 36117,
|
|
36146, 36176, 36206, 36236, 36266, 36296, 36326, 36357,
|
|
36387, 36418, 36449, 36480, 36511, 36542, 36573, 36605,
|
|
36636, 36668, 36700, 36732, 36764, 36796, 36828, 36860,
|
|
36893, 36925, 36958, 36991, 37024, 37057, 37090, 37124,
|
|
37157, 37191, 37224, 37258, 37292, 37326, 37360, 37395,
|
|
37429, 37463, 37498, 37533, 37568, 37603, 37638, 37673,
|
|
37708, 37744, 37779, 37815, 37851, 37887, 37923, 37959,
|
|
37995, 38032, 38068, 38105, 38141, 38178, 38215, 38252,
|
|
38289, 38327, 38364, 38402, 38439, 38477, 38515, 38553,
|
|
38591, 38629, 38667, 38706, 38744, 38783, 38822, 38861,
|
|
38900, 38939, 38978, 39017, 39057, 39096, 39136, 39176,
|
|
39215, 39255, 39296, 39336, 39376, 39416, 39457, 39498,
|
|
39538, 39579, 39620, 39661, 39702, 39744, 39785, 39827,
|
|
39868, 39910, 39952, 39994, 40036, 40078, 40120, 40163,
|
|
40205, 40248, 40290, 40333, 40376, 40419, 40462, 40505,
|
|
40549, 40592, 40635, 40679, 40723, 40767, 40811, 40855,
|
|
40899, 40943, 40987, 41032, 41076, 41121, 41166, 41211,
|
|
41256, 41301, 41346, 41391, 41436, 41482, 41527, 41573,
|
|
41619, 41665, 41711, 41757, 41803, 41849, 41895, 41942,
|
|
41989, 42035, 42082, 42129, 42176, 42223, 42270, 42317,
|
|
42365, 42412, 42460, 42507, 42555, 42603, 42651, 42699,
|
|
42747, 42795, 42843, 42892, 42940, 42989, 43037, 43086,
|
|
43135, 43184, 43233, 43282, 43331, 43381, 43430, 43480,
|
|
43529, 43579, 43629, 43679, 43729, 43779, 43829, 43879,
|
|
43930, 43980, 44031, 44081, 44132, 44183, 44234, 44284,
|
|
44336, 44387, 44438, 44489, 44541, 44592, 44644, 44695,
|
|
44747, 44799, 44851, 44903, 44955, 45007, 45060, 45112,
|
|
45164, 45217, 45270, 45322, 45375, 45428, 45481, 45534,
|
|
45587, 45640, 45694, 45747, 45800, 45854, 45908, 45961,
|
|
46015, 46069, 46123, 46177, 46231, 46285, 46340, 46394,
|
|
46448, 46503, 46557, 46612, 46667, 46722, 46777, 46832,
|
|
46887, 46942, 46997, 47052, 47108, 47163, 47219, 47274,
|
|
47330, 47386, 47442, 47498, 47554, 47610, 47666, 47722,
|
|
47778, 47835, 47891, 47948, 48004, 48061, 48118, 48174,
|
|
48231, 48288, 48345, 48402, 48460, 48517, 48574, 48631,
|
|
48689, 48746, 48804, 48862, 48919, 48977, 49035, 49093,
|
|
49151, 49209, 49267, 49325, 49384, 49442, 49500, 49559,
|
|
49618, 49676, 49735, 49794, 49852, 49911, 49970, 50029,
|
|
50088, 50147, 50207, 50266, 50325, 50385, 50444, 50504,
|
|
50563, 50623, 50683, 50742, 50802, 50862, 50922, 50982,
|
|
51042, 51102, 51162, 51223, 51283, 51343, 51404, 51464,
|
|
51525, 51585, 51646, 51707, 51768, 51829, 51889, 51950,
|
|
52011, 52072, 52134, 52195, 52256, 52317, 52379, 52440,
|
|
52502, 52563, 52625, 52686, 52748, 52810, 52871, 52933,
|
|
52995, 53057, 53119, 53181, 53243, 53305, 53368, 53430,
|
|
53492, 53555, 53617, 53679, 53742, 53805, 53867, 53930,
|
|
53992, 54055, 54118, 54181, 54244, 54307, 54370, 54433,
|
|
54496, 54559, 54622, 54685, 54749, 54812, 54875, 54939,
|
|
55002, 55066, 55129, 55193, 55256, 55320, 55384, 55447,
|
|
55511, 55575, 55639, 55703, 55767, 55831, 55895, 55959,
|
|
56023, 56087, 56151, 56216, 56280, 56344, 56408, 56473,
|
|
56537, 56602, 56666, 56731, 56795, 56860, 56925, 56989,
|
|
57054, 57119, 57184, 57248, 57313, 57378, 57443, 57508,
|
|
57573, 57638, 57703, 57768, 57833, 57898, 57964, 58029,
|
|
58094, 58159, 58225, 58290, 58355, 58421, 58486, 58552,
|
|
58617, 58683, 58748, 58814, 58880, 58945, 59011, 59077,
|
|
59142, 59208, 59274, 59340, 59405, 59471, 59537, 59603,
|
|
59669, 59735, 59801, 59867, 59933, 59999, 60065, 60131,
|
|
60197, 60263, 60330, 60396, 60462, 60528, 60594, 60661,
|
|
60727, 60793, 60860, 60926, 60992, 61059, 61125, 61191,
|
|
61258, 61324, 61391, 61457, 61524, 61590, 61657, 61723,
|
|
61790, 61857, 61923, 61990, 62056, 62123, 62190, 62256,
|
|
62323, 62390, 62457, 62523, 62590, 62657, 62724, 62790,
|
|
62857, 62924, 62991, 63058, 63124, 63191, 63258, 63325,
|
|
63392, 63459, 63526, 63593, 63659, 63726, 63793, 63860,
|
|
63927, 63994, 64061, 64128, 64195, 64262, 64329, 64396,
|
|
64463, 64530, 64597, 64664, 64731, 64798, 64865, 64932,
|
|
64999, 65066, 65133, 65200, 65267, 65334, 65401, 65468,
|
|
65535,
|
|
};
|
|
|
|
/*
|
|
* -32768*cos(2*pi*fk./fs) + 65535
|
|
*/
|
|
uint16_t phy_alpha_cal(uint16_t tone_num)
|
|
{
|
|
uint16_t alpha_val = 0;
|
|
uint16_t cnt = IOT_ARRAY_CNT(phy_alpha_cal_tbl);
|
|
uint16_t tbl_max = 2 * (cnt - 1);
|
|
/* check valid */
|
|
IOT_ASSERT(tone_num < tbl_max);
|
|
|
|
if (tone_num >= cnt) {
|
|
alpha_val = PHY_ALPHA_MAX - phy_alpha_cal_tbl[tbl_max - tone_num];
|
|
} else {
|
|
alpha_val = phy_alpha_cal_tbl[tone_num];
|
|
}
|
|
|
|
return alpha_val;
|
|
}
|