예제 #1
0
static ssize_t leds_dev_write (struct file *file, const char *buf, size_t len,
			       loff_t *pos)
{
	char temp_buf[LED_NUM_DIGITS];
	if (copy_from_user (temp_buf, buf, min_t(size_t, len, LED_NUM_DIGITS)))
		return -EFAULT;
	len = write_leds (*pos, temp_buf, len);
	*pos += len;
	return len;
}
예제 #2
0
static void led_tick ()
{
	static unsigned counter = 0;
	
	if (++counter == (HZ / TICK_UPD_FREQ)) {
		/* Which frame we're currently displaying for each digit.  */
		static unsigned frame_nums[LED_NUM_DIGITS] = { 0 };
		/* Display image.  */
		static unsigned char image[LED_NUM_DIGITS] = { 0 };
		unsigned char prev_image[LED_NUM_DIGITS];
		int write_to_leds = 1; /* true if we should actually display */
		int digit;

		/* We check to see if the physical LEDs contains what we last
		   wrote to them; if not, we suppress display (this is so that
		   users can write to the LEDs, and not have their output
		   overwritten).  As a special case, we start writing again if
		   all the LEDs are blank, or our display image is all zeros
		   (indicating that this is the initial update, when the actual
		   LEDs might contain random data).  */
		read_leds (0, prev_image, LED_NUM_DIGITS);
		for (digit = 0; digit < LED_NUM_DIGITS; digit++)
			if (image[digit] != prev_image[digit]
			    && image[digit] && prev_image[digit])
			{
				write_to_leds = 0;
				break;
			}

		/* Update display image.  */
		for (digit = 0;
		     digit < LED_NUM_DIGITS && tick_frames[digit][0] >= 0;
		     digit++)
		{
			int frame = tick_frames[digit][frame_nums[digit]];
			if (frame < 0) {
				image[digit] = tick_frames[digit][0];
				frame_nums[digit] = 1;
			} else {
				image[digit] = frame;
				frame_nums[digit]++;
				break;
			}
		}

		if (write_to_leds)
			/* Write the display image to the physical LEDs.  */
			write_leds (0, image, LED_NUM_DIGITS);

		counter = 0;
	}
}
예제 #3
0
void machine_halt (void)
{
#ifdef CONFIG_RESET_GUARD
	disable_reset_guard ();
#endif

	/* Ignore all interrupts.  */
	local_irq_disable ();

	/* Write a little message.  */
	write_leds (0, halt_leds_msg, sizeof halt_leds_msg);

	/* Really halt.  */
	for (;;)
		asm ("halt; nop; nop; nop; nop; nop");
}
예제 #4
0
char *
pre_task_setup()
{
#ifdef USE_LCD
   write_leds(0);
   write_7seg_raw(0x0000);
#endif

   /* preset buffer counts; may be overridden from command line */
   bigbufs = MAXBIGPKTS;
   lilbufs = MAXLILPKTS;
   bigbufsiz = BIGBUFSIZE;
   lilbufsiz = LILBUFSIZE;

   /* Install callback to prep_armintcp from prep_ifaces() */
   port_prep = prep_armintcp;

/*
 * Altera Niche Stack Nios port modification:
 * The alt_iniche_dev initialization code provides
 * for calling get_ip_addr() (which is in *application* 
 * code) for IP address assignment, for each mac (net).
 * The following is thus disabled.
 */
#ifndef ALT_INICHE
#ifndef INCLUDE_NVPARMS
   {
      int i = 0;              /* network index */

#ifdef USE_SMSC91X
      /* Ethernet */
      if (i < MAXNETS)
      {
         netstatic[i].n_ipaddr = htonl(0x0a000064);  /* 10.0.0.100 */
         netstatic[i].snmask = htonl(0xff000000);    /* 255.0.0.0 */
         netstatic[i].n_defgw = htonl(0x0a000001);   /* 10.0.0.1 */
#ifdef DHCP_CLIENT
         netstatic[i].n_flags |= NF_DHCPC;
#endif
         i++;
      }
#endif /* SMSC91x */

#ifdef USE_PPP
      /* PPP */
      if (i < MAXNETS)
      {
         netstatic[i].n_ipaddr = htonl(0xc0a80301);  /* 192.168.3.1 */
         netstatic[i].snmask = htonl(0xffffff00);    /* 255.255.255.0 */
         netstatic[i].n_defgw = htonl(0x00000000);   /* 0.0.0.0 */
         i++;
      }

#ifdef LB_XOVER
      if (i < MAXNETS)
      {
         netstatic[i].n_ipaddr = htonl(0x00000000);
         netstatic[i].snmask = htonl(0x00000000);
         netstatic[i].n_defgw = htonl(0x00000000);
         i++;
      }
#endif /* LB_XOVER */
#endif /* USE_PPP */

#ifdef MAC_LOOPBACK
      /* loopback */
      if (i < MAXNETS)
      {
         netstatic[i].n_ipaddr = htonl(0x7f000001); /* 127.0.0.1 */
         netstatic[i].snmask = htonl(0xff000000);   /* 255.0.0.0 */
         netstatic[i].n_defgw = htonl(0x00000000);  /* 0.0.0.0 */
         i++;
      }
#endif /* MAC_LOOPBACK */
   }

#else  /* INCLUDE_NVPARMS is used */

   /* set callback to set up default NV values. The generic NV system 
    * code in misclib\nvparams.c may call this NIOS2INI specific 
    * routine if it is set.
    */
   set_nv_defaults = nv_defaults;   /* set nv parameter init routine */

#endif /* INCLUDE_NVPARMS */

#endif /* not ALT_INICHE */

#ifdef   USE_PPP
#ifdef   MINI_IP
   /* If we are using the mini IP layer and PPP, then  overwrite the 
    * NDIS hook with the PPP prep routine 
    */
   port_prep = prep_ppp;
#endif   /* MINI_IP */

   /* for all PPP implementations, set a callback so the we can
    * set the device type of new PPP links.
    */
   ppp_default_type = LN_PORTSET;
   ppp_type_callback = ppp_type_setup;

   /* Set the number of static PPP ifaces. Allow one each for modem and
    * PPPOE, and two for Loopback-crossover.
    */
   ppp_static = 1;   /* base for modem or UART direct connect */

#ifdef LB_XOVER
   ppp_static += 2;     /* add pair for loopback crosover */
#endif   /* LB_XOVER */


#ifdef NOTDEF
   /* This little block of code is usefully for testing PPPoE in loopback
    * on windows (e.g. bouncing the packets off the NDIS driver) but for
    * most purposes should not be used.
    */
#ifdef USE_PPPOE
#ifdef PPPOE_LBTEST
   ppp_static += 2;     /* loopback test needs 2 interfaces */
#else
   ppp_static++;
#endif   /* PPPOE_LBTEST */
#endif   /* USE_PPPOE */
#endif   /* NOTDEF */

#endif   /* USE_PPP */


   return NULL;
}
예제 #5
0
파일: tlc5916.c 프로젝트: smeyel/M2
void tlc5916_write_leds(const void* states, int from_led, int led_count){
	write_leds(states, from_led, led_count);
}
예제 #6
0
int main() {        
    char buzz = 0;
    unsigned char leds = 0;
    unsigned char stage = 0;
    /* array to do the "fan" assignment */
    unsigned char fan[] = { bit(3)|bit(4), bit(2)|bit(5),
                               bit(1)|bit(6), bit(0)|bit(7) };
    switches sw = {0}, prevsw = {0};
    init();

    while (1) {
        prevsw = sw; /* set the previous switches aside */
        sw.all = read_sw(); /* read switches */
        
        /* if function changed - start new function from scratch */
        /*     if( (sw.all & 7) != (prevsw.all & 7))
            stage = 0; */

        /* switch 5 stops all motion*/
        if(sw.s5)
            continue;

        /* switch logic */
        /* switch s2 does the fan thing */
        if (sw.s2){

                stage = stage % 4;
                leds = fan[stage];

        /* switch s1 does the shift bit thing */
        } else if(sw.s1) {

            stage = stage % 8;
            leds = 1 << stage;

        /* switch s0 does the counter */
        } else if(sw.s0) {

            leds = stage;
        }

        /* setup the next stage */
        if(sw.s3)
            stage--;
        else
            stage++;

        
        if (sw.s6) {
            buzz = ~buzz;
            buzzer(buzz);
        } else {
            buzzer(OFF);
        }

        write_leds(leds);

        if (sw.s4)
            delay(LONG_DELAY);
        else
            delay(SHORT_DELAY);

        /* exit the main loop */
        if(sw.s7)
            break;
    }

    /* blink the leds before dying */
    write_leds(0xFF);
    delay(LONG_DELAY);
    write_leds(OFF);

    return 0;
}