/** * Function for application main entry. */ int main(void) { init_leds(); init_clock(); uint32_t err_code; // Button configuration structure. static app_button_cfg_t p_button[] = { {BUTTON_1, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}, {BUTTON_2, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}, {BUTTON_3, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}, {BUTTON_4, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}}; // Macro for initializing the application timer module. // It will handle dimensioning and allocation of the memory buffer required by the timer, making sure that the buffer is correctly aligned. It will also connect the timer module to the scheduler (if specified). APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL); // Macro for initializing the GPIOTE module. // It will handle dimensioning and allocation of the memory buffer required by the module, making sure that the buffer is correctly aligned. APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS); // Initializing the buttons. err_code = app_button_init(p_button, sizeof(p_button) / sizeof(p_button[0]), BUTTON_DEBOUNCE_DELAY); APP_ERROR_CHECK(err_code); // Enabling the buttons. err_code = app_button_enable(); APP_ERROR_CHECK(err_code); while(true) { // Do nothing. } }
int main(void) { union uKeyRoster scan; chip_init(); /* Chip initialization */ can_init(); /* Enables Mob0 for Reception! */ an_init(); /* Analog SPI module init */ init_leds(); can_init_test_msg(); byte result = CANSTMOB; /* TEST B) Button boards configured as receivers; LEDs showing upper nibble. 1 Analog board on network will transmit a message. */ send_test_msgs(); while (1) { // READ ALL ACTIVE ANALOG SIGNALS: an_read_actives(); // TRANSMIT ACTIVE SIGNALS can_send_analog_msgs(); /* Send about every 1 second */ delay( one_second ); } return(0); }
}END_TEST /* Id/Title: tc-10 tests leds condition on 1 percentage Purpose: tests when battery percentage is 1, currentTimer minus previous Timer is greater than 500, then currentTimer should be equal to previousTimer; Expected results: currentTimer equals to previousTimer Pass/Fail criteria: when check is run response is 100%: Checks: 15, Failures: 0, Errors: 0 */ START_TEST(test_loop_timer) { init_leds(); display_percentage(1); unsigned long currentTimer= 1200; unsigned long previousTimer= 600; if (currentTimer - previousTimer > 500 ) previousTimer = currentTimer; fail_unless(previousTimer == 1200); }END_TEST
void init() { ResetReason = MCUSR; cli(); WDT_off(); // Turn off until initialization is done and we can pet the dog. init_leds (); init_buttons(); init_limit_switches(); init_motor(); float mBaseFrequencyHerz = 500.0; // 4khz pwm_init( mBaseFrequencyHerz, TRUE ); init_serial(); init_configuration(); // read_configuration_and_set(); // init_adc(); // start_sampling(); encoder_init(); // pot_init (); WDT_Prescaler_Change(); //delay(100000); // ~ 2 sec //read_cal(); // Read everything including motor stops. sei(); //OS_InitTask(); }
int main(){ //sei(); //initializing a2d converter adc_init(); // initialize fast PWM on PB1 (OSCR1A) //setup_pwm(); // setting up serial communication 8E2 asynchronous mode. // 4800 baud , 8 data bits , two stop bits, even parity. //serial_init(BAUD_RATE); serial_init(4800); //initilize LEDs init_leds(); TCCR0 = 0b101; TCNT0=0; TIMSK |= _BV(TOIE0); sei(); TIMSK |= _BV(TOIE0); // initial blink startblink(); OCR1A = 0x0000; // main loop that polls the distance sensor. while(1){ _serial_write('a'); while ((UCSRA & 0b01000000) == 0b00000000); _delay_ms(150); } return 0; }
//Initialize all the peripherals void init_peripherals(void) { //Hardware modules: init_systick_timer(); //SysTick timer init_usart1(2000000); //USART1 (RS-485 #1) init_usart6(2000000); //USART6 (RS-485 #2) init_rs485_outputs(); init_leds(); init_switches(); init_dio(); //All inputs by default init_adc1(); init_spi4(); //Plan //init_spi5(); //FLASH //init_spi6(); //Expansion init_i2c1(); init_imu(); init_adva_fc_pins(); init_pwr_out(); //Software: init_master_slave_comm(); //All RGB LEDs OFF LEDR(0); LEDG(0); LEDB(0); //Default analog input states: set_default_analog(); }
main(void) { /* hardware initialisation: */ init_leds(); init_buzzr(); //USART0_Init(); // init_motor(); //init_pwm(); //init_sampletimer(); /* syntesizer initialisation */ //synth_init(); /* here the show begins:*/ //sei(); //set_motor(MOTOR_ON); for(;;) /* ever */ { //do something waitr(50,5000); click(); ledr(); //synth_poll(); //USART0_put_uint16(0xA09F); //USART0_crlf(); } /* never return 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(); } }
void init() { ResetReason = MCUSR; cli(); chip_init (); // Chip initialization init_leds (); delay(1000000); // ~ 2 sec read_cal(); // Read everything including motor stops. // yes can_init() needs MyInstance to be set already for filtering! can_init(CAN_250K_BAUD); /* Enables Mob0 for Reception! */ // INIT MYINSTANCE: config_init(); can_instance_init(); set_rx_callback ( can_file_message ); set_configure_callback ( config_change ); sei(); OS_InitTask(); pot_init(); motor_init (); can_prep_instance_request( &msg2, 0xBB ); can_send_msg( 0, &msg2 ); }
}END_TEST /* Id/Title: tc-11 tests leds condition on 1 percentage Purpose: tests when battery percentage is 1, currentTimer minus previous Timer is greater than 500, then if the ledState is LOW, the state should change to HIGH and the leds should be in HIGH position Expected results: All the ledpins be in HIGH position Pass/Fail criteria: when check is run response is 100%: Checks: 15, Failures: 0, Errors: 0 */ START_TEST(test_loop_ledState1) { init_leds(); display_percentage(1); int ledState = LOW; if(ledState == LOW) ledState = HIGH; else { ledState = LOW; } fail_unless(digitalRead(ledPin1) == ledState); fail_unless(digitalRead(ledPin2) == ledState); fail_unless(digitalRead(ledPin3) == ledState); fail_unless(digitalRead(ledPin4) == ledState); }END_TEST
/*! * @brief initialize all * @return 0 */ int init_battery_meter() { /* init the leds */ init_leds(); /* init the alarm*/ init_alarm(); return 0; }
/* main function */ int main(void) { /* ============================== */ /* initialization =============== */ /* ============================== */ WDT_EnableAndSetTimeout(WDT_PER_512CLK_gc); /* set up LED pins */ init_leds(); /* set up I2C as slave */ init_twi(); /* set up our clocks */ init_clock(); /* set up sensors */ init_sensors(); /* set up motors */ init_motors(); /* set up crude digital outputs */ init_digout(); /* Flash all the LEDs for two and a half seconds to make sure * they're hooked up */ led_orders->behavior = LED_BEHAVIOR_TIMED; led_orders->time = 4000; led_error1->behavior = LED_BEHAVIOR_TIMED; led_error1->time = 6000; led_error2->behavior = LED_BEHAVIOR_TIMED; led_error2->time = 8000; led_mota->behavior = LED_BEHAVIOR_TIMED; led_mota->time = 10000; led_motb->behavior = LED_BEHAVIOR_TIMED; led_motb->time = 12000; /* motA.duty = 4000; */ /* motA.direction = 1; */ /* motB.duty = 16000; */ /* motB.direction = 1; */ /* enable interrupts - things start ticking now */ sei(); /* ============================== */ /* main loop ==================== */ /* ============================== */ for(;;) { _delay_us(10); WDT_Reset(); } }
int main(int argc, char *argv[]) { printf("NRF24 recv test start\n"); init_leds(); BSP_LED_Toggle(LED5); nrf24_test(); return 0; }
int main(void){ IntInit(); init_leds(); DoUndef(); DoSWI(); DoDabort(); while(1); return (0); }
void init_cli(void) { //initialize the hardware init_leds(); init_uart(); init_info(); init_keyboard(); cli_set_prompt(CLI_PROMPT); }
int main(void) { INIT(); //initialises the system modes (reloj interno, modos de ejecucion) init_leds (); STM_config_clock(); INTC.CPR.B.PRI = 0; INTC_InstallINTCInterruptHandler(function_time,30,1); scheduler(); }
void init_cli(void) { //initialize the hardware init_leds(); init_uart(); init_info(); init_24lc16b(); init_25lc040a(); cli_set_prompt(CLI_PROMPT); }
void main(void) { unsigned char received = 'c'; init_leds(); GPIOB->ODR |= 0xAA; init_usart(); for(;;) { while ( (USART1->ISR & USART_ISR_RXNE) == 0); // while receive IS empty, hang received = USART1->RDR; GPIOB->ODR = received; USART1->TDR = received+1; } }
int main(void) { init_buttons(); init_leds(); init_display(intensity); init_uart(); uart_interrupt_enable(); sei(); // main loop while(1) { // while button 1 is pressed, increment display brightness (mod 16) uint8_t button_status = debounce(&BUTTON0_PIN, BUTTON0); if(button_status == 1) { intensity = (intensity + 1) % 16; set_register_b(REG_INTENSITY, intensity); } else if(button_status == 2) { LIGHT_PORT ^= (1<<LIGHT); } // if timer is stopped (but not yet resetted) ... if(state == 'S') { // ... and button 0 has been pressed (and released), // save the current time in the times array (only once!) if(debounce(&BUTTON1_PIN, BUTTON1) && !time_already_saved) { uart_interrupt_disable(); append(times, TIMES, last_correct_decoded_time); led_blink(2); time_already_saved = 1; uart_interrupt_enable(); } } // if timer has been stopped or reset ... if(state == 'I' || state == 'S') { // ... and button 0 is pressed, show the current average if(!(BUTTON2_PIN & (1<<BUTTON2))) { uart_interrupt_disable(); display_uint16_time(average()); my_delay_ms(1500); while(!(BUTTON2_PIN & (1<<BUTTON2))); uart_interrupt_enable(); } } } }
int main(void) { /* hardware initialisation: */ init_motor(); init_buzzr(); init_leds(); init_switch(); uint8_t mode = 0; for(;;) /* ever */ { //do something switch(mode){ case 1: mode_blinktest(); break; case 2: mode_motortest(); break; case 3: mode_beeptest(); break; default: //mode=0; blinkrattlebeep(); } //check switches and change mode switch( PIND & 0b00000011){ case 0b00000010: //left switch pressed mode--; if (mode > 3) mode =3; flashleds(LED_L); break; case 0b00000001: //right switch pressed mode++; if (mode > 3) mode = 0; flashleds(LED_R); break; case 0b00000000: //both switches pressed flashleds(LED_R|LED_L); break; } } /* never return 0; */ return 0; }
void main(void) { init_leds(); init_push_buttons(); for(;;) { if ((GPIOA->IDR & GPIO_IDR_0) == 0 ) { GPIOB->ODR = 0x03; } else if ((GPIOA->IDR & GPIO_IDR_1) == 0) { GPIOB->ODR = 0x0C; } else if ((GPIOA->IDR & GPIO_IDR_2) == 0) { GPIOB->ODR = 0x30; } else if ((GPIOA->IDR & GPIO_IDR_3) == 0) { GPIOB->ODR = 0xC0; } else { GPIOB->ODR = 0x00; } } }
void main(void) { int i = 0; init_leds(); init_push_buttons(); init_EXTI(); init_NVIC(); for(;;) { GPIOB->ODR += 1; for(i = 0; i < 65535; i++); } }
void init_system() { delay_init(); //延时函数初始化 NVIC_Configuration(); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级 init_leds(); //初始化led init_jdqs(); //初始化继电器 uart1_init(9600); //串口1初始化为9600 调试用 //uart2_init(115200); //串口2初始化为115200 WIFI模块用 Uart2Init(); //串口2初始化为115200 WIFI模块用 uart1_send("System Running...\r\n\0",19); }
void hardware_setup(void) { /* Drive at 50MHz crystal clock */ SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); SysCtlDelay(3); uart_init_hw(); status_led_init_hw(); display_init(); init_leds(); init_dreh(); key_init(); init_adc(); #ifdef DEBUG timer0_config_hw(); #endif /* DEBUG */ }
int main(int argc, char *argv[]) { int res; printf("SPI slave start!\n"); //HAL_Init(); init_leds(); res = spi_init(); if (res < 0) { return -1; } BSP_LED_Toggle(LED4); spi_test(); return 0; }
static void setupHardware(void) { // TODO: Put hardware configuration and initialisation in here disable_global_int(); clk_system_init(); init_leds(); //init_pot(); init_buttons(); init_spi(); init_lcd_write_task(); init_uart0(); init_joystick(); enable_global_int(); // Warning: If you do not initialize the hardware clock, the timings will be inaccurate }
void init() { cli(); chip_init ( ); init_leds ( ); buttons_init( ); delay(40000); // ~ 1 sec read_cal(); can_init( CAN_250K_BAUD ); /* Enables Mob0 for Reception! */ config_init(); can_instance_init(); set_configure_callback ( config_change ); //set_rx_callback( can_file_message ); // empty sei(); OS_InitTask ( ); }
int main (void){ init_watchdog(); init_leds(); init_pushbutton(); while(1){ if ((P1IN & BUTTON) == BUTTON){ P1OUT |= 0x01; // LED0 on P1OUT &= 0xBF; // LED1 off } else{ P1OUT &= 0xFE; // LED0 off P1OUT |= 0x40; // LED on } } return 0; }
/* Intializes the LED, sets the default value, and loops. */ void main(void) { //initialize the hardware init_buttons(); init_speaker(); init_leds(); //initialize the oscillator and global timer init_oscillator(OSC_5_52MHZ); init_timer(TIMER_2MS); //enable interrupts EI(); //run forever while(1) { //do nothing while responding to interrupts } }
int main(void) { //Hier wird alles initialisiert, dh Grundeinstellungen festgelegt init_Motor(); //Motor einstellen init_system_tick(); //System Tick einstellen init_drehzahlsensor(); //Drehzahlsensor einstellen init_leds(); //LEDs einstellen init_hupe(); //Hupe einstellen sei(); //Alle Interrupts einschalten while(1) //Alles innerhalb der while Schleife wird immer wieder wiederholt { if (~PINB & 0x01) //Wenn der invertierte Wert des ersten Bits in PINB 1 ist, dann (also wenn der Button gedrückt wird) { led1(AN); //Mach die LEDs 1 und 3 an led3(AN); m_r(255,0); //Und die Motoren mit Vollgas (255) in 2 Richtungen m_l(255,1); _delay_ms(500); //Warte 500 ms led1(AUS); //LEDs 1 und 3 aus, LEDs 2 und 4 an led3(AUS); led2(AN); led4(AN); m_r(255,1); //Richtungen ändern m_l(255,0); _delay_ms(500); //und wieder 500ms in die andere Richtung m_r(0,0); //Motoren aus m_l(0,0); led2(AUS); //Leds aus led4(AUS); hupe(AN); //Hupe an _delay_ms(1000); //1 s warten hupe(AUS); //Hupe aus _delay_ms(300); //300ms warten hupe(AN); //Hupe an _delay_ms(500); //warte 500 ms hupe(AUS); //Hupe aus } //wieder nach oben } }