📄 radio_power.c
字号:
/*************************************************************************** radio_bs.c - ICS-test ------------------- 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/03/01 - ineiti - all chains work now 04/04/27 - ineiti - for power-measurements, fill all slots **************************************************************************//*************************************************************************** * * * 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 * - two downlink chains on antenna #0, one uplink on antenna #1 */#include "system.h"#include "sdb.h"#include "stfa.h"#include "antenna.h"#include "std.h"#include "debugging.h"#include "chain.h"#include "spc.h"#define DBG_LVL 4#define SLOTS 8#define SEND_SLOTS 1#define SLOT_LEN 20#define ANTENNAS 2#define SLOT_OFFSET 6swr_sdb_id stfa[ANTENNAS];struct chain_t *ch_power[SEND_SLOTS];int looping, delay;void *start_it( void *arg ) { swr_sdb_id src, rrc; int i; looping = 1; usleep( 100000 ); PR( "Init STFA\n" ); stfa[0] = swr_sdb_instantiate_name( "stfa_ics" ); for ( i=1; i<ANTENNAS; 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 ); PR( "Setting up some random stuff on slot 0 of stfa %i\n", i ); swr_stfa_go( stfa[0] ); PR( "Waiting for STFA to burn in\n" ); usleep( 100000 ); PR( "Setting up our chains\n" ); for ( i=0; i<SEND_SLOTS; i++ ){ PR( "Setting up BCh on slot %i\n", i ); ch_power[i] = swr_chain_create( NEW_SPC_VAR( "random", src ), NEW_SPC( "mapper" ), NEW_SPC_VAR( "rrc_complex_send", rrc ), OLD_SPC_IN( stfa[0], i ), CHAIN_END ); swr_sdb_set_config_int( rrc, "rrc_index", 5 ); swr_sdb_set_config_double( rrc, "amplitude", 2 );#if SEND_SLOTS == 1 swr_stfa_notice_sdb( stfa[0], 0, src );#else call_module( src );#endif } 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; for ( i=0; i<SEND_SLOTS; i++ ){ ch_power[ 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 ); for ( i=0; i<SEND_SLOTS; i++ ){ if ( ch_power[ i ] ){ PR( "Deleting ch_power[%i]\n", i ); swr_chain_destroy( ch_power[ i ] ); } } PR( "Destroying stfas\n" ); for ( i=0; i<ANTENNAS; i++ ){ PR( "Destroying stfa[%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 + -