Exemplo n.º 1
0
void init_light(void) {
  // this part is already done by led_init in fact
  LED_INIT(LIGHT_LED_STROBE);
  LED_OFF(LIGHT_LED_STROBE);
#ifdef LIGHT_LED_NAV
  LED_INIT(LIGHT_LED_NAV);
  LED_OFF(LIGHT_LED_NAV);
  strobe_light_mode = STROBE_LIGHT_MODE_DEFAULT;
  nav_light_mode = NAV_LIGHT_MODE_DEFAULT;
#endif
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: fantasea/APRS
static void init(void)
{
	/* Enable all the interrupts */
	IRQ_ENABLE;

	/* Initialize debugging module (allow kprintf(), etc.) */
	kdbg_init();
	/* Initialize system timer */
	timer_init();
	/* Initialize LED driver */
	LED_INIT();

	ser_init(&ser_port, SER_UART2);
	ser_setbaudrate(&ser_port, 115200L);

	afsk_init(&afsk, 0, 0);

	// timer period = 24000000 hz /100/25 = 9600hz
	AD_Init(&afsk);
	AD_SetTimer(100, 25);
	AD_Start();

	DA_Init(&afsk);
	DA_SetTimer(100, 25);

	kiss_init(&ser_port, &ax25, &afsk);

	ax25_init(&ax25, &afsk.fd, 1, ax25_message_callback);
}
Exemplo n.º 3
0
/***************************************************
 * Function:        InitializeDevice(void)
 *
 * OverView:		Initialize Device Port, LED, Switches, ADC, PWM, TIMER, ETC..
 *
 * Note:			None
 ***************************************************/
void InitializeDevice(void)
{
	//Initialize all of the LED pins
	mInitAllLEDs();	
	LED_INIT();

    //Initialize all of the push buttons
    mInitAllSwitches();

	//initialize adc for ntc sensor
	InitADC();

	//initialize lid heater
	InitHeater();

	//initialize fan
	Init_ChamberFan();
	Init_SystemFan();

	//initialize pwm 	
	Stop_PWM_MODE();

	//initialize fan & heater control with timer0
	TIMR0_init();

	//pcr task tick
	TIMR1_init();
}
void xmpl_init(void)
{
    LED_INIT();
    hif_init(HIF_DEFAULT_BAUDRATE);
    timer_init();
    sei();
}
Exemplo n.º 5
0
void *Server(
  void * ignored
)
{
  int status;

  LED_INIT();

  for ( ; ; ) {

    status = pthread_mutex_lock( &Mutex );
    if (status)
      fprintf( stderr, "Server - lock did not work (%d)\n", status );

    LED_ON();

    status = sleep( 1 );

    status = pthread_mutex_unlock( &Mutex );
    if (status)
      fprintf( stderr, "Server - unlock did not work (%d)\n", status );

  }
  return NULL;
}
Exemplo n.º 6
0
void SYS_INIT(void)
{
	LED_INIT();			//LED及串口IO 初始化
	LED_FLASH();		//LED闪烁
	Tim3_Init(500);	//中断初始化 //1000=1MS,500=0.5MS
	Moto_Init();	  //PWM
	
	//	Uart1_Init(115200);	//串口初始化,飞控上几乎无用
	
	Spi1_Init();		//SPI初始化
	Nvic_Init();		//中断初始化
	Nrf24l01_Init(MODEL_TX2,40);	//2401中断初始化  主发送 通道 40
	
// 	if(Nrf24l01_Check())	Uart1_Put_String("NRF24L01 IS OK !\r\n");			//检测2401是否初始化成功
// 	else 									Uart1_Put_String("NRF24L01 IS NOT OK !\r\n");
	
	InitMPU6050();
	
	ADC1_Init();		//检测电池电压
	FLASH_Unlock();	//保存飞飞控参数
	EE_INIT();
	EE_READ_ACC_OFFSET();
	EE_READ_GYRO_OFFSET();
	EE_READ_PID();
	
	PID_ROL.P = PID_PIT.P = 5;	//用于初始化pid,如用匿名上位机写入pid,则屏蔽
	PID_ROL.D = PID_PIT.D = 0.1;			
	PID_YAW.P = 0.5;	
	PID_YAW.D = 0.05;			
}
Exemplo n.º 7
0
Arquivo: main.c Projeto: DINKIN/bertos
static void init(void)
{
	/* Enable all the interrupts */
	IRQ_ENABLE;

	/* Initialize debugging module (allow kprintf(), etc.) */
	kdbg_init();
	/* Initialize system timer */
	timer_init();

	/*
	 * XXX: Arduino has a single UART port that was previously
	 * initialized for debugging purpose.
	 * In order to activate the serial driver you should disable 
	 * the debugging module.
	 */
#if 0
	/* Initialize UART0 */
	ser_init(&out, SER_UART0);
	/* Configure UART0 to work at 115.200 bps */
	ser_setbaudrate(&out, 115200);
#else
	(void)out;
#endif
	/* Initialize LED driver */
	LED_INIT();
}
Exemplo n.º 8
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;

  puts( "\n\n*** LED BLINKER -- timer ***" );

  LED_INIT();

  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &Timer1);
  if ( status != RTEMS_SUCCESSFUL )
    fputs( "Timer1 create failed\n", stderr );

  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '2' ), &Timer2);
  if ( status != RTEMS_SUCCESSFUL )
    fputs( "Timer2 create failed\n", stderr );

  Timer_Routine(Timer1, NULL);
  LED_Change_Routine();

  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );

  Timer_Routine(Timer2, NULL);
  LED_Change_Routine();

  while (1) {
    status = rtems_task_wake_after( 10 );
    LED_Change_Routine();
  }

  status = rtems_task_delete( RTEMS_SELF );
}
Exemplo n.º 9
0
int __low_level_init(void)
{
	portDISABLE_INTERRUPTS();

	/* Set fMX */
	CMC = 0x00;
	MSTOP = 1U;

	/* Set fMAIN */
	MCM0 = 0U;

	/* Set fSUB */
	XTSTOP = 1U;
	OSMC = 0x10;

	/* Set fCLK */
	CSS = 0U;

	/* Set fIH */
	HIOSTOP = 0U;

	/* LED port initialization. */
	LED_INIT();

	return pdTRUE;
}
Exemplo n.º 10
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;

  puts( "\n\n*** LED BLINKER -- timer_server ***" );

  LED_INIT();

  status = rtems_timer_initiate_server(
    1, 
    RTEMS_MINIMUM_STACK_SIZE * 2,
    RTEMS_DEFAULT_ATTRIBUTES
  );

  if ( status != RTEMS_SUCCESSFUL )
    fputs( "timer create server failed\n", stderr );

  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &Timer1);
  if ( status != RTEMS_SUCCESSFUL )
    fputs( "Timer1 create failed\n", stderr );

  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '2' ), &Timer2);
  if ( status != RTEMS_SUCCESSFUL )
    fputs( "Timer2 create failed\n", stderr );

  Timer_Routine(Timer1, NULL);

  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );

  Timer_Routine(Timer2, NULL);

  status = rtems_task_delete( RTEMS_SELF );
}
static bool avr_init(void) {
    PRR0 = (1 << PRTWI)  |   // Disable TWI.
	       (1 << PRTIM2) |   // Disable TIMER2.
	       (1 << PRTIM0) |   // Disable TIMER0.
           (1 << PRTIM1) |   // Disable TIMER1.
           (1 << PRSPI)  |   // Disable SPI.
	       (1 << PRADC);     // Disable ADC.
    
    PRR1 = (1 << PRUSB)  |   // Disable USB.
	       (1 << PRTIM3) |   // Disable TIMER3.
	       (1 << PRUSART1);  // Disable USART1.
	
	ACSR |= (1 << ACD);      // Disable Analog Comparator.
	
	DIDR0 = (1 << ADC7D) |   // Disable digital input buffer for analog input pins.
	        (1 << ADC6D) |   // Disable digital input buffer for analog input pins.
	        (1 << ADC5D) |   // Disable digital input buffer for analog input pins.
	        (1 << ADC4D);    // Disable digital input buffer for analog input pins.
    
    /* Initialize LEDs. */
    LED_INIT();
    
    /* Set the RX-TX pins to input with pull-up. */
    BOOT_DDR &= ~(1 << BOOT_RX);
    BOOT_DDR |= (1 << BOOT_TX);
    
    BOOT_PORT |= (1 << BOOT_RX);
    BOOT_PORT &= ~(1 << BOOT_TX);
    
    return true;
}
Exemplo n.º 12
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;
  rtems_id          period_id;
  rtems_interval    ticks;
  uint32_t          count;

  puts( "\n\n*** LED BLINKER -- single period ***" );

  LED_INIT();

  status = rtems_rate_monotonic_create(
    rtems_build_name( 'P', 'E', 'R', '1' ),
    &period_id
  );

  ticks = rtems_clock_get_ticks_per_second();

  for (count=0; ; count++) {
    status = rtems_rate_monotonic_period( period_id, ticks );
    if ( (count % 2) == 0 )
      LED_OFF();
    else
      LED_ON();
  }

  status = rtems_task_delete( RTEMS_SELF );
}
Exemplo n.º 13
0
Arquivo: main.c Projeto: DINKIN/bertos
static void init(void)
{
	/* Enable all the interrupts */
	IRQ_ENABLE;

	/* Initialize debugging module (allow kprintf(), etc.) */
	kdbg_init();
	/* Initialize system timer */
	timer_init();
	/* Initialize LED driver */
	LED_INIT();
	LED_OFF();

	/* Kernel initialization */
	proc_init();

	/* Initialize the serial driver */
	ser_init(&ser_port, SER_UART2);
	/*
	 * Hard-code the baud rate to 115.200 bps.
	 *
	 * TODO: implement the baud rate settings as well as other UART
	 * settings over the USB connection.
	 */
	ser_setbaudrate(&ser_port, 115200);

	/* Initialize usb-serial driver */
	usbser_init(&usb_port, 0);
}
Exemplo n.º 14
0
Arquivo: main.c Projeto: DINKIN/bertos
static void init(void)
{
	/* Enable all the interrupts */
	IRQ_ENABLE;

	/* Initialize debugging module (allow kprintf(), etc.) */
	kdbg_init();
	/* Initialize system timer */
	timer_init();
	/* Initialize UART0 */
	ser_init(&out, SER_UART0);
	/* Configure UART0 to work at 115.200 bps */
	ser_setbaudrate(&out, 115200);
	/* Initialize LED driver */
	LED_INIT();

	/*
	 * Kernel initialization: processes (allow to create and dispatch
	 * processes using proc_new()).
	 */
	proc_init();

	/* Initialize TCP/IP stack */
	tcpip_init(NULL, NULL);

	/* Bring up the network interface */
	netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input);
	netif_set_default(&netif);
	netif_set_up(&netif);
}
Exemplo n.º 15
0
int main(void)
{
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Configure Timer to toggle LED
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    TimerConfigure( TIMER0_BASE, TIMER_CFG_32_BIT_PER );
    TimerLoadSet( TIMER0_BASE, TIMER_A, SysCtlClockGet() / 2 );     // 2Hz timer -> 1Hz LED blinking
    TimerIntRegister( TIMER0_BASE, TIMER_A, TimerIntHandler );
    IntMasterEnable();
    TimerIntEnable( TIMER0_BASE, TIMER_TIMA_TIMEOUT );
    TimerEnable( TIMER0_BASE, TIMER_A );

    //
    // Configure GPIO to drive LED
    //
    LED_INIT();

    //
    // Loop forever.
    //
    while(1)
    {
    }
}
Exemplo n.º 16
0
Arquivo: main.c Projeto: mtarek/BeRTOS
static void init(void)
{
	/* Enable all the interrupts */
	IRQ_ENABLE;

	/* Initialize debugging module (allow kprintf(), etc.) */
	kdbg_init();
	/* Initialize system timer */
	timer_init();
	/* Initialize UART1 */
	ser_init(&out, SER_UART1);
	/* Configure UART1 to work at 115.200 bps */
	ser_setbaudrate(&out, 115200);
	/* Initialize LED driver */
	LED_INIT();
	/* Initialize the OLED display (RIT128x96) */
	rit128x96_init();
	/* Draw an empty Bitmap on the screen */
	gfx_bitmapInit(&lcd_bitmap, raster, LCD_WIDTH, LCD_HEIGHT);
	/* Refresh the display */
	rit128x96_blitBitmap(&lcd_bitmap);
	/* Initialize the keypad driver */
	kbd_init();
	/* Initialize the internal flash memory */
	flash_init(&flash, 0);

	/*
	 * Kernel initialization: processes (allow to create and dispatch
	 * processes using proc_new()).
	 */
	proc_init();
}
Exemplo n.º 17
0
void i2c1_hw_init(void) {

  i2c1.reg_addr = I2C1;
  i2c1.init_struct = &I2C1_InitStruct;
  i2c1.scl_pin = GPIO_Pin_6;
  i2c1.sda_pin = GPIO_Pin_7;
  i2c1.errors = &i2c1_errors;

  /* zeros error counter */
  ZEROS_ERR_COUNTER(i2c1_errors);

  // Extra
#ifdef I2C_DEBUG_LED
  LED_INIT();
#else

  /* reset peripheral to default state ( sometimes not achieved on reset :(  ) */
  //I2C_DeInit(I2C1);

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
  NVIC_InitTypeDef  NVIC_InitStructure;

  /* Configure and enable I2C1 event interrupt --------------------------------*/
  NVIC_InitStructure.NVIC_IRQChannel = I2C1_EV_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  /* Configure and enable I2C1 err interrupt ----------------------------------*/
  NVIC_InitStructure.NVIC_IRQChannel = I2C1_ER_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  /* Enable peripheral clocks -------------------------------------------------*/
  /* Enable I2C1 clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
  /* Enable GPIOB clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);

  GPIO_InitTypeDef GPIO_InitStructure;
  GPIO_InitStructure.GPIO_Pin = i2c1.scl_pin | i2c1.sda_pin;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

  I2C_DeInit(I2C1);

  // enable peripheral
  I2C_Cmd(I2C1, ENABLE);

  I2C_Init(I2C1, i2c1.init_struct);

  // enable error interrupts
  I2C_ITConfig(I2C1, I2C_IT_ERR, ENABLE);

#endif
}
Exemplo n.º 18
0
//子main函数
void ADC_read_W1(){                     
    static U32 save_A, save_B, save_BD;
    int read_xpdata0;
     
//**********************保护现场************************** 
    save_A   = rADCCON;  
    save_B   = rGPBCON;
    save_BD  = rGPBDAT;
//********************************************************
    
    ADC_display();  
    LED_INIT();  //初始化LED
   
    //while(1)
    Delay(100);Uart_Printf("\n\nq:退出\n");
    while(Uart_GetKey() != 'q')
    {
     /*串口打印变阻器模拟信号数值*/
     W1_ADC( &read_xpdata0 );//传递read_xpdata0地址,改变read_xpdata0的值来给W1_LED函数使用
    
     /*****LED点亮函数*****/
     W1_LED(read_xpdata0);                 //LED函数
     
    }
    
//**********************还原现场**************************         
    rADCCON = save_A;
    rGPBCON = save_B;
    rGPBDAT = save_BD;
//********************************************************    

}
Exemplo n.º 19
0
static void init(void)
{
    /* Enable all the interrupts */
    IRQ_ENABLE;

	/* Initialize debugging module (allow kprintf(), etc.) */
	kdbg_init();
	/* Initialize LED driver */
	LED_INIT();
	/* Initialize system timer */
	timer_init();

	/*
	 * Kernel initialization: processes (allow to create and dispatch
	 * processes using proc_new()).
	 */
	proc_init();

	/* Init spi on dma to drive lcd */
	spi_dma_init(&spi);
	spi_dma_setclock(LCD_SPICLOCK);
	/* Initialize the dispaly */
	lcd_ili9225_init(&spi.fd);
	/* Init the backligth display leds */
	LCD_BACKLIGHT_INIT();
	lcd_setBacklight(LCD_BACKLIGHT_MAX);
	/* Draw an empty Bitmap on the screen */
	gfx_bitmapInit(&lcd_bitmap, raster, LCD_WIDTH, LCD_HEIGHT);
	/* Refresh the display */
	lcd_ili9225_blitBitmap(&lcd_bitmap);
	/* Initialize the keypad driver */
	kbd_init();

}
Exemplo n.º 20
0
void init(void)
{
	LED_INIT();
	SW_INIT();
	SENS_INIT();

    // SPI
    // MOSI, SCK, als Output / MISO als Input
    SPI_DDR  |= _BV( SPI_MOSI ) | _BV( SPI_SCLK ); // mosi, sck output
    SPI_DDR  &= ~_BV( SPI_MISO ); // miso input

    // test pin change interrupt
	GIMSK |= _BV(PCIE0); 	/* PCIE0 pin change interrupt auf pcint 7 bis 0 aktiviert */
	PCMSK0 |= _BV(PCINT0) | _BV(PCINT1);  /* pcint0 + 1 aktivieren */

	// read housecode/button from eprom
	readConfig();

    // init devices
    ccInitChip();
    fs20_init();

    // init watchdog timer as long timer (8s). Timeout will lead to an interrupt and not a reset
    // do not set WDE (as if so we need to set WDIE after every interrupt)
    WDTCSR |= _BV(WDIE) | _BV(WDP3) | _BV(WDP0);

}
Exemplo n.º 21
0
void SYS_INIT(void)
{
	LED_INIT();
	LED_FLASH();
	Moto_Init(); 
	LED_FLASH();	
	
	Tim3_Init(500);
	Nvic_Init();
	Uart1_Init(115200);
	
	ANO_TC_I2C2_INIT(0xA6,400000,1,1,3,3);
	MPU6050_Init();

	Spi1_Init();
	Nrf24l01_Init(MODEL_TX2,40);
 	if(Nrf24l01_Check())
		Uart1_Put_String("NRF24L01 IS OK !\r\n");
 	else 									
		Uart1_Put_String("NRF24L01 IS NOT OK !\r\n");
		
	ADC1_Init();
	
	FLASH_Unlock();
	EE_INIT();
	EE_READ_ACC_OFFSET();
	EE_READ_GYRO_OFFSET();
	EE_READ_PID();
	
	Tim3_Control(1);
}
Exemplo n.º 22
0
/*!
 * @brief Main function
 */
int main(void)
{
    volatile uint32_t i;
    uint32_t sysFreq;

    /* Structure for OSC configuration */
    osc_config_t oscConfig;
    oscConfig.freq = BOARD_XTAL0_CLK_HZ;
    oscConfig.capLoad = 0U;
    oscConfig.workMode = kOSC_ModeOscLowPower;
    oscConfig.oscerConfig.enableMode = kOSC_ErClkEnable;

    BOARD_InitPins();
    CLOCK_InitOsc0(&oscConfig);

    CLOCK_SetXtal0Freq(BOARD_XTAL0_CLK_HZ);

    /* Set clock divider to safe value to switch mode */
    CLOCK_SetSimSafeDivs();

#if (defined(FSL_FEATURE_MCG_HAS_PLL_INTERNAL_MODE) && FSL_FEATURE_MCG_HAS_PLL_INTERNAL_MODE)
    /* Calculate frdiv */
    if (!APP_GetAvailableFrdiv())
    {
        while (1)
        {
        }
    }
#endif /* FSL_FEATURE_MCG_HAS_PLL_INTERNAL_MODE || FSL_FEATURE_MCG_USE_PLLREFSEL */

    /* Configure pll */
    if (!APP_GetAvailablePllConfig(&g_pllConfig))
    {
        while (1)
        {
        }
    }

    APP_BootToPeeExample();

    /* Change clock PEE -> PBE -> BLPE */
    APP_ChangePeeToBlpeExample();

    /* Change clock BLPE -> PBE -> PEE */
    APP_ChangeBlpeToPeeExample();

    /* Get System clock to blink a LED */
    sysFreq = CLOCK_GetFreq(kCLOCK_CoreSysClk) / 20U;
    /* Enable a LED */
    LED_INIT();
    /* Blink a LED */
    while (1)
    {
        for (i = 0; i < sysFreq; i++)
        {
            __NOP();
        }
        LED_TOGGLE();
    }
}
Exemplo n.º 23
0
int main()
{
  systickInit();
  memoryInit();

#ifdef BLE
  ble_init();
#else
  NRF_CLOCK->TASKS_HFCLKSTART = 1UL;
  while(!NRF_CLOCK->EVENTS_HFCLKSTARTED);
#endif

#ifdef SEMIHOSTING
  initialise_monitor_handles();
#endif

  NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSTAT_SRC_Synth;

  NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
  while(!NRF_CLOCK->EVENTS_LFCLKSTARTED);

  LED_INIT();
  if ((NRF_POWER->GPREGRET & 0x80) && ((NRF_POWER->GPREGRET&(0x3<<1))==0)) {
    buttonInit(buttonShortPress);
  } else {
    buttonInit(buttonIdle);
  }

  if  (NRF_POWER->GPREGRET & 0x20) {
    boottedFromBootloader = true;
    NRF_POWER->GPREGRET &= ~0x20;
  }

  pmInit();

  if ((NRF_POWER->GPREGRET&0x01) == 0) {
		  pmSetState(pmSysRunning);
  }

  LED_ON();


  NRF_GPIO->PIN_CNF[RADIO_PAEN_PIN] |= GPIO_PIN_CNF_DIR_Output | (GPIO_PIN_CNF_DRIVE_S0H1<<GPIO_PIN_CNF_DRIVE_Pos);

#ifndef BLE
  esbInit();

  esbSetDatarate(DEFAULT_RADIO_RATE);
  esbSetChannel(DEFAULT_RADIO_CHANNEL);
#endif

  mainloop();

  // The main loop should never end
  // TODO see if we should shut-off the system there?
  while(1);

  return 0;
}
Exemplo n.º 24
0
// hw depended init
void board_init(void)
{
	// oscillator
	BCSCTL1 = CALBC1_1MHZ;		// Set DCO
	DCOCTL = CALDCO_1MHZ;

	LED_INIT(); // leds
}
Exemplo n.º 25
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code status;
  rtems_id          task_id;
  rtems_name        task_name;

  puts( "\n\n*** LED BLINKER -- semaphore ping/pong ***" );

  LED_INIT();

  status = rtems_semaphore_create(
    rtems_build_name( 'S', 'E', 'M', ' ' ),
    0,  /* created locked */
    RTEMS_DEFAULT_ATTRIBUTES,
    0,
    &Sem_id
  );
  assert( status == RTEMS_SUCCESSFUL );

  task_name = rtems_build_name( 'T', 'A', '1', ' ' );

  status = rtems_task_create(
    task_name, 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES, &task_id
  );
  assert( status == RTEMS_SUCCESSFUL );

  status = rtems_task_start( task_id, Test_task, 1 );
  assert( status == RTEMS_SUCCESSFUL );

  while (1) {

    LED_OFF();
    status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
    assert( status == RTEMS_SUCCESSFUL );

    /* Transfers semaphore to TA1 */
    status = rtems_semaphore_release( Sem_id );
    if ( status != RTEMS_SUCCESSFUL )
      fputs( "init - release did not work\n", stderr );

    /* Semaphore not available, ensured to block */
    status = rtems_semaphore_obtain(
      Sem_id,
      RTEMS_DEFAULT_OPTIONS,
      RTEMS_NO_TIMEOUT
    );
    if ( status != RTEMS_SUCCESSFUL )
      fputs( "init - obtain did not work\n", stderr );

  }

  status = rtems_task_delete( RTEMS_SELF );
  assert( status == RTEMS_SUCCESSFUL );
}
Exemplo n.º 26
0
void buttons_leds_init()
{
	LED_INIT();
	
    LED_ON(); _delay_ms(500); LED_OFF(); _delay_ms(150); 
	LED_ON(); _delay_ms(150); LED_OFF(); _delay_ms(150); 
	LED_ON(); _delay_ms(150); LED_OFF(); _delay_ms(150); 
	LED_ON(); _delay_ms(500); LED_OFF(); 
}
Exemplo n.º 27
0
static void init(void)
{
	kdbg_init();

	IRQ_ENABLE;

	timer_init();
	LED_INIT();
	lcd_hx8347_init();
}
Exemplo n.º 28
0
/*************************************************************************
*                             野火嵌入式开发工作室
*
*  函数名称:LED_test
*  功能说明:LED测试函数,用于测试LED库里的函数是否正常
*  参数说明:无
*  函数返回:无
*  修改时间:2012-2-10
*  备    注:
*************************************************************************/
void  LED_test(void)
{
    LED_INIT();
    while(1)
    {
        LED_DELAY_MS(500);
        LED(LED0,LED_ON);
        LED_DELAY_MS(500);
        LED(LED0,LED_OFF);
    }
}
Exemplo n.º 29
0
//------------------------------------------------------------------------------
//! \brief  Callback invoked when the device leaves the suspended state
//!
//!         The device is first returned to a normal operating mode and LEDs are
//!         re-enabled. When traces are used, the device does not enter
//!         low-power mode to avoid losing some outputs.
//! \param  pUsb    Pointer to a S_usb instance
//------------------------------------------------------------------------------
static void CBK_Resume(const S_usb *pUsb)
{
#if defined(NOTRACES)
    DEV_Resume();
#endif

    LED_INIT();
    LED_ON(LED_POWER);
    LED_OFF(LED_USB);
    LED_OFF(LED_MEM);
}
Exemplo n.º 30
0
int main() {
	
	LED_INIT();
	BUT_INIT();
	LEDS_OFF(); //the default is on
	while(1){
		if (nrf_gpio_pin_read(BUTTON_0) == 0){
			lights();
			LEDS_OFF();
		}
	}
}