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

📄 emul.c

📁 软件无线电的平台
💻 C
字号:
/***************************************************************************           emul.c  -  Emulator for the hardware-layer                            -------------------    begin                :  2002    authors              :  Linus Gasser    emails               :  linus.gasser@epfl.ch ***************************************************************************//***************************************************************************                                 Changes                                 ------- date - name - description 02-10-14 - ineiti- begin 02-12-11 - ineiti - copy Sender to Receiver by default 02-12-12 - ineiti - rip out everything already in antenna  **************************************************************************//*************************************************************************** *                                                                         * *   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.                                   * *                                                                         * ***************************************************************************//** * A very simple, flat-channel simulator. Works only with one process. */#define DBG_LVL 3#include "system.h"#include "debugging.h"#include "memory.h"#include "sdb.h"#include "antenna.h"swr_ant_param_t *params[ MAX_ANTENNAS ];int antennas;/** * @short Initialises an antenna's channel */int swr_ant_ch_init( swr_ant_param_t *p ) {  if ( antennas < MAX_ANTENNAS ){    params[ antennas ] = p;    params[ antennas ]->rx_tx_delay = 0;    params[ antennas ]->slot_length = 20;    return antennas++;  } else {    PR_DBG( 0, "Asking for too many antennas\n" );    return -1;  }}/** * @short Deletes an antenna's channel */void swr_ant_ch_free( int nbr_ant ) {  if ( !antennas ){    PR_DBG( 0, "There are no antennas to be freed\n" );  }  if ( nbr_ant != --antennas ){    PR_DBG( 0, "Out of order freeing.\n" );  }}/** * @short Starts the channel */void swr_ant_ch_start( void ) {  // Well, there's nothing to do, really ;)}/** * @short Stops the channel */void swr_ant_ch_stop( void ) {}/** * @short IOs the antenna */int swr_ant_ch_io( int block ) {  swr_ant_param_t *p;  int pos_tx, pos_rx, pos;  short int *buf_rx, *buf_tx;  int nbr_ant;    for ( nbr_ant=0; nbr_ant<antennas; nbr_ant++ ){    p = params[ nbr_ant ];    PR_DBG( 4, "Copying block %i with length %i\n", block, p->slot_length );    pos_tx = ( block % p->frame_blocks ) * DAQ_DMA_BLOCK_SIZE_BYTES;    block += p->slot_length;    pos_rx = ( block % p->frame_blocks ) * DAQ_DMA_BLOCK_SIZE_BYTES;    // Copy the transmitted part to the emission signal to the    // received part.    buf_rx = p->addr_rx + pos_rx;    buf_tx = p->addr_tx + pos_tx;    for ( pos = 0; pos < p->slot_length * DAQ_DMA_BLOCK_SIZE_SAMPLES; pos++ ){      buf_rx[pos] = buf_tx[pos] / 16;    }  }  return 1000;}int swr_ant_ch_reconfig( int nbr_ant ){  return 0;}int swr_emul_init( void ){  antennas = 0;  return 0;}void swr_emul_exit( void ){  if ( antennas > 0 ){    PR_DBG( 0, "Hmm, still some antennas left...\n" );  }}module_init( swr_emul_init );module_exit( swr_emul_exit );EXPORT_SYMBOL(swr_ant_ch_init);EXPORT_SYMBOL(swr_ant_ch_free);EXPORT_SYMBOL(swr_ant_ch_start);EXPORT_SYMBOL(swr_ant_ch_stop);EXPORT_SYMBOL(swr_ant_ch_io);EXPORT_SYMBOL(swr_ant_ch_reconfig);

⌨️ 快捷键说明

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