void philosopher(void* args) { int pos = (int) args; while (1) { if (pos == 0) led_on(); //sleep_proc(5); if (pos == 0) led_off(); yield(); } }
//***************************************************************************** // // Blink the on-board LED. // //***************************************************************************** int main(void) { volatile uint32_t ui32Loop; // // Enable the GPIO port that is used for the on-board LED. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // // Enable the GPIO pin for the LED (PF3). Set the direction as output, and // enable the GPIO pin for digital function. // GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3); // // Loop forever. // while(1) { // // Turn on the LED. // led_on(); // // Delay for a bit. // for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++) { } // // Turn off the LED. // led_off(); // // Delay for a bit. // for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++) { } } }
/** * Function to manage status updates to the user. This is done via LEDs on the * given board, if available, but may be changed to log to a serial port, or * anything else that is suitable for status updates. * * \param CurrentStatus Current status of the system, from the CDC_StatusCodes_t enum *****************************************************************************/ void UpdateStatus(uint8_t CurrentStatus) { // Set the LED mask to the appropriate LED mask based on the given status code switch (CurrentStatus) { case Status_USBNotReady: led_off(HW_LED1); led_on(HW_LED1); break; case Status_USBEnumerating: led_toggle(HW_LED1 | HW_LED2); break; case Status_USBReady: led_off(HW_LED1 | HW_LED2); break; } }
int main() { led_on(); usart_init(); debugln("\nUSART initialized"); spi_init_master(); debugln("SPI master"); for(int i=0; i<5; i++) { debugx(spi_tx(42)); debugln(" spi_tx"); } for (;;){} return 1; }
/* ADC test */ void adctest(void) { byte adc, old; while (1) { adc = ADCH; output(adc); if (old != adc) { led_on(GREEN); } old = adc; delay(25); led_off(GREEN); } }
int main() { init_led(); led_off_all(); int i=1; while (1) { for(i=1; i<5; i++) { led_on(i); delay(0xfff); led_off(i); delay(0xfff); } } return 0; }
void add_TM_key(uint8_t id[8]){ if (tm_key_number < MAX_TM){ led_on(4); #ifdef DEBUG send_string_to_UART3("TM: Add key: #"); send_int_to_UART3(tm_key_number); send_string_to_UART3("\n\r"); #endif tm_key_number++; EEPROMWrite(EEPROM_tms_numbers,tm_key_number,1); int i; for (i = 0;i<8;i++){ TM_KEY[tm_key_number-1].id[i] = id[i]; EEPROMWrite((EEPROM_tms_id + ((tm_key_number-1)*8) + i),id[i],1); } } }
int PF_do(String args){ auto intarg = args.toInt(); if(intarg!=0){ return PF_do_int(intarg); } if(args.equals("led_on")){ return led_on(); } else if(args.equals("led_off")) { return led_off(); } else if(args.equals("i2c_scan")) { return I2C_scan(); } else { // Did not match any known instructions return -1; // Return a error. } }
/**@brief Application's Stack BLE event handler. * * @param[in] p_ble_evt Bluetooth stack event. */ static void on_ble_evt(ble_evt_t * p_ble_evt) { uint32_t err_code = NRF_SUCCESS; switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: led_on(CONNECTED_LED_PIN_NO); led_off(ADVERTISING_LED_PIN_NO); m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; break; case BLE_GAP_EVT_DISCONNECTED: led_off(CONNECTED_LED_PIN_NO); m_conn_handle = BLE_CONN_HANDLE_INVALID; break; case BLE_GAP_EVT_SEC_PARAMS_REQUEST: err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); APP_ERROR_CHECK(err_code); break; case BLE_GAP_EVT_TIMEOUT: if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING) { led_off(ADVERTISING_LED_PIN_NO); } break; case BLE_GATTS_EVT_SYS_ATTR_MISSING: err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS)); APP_ERROR_CHECK(err_code); break; default: // No implementation needed. break; } }
void TC0_IrqHandler(void) { // acknowledge interrupt tc_channel_interrupt_ack(&ENCODER_TC_CHANNEL); if(led_is_on(LED_STD_RED)) { led_off(LED_STD_RED); } else { led_on(LED_STD_RED); } uint8_t encoder_value = PIO_Get(&pin_encoder_a); encoder_value |= (PIO_Get(&pin_encoder_b) << 1); int8_t add = encoder_table[encoder_value_last][encoder_value]; encoder_count += add; encoder_count_external += add; encoder_value_last = encoder_value; }
int main(void) { system_init(); led_init(); button_init(); interrupts_configure(); interrupts_enable(); led_on(LED_RED); led_off(LED_GREEN); // config timer A to toggle leds timer_init(TIMER_A, TIMER_SRC_SMCLK, TIMER_DIV_8, TIMER_COUNT_UP); timer_match_enable(TIMER_A, 32000, test_toggle); while (1) {;} return 0; }
int main(void) { uint32_t err_code; // Initialization led_init(LED_0); led_on(LED_0); // Setup clock SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION, false); // Setup and start timer timers_init(); timers_start(); while (1) { power_manage(); } }
void timer_interrupt() { systemUpTime++; if ((systemUpTime % 50) == 0) { if (ledIsOn) { print("tock\r\n"); led_off(CD_LED); } else { print("tick\r\n"); led_on(CD_LED); } ledIsOn = !ledIsOn; } }
void c_swi_handler(unsigned int num, int *param) { uart0_puts("\n c_swi_handler \n"); switch(num){ case 1: uart0_puts("\n ledon"); led_on(); break; case 2: uart0_puts("\n ledoff"); led_off(); break; default: uart0_puts("\n num error"); break; } return ; }
int16_t main(void) { init_clock(); init_ui(); init_timer(); led_on(&led1); timer_setPeriod(&timer2, 1.0); timer_start(&timer2); while (1) { if (timer_flag(&timer2)) { timer_lower(&timer2); led_toggle(&led1); led_toggle(&led2); } led_write(&led3, !sw_read(&sw3)); } }
int main(void) { // print something to the LCD screen lcd_printf("Hello Aithon!\n"); // start with led 0 on led_on(0); // main should never return, so enter infinite loop while (1) { // main thread code here led_toggle(0); led_toggle(1); delayS(1); } }
void led_start() { led_on(); _delay_ms(500); led_off(); //we start with a dark led OCR0B = 0; //start the LED timer //FAST PWM set at top, clear at b TCCR0A = _BV( COM0B1 ) | _BV(COM0B0) | _BV(WGM01) | _BV(WGM00); TCCR0B = _BV(CS01) | _BV(CS00) | _BV(CS00); //we calculate new values after the timer has overflown //& update the value after we reach top TIMSK0 = _BV(TOIE0); }
static int __init blink_pi_init(void) { printk(KERN_INFO "Hello blink pi.\n"); /* * A non 0 return means init_module failed. Module can't be loaded. */ // Init the output ra = GET32(GPFSEL0); // Read the current GDFSEL1 register value into ra ra &= ~(7<<BIT); // Make input first. (7 = 111, ~7 = 000) ra |= 1<<BIT; // Make output PUT32(GPFSEL0,ra); led_on(); return (0); }
void led_PRTIndicater(uint8_t index) { if(ledPRTIndicatorTimer++ >= LED_INDICATOR_MAXTIME) { if(ledPRTIndicator[index][ledPRTIndicatorIndex] == 1) { led_on(LED_PIN_PRT); }else { led_off(LED_PIN_PRT); } if (++ledPRTIndicatorIndex >= LED_INDICATOR_MAXINDEX) { ledPRTIndicatorIndex = 0; } ledPRTIndicatorTimer = 0; } }
irom void mjyun_receive(const char *event_name, const char *event_data) { os_printf("RECEIVED: key:value [%s]:[%s]", event_name, event_data); if (os_strncmp(event_data, "on", 2) == 0) { os_printf("set led on\r\n"); led_on(); // notify the app mjyun_publishstatus("on"); } if (os_strncmp(event_data, "off", 3) == 0) { os_printf("set led off\r\n"); led_off(); // notify the app mjyun_publishstatus("off"); } }
void led_ESCIndicater(uint8_t layer) { if(ledESCIndicatorTimer++ >= LED_INDICATOR_MAXTIME) { if(ledESCIndicator[layer][ledESCIndicatorIndex] == 1) { led_on(LED_PIN_ESC); }else { led_off(LED_PIN_ESC); } if (++ledESCIndicatorIndex >= LED_INDICATOR_MAXINDEX) { ledESCIndicatorIndex = 0; } ledESCIndicatorTimer = 0; } }
int LED::ioctl(struct file *filp, int cmd, unsigned long arg) { int result = OK; switch (cmd) { case LED_ON: led_on(arg); break; case LED_OFF: led_off(arg); break; default: result = CDev::ioctl(filp, cmd, arg); } return result; }
/**@brief Function for error handling, which is called when an error has occurred. * * @warning This handler is an example only and does not fit a final product. You need to analyze * how your product is supposed to react in case of error. * * @param[in] error_code Error code supplied to the handler. * @param[in] line_num Line number where the handler is called. * @param[in] p_file_name Pointer to the file name. */ void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name) { // APPL_LOG("[APPL]: ASSERT: %s, %d, error 0x%08x\r\n", p_file_name, line_num, error_code); // nrf_gpio_pin_set(ASSERT_LED_PIN_NO); // This call can be used for debug purposes during development of an application. // @note CAUTION: Activating this code will write the stack to flash on an error. // This function should NOT be used in a final product. // It is intended STRICTLY for development/debugging purposes. // The flash write will happen EVEN if the radio is active, thus interrupting // any communication. // Use with care. Un-comment the line below to use. // ble_debug_assert_handler(error_code, line_num, p_file_name); // On assert, the system can only recover with a reset. //NVIC_SystemReset(); led_on(SQUALL_LED_PIN); while(1); }
int main() { init_led(); init_beep(); int i; while(1) { for(i=1;i<=4;i++) { beep_on(); led_on(i); delay(0xffff); beep_off(); led_off(i); delay(0xffff); } } return 0; }
int main (void) { system_init (); led_init (); button_init (); while (1) { if (button_pressed_p ()) { led_on (); } else { led_off (); } } }
int main(void) { target_init(); HAL_SET_PIN_DIRECTIONS(); wdt_disable(); //hal_init( NULL, NULL ); led_on( LED_ALL ); hal_delay( 500 ); led_off( LED_ALL ); dbo_open(0, 38400); // the parameter id can be 0-3 denoting timer hardware 0 to 3 timer_interrupt_driven_test( 0 ); // timer_query_driven_test( 2 ); while(1){} }
void __attribute__((interrupt("IRQ"))) interrupt_handler(void) { static int lit = 0; /* Check that it was in fact a timer interrupt */ if (mmio_read(IRQ_BASIC_PENDING)&&0x1) { /* Clear the ARM Timer interrupt */ mmio_write(TIMER_IRQ_CLEAR, 0x1); /* Toggle the LED state */ if(lit) { led_off(); lit = 0; } else { led_on(); lit = 1; } } else printk("Other Interrupt \r\n"); }
void long_press(int key_num,int num){ if((rEXTINT1 &(num))==0){ //低电平触发了中断 if(key_num == 5 || key_num == 6){ led_on_all(); }else{ led_on(key_num); } beep_on(); //改变中断的触发方式为上升沿 rEXTINT1 &= ~(num); rEXTINT1 |= 0x4; } else if((rEXTINT1 &(num)) == 0x4){ //上升沿触发中断 led_off_all(); beep_off(); rEXTINT1 &= ~(num); } }
/* Fading test */ void fading(void) { int i; while (1) { for (i = 255; i > 5; i --) { led_on(GREEN); output(i); delay(30); } for (i = 5; i < 255; i ++) { led_off(GREEN); output(i); delay(30); } } }
void send_data_loop(float temperature_sensor_value, int light_sensor_value) { if (LWiFi.status() == LWIFI_STATUS_DISCONNECTED) { Serial.println("Disconnected from WiFi"); while (0 == LWiFi.connect(ssid, LWiFiLoginInfo(WIFI_AUTH, key))){ Serial.println("Connecting to WiFi..."); delay(1000); } } LDateTime.getRtc(&rtc); if ((rtc - lrtc) >= per) { senddata(temperature_sensor_value, light_sensor_value); lrtc = rtc; } //Check for TCP socket command from MCS Server String tcpcmd=""; while (c.available()) { int v = c.read(); if (v != -1) { Serial.print((char)v); tcpcmd += (char)v; if (tcpcmd.indexOf("led on") >= 0) { Serial.print("Received actuator command: "); Serial.println(tcpcmd); Serial.println("Switching LED ON..."); led_on(); tcpcmd=""; }else if(tcpcmd.indexOf("led off") >= 0) { Serial.print("Received actuator command: "); Serial.println(tcpcmd); Serial.println("Switching LED OFF..."); led_off(); tcpcmd=""; } } } //Check for hearbeat interval LDateTime.getRtc(&rtc2); if ((rtc2 - lrtc2) >= per1) { heartBeat(); lrtc2 = rtc2; } }