⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 radio_ics_bs.c

📁 软件无线电的平台
💻 C
字号:
/***************************************************************************               radio_ics_bs.c  -  SRadio simple bs                            -------------------    begin                :  02/10/30    authors              :  Linus Gasser    emails               :  linus.gasser@epfl.ch ***************************************************************************//***************************************************************************                                 Changes                                 ------- date - name - description 02/10/30 - ineiti - begin 02/11/04 - ineiti - no msgqs... 03/02/27 - ineiti - simplified to only two slots: BCH and RACH 03/03/19 - ineiti - added SCH and gain-control 04/04/08 - ineiti - adjusted offset_samples_send to 0  **************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************//** * Make a simple BS * * Function: * - emit sync * - listen to RACh */#include "system.h"#include "sdb.h"#include "stfa.h"#include "antenna.h"#include "std.h"#include "debugging.h"#include "../radio_ics.h"#include "chain.h"#include "spc.h"#define DBG_LVL 4#define DATA_LEN 4096swr_sdb_id stfa[NO_TX];struct chain_t *ch_bch, *ch_supp[NO_TX];int looping, delay;/* * Synchronisation chain */void setup_synch( void ){  swr_sdb_id mod, sch, rrc_send;  PR( "Setting up BCh on slot 0\n" );  ch_bch = swr_chain_create(             NEW_SPC_VAR( "sch_send", sch ),             NEW_SPC_VAR( "mapper", mod ),             NEW_SPC( "spread" ),             NEW_SPC( "chest_send" ),             NEW_SPC( "synch_send" ),             NEW_SPC_VAR( "rrc_complex_send", rrc_send ),             OLD_SPC_IN( stfa[0], 0 ),             CHAIN_END );  swr_stfa_notice_sdb( stfa[0], 0, sch );  swr_sdb_set_config_int( rrc_send, "rrc_index", 2 );  swr_sdb_set_config_int( sch, "id0", 0x1234 );  swr_sdb_set_config_int( sch, "uplinks0", 2 );   //swr_sdb_set_config_int( stfa[0], "tx", 1 );  //swr_sdb_set_config_int( stfa[0], "freq", 2380 );  //swr_sdb_set_config_int( stfa[0], "attn_tx", 20 );}/* * LDPC-chain */void setup_ldpc( void ){  int a;  swr_sdb_id rand_u8, encoder, rrc_send[NO_TX],    mapper, chest_send[NO_TX], split;  PR( "Setting up an LDPC-chain\n" );  ch_supp[0] = swr_chain_create(				NEW_SPC_VAR( "random", rand_u8 ),				NEW_SPC_VAR( "ldpc_encode_2fold", encoder ),				NEW_SPC_VAR( "mapper", mapper ),				NEW_SPC_VAR( "split", split ),				NEW_SPC_VAR( "chest_send", chest_send[0] ),				NEW_SPC_VAR( "rrc_complex_send", rrc_send[0] ),				OLD_SPC_IN( stfa[0], 2 ),				CHAIN_END );    swr_sdb_set_config_int( rrc_send[0], "rrc_index", 2 );    swr_sdb_set_config_int( rand_u8, "mode", 1 );  swr_sdb_set_config_int( rand_u8, "seed", 0x1234 );  // 2fold encoder settings....  swr_sdb_set_config_int( encoder, "bplcn", NO_TX * 2 );  swr_sdb_set_config_int( encoder, "ldpc_code_id", 1 );    // The other transmitting LDPC chains....  for ( a=1; a<NO_TX; a++ ){    ch_supp[a] = swr_chain_create(				  OLD_SPC_OUT( split, a ),				  NEW_SPC_VAR( "chest_send", chest_send[a] ),				  NEW_SPC_VAR( "rrc_complex_send", rrc_send[a] ),				  OLD_SPC_IN( stfa[a], 2 ),				  CHAIN_END );    swr_sdb_set_config_int( chest_send[a], "index", a );     swr_sdb_set_config_int( rrc_send[a], "rrc_index", 2 );  }  swr_stfa_notice_sdb( stfa[0], 2, rand_u8 );}void *start_it( void *arg ) {  int i;  looping = 1;  usleep( 100000 );  PR( "Init STFA\n" );  stfa[0] = swr_sdb_instantiate_name( "stfa_ics" );  for ( i=1; i<NO_TX; i++ ){    stfa[i] = swr_sdb_instantiate_name( "stfa_ics" );    swr_sdb_set_config_int( stfa[i-1], "stfa_id", stfa[i] );  }  PR( "Initialized STFA\n" );  swr_sdb_set_config_int( stfa[0], "slots_per_frame", SLOTS );  swr_sdb_set_config_int( stfa[0], "blocks_per_slot", SLOT_LEN );  swr_sdb_set_config_int( stfa[0], "slot_send_offset", SLOT_OFFSET );  swr_sdb_set_config_int( stfa[0], "tx", 1 );  swr_sdb_set_config_int( stfa[0], "freq", 2380 );  swr_sdb_set_config_int( stfa[0], "attn_tx", 31 );  // here we call the two chains we set up before  setup_synch();  setup_ldpc();      swr_stfa_go( stfa[0] );    while ( looping ) {    usleep( 1000000 );  }  swr_stfa_stop( stfa[0] );  usleep( 1000000 );  return 0;}struct thread start;/** * This function is called upon "insmod" and is used to register the * different parts of the module to the SPM. */int um_module_init(void) {  int i;  MOD_INC_USE_COUNT;  looping = 1;  delay = 0;  ch_bch = NULL;  for ( i=0; i<NO_TX; i++ ){    ch_supp[i] = NULL;  }  if ( swr_thread_init( &start, start_it, NULL ) ) {    goto rrc_no_thread;  }  MOD_DEC_USE_COUNT;  return 0;rrc_no_thread:  PR_DBG( 0, "Couldn't init thread\n" );  MOD_DEC_USE_COUNT;  return -1;}void um_module_exit( void ) {  int i;  looping = 0;  swr_thread_free( &start, NULL );  PR_DBG( 0, "deleting everything\n" );  swr_chain_destroy( ch_bch );  PR_DBG( 0, "deleted ch_bch and still alive\n" );  for ( i=NO_TX-1; i>=0; i-- ){    PR_DBG(0,"Destroying tx_chain no %i\n",i);    swr_chain_destroy( ch_supp[ i ] );  }    for ( i=NO_TX-1; i>=0; i-- ){    PR_DBG(0,"Destroying tx_stfa no %i\n",i);    swr_sdb_destroy( stfa[i] );  }}module_init( um_module_init );module_exit( um_module_exit );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -