示例#1
0
int main(void)
{
	int i;

	system_init();
	p_init();
	led_init();
	cdcacm_init();
	cdcacm_register_receive_callback(cdcacm_input_callback);
	usart_init();

	led1_on();
	led2_on();
	led3_on();
	led4_on();
	led5_on();

	for (i = 0; i < 0x800000; i++)
		__asm__("nop");

	led1_off();
	led2_off();
	led3_off();
	led4_off();
	led5_off();

	while (1) {
		cdcacm_run();
		led_process();
	}
}
示例#2
0
void led1_toggle()
{
    if (led1_is_off())
        led1_on();
    else
        led1_off();
}
示例#3
0
/*********************************************************************************************
* name:		Led_Test
* func:		leds test funciton
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void Led_Test()
{
	/* 1 on -> 2 on -> all on -> 2 off -> 1 off */
	leds_off();
	Delay(1000);
	led1_on();
	Delay(1000);
	led1_off();
	led2_on();
	Delay(1000);
	leds_on();
	Delay(1000);
	led2_off();
	Delay(1000);
	led1_off();
}
示例#4
0
文件: main.c 项目: michz/diy14bus
void packet_received(cowpacket pkt) {
	led1_off();
    // TODO packet handling (switch led on/off, ping response, ...)
    switch (pkt.type) {
        case event:
            // only interpret this if address is my node's address
            if (pkt.addr == cowbus_address) {
                // TODO interpret message payload (led1 on, led2 color, ...)
            }
            else {
                // TODO go through programmed event handlers
            }
            break;

        case get_name:
            if (pkt.addr == cowbus_address) {
                // TODO send packet with our name
            }
            break;

        case ping:
            if (pkt.addr == cowbus_address) {
                radio_nrf_send_packet(cowbus_address, ping_answer, "", 0);
            }
            break;

        case set_name:
            if (pkt.addr == cowbus_address) {
                // TODO save name into eeprom and RAM
            }
            break;
    }
}
示例#5
0
文件: main.c 项目: huig-/SED
/*--- codigo de la funcion ---*/
int Main(void){

	char *pt_str = str;
	leds_off();
	sys_init(); // inicializacion de la placa, interrupciones, puertos
	Eint4567_init();
	keyboard_init();
	Uart_Init(115200); // inicializacion de la Uart
	Uart_Config(); // configuración de interrupciones y buffers

	while(1){
		*pt_str = Uart_Getch1(); // leer caracter
		if(pt_str[0] == 'L'){
			led1_on();
			led2_off();
		} else if (pt_str[0] == 'R'){
			led2_on();
			led1_off();
		}

		else  {
			D8Led_symbol(pt_str[0]-'0');
		}
	}
}
示例#6
0
文件: main.c 项目: michz/diy14bus
//<just for debug>
void test(void)
{

	led1_off();
	printf("test_uart.\n");

}
int
main(int argc, char *argv[])
{
    /* Initialize board-specific hardware */
    BSP_Init();
    led1_off();
    led2_off();

#if 1
    /* Initialize TimerA and oscillator */
    BCSCTL3 |= LFXT1S_2;                      // LFXT1 = VLO
    TACCTL0 = CCIE;                           // TACCR0 interrupt enabled
    TACCR0 = 12000;                           // ~1 second
    TACTL = TASSEL_1 + MC_1;                  // ACLK, upmode
#endif

    while (1)
    {
        main_init();

        while (1)
        {
            main_task();
        }
    }

    return 0;
}
示例#8
0
文件: leds.c 项目: powertang/yard-ice
int led_task(void)
{
	DCC_LOG1(LOG_TRACE, "[%d] started.", thinkos_thread_self());

	while (1) {
		DCC_LOG(LOG_MSG, "thinkos_flag_wait()...");
		thinkos_flag_wait(led_flag);
		if (led1_flash_tail != led1_flash_head) {
			led1_flash_tail++;
			if (!led_locked)
				led1_on();
		}
		if (led2_flash_tail != led2_flash_head) {
			led2_flash_tail++;
			if (!led_locked)
				led2_on();
		}

		if ((led1_flash_tail == led1_flash_head) &&
			(led2_flash_tail == led2_flash_head)) 
			thinkos_flag_clr(led_flag);

		thinkos_sleep(100);
		if (!led_locked) {
			led1_off();
			led2_off();
		}
		thinkos_sleep(100);
	}
}
示例#9
0
文件: uart.c 项目: samjacoby/avr
int uart_putchar_f(char c, FILE *stream) {
    led1_on();
    if(c == '\n') uart_putchar_f('\r', stream);
	while( ! (UCSR0A & (1<<UDRE0)) );
	UDR0 = c;
    led1_off();
    return 0;
}
void led_off_id(unsigned char id)
{
	switch (id)
	{
		case 1: led1_off();break;
		case 2: led2_off();break;
		case 3: led3_off();break;
		case 4: led4_off();break;
		default: led_all_off();break;
	}
}
示例#11
0
文件: led.c 项目: iipr/EC-practicas
void switchLed1() {
/*TAREA 4a*/
/*El alumno/a debe completar esta funcion para que cambie el estado del led 1, 
si estaba encendido debera apagarlo
y si esta apagado encenderlo */
if ((led_state == 1) || (led_state == 3))
	led1_off();
else
	led1_on();
/*fin TAREA 4a*/
}
示例#12
0
void *th_advert( void *arg ){
	while(1){
		pthread_mutex_lock( &mutex_lock );
		led1_on();
	
		radio_send(	BROADCAST_ADDR, RADIO_PORT, sizeof( my_info_t ), (rf_pkt*)&my_info );

		led1_off();

		pthread_mutex_unlock( &mutex_lock );		
		sleep( ADVERT_BASE_PERIOD );
	}
}
示例#13
0
文件: main.c 项目: jarodz/otolith
/**@brief Application's BLE Stack 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;
    static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID;

    switch (p_ble_evt->header.evt_id)
    {
    case BLE_GAP_EVT_CONNECTED:
        led_stop();
        led1_on();
        connected = true;

        m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;

        // Start handling button presses
        //err_code = app_button_enable();
        break;

    case BLE_GAP_EVT_DISCONNECTED:
        // Since we are not in a connection and have not started advertising, store bonds
        err_code = ble_bondmngr_bonded_masters_store();
        APP_ERROR_CHECK(err_code);

        led1_off();
        connected = false;

        // Go to system-off mode, should not return from this function, wakeup will trigger
        // a reset.
        //system_off_mode_enter();
        break;

    case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
        err_code = sd_ble_gap_sec_params_reply(m_conn_handle,
                                               BLE_GAP_SEC_STATUS_SUCCESS,
                                               &m_sec_params);
        break;

    case BLE_GAP_EVT_TIMEOUT:
        if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT)
        {
            led_stop();
            //system_off_mode_enter();
        }
        break;

    default:
        break;
    }

    APP_ERROR_CHECK(err_code);
}
示例#14
0
文件: timer.c 项目: huig-/SED
void timer2_ISR(void)
{
	if (row) {
	    led1_on();
	    DelayMs(30);
	    led1_off();
	}
	else {
	    led2_on();
	    DelayMs(30);
	    led2_off();
	}
	rI_ISPC = BIT_TIMER2;
}
示例#15
0
文件: leds.c 项目: mallius/arm-m
int main(void)
{
	gpbcon = (led1_out | led2_out | led3_out | led4_out);
	while(1)
	{
		delay(30000);
		led1_on();
		delay(30000);
		led1_off();
		
	}

	return 0;
}
示例#16
0
void 
hw_init()
{
#if defined (PLATFORM_HAS_LEDS)
// leds_off(LEDS_RED);
led1_off();
#endif
#if PLATFORM_HAS_DS1820
  ds1820_temp();
#endif
#if PLATFORM_HAS_DHT11HUM
  DHT_Read_Data(&dht11_temp, &dht11_hum);
#endif
}
示例#17
0
文件: led_driver.c 项目: rongc5/test
static int led_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg)
{
    printk("FUN %s is calling\n", __func__);

    if (cmd == LED1) {
        if (arg == ON) {
            led1_on();
        } else if(arg == OFF) {
            led1_off();   
        }
    }

    if (cmd == LED2) {
        if (arg == ON) {
            led2_on();
        } else if(arg == OFF) {
            led2_off();   
        }
    }

    if (cmd == LED3) {
        if (arg == ON) {
            led3_on();
        } else if(arg == OFF) {
            led3_off();   
        }
    }

    if (cmd == LED4) {
        if (arg == ON) {
            led4_on();
        } else if(arg == OFF) {
            led4_off();   
        }
    }

    return 0;
}
示例#18
0
void main( void )
{

  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;
  button_init();
  led_init();
  Clock_Init();
  NRF24L01_init(1,1);
  NRF24L01_ConfigMode(MODETX);
  NRF24L01_TxPacket(temp);
  NRF24L01_ConfigMode(MODERX);
  while(1)
  {
    LPM3;  

    //SMG_Display(rece_buf[0]);
    led1_on(0);
    Delay_ms(300);
    led1_off(0);
    Delay_ms(300);
  }
}
示例#19
0
PROCESS_THREAD(rest_server_example, ev, data)
{
  static struct etimer ds_periodic_timer;
  static int ext4=0;
  static int ext5=0;
  static int ext6=0;
//  ext4 = is_button_ext4();
//  ext5 = is_button_ext5();
//  ext6 = is_button_ext6();
  
	  
  PROCESS_BEGIN();
  PRINTF("Starting Erbium Example Server\n");

#ifdef RF_CHANNEL
  PRINTF("RF channel: %u\n", RF_CHANNEL);
#endif
#ifdef IEEE802154_PANID
  PRINTF("PAN ID: 0x%04X\n", IEEE802154_PANID);
#endif

  PRINTF("uIP buffer: %u\n", UIP_BUFSIZE);
  PRINTF("LL header: %u\n", UIP_LLH_LEN);
  PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
  PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE);

/* if static routes are used rather than RPL */
#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE)
  set_global_address();
  configure_routing();
#endif

  /* Initialize the OSD Hardware. */
  hw_init();
  /* Initialize the REST engine. */
  rest_init_engine();

  /* Activate the application-specific resources. */
  rest_activate_resource(&resource_led1);
  rest_activate_resource(&resource_extbutton);
#if REST_RES_INFO
  rest_activate_resource(&resource_info);
#endif
  /* Activate the application-specific resources. */
#if REST_RES_OPTRIAC
  SENSORS_ACTIVATE(optriac_sensor);
  rest_activate_resource(&resource_optriac);
#endif
#if defined (PLATFORM_HAS_PIR) && (REST_RES_EVENT)
  SENSORS_ACTIVATE(pir_sensor);
  rest_activate_event_resource(&resource_pir);
  PRINTF("ACTIVATE PIR\n");
#endif
#if defined (PLATFORM_HAS_LEDS)
#if REST_RES_LEDS
  rest_activate_resource(&resource_leds);
#endif
#if REST_RES_TOGGLE
  rest_activate_resource(&resource_toggle);
#endif
#endif /* PLATFORM_HAS_LEDS */
#if defined (PLATFORM_HAS_TEMPERATURE) && REST_RES_TEMPERATURE
  SENSORS_ACTIVATE(temperature_sensor);
  rest_activate_resource(&resource_temperature);
#endif
#if defined (PLATFORM_HAS_BATTERY) && REST_RES_BATTERY
  SENSORS_ACTIVATE(battery_sensor);
  rest_activate_resource(&resource_battery);
#endif

  etimer_set(&ds_periodic_timer, MESURE_INTERVAL);
  /* Define application-specific events here. */
  while(1) {
    PROCESS_WAIT_EVENT();
#if defined (REST_RES_EVENT)
    if (ev == sensors_event ) {
      PRINTF("EVENT\n");
#if (REST_RES_EVENT && defined (PLATFORM_HAS_PIR))
    if (data == &pir_sensor) {
      PRINTF("PIR EVENT\n");
        /* Call the event_handler for this application-specific event. */
        pir_event_handler(&resource_pir);
        PRINTF("CALL EVENT HANDLER\n");
      }
#endif /* PLATFORM_HAS_PIR */
    }
#endif /* REST_RES_EVENT */
    /* Button Tric Logic */
    if(etimer_expired(&ds_periodic_timer)) {
        PRINTF("Periodic %d %d\n",ext5,ext6);
	if(ext5 != is_button_ext5()) {
	  ext5 = is_button_ext5();
          PRINTF("Toggle Triac A\n");
          // Toggle Triac A
          if(optriac_sensor.value(OPTRIAC_SENSOR_A) == 0){
            optriac_sensor.configure(OPTRIAC_SENSOR_A,1);
            led1_on();
          }else{
            optriac_sensor.configure(OPTRIAC_SENSOR_A,0);
            led1_off();
          }
	}
	if(ext6 != is_button_ext6()) {
	  ext6 = is_button_ext6();
          PRINTF("Toggle Triac B\n");
          // Toggle Triac B
          if(optriac_sensor.value(OPTRIAC_SENSOR_B) == 0){
            optriac_sensor.configure(OPTRIAC_SENSOR_B,1);
            led2_on();
          }else{
            optriac_sensor.configure(OPTRIAC_SENSOR_B,0);
            led2_off();
          }
	}
      etimer_reset(&ds_periodic_timer);
    }
  } /* while (1) */

  PROCESS_END();
}
示例#20
0
void 
hw_init()
{
  led1_off();
  key_init();
}
示例#21
0
void
optriac_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
  const char *type = NULL;
  const char *mode = NULL;
  static char namea[17]="Triac-a";
  static char nameb[17]="Triac-b";

  char temp[100];
  int index = 0;
  size_t len = 0;

  uint8_t triac = 0;
  int success = 1;
  switch(REST.get_method_type(request)){
   case METHOD_GET:
     // jSON Format
     index += sprintf(temp + index,"{\n \"%s\" : ",namea);
     if(optriac_sensor.value(OPTRIAC_SENSOR_A) == 0)
         index += sprintf(temp + index,"\"off\",\n");
     if(optriac_sensor.value(OPTRIAC_SENSOR_A) == 1)
         index += sprintf(temp + index,"\"on\",\n");
     index += sprintf(temp + index," \"%s\" : ",nameb);
     if(optriac_sensor.value(OPTRIAC_SENSOR_B) == 0)
         index += sprintf(temp + index,"\"off\"\n");
     if(optriac_sensor.value(OPTRIAC_SENSOR_B) == 1)
         index += sprintf(temp + index,"\"on\"\n");
     index += sprintf(temp + index,"}\n");

     len = strlen(temp);
     memcpy(buffer, temp,len );

     REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
     REST.set_response_payload(response, buffer, len);
     break;

   case METHOD_POST:
     success = 0;
     break;
   case METHOD_PUT:
  if ((len=REST.get_query_variable(request, "type", &type))) {
    PRINTF("type %.*s\n", len, type);

    if (strncmp(type, "a", len)==0) {
      triac = OPTRIAC_SENSOR_A;
    } else if(strncmp(type,"b", len)==0) {
      triac = OPTRIAC_SENSOR_B;
    } else {
      triac = OPTRIAC_SENSOR_A;
    }
  } else {
    success = 0;
  }

  if (success && (len=REST.get_post_variable(request, "mode", &mode))) {
    PRINTF("mode %s\n", mode);

    if (strncmp(mode, "on", len)==0) {
      led1_on();  // Debug
      optriac_sensor.configure(triac,1);
    } else if (strncmp(mode, "off", len)==0) {
      optriac_sensor.configure(triac,0);
      led1_off();  // Debug
    } else {
      success = 0;
    }
  } else {
    success = 0;
  }
    break;
  default:
    success = 0;
  }
  if (!success) {
    REST.set_response_status(response, REST.status.BAD_REQUEST);
  }
}
示例#22
0
void
led1_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
  char mode[10];
  static uint8_t led1 = 0;
  static char name[17]="led1";
  int success = 1;

  char temp[100];
  int index = 0;
  size_t len = 0;

  const char *pmode = NULL;
  const char *pname = NULL;

  switch(REST.get_method_type(request)){
   case METHOD_GET:
     // jSON Format
     index += sprintf(temp + index,"{\n \"name\" : \"%s\",\n",name);
     if(led1 == 0)
         index += sprintf(temp + index," \"mode\" : \"off\"\n");
     if(led1 == 1)
         index += sprintf(temp + index," \"mode\" : \"on\"\n");
     index += sprintf(temp + index,"}\n");

     len = strlen(temp);
     memcpy(buffer, temp,len );

     REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
     REST.set_response_payload(response, buffer, len);
     break;
   case METHOD_POST:
     success = 0;
     break;
   case METHOD_PUT:
     if (success &&  (len=REST.get_post_variable(request, "mode", &pmode))) {
       PRINTF("name %s\n", mode);
       memcpy(mode, pmode,len);
       mode[len]=0;
       if (!strcmp(mode, "on")) {
         led1_on();
         led1 = 1;
       } else if (!strcmp(mode, "off")) {
         led1_off();
         led1 = 0;
       } else {
         success = 0;
       }
    } else if (success &&  (len=REST.get_post_variable(request, "name", &pname))) {
       PRINTF("name %s\n", name);
       memcpy(name, pname,len);
       name[len]=0;
    } else {
      success = 0;
    }
    break;
  default:
    success = 0;
  }

  if (!success) {
    REST.set_response_status(response, REST.status.BAD_REQUEST);
  }
}
示例#23
0
文件: uart.c 项目: samjacoby/avr
void uart_putdata(uint8_t *data, uint8_t count) {
	int i;
    led1_on();
	for(i=0; i<count; i++) uart_putchar(data[i]);
    led1_off();
}
示例#24
0
文件: uart.c 项目: samjacoby/avr
void uart_putchar(uint8_t c) {
    led1_on();
	while( ! (UCSR0A & (1<<UDRE0)) );
	UDR0 = c;
    led1_off();
}