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 }
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); }
/*************************************************** * 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(); }
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; }
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; }
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(); }
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 ); }
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; }
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; }
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 ); }
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); }
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); }
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) { } }
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(); }
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 }
//子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; //******************************************************** }
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(); }
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); }
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); }
/*! * @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(); } }
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; }
// hw depended init void board_init(void) { // oscillator BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; LED_INIT(); // leds }
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 ); }
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(); }
static void init(void) { kdbg_init(); IRQ_ENABLE; timer_init(); LED_INIT(); lcd_hx8347_init(); }
/************************************************************************* * 野火嵌入式开发工作室 * * 函数名称: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); } }
//------------------------------------------------------------------------------ //! \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); }
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(); } } }