void tst_CoreLED_Process(void) { /// Stuff that needs doing is done here if (Timer_Expired(tst_CoreLED_Blink_TIMER)) { gpio_toggle_pin(tst_CoreLED_PIN); } }
void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) { if( uxLED < partestNUM_LEDS ) { taskENTER_CRITICAL(); { gpio_toggle_pin( ulLED[ uxLED ] ); } taskEXIT_CRITICAL(); } }
int main(void) { sysclk_init(); board_init(); while (1) { gpio_toggle_pin(LED0_GPIO); delay_ms(500); } }
int main(void) { board_init(); #if (BOARD == XMEGA_A3BU_XPLAINED) /* Turn off status LED and back light, * as it is used to show success of tests. */ ioport_set_pin_high(LED3_GPIO); #endif if (test_atomic_write_app_table() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_0); } if (test_split_write_app_table() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_1); } if (test_atomic_write_boot() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_2); } if (test_split_write_boot() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_3); } #if (BOARD == XMEGA_A3BU_XPLAINED) /* Turn on the LCD back light to show that we are done */ ioport_set_pin_high(LCD_BACKLIGHT_ENABLE_PIN); #else /* Turn on LED 7 to show that we are done */ gpio_toggle_pin(LED_PIN_7); #endif while (true) {} }
/** * \brief Timeout example 2 main application routine */ int main( void ) { // Initialize drivers sysclk_init(); board_init(); pmic_init(); timeout_init(); cpu_irq_enable(); bool button_pressed; bool button_previous_state_pressed = false; // Initialize LEDs gpio_set_pin_group_high(LED_PORT, LED_PORT_MASK); while (1) { button_pressed = gpio_pin_is_low(GPIO_PUSH_BUTTON_0); // Test for any change in state since last sample if (button_previous_state_pressed != button_pressed) { /* Start debounce timeout. This will cancel any currently running timeout for selected id. */ timeout_start_singleshot(DEBOUNCE_TIMEOUT, DEBOUNCE_TICKS); button_previous_state_pressed = button_pressed; } // Check for debounce timeout expire if (timeout_test_and_clear_expired(DEBOUNCE_TIMEOUT)) { // Toggle LED0 if button is pressed down if (button_pressed) { gpio_toggle_pin(LED0_GPIO); } } // No debounce filter on button 1 if (gpio_pin_is_low(GPIO_PUSH_BUTTON_1)) { gpio_toggle_pin(LED1_GPIO); } } }
void config_IMU(void){ if (twi_init() == TWI_SUCCESS){ adxl_init(); itg_init(); } else { while(1){ gpio_toggle_pin(LED2_GPIO); mdelay(5000); //Delay 500.0 ms } } }
int main (void) { uint8_t menu_status; struct keyboard_event input; static usart_rs232_options_t SERIAL_OPTIONS = { .baudrate = 57600, .charlength = USART_CHSIZE_8BIT_gc, .paritytype = USART_PMODE_DISABLED_gc, .stopbits = false }; sysclk_init(); board_init(); solenoid_init(); gfx_mono_init(); usart_init_rs232(USART_SERIAL, &SERIAL_OPTIONS); gpio_toggle_pin(NHD_C12832A1Z_BACKLIGHT); while(true) { gfx_mono_menu_init(&main_menu); do { do { keyboard_get_key_state(&input); } while (input.type != KEYBOARD_RELEASE); menu_status = gfx_mono_menu_process_key(&main_menu, input.keycode); } while (menu_status == GFX_MONO_MENU_EVENT_IDLE); //Determine what song to play based on //the input from the user controlling the A3BU switch(menu_status) { case 0: song_menu(0); play_song_with_input(SAMPLE_SONG, SAMPLE_SONG_LENGTH); break; case 1: song_menu(1); play_song_with_input(STAIRWAY, 6); break; case 2: song_menu(2); play_song_with_input(MISERLOU, 1); break; case 3: song_menu(3); play_serial(); break; } } }
static void vCpuWork(void *pvParameters){ int i; double dummy; while (1){ for(i = 0; i < 1000000; i++){ dummy = 2.5 * i; //not important } gpio_toggle_pin(LED0_GPIO); } }
void act_linearAct_Process(void) { if (Timer_Expired(act_linearAct_TIMER_report)) { linearAct_sendPosition(0); } #if (USE_STIMULI == 1) if (Timer_Expired(act_linearAct_TIMER_stimuli)) { gpio_toggle_pin(STIMULI); } #endif }
/*************** TASKS ********************/ static void vBasicTask(void *pvParameters) { const portTickType xDelay = 1000 / portTICK_RATE_MS; while(1) { gpio_toggle_pin(LED0_GPIO); printf("tick\n"); vTaskDelay(xDelay); } }
void vParTestToggleLED(unsigned portBASE_TYPE uxLED) { #if defined(LED_0_NAME) || defined(LED_1_NAME) || defined(LED_2_NAME) || defined(LED_3_NAME) if (uxLED < partestNUM_LEDS) { taskENTER_CRITICAL(); { gpio_toggle_pin(ulLED[ uxLED ]); } taskEXIT_CRITICAL(); } #endif }
int main(void) { board_init(); if (test_erase() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_0); } if (test_write() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_1); } if (test_atomic_write() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_2); } if (test_split_write() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_3); } if (test_erase_bytes() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_4); } /* Toggle LED to indicate that we are done */ gpio_toggle_pin(LED_PIN_7); while (true) {} }
static void vCpuWork(void *pvParameters) { double dummy; while(1){ for (int i=0; i<1000000; i++) { dummy = 2.5 * i; // dummy work } gpio_toggle_pin(LED0_GPIO); } }
int main(void) { sysclk_init(); board_init(); while (true) { for (int i = 0; i < 5; i++) { gpio_toggle_pin(LED0_GPIO); delay_s(1); } for (int i = 0; i < 50; i++) { gpio_toggle_pin(LED0_GPIO); delay_ms(100); } for (int i = 0; i < 5000; i++) { gpio_toggle_pin(LED0_GPIO); delay_us(100); } } }
/*-----------------------------------------------------------*/ void task_led(void *pvParameters) { uint32_t ul_last_page_addr = LAST_PAGE_ADDRESS; uint32_t *pul_last_page = (uint32_t *) ul_last_page_addr; (void) pvParameters; // memset(&IPsave_tmp, 0, sizeof(ip_save_t)); /* Initialize flash: 6 wait states for flash writing. */ flash_init(FLASH_ACCESS_MODE_128, 6); /* Unlock page */ flash_unlock(ul_last_page_addr, ul_last_page_addr + IFLASH_PAGE_SIZE - 1, 0, 0); /* Read Flash page */ memcpy((uint8_t*)(&IPsave_tmp), (uint8_t*)pul_last_page, sizeof(ip_save_t)); // IPsave_tmp.mode = 2; if (IPsave_tmp.ip[0] == 0) { IPsave_tmp.ip[0] = 223; } if (gpio_pin_is_low(RESTKEY_GPIO) == 1) { uint32_t ul_last_page_addr = LAST_PAGE_ADDRESS; uint32_t ul_page_buffer[IFLASH_PAGE_SIZE / sizeof(uint32_t)]; IPsave_tmp.mode = 1; IPsave_tmp.ip[0] = 223; /* Copy information to FLASH buffer..*/ memcpy((uint8_t*)ul_page_buffer, (uint8_t *)(&IPsave_tmp), sizeof(ip_save_t)); /* Write page */ flash_write(ul_last_page_addr, ul_page_buffer, IFLASH_PAGE_SIZE, 1); } /* Lock page */ flash_lock(ul_last_page_addr, ul_last_page_addr + IFLASH_PAGE_SIZE - 1, 0, 0); for (;;) { gpio_toggle_pin(LED0_GPIO); vTaskDelay(1000); } }
void task_start(void *pvParameters) { (void) pvParameters; /* Start the ethernet tasks. */ vStartEthernetTaskLauncher( TASK_START_ETH_PRIORITY ); /* Start the Radio app tasks. */ vStartRadioTaskLauncher( TASK_RADIO_HANDLE_PRIORITY ); for (;;) { gpio_toggle_pin(LED0_GPIO); vTaskDelay(1000); //vTaskSuspend(vStartTaskHandler); /* Suspend START task. */ } }
int main(void) { uint32_t tick = 0, last_tick = 0; init(); while (1) { tick = sys_get_tick(); if (tick != last_tick) { // toggle gpio_systick to dbg sys tick timing issues gpio_toggle_pin(&gpio_systick); } last_tick = tick; } return 0; }
//set the relay and store the new state in //the backup register in case of software reset int mon_relay(int argc, char **argv){ int state; state = gpbr_read(GPBR_RELAY_STATE); if(argc==1){ //print the relay state if(state) printf("relay [on]\n"); else printf("relay [off]\n"); return -1; } if(argc!=2){ printf("relay [on|off|toggle]\n"); return -1; } if(strcmp(argv[1],"on")==0){ gpio_set_pin_high(RELAY_PIN); gpbr_write(GPBR_RELAY_STATE,1); } else if(strcmp(argv[1],"off")==0){ gpio_set_pin_low(RELAY_PIN); gpbr_write(GPBR_RELAY_STATE,0); } else if(strstr(argv[1],"toggle")==argv[1]){ gpio_toggle_pin(RELAY_PIN); if(state==0) state = 1; else state = 0; gpbr_write(GPBR_RELAY_STATE,state); } else{ printf("bad argument to relay\n"); return -1; } return 0; }
/** * \brief Timer Counter Overflow interrupt callback function * * This function is called when an overflow interrupt has occurred on * TCC4 and toggles LED0. */ static void example_ovf_interrupt_callback(void) { gpio_toggle_pin(LED0_GPIO); tc45_clear_overflow(&TCC4); }
bool Gpio_avr32::toggle(void) { gpio_toggle_pin(config_.pin); return true; }
/** * \brief Timer Counter Capture/Compare B interrupt callback function * * This function is called when an a capture compare channel B has occurred * on TCC4 and toggles LED2 (only on STK600). */ static void example_ccb_interrupt_callback(void) { #if (BOARD == STK600_RC032X) gpio_toggle_pin(LED2_GPIO); #endif }
void led0_link(void) { gpio_toggle_pin(GPIO_P32); }
void led_ctrl(led_id_t led_no, led_action_t led_setting) { static uint8_t led_state = 0x00; switch (board_type) { case SENSOR_TERM_BOARD: { uint8_t pin; /* New values of LED pins based on new LED state. */ uint8_t led_pin_value; /* * Original value of LED port before writing new value. * This value needs to be restored. */ uint8_t orig_led_port = LED_PORT & ~LED_BIT_MASK; /* Both LEDs need to be updated, since several peripherals * are dealing with the same port for this board * (USB, EEPROM, LEDs, Button). */ LED_PORT_DIR |= (1 << LED_BIT_0); LED_PORT_DIR |= (1 << LED_BIT_1); if (led_no == LED_2) led_no = LED_0; switch (led_no) { case LED_0: pin = LED_BIT_0; break; case LED_1: pin = LED_BIT_1; break; default: return; } switch (led_setting) { case LED_ON: led_state |= _BV(pin); break; case LED_OFF: led_state &= ~_BV(pin); break; case LED_TOGGLE: default: if (led_state & _BV(pin)) { /* * LED is currently on, * Switch it off */ led_state &= ~_BV(pin); } else { /* * LED is currently off, * Switch it on */ led_state |= _BV(pin); } break; } led_pin_value = (uint8_t)(~(uint16_t)led_state); // Implicit casting required to avoid IAR Pa091. led_pin_value &= LED_BIT_MASK; LED_PORT = orig_led_port | led_pin_value; led_helper_func(); break; } case PLAIN: { switch (led_setting) { case LED_ON: if(led_no == LED_0) gpio_set_pin_low(LED0_RCB); else if(led_no == LED_1) gpio_set_pin_low(LED1_RCB); else gpio_set_pin_low(LED2_RCB); break; case LED_OFF: if(led_no == LED_0) gpio_set_pin_high(LED0_RCB); else if(led_no == LED_1) gpio_set_pin_high(LED1_RCB); else gpio_set_pin_high(LED2_RCB); break; case LED_TOGGLE: if(led_no == LED_0) gpio_toggle_pin(LED0_RCB); else if(led_no == LED_1) gpio_toggle_pin(LED1_RCB); else gpio_toggle_pin(LED2_RCB); break; } } } }
int main (void) { // PM and PWM stuff volatile avr32_pm_t *ourPM; ourPM = GNMS_PM; gnms_pm_init(ourPM); gnms_pwm_init(); gnms_sci_init(); gnms_button_init(); gnms_adc_init(); #if 0 volatile avr32_gpio_port_t* led0_gpio_port = &AVR32_GPIO.port[LED0_PIN/32]; led0_gpio_port->oderc = 1 << LED0_PIN; led0_gpio_port->gpers = 1 << LED0_PIN; led0_gpio_port->puerc = 1 << LED0_PIN; led0_gpio_port->ovrc = 1 << LED0_PIN; led0_gpio_port->oders = 1 << LED0_PIN; while (true) { gpio_toggle_pin(LED0_PIN); cpu_delay_ms(500, 12000000); } #endif #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_POWER_ON_STRING); #endif cpu_delay_ms(5000, CLOCK_SPEED); send_IR_Command(gnms_power_str); unsigned long curTemp = 0; //gnms_adc_get_temp(); enum gnmsFanSpeed_e fanSpeed = GNMS_FAN_SPEED_NA; unsigned long sciVar = 0; unsigned long adcVar = 500000; while (true) { // button press detection cur_proj_left = gpio_get_pin_value(PROJECTOR_LEFT); cur_proj_right = gpio_get_pin_value(PROJECTOR_RIGHT); cur_proj_up = gpio_get_pin_value(PROJECTOR_UP); cur_proj_down = gpio_get_pin_value(PROJECTOR_DOWN); cur_proj_menu = gpio_get_pin_value(PROJECTOR_MENU); cur_proj_enter = gpio_get_pin_value(PROJECTOR_ENTER); cur_proj_exit = gpio_get_pin_value(PROJECTOR_EXIT); cur_vol_up = gpio_get_pin_value(VOLUME_UP); cur_vol_dn = gpio_get_pin_value(VOLUME_DN); if (cur_proj_left != prev_proj_left) { if (cur_proj_left != 0) { send_IR_Command(gnms_left_str); #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_LEFT); #endif } prev_proj_left = cur_proj_left; } if (cur_proj_right != prev_proj_right) { if (cur_proj_right != 0) { send_IR_Command(gnms_right_str); #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_RIGHT); #endif } prev_proj_right = cur_proj_right; } if (cur_proj_up != prev_proj_up) { if (cur_proj_up != 0) { send_IR_Command(gnms_up_str); #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_UP); #endif } prev_proj_up = cur_proj_up; } if (cur_proj_down != prev_proj_down) { if (cur_proj_down != 0) { send_IR_Command(gnms_down_str); #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_DOWN); #endif } prev_proj_down = cur_proj_down; } if (cur_proj_menu != prev_proj_menu) { if (cur_proj_menu != 0) { send_IR_Command(gnms_menu_str); #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_MENU); #endif } prev_proj_menu = cur_proj_menu; } if (cur_proj_enter != prev_proj_enter) { if (cur_proj_enter != 0) { send_IR_Command(gnms_enter_str); #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_ENTER); #endif } prev_proj_enter = cur_proj_enter; } if (cur_proj_exit != prev_proj_exit) { if (cur_proj_exit != 0) { send_IR_Command(gnms_esc_str); #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_EXIT); #endif } prev_proj_exit = cur_proj_exit; } if (cur_vol_up != prev_vol_up) { if (cur_vol_up != 0) { gnms_sci_write_line(GNMS_VOLUME_UP_STRING); } prev_vol_up = cur_vol_up; } if (cur_vol_dn != prev_vol_dn) { if (cur_vol_dn != 0) { gnms_sci_write_line(GNMS_VOLUME_DN_STRING); } prev_vol_dn = cur_vol_dn; } if (adcVar > 500000) { adcVar = 0; // temperature check curTemp = gnms_adc_get_high(); if (curTemp >= GNMS_TEMP_HIGH) { if (fanSpeed != GNMS_FAN_SPEED_HIGH) { //run the fans on high gnms_turn_fans_on_high(); fanSpeed = GNMS_FAN_SPEED_HIGH; #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_HIGH); #endif } } else if (curTemp >= GNMS_TEMP_MED) { if (fanSpeed != GNMS_FAN_SPEED_MED) { // run the fans on med gnms_turn_fans_on_med(); fanSpeed = GNMS_FAN_SPEED_MED; #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_MED); #endif } } else if (curTemp >= GNMS_TEMP_LOW) { if (fanSpeed != GNMS_FAN_SPEED_LOW) { // turn fans low gnms_turn_fans_on_low(); fanSpeed = GNMS_FAN_SPEED_LOW; #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_LOW); #endif } } else if (curTemp < GNMS_TEMP_LOW) { if (fanSpeed != GNMS_FAN_SPEED_OFF) { gnms_turn_fans_off(); fanSpeed = GNMS_FAN_SPEED_OFF; #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_OFF); #endif } } } if (sciVar > 10000) { sciVar = 0; if (gnms_sci_check_for_input() == true) { #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_POWER_DN_STRING); #endif break; } } sciVar++; adcVar++; } // power off the projector by sending it the power signal twice #if GNMS_DEBUG == 1 gnms_sci_write_line(GNMS_DEBUG_STR_PROJ); #endif send_IR_Command(gnms_power_str); cpu_delay_ms(300, CLOCK_SPEED); send_IR_Command(gnms_power_str); adc_disable(adc,GNMS_ADC_0); adc_disable(adc,GNMS_ADC_1); while (true) { // wait for shut down to complete } }
void Led_toggle(void) { gpio_set_direction(GPIO_P01, GPIO_OUTPUT); gpio_toggle_pin(GPIO_P01); delay(100000); }
/** * \brief Main function. * * Initializes the board and reads out the production date stored in EEPROM and * set timezone from EEPROM if it is set. If it is not set it will open the * timezone selector to select the local timezone. It then runs the menu system * in an infinite while loop. */ int main(void) { uint8_t menu_status; struct keyboard_event input; uint32_t rtc_timestamp; sysclk_init(); board_init(); pmic_init(); gfx_mono_init(); touch_init(); adc_sensors_init(); // Enable display backlight gpio_set_pin_high(NHD_C12832A1Z_BACKLIGHT); // Workaround for known issue: Enable RTC32 sysclk sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC); while (RTC32.SYNCCTRL & RTC32_SYNCBUSY_bm) { // Wait for RTC32 sysclk to become stable } // If we have battery power and RTC is running, don't initialize RTC32 if (rtc_vbat_system_check(false) != VBAT_STATUS_OK) { rtc_init(); // Set current time to after production date rtc_timestamp = production_date_get_timestamp() + 1; rtc_set_time(rtc_timestamp); } // Get current time rtc_timestamp = rtc_get_time(); // Make sure RTC has not been set to a too early date . if (rtc_timestamp < FIRST_POSSIBLE_TIMESTAMP) { // Set time to 01.01.2011 00:00:00 rtc_set_time(FIRST_POSSIBLE_TIMESTAMP); } // Initialize USB CDC class cdc_start(); cpu_irq_enable(); // Display a splash screen showing button functions button_splash(); // Set timezone from EEPROM or to a default value timezone_init(); /* Main loop. Read keyboard status and pass input to menu system. * When an element has been selected in the menu, it will return the * index of the element that should be run. This can be an application * or another menu. */ while (true) { // (re)initialize menu system gfx_mono_menu_init(&main_menu); do { do { keyboard_get_key_state(&input); // Wait for key release } while (input.type != KEYBOARD_RELEASE); // Send key to menu system menu_status = gfx_mono_menu_process_key(&main_menu, input.keycode); // Wait for something useful to happen in the menu system } while (menu_status == GFX_MONO_MENU_EVENT_IDLE); switch (menu_status) { case 0: ntc_sensor_application(); break; case 1: lightsensor_application(); break; case 2: production_date_application(); break; case 3: date_time_application(); break; case 4: // Toggle LCD Backlight gpio_toggle_pin(NHD_C12832A1Z_BACKLIGHT); break; case GFX_MONO_MENU_EVENT_EXIT: // Fall trough to default and show button splash default: button_splash(); break; }; } }
void led1_link(void) { gpio_toggle_pin(GPIO_P31); }
/** * \brief Timer Counter Capture/Compare A interrupt callback function * * This function is called when an a capture compare channel A has occurred * on TCC4 and toggles LED1. */ static void example_cca_interrupt_callback(void) { gpio_toggle_pin(LED1_GPIO); }
void led3_link(void) { gpio_toggle_pin(GPIO_P04); }
void led2_link(void) { gpio_toggle_pin(GPIO_P05); }