Пример #1
0
static void wfl_timer_cb(os_timer_arg_t arg)
{
    STATIC UINT last_wf_stat = 0xffffffff;
    GW_WIFI_STAT_E wf_stat = get_wf_gw_status();
    
    if(last_wf_stat != wf_stat) {
        PR_DEBUG("wf_stat:%d",wf_stat);
        switch(wf_stat) {
            case STAT_UNPROVISION: {
                led_blink(WF_DIR_LEN, 250, 250);
            }
            break;
            
            case STAT_AP_STA_UNCONN:
            case STAT_AP_STA_CONN: {
                led_blink(WF_DIR_LEN, 1500, 1500);
            }
            break;
            
            case STAT_STA_UNCONN: {
                led_off(WF_DIR_LEN);
            }
            break;
            
            case STAT_STA_CONN: {
                led_on(WF_DIR_LEN);
            }
            break;
        }

        last_wf_stat = wf_stat;
    }
}
Пример #2
0
void led_test()
{
	led_init();
	while(1)
	{
		led_blink(1);
		delay();
		led_blink(0);
		delay();
	}
}
Пример #3
0
void setup(void)
{
   unsigned char i;

   watchdog_disable();
   
   XBR0 = 0x01;                 // Enable RX/TX
   XBR1 = 0x40;                 // Enable crossbar
   P0MDOUT = 0x90;              // P0.4: TX, P0.7: RS485 enable Push/Pull
   P0SKIP  = 0x0C;              // Skip P0.2&3 for Xtal
   P0MDIN  = 0xF3;              // P0.2&3 as analog input for Xtal
   P2MDOUT = 0x02;              // P2.1 for external watchdog

   OSCXCN = 0;
   OSCICN |= 0x03;              // Configure internal oscillator for
                                // its maximum frequency

   CLKMUL = 0x00;               // Select internal oscillator as
                                // input to clock multiplier

   CLKMUL |= 0x80;              // Enable clock multiplier
   for (i=0 ; i<100 ; i++);     // Delay for >5us
   CLKMUL |= 0xC0;              // Initialize the clock multiplier

   while(!(CLKMUL & 0x20));     // Wait for multiplier to lock

   CLKSEL |= USB_4X_CLOCK;      // Select USB clock
   CLKSEL |= SYS_INT_OSC;       // Select system clock

   VDM0CN = 0x80;               // VDD monitor enable
   while ((VDM0CN & 0x40)==0);  // wait for VDD monitor to stabilize

   /* start system clock */
   sysclock_init();

   /* init memory */
   RS485_ENABLE = 0;

   /* initialize UART0 */
   uart_init(0, BD_115200);
   PS0 = 1;                     // serial interrupt high priority

   /* Blink LEDs */
   led_blink(0, 3, 150);
   led_blink(1, 3, 150);

   /* invert first LED */
   led_mode(0, 1);

   /* dummy to prevent linker error */
   delay_us(1);
}
Пример #4
0
void notify_completion(bool success) {
    if (success) {
        printf("{{success}}" NL );
    } else {
        printf("{{failure}}" NL );
    }
    
    printf("{{end}}" NL);
#ifdef LED4
    led_blink(success ? LED1 : LED4);
#else
    led_blink(success ? LED1 : NC);
#endif
}
Пример #5
0
/********************************************************************
 *	PICライター系コマンド受信と実行.
 ********************************************************************
 *	Cmd0 : 0x10〜0x1F
 */
void cmd_picspx(void)
{
	led_blink(8);

#if	PICAVR_WRITER
	if(		Cmd0==PICSPX_SETCMD16L) {	pic_setcmd16L();	} 
	else if(Cmd0==PICSPX_SETADRS24) {	setaddress24();		} 
	else if(Cmd0==PICSPX_GETDATA8L) {	pic_getdata8L();	} 
	else if(Cmd0==PICSPX_BITBANG)   {	pic_bitbang();      } 
	else if(Cmd0==PICSPX_BITREAD)   {	pic_bitbang();		}
#if	SUPPORT_PIC24F
	else if(Cmd0==PICSPX_WRITE24F) 	{	pic_write24f();		} 
	else if(Cmd0==PICSPX_READ24F) 	{	pic_read24f();		}
#endif
	else 
#endif

#if	INCLUDE_JTAG_CMD
		 if(Cmd0==HIDASP_JTAG_WRITE) {	jtag_command(0);	} 
	else if(Cmd0==HIDASP_JTAG_READ)  {	jtag_command(1);	}
	else if(Cmd0==HIDASP_JTAG_CTRLW) {	jtag_control(0);	}
	else if(Cmd0==HIDASP_JTAG_CTRLR) {	jtag_control(1);	}
#endif

//	else if(Cmd0==PICSPX_SETPGM) 	{pic_setpgm();}

	ToPcRdy = Cmd0 & 1;	// LSBがOnなら返答が必要.
}
Пример #6
0
static void usb_b_out_complete(struct urb *urb)
{
    struct st5481_bcs *bcs = urb->context;
    struct st5481_b_out *b_out = &bcs->b_out;
    struct st5481_adapter *adapter = bcs->adapter;
    int buf_nr;

    buf_nr = get_buf_nr(b_out->urb, urb);
    test_and_clear_bit(buf_nr, &b_out->busy);

    if (urb->status < 0) {
        if (urb->status != USB_ST_URB_KILLED) {
            WARN("urb status %d",urb->status);
            if (b_out->busy == 0) {
                st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL);
            }
        } else {
            DBG(1,"urb killed");
            return; // Give up
        }
    }

    usb_b_out(bcs,buf_nr);

    if (adapter->number_of_leds == 2)
        led_blink(adapter);
}
Пример #7
0
/**
 * \brief Displays fatal error using LED blink
 *
 * Based on boot error, displays fatal error. 
 * and wait indefinitely !!!.
 *  
 */
static void error_fatal(boot_error error)
{
	int iMsDelay = DEFAULT_BLINK_DELAY;
#ifdef __DEBUG_PRINT__

	switch(error)
	{
		case MAX_SIZE_ERROR:
			iMsDelay = MAX_SIZE_BLINK_DELAY;
			printf("\r\n!!! [ABORT] MAXIMUM SIZE ERROR !!!\r\n");
			break;
		case FILE_OPEN_ERROR:
			iMsDelay = FILE_OPEN_BLINK_DELAY;
			printf("\r\n!!! [ABORT] FILE OPEN ERROR !!!\r\n");
			break;
		case FILE_READ_ERROR:
			iMsDelay = FILE_READ_BLINK_DELAY;
			printf("\r\n!!! [ABORT] FILE READ ERROR !!!\r\n");
			break;		
		case SD_CARD_MOUNTERR:
			iMsDelay = SD_CARD_BLINK_DELAY;
			printf("\r\n!!! [ABORT] SD CARD MOUNT ERROR !!!\r\n");
			break;
		default:
			iMsDelay = DEFAULT_BLINK_DELAY;
			printf("\r\n!!! [ABORT] UNKNOWN ERROR !!!\r\n");
			break;
	}
#endif	
	led_blink(iMsDelay, CONF_BLINK_TIME);
	start_application();
}
Пример #8
0
int main(void)
{
    bl_init();

    usart_start();
    spi_start();
    if (usbd_start()) {
        led_blink(LED_ACTIVITY, LED_STATE_RAPID);
        for (;;);
    }

    /* HW initialized */
    led_on(LED_ACTIVITY);
    bl_dbg("Bootloader started.");

//    test_fatfs();

    if (usb_connect()) {
        led_on(LED_USB);
        bl_dbg("USB connected.");
        bl_listen();
    } else
        led_off(LED_USB);

    bl_dbg("No USB.");

    jump_to_app(APP_LOAD_ADDRESS);

    return 0;
}
Пример #9
0
void	CDC_start_check(void)
{
	while ( P_IsConfigured() != USB_YES ) {
		led_blink(15);
	}
	led_on();
}
Пример #10
0
static int dell_led_blink(struct led_classdev *led_cdev,
		unsigned long *delay_on,
		unsigned long *delay_off)
{
	unsigned long on_eighths;
	unsigned long off_eighths;

	/* The Dell LED delay is based on 125ms intervals.
	   Need to round up to next interval. */

	on_eighths = (*delay_on + 124) / 125;
	if (0 == on_eighths)
		on_eighths = 1;
	if (on_eighths > 255)
		on_eighths = 255;
	*delay_on = on_eighths * 125;

	off_eighths = (*delay_off + 124) / 125;
	if (0 == off_eighths)
		off_eighths = 1;
	if (off_eighths > 255)
		off_eighths = 255;
	*delay_off = off_eighths * 125;

	led_blink(on_eighths, off_eighths);

	return 0;
}
Пример #11
0
int main(void) {
	
	// Initialise the LED.
	led_init();
	
	// Initialise the IR decoder.
	ir_init();
	
	// Initialise the USB keyboard handler.
	usb_keyboard_init();

	// Initialise timer 0 to use it as a 4ms timer.
	TCCR0A |= _BV(WGM01); // Mode = 2, CTC.
	TCCR0B |= _BV(CS02); // clkIO/256
	OCR0A = ((256 * 4) / ((1000.0 * 256 * 256) / F_CPU)) - 1; // Desired interrupt frequency is once every 4ms.
	TIMSK0 |= _BV(OCIE0A);
	
	// Enable interrupts.
	sei();
	
	// Flash the LED to indicate we're running.
	led_blink(LED_BLINK_PATTERN_3_MEDIUM);
	
	// Infinite loop.
	for(;;) {
		// USB polling.
		usb_keyboard_poll();
	}
}
Пример #12
0
static void usb_b_out_complete(struct urb *urb, struct pt_regs *regs)
{
	struct st5481_bcs *bcs = urb->context;
	struct st5481_b_out *b_out = &bcs->b_out;
	struct st5481_adapter *adapter = bcs->adapter;
	int buf_nr;
	
	buf_nr = get_buf_nr(b_out->urb, urb);
	test_and_clear_bit(buf_nr, &b_out->busy);

	if (unlikely(urb->status < 0)) {
		switch (urb->status) {
			case -ENOENT:
			case -ESHUTDOWN:
			case -ECONNRESET:
				DBG(4,"urb killed status %d", urb->status);
				return; // Give up
			default: 
				WARN("urb status %d",urb->status);
				if (b_out->busy == 0) {
					st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL);
				}
				break;
		}
	}

	usb_b_out(bcs,buf_nr);

	if (adapter->number_of_leds == 2)
		led_blink(adapter);
}
Пример #13
0
void SWNUI::mode_continuous()
{
    changeMode_management();
    samples = adxl335->sampling();
    continuosSend();
    led_blink(1000);
    delay(T_SAMPLE);
}
Пример #14
0
void user_loop(void)
{
   /* check terminal buffer */
   if (towp > 0 && (term_obuf[towp - 1] == 13 || term_obuf[towp - 1] == 0)) {
      
      DISABLE_INTERRUPTS;
   
      /* add trailing "0" */
      if (towp == sizeof(term_obuf))
         towp--;
      term_obuf[towp] = 0;

      /* send buffer */
      send(user_data.gpib_adr, term_obuf);
      towp = 0;

      /* receive buffer */
      tiwp = enter(user_data.gpib_adr, term_ibuf, sizeof(term_ibuf));
      tirp = 0;

      /* add newline */
      if (tiwp > 0 && tiwp < sizeof(term_ibuf)-1)
         term_ibuf[tiwp++] = 10;

      ENABLE_INTERRUPTS;
   }

   if (output_flag) {
      output_flag = 0;

      /* send buffer */
      send(user_data.gpib_adr, user_data.output);

      /* receive buffer */
      if (enter(user_data.gpib_adr, user_data.input, sizeof(user_data.input)))
         led_blink(1, 1, 100);

      /* stip NL */
      if (strlen(user_data.input) > 0 &&
          user_data.input[strlen(user_data.input) - 1] == 10)
         user_data.input[strlen(user_data.input) - 1] = 0;
   }

   if (control_flag) {
      control_flag = 0;

      GPIB_ATN = 0;             // assert attention
      send_byte(0x3F);          // unlisten
      send_byte(0x5F);          // untalk
      send_byte(0x20 | user_data.gpib_adr);     // listen device
      send_byte(0x40 | 21);     // talk 21
      send_byte(user_data.control);     // send control
      send_byte(0x3F);          // unlisten
      send_byte(0x5F);          // untalk
      GPIB_ATN = 1;             // remove attention
   }
}
Пример #15
0
void
ledattach(struct device *parent, struct device *self, void *aux)
{
	struct led_softc *sc = (void *)self;
#if VAX49 || VAX53 || VXT
	vaddr_t pgva;
#endif

	printf("\n");

	switch (vax_boardtype) {
#if VAX46
	case VAX_BTYP_46:
	{
		extern struct vs_cpu *ka46_cpu;
		sc->sc_reg = (volatile u_short *)(&ka46_cpu->vc_diagdsp);
		sc->sc_pat = led_pattern8;
	}
		break;
#endif
#if VAX48
	case VAX_BTYP_48:
	{
		extern struct vs_cpu *ka48_cpu;
		sc->sc_reg = (volatile u_short *)(&ka48_cpu->vc_diagdsp);
		sc->sc_pat = led_pattern8;
	}
		break;
#endif
#if VAX49
	case VAX_BTYP_49:
		pgva = vax_map_physmem(0x25800000, 1);
		sc->sc_reg = (volatile u_short *)(pgva + 4);
		sc->sc_pat = led_pattern8;
		break;
#endif
#if VAX53
	case VAX_BTYP_1303:
		pgva = vax_map_physmem(0x20140000, 1);
		sc->sc_reg = (volatile u_short *)(pgva + 0x30);
		sc->sc_pat = led_pattern4;
		break;
#endif
#if VXT
	case VAX_BTYP_VXT:
		pgva = vax_map_physmem(0x200c1000, 1);
		sc->sc_reg = (volatile u_short *)pgva;
		sc->sc_pat = led_pattern8;
		break;
#endif
	}

	sc->sc_patpos = sc->sc_pat;
	timeout_set(&sc->sc_tmo, led_blink, sc);
	led_blink(sc);
}
Пример #16
0
void notify_completion(bool success) {
    if (success) {
        printf("{success}\n");
    } else {
        printf("{failure}\n");
    }
    
    printf("{end}\n");
    led_blink(success ? LED1 : LED4);
}
Пример #17
0
void adc_calib()
{
   unsigned char i;

   for (i=0 ; i<8 ; i++) {

      write_adc(REG_CONTROL, i << 4 | 0x0F);

      /* zero calibration */
      write_adc(REG_MODE, 4);
      while (ADC_NRDY) led_blink(1, 1, 100);

      /* full scale calibration */
      write_adc(REG_MODE, 5);
      while (ADC_NRDY) led_blink(1, 1, 100);
   }

   /* restart continuous conversion */
   write_adc(REG_MODE, 3);
}
Пример #18
0
void BlinkUSBStatus(void)
{
    static WORD led_count=0;
    
    if(led_count == 0)led_count = 40000U;

    led_count--;
    if(led_count==0) {
		led_blink();
    }
}
Пример #19
0
static void sanity_check(void)
{
    UINT32 dram_requirement = RD_BUF_BYTES + WR_BUF_BYTES + COPY_BUF_BYTES + FTL_BUF_BYTES
        + HIL_BUF_BYTES + TEMP_BUF_BYTES + BAD_BLK_BMP_BYTES;

    if (dram_requirement > DRAM_SIZE) // DRAM metadata size check
    {
        led_blink();
        while (1);
    }
}
Пример #20
0
void notify_completion(bool success)
{
    printf("{{%s}}" NL, success ? TEST_ENV_SUCCESS : TEST_ENV_FAILURE);
#ifdef YOTTA_CFG_DEBUG_OPTIONS_COVERAGE
    coverage_report = true;
    gcov_exit();
    coverage_report = false;
#endif
    printf("{{%s}}" NL, TEST_ENV_END);
    led_blink(LED1, success ? 1.0 : 0.1);
}
Пример #21
0
void main()
{
	uint32_t timestamp;
	sx1276_config_t sx1276_config;

	DISABLE_IRQ();

	hal_clk_init();
	sys_tick_init();

	ENABLE_IRQ();

    led_init();
	sx1276_init(LORA, NULL);

	sx1276_config.frequency = 433400000;
	sx1276_config.spread_factor = SX1276_SF7;
	sx1276_config.bandwidth = SX1276_BW_125K;
	sx1276_config.coding_rate = SX1276_CR1;
	sx1276_config.crc_mode = SX1276_CRC_ON;
	sx1276_config.header_mode = SX1276_HEADER_ENABLE;
	sx1276_config.payload_len = 0;		// Set in HEADER disable mode
	sx1276_config.tx_power = 20;
	sx1276_config.tx_preamble_len = 12;
	sx1276_config.rx_preamble_len = 12;
	sx1276_set_config(&sx1276_config);

    /** Enter HF/LF test mode */
    if(sx1276_config.frequency < SX1276_LF_FREQ_MAX){
        sx1276_write( 0x01, 0x88 );
    }else{
        sx1276_write( 0x01, 0x80 );
    }
    sx1276_write( 0x3D, 0xA1 );
    sx1276_write( 0x36, 0x01 );
    sx1276_write( 0x1e, 0x08 );

    /** Enable TX to enter continuous wave transmitting mode */
    sx1276_send(NULL, 0, 0);

    /** Get system tick */
    timestamp = millis();

	while(1){
		/** Blink LED every 1s*/
        if( millis() - timestamp > 1000){
			timestamp = millis();
            led_blink(LED0, 100);
		}

        /** LED event polling */
        led_evt();
	}
}
Пример #22
0
void PlunWorker(void)
{
    switch(state)
    {
    case	IDLE:	break;
    case	INIT:	led(OFF);	setState(IDLE); break;
    case	READY:	led_blink(RED);	break;
    case	AP_CONNECTED:	led(RED); break;
    case	HOST_CONNECTED: led(BLUE); break;
    }
}
Пример #23
0
int	USBgetpacket(uchar *buf,int len)
{
	int rc;
	while(1) {
		led_blink(18);
		rc = USBpeekpacket(buf,len);
		if(rc!=0) return rc;
		
		// baudrateが変更されたら、エラーとする.
		if(s_linecoding) return -1;
	}
}
Пример #24
0
static void sanity_check(void)
{
    UINT32 dram_requirement = RD_BUF_BYTES + WR_BUF_BYTES + COPY_BUF_BYTES + FTL_BUF_BYTES
        + HIL_BUF_BYTES + TEMP_BUF_BYTES + BAD_BLK_BMP_BYTES + PAGE_MAP_BYTES + VCOUNT_BYTES;

    if ((dram_requirement > DRAM_SIZE) || // DRAM metadata size check
        (sizeof(misc_metadata) > BYTES_PER_PAGE)) // misc metadata size check
    {
        led_blink();
        while (1);
    }
}
void send_prepared_message(void)
{
	inc_packetcounter();
	
	pkg_header_set_senderid(device_id);
	pkg_header_set_packetcounter(packetcounter);
	
	rfm12_send_bufx();
	rfm12_tick(); // send packet, and then WAIT SOME TIME BEFORE GOING TO SLEEP (otherwise packet would not be sent)

	led_blink(200, 0, 1);
}
Пример #26
0
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();
			}

		}
	}
}
Пример #27
0
/**
 * Enable/disable external power supply and start measurements
**/
void setSensorStatus(void) {
	if (config.enable) {
		SENS_PORT |= _BV(SENS_PIN);
		adc_start();
		windspeed_start();
		led_on();
	} else {
		SENS_PORT &= ~_BV(SENS_PIN);
		adc_stop();
		windspeed_stop();
		led_blink();
	}
}
Пример #28
0
__irq void irq_handler(void)
#endif
{
	UINT32 intr_stat = GETREG(APB_INT_STS);

	if (intr_stat & (INTR_TIMER_1 | INTR_TIMER_2 | INTR_TIMER_3))
	{
		g_timer_interrupt_count++;

		CLEAR_TIMER_INTR(TIMER_CH1);
		CLEAR_TIMER_INTR(TIMER_CH2);
		CLEAR_TIMER_INTR(TIMER_CH3);
		SETREG(APB_INT_STS, INTR_TIMER_1 | INTR_TIMER_2 | INTR_TIMER_3);
	}
	else if (intr_stat & INTR_FLASH)
	{
		ftl_isr();
	}
	else if (intr_stat & INTR_SDRAM)
	{
		UINT32 sdram_interrupt = GETREG(SDRAM_INTSTATUS);

	    SETREG(SDRAM_INTSTATUS, 0xFFFFFFFF);

		// clear the DRAM interrupt flag at the interrupt controller
	    SETREG(APB_INT_STS, INTR_SDRAM);

		if (sdram_interrupt & SDRAM_INT_ECC_CORR)
		{
			// Bit errors were detected and corrected.
			// Usually this is NOT an indication of poor SDRAM quality.
			// If the firmware has a bug due to which SDRAM is written by CPU without the help of mem util functions,
			// ECC correction or ECC failure can happen.

			g_sdram_ecc_count++;
		}

		if (sdram_interrupt & SDRAM_INT_ECC_FAIL)
		{
			// Bit errors were detected but could not be corrected.
			g_sdram_ecc_fail_count++;
		}

		if (sdram_interrupt & SDRAM_INT_ADDR_OF)
		{
			// There was an attempt to access beyond DRAM address boundary.
            uart_printf("Error: SDRAM interrupt occred: attempt to access beyond DRAM address boundary");
            led_blink();
		}
	}
}
Пример #29
0
void wait_until_ball_in_the_loader(void)
{
	uint8_t i;

	for (i=0; i<2; i++) {
		while (!sw_ball_in_the_loader())
			if (sw_user_switch())
				shake_it(2); /* shake 1 sec */
			else 
				led_blink(1, 1); /* red led blink */

		_delay_ms(WAIT_LOADER);
	}
}
Пример #30
0
void kmain()
{
	irq_disable();
	/* 
	 * A primeira coisa a se fazer é iniciar todo o gerenciador
	 * de memória.
	 */
	mm_init();
	arch_early_init();
	ioremap_init();
	irq_init();
	sched_init();
	timer_init();
	/* 
	 * Neste momento temos o gerenciador de memória e escalonador prontos,
	 * já podemos habilitar as interrupções, que podem ser utilizadas
	 * pelos drivers.
	 */
	irq_enable();

	/* Inicia os drivers da plataforma */
	arch_setup();

	/* Requisita um modo se existir um framebuffer*/
	fb_set_mode();
	/* Inicia o console sobre o framebuffer */
	fb_console_init();
	kernel_info();

#if 1
	irq_disable();
	semaphore_init(&sem, 1);
	create_task("a", 4);
	create_task("b", 5);
	create_task("c", 6);
	create_task("d", 7);
	create_task("b", 8);
	create_task("b", 9);
	irq_enable();
	/* Fica de boas esperando as trocas de contexto */
#endif
	/* Como queremos imprimir para depuração do driver, inicializamos ele agora */
	//bcm2835_emmc_init();
	for (;;) {
		led_blink();
		//printk("-");
	}
}