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

📄 radio_bs.c

📁 软件无线电的平台
💻 C
字号:
/***************************************************************************               radio_bs.c  -  LDPC 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/04/04 - ineiti - uses synch-macro **************************************************************************//*************************************************************************** *                                                                         * *   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 "../simple_radio.h"#include "chain.h"#include "../common.h"#define ANTENNA 0#define DBG_LVL 0#define MIN_AMP 20swr_sdb_id stfa, energy, sch, decode, sink, mafi;struct chain_t *ch_bch, *ch_rach;struct slot_bch bch_data;int slots_per_frame, looping, count;int callback( int msg, void *data, swr_sdb_id ret_id ) {  int mid_amp, variance;  count++;  mid_amp = swr_sdb_get_stats_int(mafi, "mid_amp" );  variance = swr_sdb_get_stats_int(mafi, "noise_var" );  PR_DBG( 4, "mid_amp: %i, variance: %i\n", mid_amp, variance );  if ( mid_amp < MIN_AMP ) {    // Mobile doesn't send yet    if ( !(count % 100 ) ) {      PR( "Mobile is not here for %i, amp %i\n", count, mid_amp );    }    return -1;  } else {    swr_sdb_set_config_int( sink, "flag", 1 );  }  return 0;}void *start_it( void *arg ) {  looping = 1;  usleep( 100000 );  stfa = swr_sdb_instantiate_name( "stfa" );  PR( "Setting up BCh on slot 0\n" );  ch_bch = swr_chain_create( NEW_SPC_VAR( "sch_send", sch ),                             NEW_SPC( "mapper" ),                             NEW_SPC( "spread" ),                             NEW_SPC( "midamble" ),                             NEW_SPC( "synch_send" ),                             NEW_SPC( "rrc" ),                             OLD_SPC_IN( stfa, 0 ),			     CHAIN_END );  swr_stfa_notice_sdb( stfa, 0, sch );  swr_sdb_set_config_int( sch, "id0", 0x1234 );  swr_sdb_set_config_int( sch, "uplinks0", 2 );  swr_sdb_set_config_pointer( sch, "data_usr", &bch_data );  swr_sdb_set_config_int( sch, "len_usr", sizeof( struct slot_bch ) );  bch_data.ldpc_code_id = 3;  PR( "Setting up LDPC slot 1\n" );  ch_rach = swr_chain_create( OLD_SPC_OUT( stfa, 1 ),                              NEW_SPC_VAR( "energy", energy ),                              NEW_SPC_VAR( "matched_filter", mafi ),                              NEW_SPC_VAR( "ldpc_decode", decode ),                              NEW_SPC_VAR( "sink" ,sink ),			      CHAIN_END );  swr_sdb_set_config_int( sch, "mafi0", mafi );  swr_sdb_set_config_int( decode, "mafi", mafi );  // set up the ldpc-decoder  swr_sdb_set_config_int( decode, "ldpc_code_id", bch_data.ldpc_code_id );  swr_sdb_set_config_int( decode, "iterations", 30 );  swr_sdb_set_config_int( decode, "channel_type", 2 );  swr_sdb_set_config_double( decode, "channel_param", 600 );  count = 0;  swr_stfa_notice_func( stfa, 10, callback );  // Start the transmission  swr_stfa_go( stfa );  while ( looping ) {    usleep( 1000000 );  }  swr_stfa_stop( stfa );  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) {  MOD_INC_USE_COUNT;  looping = 0;  ch_bch = NULL;  ch_rach = 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 ) {  looping = 0;  swr_thread_free( &start, NULL );  PR_DBG( 0, "deleting everything\n" );  swr_chain_destroy( ch_bch );  swr_chain_destroy( ch_rach );  swr_sdb_destroy( stfa );}module_init( um_module_init );module_exit( um_module_exit );

⌨️ 快捷键说明

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