Example #1
0
/**
 * @brief Function for setup all thinks not directly associated witch ANT stack/protocol.
 * @desc Initialization of: @n
 *         - app_tarce for debug.
 *         - app_timer, presetup for bsp and ant pulse simulation.
 *         - bsp for signaling leds and user buttons (if use button is enabled in example).
 *         - ant pulse simulate for task of filling hrm profile data.
 */
static void utils_setup(void)
{
    uint32_t err_code;

    app_trace_init();

    // Initialize and start a single continuous mode timer, which is used to update the event time
    // on the main data page.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);

    #if (MODIFICATION_TYPE == MODIFICATION_TYPE_BUTTON)
    /** @snippet [ANT Pulse simulator button init] */
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        bsp_evt_handler);
    /** @snippet [ANT Pulse simulator button init] */
    #else
    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);
    #endif

    err_code = app_timer_create(&m_tick_timer,
                                APP_TIMER_MODE_REPEATED,
                                app_tick_handler);
    APP_ERROR_CHECK(err_code);

    // Schedule a timeout event every 2 seconds
    err_code = app_timer_start(m_tick_timer, APP_TICK_EVENT_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);
}
Example #2
0
File: main.c Project: tkadom/TWBLE
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    // Initialize.
    app_trace_init();
    ble_stack_init();
    device_manager_init();
    timers_init();
    APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        NULL);
    APP_ERROR_CHECK(err_code);
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    // Start execution.
    application_timers_start();
    advertising_start();

    // Enter main loop.
    for (;; )
    {
        power_manage();
    }
}
Example #3
0
/**
 * @brief Function for application main entry.
 * @return 0. int return type required by ANSI/ISO standard.
 */
int main(void)
{
    uint32_t err_code = NRF_SUCCESS;

    clock_initialization();
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);

    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);
    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);

    // Set radio configuration parameters
    radio_configure();
    NRF_RADIO->PACKETPTR = (uint32_t)&packet;

    err_code = bsp_indication_set(BSP_INDICATE_USER_STATE_OFF);
    NRF_LOG_INFO("Wait for first packet\r\n");
    APP_ERROR_CHECK(err_code);
    NRF_LOG_FLUSH();    

    while (true)
    {
        uint32_t received = read_packet();

        err_code = bsp_indication_set(BSP_INDICATE_RCV_OK);
        NRF_LOG_INFO("Packet was received\r\n");
        APP_ERROR_CHECK(err_code);

        NRF_LOG_INFO("The contents of the package is %u\r\n", (unsigned int)received);
        NRF_LOG_FLUSH();
    }
}
Example #4
0
int main(void)
{
    uint32_t err_code;
    // Initialize.
    timers_init();
    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);

    uart_init();
    ble_stack_init();

    twi_master_init();

    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
    nrf_delay_ms(200);
    bsp_indication_set(BSP_INDICATE_IDLE);
    nrf_delay_ms(200);
    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);

    update_sensor(0);
    start_advertising();
    timers_start();

    // Enter main loop.
    for (;; )
    {
        power_manage();
    }
}
Example #5
0
/**@brief  Application main function.
 */
int main(void)
{
	//printf("main");
    uint8_t start_string[] = START_STRING;
    uint32_t err_code;
    
    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);
    APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
    ble_stack_init();
    //uart_init();
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        NULL);
    APP_ERROR_CHECK(err_code);
    err_code = bsp_buttons_enable(1 << WAKEUP_BUTTON_ID);
    APP_ERROR_CHECK(err_code);
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();
    sec_params_init();
    
    printf("%s",start_string);
    advertising_start();
		
		init_leds();
	
		
    for (;;)
    {
        power_manage();
		}
}
Example #6
0
/**@brief Function for the timer, tracer, and BSP initialization.
 */
static void utils_setup(bool * p_erase_bonds)
{
		uint32_t err_code;
		bsp_event_t startup_event;

    app_trace_init();
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);

		//bsp init ant
		err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
	//FROM BLE uint32_t err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),bsp_event_handler);

    APP_ERROR_CHECK(err_code);
	
	  // Create timers for BLE
    err_code = app_timer_create(&m_battery_timer_id,
                                APP_TIMER_MODE_REPEATED,
                                battery_level_meas_timeout_handler);
    APP_ERROR_CHECK(err_code);

    // Create battery timer.
    err_code = app_timer_create(&m_rsc_meas_timer_id,
                                APP_TIMER_MODE_REPEATED,
                                rsc_meas_timeout_handler);
    APP_ERROR_CHECK(err_code);
		
		  err_code = bsp_btn_ble_init(NULL, &startup_event);
    APP_ERROR_CHECK(err_code);

    *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA);
		
}
Example #7
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code = NRF_SUCCESS;

    // Initialize.
    ble_stack_init();
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);

    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(APP_BUTTON_DETECTION_DELAY, APP_TIMER_PRESCALER),
                        bsp_event_handler);
    APP_ERROR_CHECK(err_code);

    // Initialize advertising.
    advertising_init();

    // Start execution.
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
    }
}
Example #8
0
int main(int argc, char **argv){

    bsp_init(bspsieve, argc, argv);

    /* sequential part */
    if (argc != 2)
    {
        printf("Usage: %s N\n", argv[0]);
        bsp_abort("Incorrect invocation.\n");
    }
    sscanf(argv[1], "%lld", &N);

    printf("max prime requested = %lld\n", N);
    P = bsp_nprocs(); // maximum amount of procs

    if ( blockSize(P, 0, N) < sqrt(N))
        printf("WARNING: such a large P (%d) with relatively small N (%lld) is inefficient. \n Choosing a lower P is recommended.\n\n", P, N);

    printf("Using %d processors. \n", P);

    /* SPMD part */
    bspsieve();

    /* sequential part */
    exit(0);

} /* end main */
Example #9
0
/**
 * @brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    // Initialize.
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);
    ble_stack_init();
    advertising_init();

    // Start execution.
    NRF_LOG_INFO("BLE Beacon started\r\n");
    advertising_start();

    // Enter main loop.
    for (;; )
    {
        if (NRF_LOG_PROCESS() == false)
        {
            power_manage();
        }
    }
}
Example #10
0
/**
 * @brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;

    clock_init();

    // Start APP_TIMER to generate timeouts.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);

    leds_init();

    err_code = bsp_init(BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        bsp_evt_handler);
    APP_ERROR_CHECK(err_code);

    nfc_init();

    m_active_led_mask = BSP_LED_0_MASK;
    err_code = led_softblink_start(m_active_led_mask);
    APP_ERROR_CHECK(err_code);

    while (true)
    {
        __WFE();
        softblink_led_update();
    }
}
Example #11
0
int main( int argc, char **argv ) {

	#define BILLION  1E9

	const int size = 4;
	
	for(unsigned int l = 0;l < size;l++)
		vector[l] = (double) 1/size;

	clock_t start = clock();
	//start
	for(unsigned int w = 0;w<50;w++){ // Power method
		count = 0;
		for(int k = 0;k < size;k++){
			bsp_init( &spmd, argc, argv );
			spmd();
			count++;
		}
		memcpy(&vector,&vector_tmp,8*size);
	}
	//end
	clock_t end = clock();

	// Calculate time it took
	double elapsed = ((double) (end - start)) / CLOCKS_PER_SEC;
	printf("Time taken: %lfs\n", elapsed);

	for(unsigned int o = 0;o < size;o++)
		printf("Stationary vector [%d] = %f\n",o,vector_tmp[o]);
}
Example #12
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    // Initialize.
    ble_stack_init();
    timers_init();
    APP_GPIOTE_INIT(1);
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);
    device_manager_init();
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    ble_evt_pool      = osPoolCreate(osPool(ble_evt_pool));
    ble_stack_msg_box = osMessageCreate(osMessageQ(ble_stack_msg_box), NULL);

    // Start execution.
    ble_stack_thread_id = osThreadCreate(osThread(ble_stack_thread), NULL);
    UNUSED_VARIABLE(ble_stack_thread_id);
    application_timers_start();
    advertising_start();

    // Enter main loop.
    for (;; )
    {
        UNUSED_VARIABLE(osDelay(1000));
    }
}
Example #13
0
File: main.c Project: tkadom/TWBLE
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    // Initialize.
    app_trace_init();
    timers_init();
    gpiote_init();
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        button_event_handler);
    APP_ERROR_CHECK(err_code);
    ble_stack_init();
    adc_configure();
    device_manager_init();
    gap_params_init();
    advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
    services_init();
    conn_params_init();

    // Start execution.
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Example #14
0
/**@brief Function for the timer, tracer, and BSP initialization.
 */
static void utils_setup(void)
{
    uint32_t err_code;

    app_trace_init();
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);

#if MODIFICATION_TYPE == MODIFICATION_TYPE_AUTO
    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
#else
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        bsp_evt_handler);
#endif
    APP_ERROR_CHECK(err_code);
}
Example #15
0
int main( int argc, char **argv )
{
    bsp_init( bspfft_test, argc, argv );

    printf( "How many processors do you want to use?\n" );
    fflush( stdout );

#ifdef _WIN32
    scanf_s( "%d", &P );
#else
    scanf( "%d", &P );
#endif

    if ( P > bsp_nprocs() )
    {
        printf( "Sorry, not enough processors available.\n" );
        fflush( stdout );
        exit( 1 );
    }

    bspfft_test();

    exit( 0 );

} /* end main */
Example #16
0
int main() {

	printf( "Sequential part 1\n" );

	bsp_init( &spmd1, 0, NULL );
	spmd1();

	printf( "Sequential part 2\n" );

	bsp_init( &spmd2, 0, NULL );
	spmd2();

	printf( "Sequential part 3\n" );

	return EXIT_SUCCESS;	
}
Example #17
0
File: main.c Project: Alicia29/TOY
int main()
{
    //unsigned int delay_1 = 5000, delay_2 = 4000;

    bsp_init();

    xSemaphore = xSemaphoreCreateBinary();

    /* Create the tasks defined within this file. */
    //xTaskCreate(CDecoder, "CDecoder", configMINIMAL_STACK_SIZE, NULL, 4, NULL );
    //xTaskCreate(loop_test_01, "loop_test_01", configMINIMAL_STACK_SIZE, (void*)&delay_1, 6, NULL );
    //xTaskCreate(loop_test_02, "loop_test_02", configMINIMAL_STACK_SIZE, (void*)&delay_2, 3, NULL );
    xTaskCreate(led_update, "led_update", configMINIMAL_STACK_SIZE, NULL, 3, &xHandle[led_task] );
    xTaskCreate(key_scan, "key_scan", configMINIMAL_STACK_SIZE, NULL, 5, &xHandle[key_task] );
    xTaskCreate(audio_play, "audio_play", configMINIMAL_STACK_SIZE, NULL, 4, &xHandle[audio_task] );
    
    /* In this port, to use preemptive scheduler define configUSE_PREEMPTION
	as 1 in portmacro.h.  To use the cooperative scheduler define
	configUSE_PREEMPTION as 0. */
    vTaskStartScheduler();     
    
    // RunSchedular fail!!
    while(1)
    {
    	reset_watchdog();  
    }
    
    return 0;
}
Example #18
0
int main(int argc, char **argv){
    multibsp_tree_node_t  tree_root = NULL;
    int i;


    tree_root = multibsp_discover_new();

    mcbsp_set_affinity_mode( MANUAL_AFFINITY ); // go MANUAL affinity

    printf("\nMBSPDiscover Benchmark\n");
    //printf("G   \t\tLEVEL\tP  \tR(Mflop/s)\tL \n");
    for (tnode=tree_root; tnode->length != 0; tnode = tnode->sons[0]) {
      printf("\n***************** LEVEL %d *******************\n", tnode->level);
      bsp_init(bspbench, argc, argv);
      bspbench();
    }

    /*
    for (tnode=tree_root; tnode->length > 0; ) {
      for (i =0; i< tnode->length; i++) {
        tnode = tnode->sons[i];
        printf("***************** LEVEL %d *******************\n", tnode->level);
        bsp_init(bspbench, argc, argv);
        bspbench();
      }
    }
    */

    printf("\n");
    exit(0);
} /* end main */
int main(void)
{
    uint32_t err_code;
    
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL);
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),NULL);
    APP_ERROR_CHECK(err_code);
    leds_init();
    timers_init();
    uart_init();
   
    ble_stack_init();
    device_manager_init();
    db_discovery_init();
    uart_c_init();
    
    printf("Scanning ...\r\n");
	
    // Start scanning for peripherals and initiate connection
    // with devices that advertise NUS UUID.
    scan_start();

    for (;;)
    {
        power_manage();
    }
}
Example #20
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;

    // Initialize.
    ble_stack_init();
    timers_init();

    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);

    device_manager_init();
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();
    
    beacon_scanner_init.evt_handler   = beacon_evt_handler;
    beacon_scanner_init.error_handler = beacon_scanner_error_handler;
    app_beacon_scanner_init(&beacon_scanner_init);
    app_beacon_scanner_start();

    // Start execution.
    application_timers_start();
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
int main(int argc, char** argv) {
    bsp_init("e_bsp_hp_variables.elf", argc, argv);
    bsp_begin(bsp_nprocs());
    ebsp_spmd();
    bsp_end();

    return 0;
}
Example #22
0
/**@brief Function for initializing bsp module.
 */
void bsp_init_app(void)
{
    uint32_t err_code;
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        bsp_event_handler);
    APP_ERROR_CHECK(err_code);
}
Example #23
0
int main(int argc, char **argv)
{
    bsp_init("e_bsp_memory.srec", argc, argv);
    bsp_begin(bsp_nprocs());
    ebsp_spmd();
    bsp_end();

    return 0;
}
Example #24
0
/**@brief Function for application main entry, does not return.
 *
 * @details The main function will do all necessary initalization. This includes sdm rx module
 * and SoftDevice.
 */
int main(void)
{
    uint32_t err_code;

#if defined(TRACE_UART)
    app_uart_comm_params_t comm_params =
    {
        RX_PIN_NUMBER,
        TX_PIN_NUMBER,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        APP_UART_FLOW_CONTROL_DISABLED,
        false,
        UART_BAUDRATE_BAUDRATE_Baud38400
    };

    APP_UART_FIFO_INIT(&comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_error_handle,
                       APP_IRQ_PRIORITY_LOW,
                       err_code);
    APP_ERROR_CHECK(err_code);
#endif // TRACE_UART
#if defined(TRACE_GPIO)
    // Initialize timer module.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);

    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);
#endif // TRACE_GPIO

    // In case of logging enabled, we enable sdm_rx module first.
    err_code = sdm_rx_init();
    APP_ERROR_CHECK(err_code);

    // Enable SoftDevice.
    err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback);
    APP_ERROR_CHECK(err_code);

    // Set application IRQ to lowest priority.
    err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW);
    APP_ERROR_CHECK(err_code);

    // Enable application IRQ (triggered from protocol).
    err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn);
    APP_ERROR_CHECK(err_code);

    err_code = ant_stack_static_config();
    APP_ERROR_CHECK(err_code);

    // Setup Channel_0 as a SDM RX.
    ant_channel_sdm_rx_setup();

    sdm_main_loop();
}
Example #25
0
File: main.c Project: IOIOI/nRF51
/**@brief Function for the Timer and BSP initialization.
 */
static void utils_setup(void)
{
    uint32_t err_code;

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        sf_bsp_evt_handler);
    APP_ERROR_CHECK(err_code);
}
Example #26
0
/**@brief Function for the Timer and BSP initialization.
 */
static void utils_setup(void)
{
    uint32_t err_code;

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    err_code = bsp_init(BSP_INIT_LED,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        NULL);
    APP_ERROR_CHECK(err_code);
}
Example #27
0
void sys_init(void)
{
#if defined(UART_ENABLE)
    uart_init();
    deg_str("power on\n");
#endif
    SYS_POWER_OFF();	

    core_power_on();
    OTP_CLK_DIV2();
    DECODER_DIV2();
    SYSTEM_CLK_DIV4();
#if (NO_DISP != monitor)
    init_display();
#endif
    sd_speed_init(0,100);

//#if SDMMC_CMD_MODE
//    sd_chk_ctl(SET_SD_H_CHK);
//#endif
    init_port_sd();
    //kv_init(); ///按键音初始化函数

#if RTC_ENABLE
    rtc_init();			//RTC初始化,检测是否闹钟开机
    //{
        //work_mode = RTC_MODE;
    //}
#else
    {
        u8 rtc_reg = read_rtc_reg();
        if (rtc_reg & BIT(7))					//检测是否掉电
        {
            rtc_reg &= ~BIT(7); 				//清零PDFLAG
            write_rtc_reg(rtc_reg);
#if USE_RTC_RAM
            reset_rtc_ram();
#endif
        }
    }
#endif

    SYS_POWER_OFF();	
    key_init();
    bsp_init();
    SYS_POWER_OFF();	
    //interrupt_init(15, rtcisr);
    interrupt_init(3, timer3isr);
    interrupt_init(0, timer0isr);
#if defined(BLUE_TOOTH_UART_FUNC)
    interrupt_init(7, uart_isr);
#endif
    enable_interrupt();
   /// flashled(3);
}
Example #28
0
int main(int argc, char** argv) {
    bsp_init("e_bsp_vertical_mp.srec", argc, argv);
    bsp_begin(bsp_nprocs());

    int n = bsp_nprocs();

    int tagsize = sizeof(int);
    ebsp_set_tagsize(&tagsize);

    int tag = 0;
    int payload = 0;
    for (int s = 0; s < n; ++s) {
        tag = 0;
        payload = 1000 + s;
        ebsp_send_down(s, &tag, &payload, sizeof(int));

        tag = 1;
        payload = 1234;
        ebsp_send_down(s, &tag, &payload, sizeof(int));
    }

    ebsp_spmd();

    int packets = 0;
    int accum_bytes = 0;
    ebsp_qsize(&packets, &accum_bytes);

    printf("packets: %i\n", packets);
    // FIXME nprocs
    // expect: (packets: 32)

    int* payloads = malloc(2 * n * sizeof(int));
    int payload_size = 0;
    int tag_in = 0;
    for (int i = 0; i < packets; ++i) {
        ebsp_get_tag(&payload_size, &tag_in);
        ebsp_move(&payloads[tag_in], sizeof(int));
    }

    for (int i = 0; i < n; ++i) {
        printf("$%02d: %i\n", i, payloads[i]);
        // expect_for_pid: (2000 + pid)
    }

    for (int i = n; i < 2 * n; ++i) {
        printf("$%02d: %i\n", i - bsp_nprocs(), payloads[i]);
        // expect_for_pid: (3)
    }

    free(payloads);

    bsp_end();

    return 0;
}
Example #29
0
int main()
{
    bsp_init();
	printf("hello world!\n");

    vAttitudeTask_init();

    vCommandConsoleTaskInit();

    vTaskStartScheduler();
}
Example #30
0
int main(int argc, char** argv) {
    bsp_init("e_bsp_streams.srec", argc, argv);
    bsp_begin(bsp_nprocs());

    int chunk_size = sizeof(int) * 4;
    int chunks = 4;

    int** upstreams = (int**)malloc(sizeof(int*) * bsp_nprocs());
    int** upstreamsDouble = (int**)malloc(sizeof(int*) * bsp_nprocs());
    int* downdata = (int*)malloc(chunks * chunk_size);
    int* downdataB = (int*)malloc(chunks * chunk_size);
    int* downdataDouble = (int*)malloc(chunks * chunk_size);

    int c = 0;
    for (int i = chunks * chunk_size / sizeof(int) - 1; i >= 0; --i) {
        downdata[c] = i;
        downdataB[c] = c;
        downdataDouble[c] = 2 * c;
        c++;
    }

    for (int s = 0; s < bsp_nprocs(); ++s) {
        upstreams[s] =
            (int*)ebsp_create_up_stream(s, chunks * chunk_size, chunk_size);
        upstreamsDouble[s] =
            (int*)ebsp_create_up_stream(s, chunks * chunk_size, chunk_size);
        ebsp_create_down_stream(downdata, s, chunks * chunk_size, chunk_size);
        ebsp_create_down_stream(downdataB, s, chunks * chunk_size, chunk_size);
        ebsp_create_down_stream(downdataDouble, s, chunks * chunk_size,
                                chunk_size);
    }

    ebsp_spmd();

    for (int i = 0; i < chunk_size * chunks / sizeof(int); ++i) {
        printf("%i ", upstreams[5][i]);
    }
    printf("\n");
    // expect: (0 1 2 3 11 10 9 8 8 9 10 11 3 2 1 0 )

    for (int i = 0; i < chunk_size * chunks / sizeof(int); ++i) {
        printf("%i ", upstreamsDouble[5][i]);
    }
    // expect: (30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 0 )

    // finalize
    bsp_end();

    free(upstreams);
    free(downdata);
    free(downdataB);

    return 0;
}