📄 wib_dl_source_gen.c
字号:
*(p_dlul_map + dlul_map_len) = (UINT8)(*p_ul_cdma_ranging + 3); // Number of subchannels[4:0], Ranging method[1:0], Dedicated ranging indicator
/* All bytes shift left 4bits */
*(p_dlul_map + dlul_map_len - 7) = (UINT8)(*(p_dlul_map + dlul_map_len - 7) >> 4);
for(l = 0; l < 8; l++){
*(p_dlul_map + dlul_map_len - 7 + l) = (UINT8)(((*(p_dlul_map + dlul_map_len - 7 + l)) << 4)
| ((*(p_dlul_map + dlul_map_len - 6 + l)) >> 4));
}
/* All bytes after CID shift left 4bits */
*(p_dlul_map + dlul_map_len - 5) = (UINT8)(*(p_dlul_map + dlul_map_len - 5) >> 4);
for(l = 0; l < 5; l++){
*(p_dlul_map + dlul_map_len - 5 + l) = (UINT8)(((*(p_dlul_map + dlul_map_len - 5 + l)) << 4)
| ((*(p_dlul_map + dlul_map_len - 4 + l)) >> 4));
}
byte_align_flag = 0;
}
}
/* Normal Data burst */
else if(ul_burst_type == 7){
/****************************** Insert UL_MAP BURST IE ********************************/
/* reflect FEC type to UIUC */
fec_code_type_bst = ul_subframe_tx->zone[i].burst[j].fec_code_type;
uiuc_bst = (UINT16)fec_code_uiuc((UINT8)fec_code_type_bst);
/* assign UL_MAP BURST IE Content */
ul_burst_profile.cid = ul_subframe_tx->zone[i].burst[j].cid_burst; // CID
ul_burst_profile.uiuc = uiuc_bst; // UIUC = 1~10 to indicate different burst profiles
ul_burst_profile.duration = ul_subframe_tx->zone[i].burst[j].number_of_slot_remain; // Duration in OFDMA slots
ul_burst_profile.repet_cod = ul_subframe_tx->zone[i].burst[j].repetition_coding; // Repetition coding indication
/* get the address of UL_MAP BURST IE */
p_ul_burst_profile = (UINT8*)(&ul_burst_profile);
/* if current last byte is aligned to byte */
if(byte_align_flag == 0){
*(p_dlul_map + dlul_map_len) = (UINT8)(*p_ul_burst_profile + 1); // CID[15:8]
dlul_map_len++;
*(p_dlul_map + dlul_map_len) = (UINT8)(*p_ul_burst_profile); // CID[7:0]
dlul_map_len++;
*(p_dlul_map + dlul_map_len) = (UINT8)(*p_ul_burst_profile + 3); // UIUC, Duration[9:6]
dlul_map_len++;
*(p_dlul_map + dlul_map_len) = (UINT8)(*p_ul_burst_profile + 2); // Duration[5:0], Repetition coding[1:0]
dlul_map_len++;
/* if current last byte is not aligned to byte */
else if(byte_align_flag == 1){
dlul_map_len++;
*(p_dlul_map + dlul_map_len) = (UINT8)(*p_ul_burst_profile + 1); // CID[15:8]
dlul_map_len++;
*(p_dlul_map + dlul_map_len) = (UINT8)(*p_ul_burst_profile); // CID[7:0]
dlul_map_len++;
*(p_dlul_map + dlul_map_len) = (UINT8)(*p_ul_burst_profile + 3); // UIUC, Duration[9:6]
dlul_map_len++;
*(p_dlul_map + dlul_map_len) = (UINT8)(*p_ul_burst_profile + 2); // Duration[5:0], Repetition coding[1:0]
/* All bytes shift left 4bits */
*(p_dlul_map + dlul_map_len - 4) = (UINT8)(*(p_dlul_map + dlul_map_len - 4) >> 4);
for(l = 0; l < 5; l++){
*(p_dlul_map + dlul_map_len - 4 + l) = (UINT8)(((*(p_dlul_map + dlul_map_len - 4 + l)) << 4)
| ((*(p_dlul_map + dlul_map_len - 3 + l)) >> 4));
}
}
}
/* padding the SUB-DL-UL-MAP message to Byte*/
if (byte_align_flag == 1){ // If the last byte of SUB-DL-UL-MAP message is not align to byte,should add 4 bits 0 as padding
*(p_dlul_map + dlul_map_len) = ((*(p_dlul_map + dlul_map_len)) & 0xf0);
dlul_map_len++;
/* set the align to byte flag */
byte_align_flag = 0;
}
/*
//* get SUB-DL-UL-MAP message length in bytes/
sub_map_len = dlul_map_len;
sub_map_len = sub_map_len - comp_map_len;
for(i = 0; i < sub_map_len; i++){
*(p_sub_map + i) = *(p_dlul_map + comp_map_len + i);
}
sub_map_crc16 = dl_crc16(p_sub_map,sub_map_len);
*(p_dlul_map + dlul_map_len) = (UINT8)((sub_map_crc16 >> 8) & 0xff);
dlul_map_len++;
*(p_dlul_map + dlul_map_len) = (UINT8)(sub_map_crc16 & 0xff);
dlul_map_len++;
sub_map_len = sub_map_len + 2;
*/
/* return the dlul_map length */
*dlul_map_length = dlul_map_len;
printf("the length of MAP Message is : %04x\n",*dlul_map_length);
/*********************** compute the slot length of SUB-DL-UL-MAP Message ***********************/
/* compute the slot length before repetition code */
if((*dlul_map_length % slot_len_qpsk_1_2) == 0){
slot_num_dlul_map = *dlul_map_length / slot_len_qpsk_1_2;
}
else{
slot_num_dlul_map = (*dlul_map_length / slot_len_qpsk_1_2) + 1;
}
/* compute the slot length after repetition code */
if (dl_subframe_tx->zone[0].burst[0].repetition_coding == 0)
{
dl_subframe_tx->zone[0].burst[0].number_of_slot = slot_num_dlul_map;
}
else
{
dl_subframe_tx->zone[0].burst[0].number_of_slot = slot_num_dlul_map * dl_subframe_tx->zone[0].burst[0].repetition_coding * 2;
}
/* compute the slot number of a symbol of zone# 0*/
slot_num_sym_zone0 = 0;
for (i = 0; i< 6; i++)
{
if (i % 2 == 0) // Each group have 6 subchannles
{
slot_num_sym_zone0 = slot_num_sym_zone0 + (dl_subframe_tx->bit_map[i] * 6);
}
else // Each group have 4 subchannles
{
slot_num_sym_zone0 = slot_num_sym_zone0 + (dl_subframe_tx->bit_map[i] * 4);
}
}
printf("slot num of dlul_map is :%d \n",dl_subframe_tx->zone[0].burst[0].number_of_slot);
/* compute the symbol number zone# 0*/
if (((dl_subframe_tx->zone[0].burst[0].number_of_slot + 4) % slot_num_sym_zone0) == 0)
{
number_of_symbol_dlulmap = ((dl_subframe_tx->zone[0].burst[0].number_of_slot + 4) / slot_num_sym_zone0);
}
else
{
number_of_symbol_dlulmap = ((dl_subframe_tx->zone[0].burst[0].number_of_slot + 4) / slot_num_sym_zone0) + 1;
}
if (number_of_symbol_dlulmap > (dl_subframe_tx->zone[0].end_symbol_offset - 1))
{
printf("\n <<<< Error : the symbol number of ZONE# 0 is not enough to MAP Message! \n");
printf(" The required symbol of ZONE# 0 is %2d \n",number_of_symbol_dlulmap);
printf(" But You only assigned %2d symbol to ZONE# 0 \n\n",(dl_subframe_tx->zone[0].end_symbol_offset - 1));
// exit(0);
}
/*
for(i = 0; i < 137; i++){
printf("%02x ",*(p_dlul_map + i));
if(i == 5 | i == 18 | i == 24 | i == 46 | i == 52 | i == 75 | i == 80 | i == 103 | i == 109 | i == 118){
printf("\n ");
}
}
*/
return 1;
};
/* generate FCH */
int gen_fch(
DL_SUBFRAME_STRUCT *p_dl_subframe_tx,
UINT8 *p_fch
)
{
/*
***************************************************************************************
* basic parameter definition
***************************************************************************************
*/
FCH_IE fch; // FCH
UINT8 *p_fch_content;
UINT16 bit_map_fch[6];
UINT8 fch_fec_code_type;
UINT16 i,j,a;
/*
***************************************************************************************
* function definition
***************************************************************************************
*/
/* get other FCH basic parameter from dl subframe descriptor */
fch.bit_map = 0;
for (i = 0; i < 6; i++)
{
bit_map_fch[i] = p_dl_subframe_tx->bit_map[i];
a = 1;
for (j = 0; j < i; j++)
{
a = a * 2;
}
fch.bit_map = fch.bit_map + a * bit_map_fch[i];
}
/* get the repetition code of DL-MAP */
fch.repet_cod = p_dl_subframe_tx->zone[0].burst[0].repetition_coding;
/* get the Coding indication of FCH */
fch_fec_code_type = (UINT8)(p_dl_subframe_tx->zone[0].burst[0].fec_code_type); // DL-MAP is defined in first burst of first dl zone
if (fch_fec_code_type <= 6)
{
fch.coding_indic = 0; //CC encoding used on DL-MAP
}
else
{
fch.coding_indic = 2; //CTC encoding used on DL-MAP
}
/* compute the slot length after repetition code */
fch.map_len = p_dl_subframe_tx->zone[0].burst[0].number_of_slot;
fch.reserved1 = 0;
fch.reserved2 = 0;
fch.byte_align = 0;
/*************************************** generate FCH ****************************************/
/* generate FCH */
p_fch_content = (UINT8*)(&fch);
*p_fch = (UINT8)(*(p_fch_content + 3));
*(p_fch + 1) = (UINT8)(*(p_fch_content + 2));
*(p_fch + 2) = (UINT8)(*(p_fch_content + 1));
return(1);
}
/* generate source data */
int gen_source_data (
DL_SUBFRAME_STRUCT *p_dl_subframe_tx, // DL frame descriptor
UINT8 *p_fch, // FCH data
UINT8 *p_dlul_map, // DL-MAP data
UINT16 *dlul_map_length, // DL-MAP data length in bytes
UINT8 *p_source_data, // DL subframe source data
UINT32 *source_data_len // DL subframe source data length in bytes
)
{
/*
***************************************************************************************
* basic parameter definition
***************************************************************************************
*/
UINT16 data_type_source;
UINT32 data_len_source;
/* frame parameter */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -