示例#1
0
int main(void)
{
  // initialize
  SystemInit();
  initialise_monitor_handles();
  init_systick();

  /* Initialize the accelerometers */
  init_accelerometers();

  /* Initialize the LCD and Touch modules */
  Delay(0x3FFFFF);
  LCD_Init();
  Delay(0x3FFFFF);
  touch_init();

  /* Clear the LCD, set text color to green and backlight to 100 */
  LCD_Clear(BLACK);
  LCD_SetTextColor(GREEN);
  LCD_SetBackColor(LCD_COLOR_BLACK);
  LCD_BackLight(100);

  /* Add update_game to the timed_task array */
  add_timed_task(update_game, 0.05);

  while(1)
  {
    /* Check if the timed task function has to be called */
    update();
  }
}
示例#2
0
文件: main.c 项目: Gozhack/firmware
void bootloader_main() {
	SystemInit();
	spiflash_reinit();
	CGU_Init();

	hw_digital_output(LED1);
	hw_digital_output(LED2);
	hw_digital_output(CC3K_CONN_LED);
	hw_digital_output(CC3K_ERR_LED);
	hw_digital_write(CC3K_CONN_LED, 0);
	hw_digital_write(CC3K_ERR_LED, 0);

	init_systick();

	__enable_irq();

	usb_init();
	usb_set_speed(USB_SPEED_FULL);
	usb_attach();

	while(!exit_and_jump) {
		led_task();
		__WFI(); /* conserve power */
	}

	delay_ms(25);

	usb_detach();

	delay_ms(100);

	if (dfu_target == TARGET_RAM) {
		jump_to_flash(DFU_DEST_BASE, 0);
	}
}
示例#3
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{

	SystemInit();
	init_systick();

#ifdef SERIAL_DEBUG
  DebugComPort_Init();  
#endif
  printf(" Artnet2WS2811 Receiver\r\n ");
  /*Initialize LCD and Leds */ 
  LED_Init();
  
  /* configure ethernet (GPIOs, clocks, MAC, DMA) */ 
  ETH_BSP_Config();
    
  /* Initilaize the LwIP stack */
  LwIP_Init();
  
  /* tcp echo server Init */
  //tcp_echoserver_init();
  telnetserver_init();
  //artnet_init();

  ws2812_init();
  /* Initialize variables for ws2812 */

	delay_ms(20);




  /* Infinite loop */
  while (1)
  {  
    /* check if any packet received */

	  if (ETH_CheckFrameReceived())
    {
      /* process received ethernet packet */
      LwIP_Pkt_Handle();
    }
    /* handle periodic timers for LwIP */
    LwIP_Periodic_Handle(system_time);

    DRAW_LED();
  }   
}
示例#4
0
int main(void)
/*****************************************************************************
*   Input    :
*   Output   :
*   Function : The super loop.
******************************************************************************/
{
  INT8U event;
  INT8U counter_value;

  disable_global_int();
  init_systick();
  init_gpio();
  enable_global_int();


  // Loop forever.
  while(1)
  {
	// System part of the super loop.
	// ------------------------------
	while( !ticks );


	// The following will be executed every 5mS
	ticks--;

	if( ! --alive_timer )
	{
    	alive_timer =	MILLISEC( 500 );
	  	GPIO_PORTD_DATA_R ^= 0x40;
	}

    // Protected operating system mode
    swt_ctrl();

    // Application mode
    task_rtc( TASK_RTC );
    task_button( TASK_BUTTON );
    task_set_time( TASK_SET_TIME );
    task_lcd( TASK_LCD );
  }
}
int main(void)
{
    rcc_clock_init();

    /* Set PA8 for MCO1 function */
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
    GPIOA->MODER = GPIO_MODER8_ALTERNATE;
    GPIOA->OTYPER = GPIO_OTYPER8_PP;
    GPIOA->OSPEED = GPIO_OSPEED8_100MHZ;
    GPIOA->PUPDR = GPIO_PUPDR8_NO;
    GPIOA->AFRH = GPIO_AFRH8_AF0;

    /* Set PC9 as MCO2 function */
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN;
    GPIOC->MODER = GPIO_MODER9_ALTERNATE;
    GPIOC->OTYPER = GPIO_OTYPER9_PP;
    GPIOC->OSPEED = GPIO_OSPEED9_100MHZ;
    GPIOC->PUPDR = GPIO_PUPDR9_NO;
    GPIOC->AFRH = GPIO_AFRH9_AF0;

    /* Set MCO1, depends on which rcc you used */
    init_mco1();

    /* Set MCO2, select SYSCLK as output source and no division */
    RCC->CFGR &= ~RCC_CFGR_MCO2;
    RCC->CFGR |= RCC_CFGR_MCO2_SYSCLK;
    RCC->CFGR &= ~RCC_CFGR_MCO2_PRE;
    RCC->CFGR |= RCC_CFGR_MCO2_PRE_DIV1;

    /* Set PG13 as general output function(LED) */
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOGEN;
    GPIOG->MODER = GPIO_MODER13_OUTPUT;
    GPIOG->OTYPER = GPIO_OTYPER13_PP;
    GPIOG->OSPEED = GPIO_OSPEED13_100MHZ;
    GPIOG->PUPDR = GPIO_PUPDR13_NO;

    /* Set SysTick, trigger every 500ms */
    init_systick();

    while(1);

    return 0;
}
示例#6
0
文件: main.c 项目: entropia/usblockd
void main(void) {
	rcc_clock_setup_in_hse_8mhz_out_72mhz();

	init_systick();
	init_usb();
	power_init();
	lock_init();

	// configure status LED
	rcc_periph_clock_enable(RCC_GPIOC);
	gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13);

	// configure buzzer input
	rcc_periph_clock_enable(RCC_GPIOB);
	gpio_set_mode(GPIOB, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO9);
	gpio_set(GPIOB, GPIO9); // pull up

	set_state(CLOSED);

	uint32_t button_start = 0;
	while(1) {
		usb_poll();

		if(get_state() == CLOSED)
			gpio_set(GPIOC, GPIO13);
		else
			gpio_clear(GPIOC, GPIO13);

		if(gpio_get(GPIOB, GPIO9) == 0) {
			if(button_start == 0)
				button_start = ticks;
		} else
			button_start = 0;

		if(button_start && time_after(ticks, button_start + (HZ/10)) && get_state() == CLOSED)
			lock();

		if(button_start && time_after(ticks, button_start + HZ * 15))
			lock();
	}
}
void ipaugenblick_main_loop()
{
    struct rte_mbuf *mbuf;
    uint8_t ports_to_poll[1] = { 0 };
    int drv_poll_interval = get_max_drv_poll_interval_in_micros(0);
    app_glue_init_poll_intervals(drv_poll_interval/(2*MAX_PKT_BURST),
                                 100 /*timer_poll_interval*/,
                                 drv_poll_interval/(10*MAX_PKT_BURST),
                                drv_poll_interval/(60*MAX_PKT_BURST));
    
    ipaugenblick_service_api_init(COMMAND_POOL_SIZE,DATA_RINGS_SIZE,DATA_RINGS_SIZE);
    TAILQ_INIT(&buffers_available_notification_socket_list_head);
    TAILQ_INIT(&ipaugenblick_clients_list_head);
    init_systick(rte_lcore_id());
    ipaugenblick_log(IPAUGENBLICK_LOG_INFO,"IPAugenblick service initialized\n");
    while(1) {
        process_commands();
	app_glue_periodic(1,ports_to_poll,1);
        while(!TAILQ_EMPTY(&buffers_available_notification_socket_list_head)) {
            if(get_buffer_count() > 0) {
                struct socket *sock = TAILQ_FIRST(&buffers_available_notification_socket_list_head);
                socket_satelite_data_t *socket_data = get_user_data(sock);
		if(socket_data->socket->type == SOCK_DGRAM)
		   	user_set_socket_tx_space(&g_ipaugenblick_sockets[socket_data->ringset_idx].tx_space,sk_stream_wspace(socket_data->socket->sk));
		//printf("%s %d %d %d %d\n",__FILE__,__LINE__,socket_data->ringset_idx,g_ipaugenblick_sockets[socket_data->ringset_idx].tx_space,sk_stream_wspace(socket_data->socket->sk));
                if(!ipaugenblick_mark_writable(socket_data)) { 
                    sock->buffers_available_notification_queue_present = 0;
                    TAILQ_REMOVE(&buffers_available_notification_socket_list_head,sock,buffers_available_notification_queue_entry); 
                }
                else {
                    break;
                }
            }
            else {
                break;
            }
        }
    }
}
示例#8
0
int main(void) {
    if (PM->RCAUSE.reg & (PM_RCAUSE_POR | PM_RCAUSE_BOD12 | PM_RCAUSE_BOD33)) {
        // On powerup, force a clean reset of the MT7620
        pin_low(PIN_SOC_RST);
        pin_out(PIN_SOC_RST);

        // turn off 3.3V to SoC
        pin_low(PIN_SOC_PWR);
        pin_out(PIN_SOC_PWR);

        // pull 1.8V low
        pin_low(PIN_18_V);
        pin_out(PIN_18_V);

        clock_init_crystal(GCLK_SYSTEM, GCLK_32K);
        timer_clock_enable(TC_BOOT);

        // hold everything low
        boot_delay_ms(50); // power off for 50ms

        pin_high(PIN_SOC_PWR);

        boot_delay_ms(2); // 2ms until 1.8 rail comes on

        pin_high(PIN_18_V);

        boot_delay_ms(50); // 50ms before soc rst comes on
    } else {
        clock_init_crystal(GCLK_SYSTEM, GCLK_32K);
    }

    pin_mux(PIN_USB_DM);
    pin_mux(PIN_USB_DP);
    usb_init();
    usb_attach();
    NVIC_SetPriority(USB_IRQn, 0xff);

    pin_high(PIN_LED);
    pin_out(PIN_LED);

    pin_in(PIN_SOC_RST);

    pin_high(PIN_SOC_PWR);
    pin_out(PIN_SOC_PWR);

    pin_low(PORT_A.power);
    pin_out(PORT_A.power);

    pin_low(PORT_B.power);
    pin_out(PORT_B.power);

    pin_pull_up(PIN_BRIDGE_CS);
    pin_pull_up(PIN_FLASH_CS);

    pin_pull_up(PIN_SERIAL_TX);
    pin_pull_up(PIN_SERIAL_RX);

    dma_init();
    NVIC_EnableIRQ(DMAC_IRQn);
    NVIC_SetPriority(DMAC_IRQn, 0xff);

    eic_init();
    NVIC_EnableIRQ(EIC_IRQn);
    NVIC_SetPriority(EIC_IRQn, 0xff);

    evsys_init();
    NVIC_EnableIRQ(EVSYS_IRQn);
    NVIC_SetPriority(EVSYS_IRQn, 0);

    adc_init(GCLK_SYSTEM, ADC_REFCTRL_REFSEL_INTVCC1);
    dac_init(GCLK_32K);

    bridge_init();

    port_init(&port_a, 1, &PORT_A, GCLK_PORT_A,
        TCC_PORT_A, DMA_PORT_A_TX, DMA_PORT_A_RX);
    port_init(&port_b, 2, &PORT_B, GCLK_PORT_B,
        TCC_PORT_B, DMA_PORT_B_TX, DMA_PORT_B_RX);

    __enable_irq();
    SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
    
    init_systick();

    while (1) { __WFI(); }
}
示例#9
0
文件: ktimer.c 项目: KunYi/f9-kernel
static void ktimer_init(void)
{
	init_systick(CONFIG_KTIMER_HEARTBEAT, 0);
}
示例#10
0
文件: ktimer.c 项目: KunYi/f9-kernel
void ktimer_enter_tickless()
{
	uint32_t tickless_delta;
	uint32_t reload;

	irq_disable();

	if (ktimer_enabled && ktimer_delta <= KTIMER_MAXTICKS) {
		tickless_delta = ktimer_delta;
	} else {
		tickless_delta = KTIMER_MAXTICKS;
	}

	/* Minus 1 for current value */
	tickless_delta -= 1;

	reload = CONFIG_KTIMER_HEARTBEAT * tickless_delta;

	reload += systick_now() - ktimer_tickless_compensation;

	if (reload > 2) {
		init_systick(reload, CONFIG_KTIMER_HEARTBEAT);

#if defined(CONFIG_KDB) && \
    defined(CONFIG_KTIMER_TICKLESS) && defined(CONFIG_KTIMER_TICKLESS_VERIFY)
		tickless_verify_count();
#endif
	}

	wait_for_interrupt();

	if (!systick_flag_count()) {
		uint32_t tickless_rest = (systick_now() / CONFIG_KTIMER_HEARTBEAT);

		if (tickless_rest > 0) {
			int reload_overflow;

			tickless_delta = tickless_delta - tickless_rest;

			reload = systick_now() % CONFIG_KTIMER_HEARTBEAT - ktimer_tickless_int_compensation;
			reload_overflow = reload < 0;
			reload += reload_overflow * CONFIG_KTIMER_HEARTBEAT;

			init_systick(reload, CONFIG_KTIMER_HEARTBEAT);

			if (reload_overflow) {
				tickless_delta++;
			}

#if defined(CONFIG_KDB) && \
    defined(CONFIG_KTIMER_TICKLESS) && defined(CONFIG_KTIMER_TICKLESS_VERIFY)
			tickless_verify_count_int();
#endif
		}
	}

	ktimer_time += tickless_delta;
	ktimer_delta -= tickless_delta;
	ktimer_now += tickless_delta;

	irq_enable();
}