Exemplo n.º 1
0
int main(void)
{
//! [main_start]
	/* Initialize system */
//! [system_init]
	system_init();
//! [system_init]

//! [run_config]
	configure_spi_master();
//! [run_config]
//! [run_callback_config]
	configure_spi_master_callbacks();
//! [run_callback_config]
//! [main_start]

//! [main_use_case]
//! [inf_loop]
	while (true) {
		/* Infinite loop */
		if (!port_pin_get_input_level(BUTTON_0_PIN)) {
			//! [select_slave]
			spi_select_slave(&spi_master_instance, &slave, true);
			//! [select_slave]
			//! [write and read]
			spi_transceive_buffer_job(&spi_master_instance, wr_buffer,rd_buffer,BUF_LENGTH);
			//! [write and read]
			//! [wait]
			while (!transrev_complete_spi_master) {
				/////* Wait for write and read complete */
			}
			//! [wait]
			//! [deselect_slave]
			spi_select_slave(&spi_master_instance, &slave, false);
			//! [deselect_slave]
		}
	}
//! [inf_loop]
//! [main_use_case]
}
Exemplo n.º 2
0
int main(void)
{
//! [add_main]
	system_init();

	struct rtc_calendar_time time;
	time.year   = 2012;
	time.month  = 12;
	time.day    = 31;
	time.hour   = 23;
	time.minute = 59;
	time.second = 59;

	configure_rtc_calendar();

	/* Set current time. */
	rtc_calendar_set_time(&rtc_instance, &time);

	rtc_calendar_swap_time_mode(&rtc_instance);
//! [add_main]

//! [main_imp]
//! [main_loop]
	while (true) {
//! [main_loop]
//! [check_alarm_match]
		if (rtc_calendar_is_alarm_match(&rtc_instance, RTC_CALENDAR_ALARM_0)) {
//! [check_alarm_match]
//! [alarm_match_action]
			/* Do something on RTC alarm match here */
			port_pin_toggle_output_level(LED_0_PIN);
//! [alarm_match_action]

//! [clear_alarm_match]
			rtc_calendar_clear_alarm_match(&rtc_instance, RTC_CALENDAR_ALARM_0);
//! [clear_alarm_match]
		}
	}
//! [main_imp]
}
Exemplo n.º 3
0
int main(void) {
  irq_initialize_vectors();
  cpu_irq_enable();
  sleepmgr_init();
  system_init();
  log_init();
  l("configure_pins");
  setup_led();
  l("ui_init");
  ui_init();

  l("ui_powerdown");
  ui_powerdown();

  // Start USB stack to authorize VBus monitoring
  l("udc_start");
  udc_start();

  while (true) {
    sleepmgr_enter_sleep();
  }
}
Exemplo n.º 4
0
int main(void)
{
  board_init();
  system_init();
  QueueInit(&lock_fifo);
  //modbus485有线的配置
  eMBInit(MB_RTU, MSlaveID, MODBUS_UART_NUMBER, MODBUS_UART_BAUDRATE, MB_PAR_NONE); 
  eMBEnable();
  while (1) {
    
    if(Timer2_Get_Sensor_Data() == 0){
      QueueInit(&lock_fifo);
      if(Door_Flag1 == 1)
    {
        SetAndSendRemoteOpenDoorCmd();
        
        Door_Flag1 = 0;
    }      
    }
    
  }
}
Exemplo n.º 5
0
int main(void)
{
	irq_initialize_vectors();
	#if SAMD || SAMR21
	system_init();
	delay_init();
	#else
	sysclk_init();
	board_init();
	#endif
	SYS_Init();
	//sio2host_init();
	configure_console();
	printf("we made it");
	cpu_irq_enable();
	LED_On(LED0);
	appInit();
	while (1) {
		SYS_TaskHandler();
		//APP_TaskHandler();
	}
}
Exemplo n.º 6
0
int main (void)
{
    timer_tick_t now;
    
    system_init ();

    timer_init ();
    led_init ();
    
    now = timer_get ();
    while (1)
    {
        led_set (LED1, 1);
        
        now = timer_wait_until (now + (timer_tick_t)(TIMER_RATE * 0.5));
        
        led_set (LED1, 0);
        
        now = timer_wait_until (now + (timer_tick_t)(TIMER_RATE * 0.75));
    }
    return 0;
}
Exemplo n.º 7
0
// Iterate over all the preinit/init routines.
inline void __libc_init_array(void)
{
  size_t count;
  size_t i;

  // fix: Atmel Studio seems not to flash correctly the 
  // tab of function pointers. 
  // Call the init function directly for now.
  system_init();
// count = __preinit_array_end - __preinit_array_start;
//  for (i = 0; i < count; i++)
//    __preinit_array_start[i]();

  // If you need to run the code in the .init section, please use
  // the startup files, since this requires the code in crti.o and crtn.o
  // to add the function prologue/epilogue.
  //_init();

  count = __init_array_end - __init_array_start;
  for (i = 0; i < count; i++)
    __init_array_start[i]();
}
Exemplo n.º 8
0
/**
 * \brief Main application function.
 *
 * Application entry point.
 *
 * \return program return value.
 */
int main(void)
{
	tstrWifiInitParam param;
	int8_t ret;

	/* Initialize the board. */
	system_init();

	/* Initialize the UART console. */
	configure_console();
	printf(STRING_HEADER);

	/* Initialize the BSP. */
	nm_bsp_init();

	/* Initialize Wi-Fi parameters structure. */
	memset((uint8_t *)&param, 0, sizeof(tstrWifiInitParam));

	/* Initialize Wi-Fi driver with data and status callbacks. */
	param.pfAppWifiCb = wifi_cb;
	ret = m2m_wifi_init(&param);
	if (M2M_SUCCESS != ret) {
		printf("main: m2m_wifi_init call error!(%d)\r\n", ret);
		while (1) {
		}
	}

	printf("Connecting to %s.\r\n", (char *)MAIN_WLAN_SSID);
	/* Connect to defined AP. */
	m2m_wifi_connect((char *)MAIN_WLAN_SSID, sizeof(MAIN_WLAN_SSID), MAIN_WLAN_AUTH, (void *)MAIN_WLAN_PSK, M2M_WIFI_CH_ALL);

	while (1) {
		/* Handle pending events from network controller. */
		while (m2m_wifi_handle_events(NULL) != M2M_SUCCESS) {
		}
	}

	return 0;
}
Exemplo n.º 9
0
int main(void)
{
	system_init();
	delay_init();
	
//! [setup_init]
	configure_adc();
//! [setup_init]

//! [main]
//! [start_conv]
	adc_start_conversion(&adc_instance);
//! [start_conv]

//! [get_res]
	uint16_t result=0;

	configure_console();
	

//! [get_res]

//! [inf_loop]
	while (1) {
		/* Infinite loop */
		//adc_read(&adc_instance, &result);
		do {
		/* Wait for conversion to be done and read out result */
		} while (adc_read(&adc_instance, &result) == STATUS_BUSY);
		printf("The result is %d\n",result);
		uint32_t far = 9.0/5.0*((float)result*.0002441406*6.0/.01)+32.0;
		printf(" The temp is %d", far);
		adc_clear_status(&adc_instance,adc_get_status(&adc_instance));
			adc_start_conversion(&adc_instance);
		delay_ms(500);
	}
//! [inf_loop]
//! [main]
}
Exemplo n.º 10
0
/** Initialize the RTC
 *
 * Initialize the RTC with default time
 * @param[void] void
 */
void rtc_init(void)
{
    if (g_sys_init == 0) {
        system_init();
        g_sys_init = 1;
    }

    struct rtc_count_config config_rtc_count;

    rtc_count_get_config_defaults(&config_rtc_count);

    config_rtc_count.prescaler           = RTC_COUNT_PRESCALER_DIV_1024;
    config_rtc_count.mode                = RTC_COUNT_MODE_32BIT;
#ifdef FEATURE_RTC_CONTINUOUSLY_UPDATED
    config_rtc_count.continuously_update = true;
#endif

    rtc_count_init(&rtc_instance, RTC, &config_rtc_count);

    rtc_count_enable(&rtc_instance);
    rtc_inited = 1;
}
Exemplo n.º 11
0
/******************************************************************************
* Public Function Definitions
*******************************************************************************/
void main()
{
    if( system_init() )
        return;
    DisableInterrupts();
    OLED_WriteText("Initialization", 20, 75);
    delay_ms(2000);
    OLED_DrawImage( irgesturen_bmp, 0, 0 );
    EnableInterrupts();
    while(1)
    {
        if( gesture_flag )
        {
            DisableInterrupts();
            handle_gesture();
            delay_ms(1000);
            OLED_DrawImage( irgesturen_bmp, 0, 0 );
            gesture_flag = false;
            EnableInterrupts();
        }
    }
}
Exemplo n.º 12
0
/*! \brief Main function. Execution starts here.
 */
int main(void)
{
	irq_initialize_vectors();
	cpu_irq_enable();
#if !SAMD21 && !SAMR21
	sysclk_init();
	board_init();
#else
	system_init();
#endif
	// Initialize the sleep manager
	sleepmgr_init();
	ui_init();
	ui_powerdown();

	// Start USB stack to authorize VBus monitoring
	udc_start();

	// The main loop manages only the power mode
	// because the USB management is done by interrupt
	while (true) {
#ifdef USB_DEVICE_LOW_SPEED
		// No USB "Keep a live" interrupt available in low speed
		// to scan mouse interface then use main loop
		if (main_b_mouse_enable) {
			static volatile uint16_t virtual_sof_sub = 0;
			static uint16_t virtual_sof = 0;
			if (sysclk_get_cpu_hz()/50000 ==
				virtual_sof_sub++) {
				virtual_sof_sub = 0;
				static uint16_t virtual_sof = 0;
				ui_process(virtual_sof++);
			}
		}
#else /* #ifdef USB_DEVICE_LOW_SPEED */
		sleepmgr_enter_sleep();
#endif
	}
}
Exemplo n.º 13
0
/* MAIN
 ******************************************************************************/
void main()
{
    system_init();
    mcp2542_init();
    mcp2542_delimiter_set( "\r\n" );

    while( 1 )
    {
        if( Button( &GPIO_PORT_24_31, 4, 100, 1 ) )
        {
            mcp2542_send( write_buffer );
            UART1_Write_Text( "\r\n< SENT >\r\n" );
        }

        if( mcp2542_rdy() )
        {
            mcp2542_read( read_buffer );
            UART1_Write_Text( "\r\n< RECEIVED >\r\n" );
            UART1_Write_Text( read_buffer );
        }
    }
}
Exemplo n.º 14
0
//------------------------------------------------------------------------------
int main(int argc, char** argv)
{
    tOplkError                  ret = kErrorOk;
    tOptions                    opts;

    getOptions(argc, argv, &opts);

#if defined(__COBALT__)
    mlockall(MCL_CURRENT | MCL_FUTURE);
#endif

    if (system_init() != 0)
    {
        fprintf(stderr, "Error initializing system!");
        return 0;
    }

    initEvents(&fGsOff_l);

    printf("----------------------------------------------------\n");
    printf("openPOWERLINK console MN DEMO application\n");
    printf("using openPOWERLINK Stack: %s\n", PLK_DEFINED_STRING_VERSION);
    printf("----------------------------------------------------\n");

    if ((ret = initPowerlink(CYCLE_LEN, opts.cdcFile, aMacAddr_g)) != kErrorOk)
        goto Exit;

    if ((ret = initApp()) != kErrorOk)
        goto Exit;

    loopMain();

Exit:
    shutdownPowerlink();
    shutdownApp();
    system_exit();

    return 0;
}
Exemplo n.º 15
0
int main(void){
    int i, d, on;

    system_init();
    led_init();
    led_fade_init();

    i=5;
    d=1;
    on=0;
    while(1){
        i+=d;
        if(i==250) d=-1;
        if(i==5){
            d=1;
            led_fade_set_orange(0);
            led_fade_set_red(0);
            led_fade_set_green(0);
            led_fade_set_blue(0);
            on++;
            if(on==4) on=0;
        }
        switch(on){
        case 0:
            led_fade_set_orange(i);
            break;
        case 1:
            led_fade_set_red(i);
            break;
        case 2:
            led_fade_set_green(i);
            break;
        case 3:
            led_fade_set_blue(i);
            break;
        }
        my_delay(50000);
    }
}
Exemplo n.º 16
0
Arquivo: main.c Projeto: rmnsfx/DVA141
int main (void)
{
	volatile char temp = 1;
	volatile uint16_t temp1 = 1;
	volatile uint16_t temp2 = 1;
	volatile bool state = false;
	
	system_init();
	
	init_gpio();

	clock_output();
	
	delay_init();	
		
	configure_spi_master_AD5421();
	configure_spi_master_ADXL();
	
	AD5421_Init();	
	ADXL345_Init();
	
	//configure_extint_channel();		
	//configure_extint_callbacks();	
	//system_interrupt_enable_global();
	

	
	xTaskCreate(Testtask, "Testtask", configMINIMAL_STACK_SIZE, (void *)100, mainQUEUE_SEND_TASK_PRIORITY, NULL);
	vTaskStartScheduler();
	

	
	
	//X = ADXL345_GetX();
 	//Y = ADXL345_GetY();
 	//Z = ADXL345_GetZ();
	
}
Exemplo n.º 17
0
int main(void)
{
	system_init();

	//! [run_initialize_i2c]
	//! [config]
	configure_i2c_slave();
	//! [config]

	//! [dir]
	enum i2c_slave_direction dir;
	//! [dir]
	//! [pack]
	struct i2c_slave_packet packet = {
		.data_length = DATA_LENGTH,
		.data        = buffer,
	};
	//! [pack]
	//! [run_initialize_i2c]

	//! [while]
	while (true) {
		/* Wait for direction from master */
		//! [get_dir]
		dir = i2c_slave_get_direction_wait(&i2c_slave_instance);
		//! [get_dir]

		/* Transfer packet in direction requested by master */
		//! [transfer]
		if (dir == I2C_SLAVE_DIRECTION_READ) {
			i2c_slave_read_packet_wait(&i2c_slave_instance, &packet);
		} else if (dir == I2C_SLAVE_DIRECTION_WRITE) {
			i2c_slave_write_packet_wait(&i2c_slave_instance, &packet);
		}
		//! [transfer]
	}
	//! [while]
}
Exemplo n.º 18
0
void
lwip_sysboot_threadtype_RunFunction(void **inPtr)
{
	char  ip[32];

        // Enable the Periodic Semaphore
	VDK_MakePeriodic(kPeriodic, SAMPLE_PERIOD, SAMPLE_PERIOD);


	/* Initializes the TCP/IP Stack and returns */
	if(system_init() == -1)
	{
		printf("Failed to initialize system\n");
		return;
	}

	/* start stack */
	start_stack();

	/*
	 * For debug purposes, printf() the IP address to the VisualDSP++
	 * console window.  Likely not needed in final application.
	 */

	memset(ip,0,sizeof(ip));
	if(gethostaddr(0,ip))
	{
		printf("IP ADDRESS: %s\n",ip);
	}

	/**
	 *  Add Application Code here
	 **/	 
	 LoopBackTest();

	/* Put the thread's exit from "main" HERE */
	/* A thread is automatically Destroyed when it exits its run function */
}
Exemplo n.º 19
0
/**
 * \brief Main application function.
 *
 * Application entry point.
 *
 * \return program return value.
 */
int main(void)
{
	tstrWifiInitParam param;
	int8_t ret;

	/* Initialize the board. */
	system_init();

	/* Initialize the UART console. */
	configure_console();
	printf(STRING_HEADER);

	/* Initialize the BSP. */
	nm_bsp_init();

	/* Initialize Wi-Fi parameters structure. */
	memset((uint8_t *)&param, 0, sizeof(tstrWifiInitParam));

	/* Initialize Wi-Fi driver with data and status callbacks. */
	param.pfAppWifiCb = wifi_cb;
	ret = m2m_wifi_init(&param);
	if (M2M_SUCCESS != ret) {
		printf("main: m2m_wifi_init call error!(%d)\r\n", ret);
		while (1) {
		}
	}

	/* Request scan. */
	m2m_wifi_request_scan(M2M_WIFI_CH_ALL);

	while (1) {
		/* Handle pending events from network controller. */
		while (m2m_wifi_handle_events(NULL) != M2M_SUCCESS) {
		}
	}

	return 0;
}
Exemplo n.º 20
0
/**
 * \brief Main application function.
 *
 * Application entry point.
 * Initialize system, UART and board specific settings.
 * Connect AP using Security mode WPA/WPA2 enterprise
 *
 * \return program return value.
 */
int main(void)
{
	tstrWifiInitParam param;
	int8_t ret;

	/* Initialize the board. */
	system_init();

	/* Initialize the UART console. */
	configure_console();
	printf(STRING_HEADER);

	/* Initialize the BSP. */
	nm_bsp_init();

	/* Initialize Wi-Fi parameters structure. */
	memset((uint8_t *)&param, 0, sizeof(tstrWifiInitParam));

	/* Initialize Wi-Fi driver with data and status callbacks. */
	param.pfAppWifiCb = wifi_cb;
	ret = m2m_wifi_init(&param);
	if (M2M_SUCCESS != ret) {
		printf("main: m2m_wifi_init call error!(%d)\r\n", ret);
		while (1) {
		}
	}

	/* Connect to the enterprise network. */
	m2m_wifi_connect((char *)MAIN_WLAN_DEVICE_NAME, sizeof(MAIN_WLAN_DEVICE_NAME), M2M_WIFI_SEC_802_1X, (char *)&gstrCred1x, M2M_WIFI_CH_ALL);

	/* Infinite loop to handle a event from the WINC1500. */
	while (1) {
		while (m2m_wifi_handle_events(NULL) != M2M_SUCCESS) {
		}
	}

	return 0;
}
Exemplo n.º 21
0
int main (void)
{
	system_init();
	//delay_init();
	configure_port_pins();
	configure_usart();
	
	uint8_t string[] = "Testing usart\n";
	
	usart_write_buffer_wait(&usart_instance, string,sizeof(string));
	port_pin_set_output_level(_RESET, 1);
	port_pin_set_output_level(_RESET, 0);
	delay_ms(100);
	port_pin_set_output_level(_RESET, 1);
	delay_ms(1000);
	
	port_pin_set_output_level(PIN_PA02, !false);
	
	uint8_t ndef_data[] = COSY_DEFAULT_DATA;
	
	rf430_init();
	rf430_write_ndef(ndef_data);
	
	port_pin_set_output_level(PIN_PA02, false);

	// Insert application code here, after the board has been initialized.
	
	//example application with cosytech data. (This data should be fetched from web/bluetooth)
	

	
	while(1){
		delay_ms(500);
		port_pin_set_output_level(PIN_PA02, true);
		delay_ms(500);
		port_pin_set_output_level(PIN_PA02, false);
	}
}
Exemplo n.º 22
0
/**
 * \brief Run EEPROM emulator unit tests
 *
 * Initializes the system and serial output, then sets up the
 * EEPROM emulator unit test suite and runs it.
 */
int main(void)
{
	system_init();
	cdc_uart_init();

	/* Define Test Cases */
	DEFINE_TEST_CASE(eeprom_init_test, NULL,
			run_eeprom_init_test, NULL,
			"Testing EEPROM emulator initialization");

	DEFINE_TEST_CASE(eeprom_buffer_read_write_test,
			setup_eeprom_buffer_read_write_test,
			run_eeprom_buffer_read_write_test, NULL,
			"Testing EEPROM buffer read/write functionality");

	DEFINE_TEST_CASE(eeprom_page_read_write_test,
			setup_eeprom_page_read_write_test,
			run_eeprom_page_read_write_test, NULL,
			"Testing EEPROM page read/write functionality");

	/* Put test case addresses in an array */
	DEFINE_TEST_ARRAY(eeprom_tests) = {
		&eeprom_init_test,
		&eeprom_buffer_read_write_test,
		&eeprom_page_read_write_test,
	};

	/* Define the test suite */
	DEFINE_TEST_SUITE(eeprom_test_suite, eeprom_tests,
			"SAM EEPROM emulator service test suite");

	/* Run all tests in the suite*/
	test_suite_run(&eeprom_test_suite);

	while (true) {
		/* Intentionally left empty */
	}
}
Exemplo n.º 23
0
int main(void) {
	// Initialize the OSS-7 Stack
	system_init();

	// Currently we address the Transport Layer for RX, this should go to an upper layer once it is working.
	trans_init();
	trans_set_query_rx_callback(&rx_callback);
	trans_set_tx_callback(&tx_callback);
	// The initial Tca for the CSMA-CA in
	trans_set_initial_t_ca(200);

	start_channel_scan = true;

	log_print_string("gateway started");

	// Log the device id
	log_print_data(device_id, 8);

	// configure blinking led event
	dim_led_event.next_event = 50;
	dim_led_event.f = &dim_led;

	system_watchdog_init(WDTSSEL0, 0x03);
	system_watchdog_timer_start();

	blink_led();

	while(1)
	{
		if (start_channel_scan)
		{
			start_rx();
		}

		// Don't know why but system reboots when LPM > 1 since ACLK is uses for UART
		system_lowpower_mode(0,1);
	}
}
Exemplo n.º 24
0
void
lwip_sysboot_threadtype_RunFunction(void **inPtr)
{
	char  ip[32];
	
	// hack
	// *pVR_CTL = 0x4000 | (*pVR_CTL);
	
	/* Initializes the TCP/IP Stack and returns */	
	// true for fake init
	if(system_init(false) == -1)
	{
		printf("Failed to initialize system\n");
		return;
	}

	/* start stack */
	start_stack();

	/*
	 * For debug purposes, printf() the IP address to the VisualDSP++
	 * console window.  Likely not needed in final application.
	 */

	memset(ip,0,sizeof(ip));
	if(gethostaddr(0,ip))
	{
		printf("IP ADDRESS: %s\n",ip);
	}

	/**
	 *  Add Application Code here
	 **/
    RunSimpleUdpTest();

	/* Put the thread's exit from "main" HERE */
	/* A thread is automatically Destroyed when it exits its run function */
}
Exemplo n.º 25
0
int main(void)
{
	system_init();

//! [setup_init]
	configure_tcc();
	configure_tcc_callbacks();

	configure_eic();
	configure_event();
//! [setup_init]

//! [main]
	//! [enable_global_interrupts]
	system_interrupt_enable_global();
	//! [enable_global_interrupts]

	//! [main_loop]
	while (true) {
	}
	//! [main_loop]
//! [main]
}
Exemplo n.º 26
0
int main(int argc, char *argv[])
{
    SETUP_DEBUG_FILE();
    DEBUG_PRINTF(V_MESSAGE, "\n\nOi Xtreme Photo Control\n\n");
    args_parsing(argc, argv);
    system_init();

    if((operation_type == OPERATION_C) // PLAN C - One time operation, triggered automatically.
    || (operation_type == OPERATION_D)) // TYPE D - Continuous operation. Stress test.
    {
        operation_state = START_TEMPORIZATION; 
        operation_event_flag = 1;   // Operation initialization trigger.
    }

    while(1)
    {
        if(operation_event_flag)
        {
            operation_event_flag = 0;
            operation_handler();
        }
        if(accelgyro_tick_flag)
        {
            accelgyro_tick_flag = 0;
            accelgyro_handler();
        }
        usleep(MAIN_USLEEP_TIME);
        timeout_watchdog++;
        if(timeout_watchdog >= LOOP_WATCHDOG)
        {
            signalize(ERROR);
            exit(EXIT_FAILURE);
        }
    }
    CLOSE_DEBUG_FILE();
    return 0;
}
Exemplo n.º 27
0
int main(void)
{
	system_init();

	//! [setup_init]
	configure_wdt();
	//! [setup_init]

	//! [main]
	//! [main_1]
	enum system_reset_cause reset_cause = system_get_reset_cause();
	//! [main_1]

	//! [main_2]
	if (reset_cause == SYSTEM_RESET_CAUSE_WDT) {
		port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE);
	}
	else {
		port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
	}
	//! [main_2]

	//! [main_3]
	while (true) {
	//! [main_3]
		//! [main_4]
		if (port_pin_get_input_level(BUTTON_0_PIN) == false) {
		//! [main_4]
		//! [main_5]
			port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);

			wdt_reset_count();
		//! [main_5]
		}
	}
	//! [main]
}
Exemplo n.º 28
0
/**
 * \brief Main application function. 
 *
 * Start the sensor task then start the scheduler.
 *
 * \return program return value.
 */
int main(void)
{
#if SAMD21
	system_init();
#elif SAME70
	sysclk_init();
	board_init();
#endif

	/* Initialize the UART console. */
	configure_console();

	/* Initialize the delay driver. */
	delay_init();
			
	/* Enable SysTick interrupt for non busy wait delay. */
#if SAMD21
	if (SysTick_Config(system_cpu_clock_get_hz()/1000)) {
		puts("main: SysTick configuration error!");
		while (1);
	}
#elif SAME70
	if (SysTick_Config(sysclk_get_main_hz()/1000)) {
		puts("main: SysTick configuration error!");
		while (1);
	}
#endif


	/* Output example information */
	puts(STRING_HEADER);

	/* Start the demo task. */
	demo_start();
	
	return 0;
}
Exemplo n.º 29
0
/**
 * \brief Run External Interrupt unit tests
 *
 * Initializes the system and serial output, then sets up the
 * External Interrupt unit test suite and runs it.
 */
int main(void)
{
	system_init();
	delay_init();
	cdc_uart_init();

	/* Define Test Cases */
	DEFINE_TEST_CASE(extint_polled_mode_test,
			setup_extint_polled_mode_test,
			run_extint_polled_mode_test,
			cleanup_extint_polled_mode_test,
			"Testing external interrupt by polling");

	DEFINE_TEST_CASE(extint_callback_mode_test,
			setup_extint_callback_mode_test,
			run_extint_callback_mode_test,
			cleanup_extint_callback_mode_test,
			"Testing external interrupt using callback");

	/* Put test case addresses in an array */
	DEFINE_TEST_ARRAY(extint_tests) = {
		&extint_polled_mode_test,
		&extint_callback_mode_test,
	};

	/* Define the test suite */
	DEFINE_TEST_SUITE(extint_test_suite, extint_tests,
			"SAM D20/D21 External Interrupt driver test suite");

	/* Run all tests in the suite*/
	test_suite_run(&extint_test_suite);

	while (true) {
		/* Intentionally left empty */
	}
}
Exemplo n.º 30
0
//------------------------------------------------------------------------------
int main (int argc, char** argv)
{
    tOplkError                  ret = kErrorOk;
    tOptions                    opts;

    getOptions(argc, argv, &opts);

    if (system_init() != 0)
    {
        fprintf(stderr, "Error initializing system!");
        return 0;
    }

    initEvents(&fGsOff_l);

    printf("----------------------------------------------------\n");
    printf("openPOWERLINK console CN DEMO application\n");
    printf("using openPOWERLINK Stack: %s\n", PLK_DEFINED_STRING_VERSION);
    printf("----------------------------------------------------\n");

    if ((ret = initPowerlink(CYCLE_LEN, aMacAddr_l, opts.nodeId))
        != kErrorOk)
        goto Exit;

    if ((ret = initApp()) != kErrorOk)
        goto Exit;

    loopMain();

Exit:
    shutdownPowerlink();
    shutdownApp();
    system_exit();

    return 0;
}