Ejemplo n.º 1
0
void init_state_init(void *arg)
{
	sw_timer_init();

	/* Set the node information base */
	config_node_ib();

	/* Initialize the TAL layer */
	if (tal_init() != MAC_SUCCESS) {
		/* something went wrong during initialization */
		app_alert();
	}

	app_timers_init();

	/* Initilaize sio rx state */
	init_sio();

	/* select the configurtion mode */
	configuration_mode_selection();

#if (TAL_TYPE == AT86RF233) && (ANTENNA_DIVERSITY == 1)
	/* In order to demonstrate RPC the antenna diversity is disabled. */
	tal_ant_div_config(ANT_DIVERSITY_DISABLE, ANT_CTRL_1); /* Enable A1/X2 */
#endif

	/* Keep compiler happy */
	arg = arg;
}
Ejemplo n.º 2
0
/**
 * @brief Main function of the Wireless UART application
 */
int main(void)
{
    /* Initialize the TAL layer */
    if (tal_init() != MAC_SUCCESS)
    {
        // something went wrong during initialization
        pal_alert();
    }

    /* Calibrate MCU's RC oscillator */
    pal_calibrate_rc_osc();

    /* Initialize LEDs */
    pal_led_init();
    pal_led(LED_START, LED_ON);     // indicating application is started
    pal_led(LED_DATA_RX, LED_OFF);  // indicating data reception
    pal_led(LED_DATA_TX, LED_OFF);  // indicating successfull data transmission

    /*
     * The stack is initialized above, hence the global interrupts are enabled
     * here.
     */
    pal_global_irq_enable();

    /* Initialize the serial interface used for communication with terminal program */
    if (pal_sio_init(SIO_CHANNEL) != MAC_SUCCESS)
    {
        // something went wrong during initialization
        pal_alert();
    }

    /* Configure TX frame and transceiver */
    configure_frame_sending();

    /* Switch receiver on */
    tal_rx_enable(PHY_RX_ON);

#if(SEND_BLOCKWISE==true)
    start_timer();
#endif

    /* Endless while loop */
    while (1)
    {
        pal_task(); /* Handle platform specific tasks, like serial interface */
        tal_task(); /* Handle transceiver specific tasks */
#if(!(SEND_BLOCKWISE==true))
        app_task(); /* Application task */
#endif
    }
}
Ejemplo n.º 3
0
static int tdm_dev_tdm_start(unsigned long arg)
{
	tdm_dev_params_t data;
	int i;

	/* Get user data */
	if(copy_from_user(&data, (void*)arg, sizeof(tdm_dev_params_t))) {
		printk("%s: copy_from_user failed\n", __FUNCTION__);
		return -EFAULT;
	}

	/* Check parameters */
	if((data.pcm_format != 1) && (data.pcm_format != 2) && (data.pcm_format != 4)) {
		printk("%s: bad parameter(pcm_format=%u)\n", __FUNCTION__, data.pcm_format);
		return -EFAULT;
	}

	if(data.total_lines > MV_TDM_TOTAL_CHANNELS) {
		printk("%s: bad parameter(data.total_lines=%u)\n", __FUNCTION__, data.total_lines);
		return -EFAULT;
	}

	tdm_dev_params.pcm_format = (tal_pcm_format_t)data.pcm_format;
	/* Fill time slot table */
	for(i = 0; i < data.total_lines; i++)
		tdm_dev_params.pcm_slot[i] = ((i+1) * data.pcm_format); /* skip time slot #0 */

	tdm_dev_params.sampling_period = MV_TDM_BASE_SAMPLING_PERIOD;
	tdm_dev_params.total_lines = data.total_lines;
	tdm_dev_params.test_enable = 1;

	/* Assign Rx/Tx callbacks */
	tdm_dev_ops.tal_mmp_rx_callback = tdm_dev_rx_callback;
	tdm_dev_ops.tal_mmp_tx_callback = tdm_dev_tx_callback;

	if(tal_init(&tdm_dev_params, &tdm_dev_ops) != MV_OK) {
		printk("%s: Error, could not init tdm driver\n",__FUNCTION__);
		return -EFAULT;
	}

	/* Prepare globals */
	atomic_set(&tdm_init, ENABLE);
	atomic_set(&rx_ready, DISABLE);
	atomic_set(&tx_ready, DISABLE);
	rx_buff_p = NULL;
	tx_buff_p = NULL;

	return 0;
}
Ejemplo n.º 4
0
/**
 * @brief Main function of the Sniffer application
 */
int main(void)
{

   /* Initialize the TAL layer */
    if (tal_init() != MAC_SUCCESS)
    {
        /* something went wrong during initialization*/
        pal_alert();
    }

    /* Calibrate MCU's RC oscillator */
    pal_calibrate_rc_osc();

    /* Initialize LEDs */
    pal_led_init();


    /*
     * The stack is initialized above, hence the global interrupts are enabled
     * here.
     */
    pal_global_irq_enable();

    /* Initialize the serial interface used for communication with sniffer
       GUI */
    if (pal_sio_init(SIO_CHANNEL) != MAC_SUCCESS)
    {
        /* something went wrong during initialization */
        pal_alert();
    }

    //sio_getchar();

    Wireshark_Settings = INIT_STATE ;

    /* Endless while loop */
    while (1)
    {
        pal_task();
        tal_task();
        app_task();
    }
}
Ejemplo n.º 5
0
/**
 * \brief Run Wireless Module unit tests
 *
 * Initializes the clock system, board and USB.
 * Then runs the wireless task continuously.
 */
int main(void)
{
	irq_initialize_vectors();
	sysclk_init();

	/* Initialize the board.
	 * The board-specific conf_board.h file contains the configuration of
	 * the board initialization.
	 */
	board_init();

	sw_timer_init();
	tal_init();
	/* Enable interrupts */
	cpu_irq_enable();

	stdio_usb_init();

	while (1) {
		tal_task();
	}
}
Ejemplo n.º 6
0
/**
 * @brief Initializes the MAC sublayer
 *
 * @return MAC_SUCCESS  if TAL is intialized successfully else FAILURE
 */
retval_t mac_init(void)
{
	#ifdef GTS_DEBUG
	struct port_config config_port_pin;
	config_port_pin.direction = PORT_PIN_DIR_OUTPUT;
	port_pin_set_config(DEBUG_PIN1, &config_port_pin);
	port_pin_set_config(DEBUG_PIN2, &config_port_pin);
	port_pin_set_config(DEBUG_PIN3, &config_port_pin);
	port_pin_set_config(DEBUG_PIN4, &config_port_pin);
	port_pin_set_config(DEBUG_PIN5, &config_port_pin);
	port_pin_set_config(DEBUG_PIN6, &config_port_pin);
	port_pin_set_config(DEBUG_PIN7, &config_port_pin);
	port_pin_set_config(DEBUG_PIN8, &config_port_pin);
	port_pin_set_config(DEBUG_PIN9, &config_port_pin);
	port_pin_set_config(DEBUG_PIN10, &config_port_pin);
	port_pin_set_config(DEBUG_PIN11, &config_port_pin);
	port_pin_set_config(DEBUG_PIN12, &config_port_pin);
	port_pin_set_config(DEBUG_PIN13, &config_port_pin);
	port_pin_set_config(DEBUG_PIN14, &config_port_pin);
	port_pin_set_config(DEBUG_PIN15, &config_port_pin);

	/*ioport_configure_pin(DEBUG_PIN1, IOPORT_DIR_OUTPUT |
	 *  IOPORT_INIT_LOW);
	 *  ioport_configure_pin(DEBUG_PIN2, IOPORT_DIR_OUTPUT |
	 *  IOPORT_INIT_LOW);
	 *  ioport_configure_pin(DEBUG_PIN3, IOPORT_DIR_OUTPUT |
	 *  IOPORT_INIT_LOW);
	 *  ioport_configure_pin(DEBUG_PIN4, IOPORT_DIR_OUTPUT |
	 *  IOPORT_INIT_LOW);*/
	#endif

	/* Initialize TAL */
	if (tal_init() != MAC_SUCCESS) {
		return FAILURE;
	}

#ifdef STB_ON_SAL
	stb_init();
#endif

#ifdef ENABLE_RTB
	/* Initialize RTB */
	if (rtb_init() != RTB_SUCCESS) {
		return FAILURE;
	}

#endif  /* ENABLE_RTB */

	/* Calibrate MCU's RC oscillator */
	if (!pal_calibrate_rc_osc()) {
		return FAILURE;
	}

	if (MAC_SUCCESS != mac_timers_init()) {
		return FAILURE;
	}

	mac_soft_reset(true);

	/* Set radio to sleep if allowed */
	mac_sleep_trans();

	/* Initialize the queues */
#ifdef ENABLE_QUEUE_CAPACITY
	qmm_queue_init(&nhle_mac_q, NHLE_MAC_QUEUE_CAPACITY);
	qmm_queue_init(&tal_mac_q, TAL_MAC_QUEUE_CAPACITY);
    #if (MAC_INDIRECT_DATA_FFD == 1)
	qmm_queue_init(&indirect_data_q, INDIRECT_DATA_QUEUE_CAPACITY);
    #endif /* (MAC_INDIRECT_DATA_FFD == 1) */
    #if (MAC_START_REQUEST_CONFIRM == 1)
    #ifdef BEACON_SUPPORT
	qmm_queue_init(&broadcast_q, BROADCAST_QUEUE_CAPACITY);
    #endif  /* BEACON_SUPPORT */
    #endif /* (MAC_START_REQUEST_CONFIRM == 1) */
#else
	qmm_queue_init(&nhle_mac_q);
	qmm_queue_init(&tal_mac_q);
    #if (MAC_INDIRECT_DATA_FFD == 1)
	qmm_queue_init(&indirect_data_q);
    #endif /* (MAC_INDIRECT_DATA_FFD == 1) */
    #if (MAC_START_REQUEST_CONFIRM == 1)
    #ifdef BEACON_SUPPORT
	qmm_queue_init(&broadcast_q);
    #endif  /* BEACON_SUPPORT */
    #endif /* (MAC_START_REQUEST_CONFIRM == 1) */
#endif  /* ENABLE_QUEUE_CAPACITY */

	return MAC_SUCCESS;
}