Exemplo n.º 1
0
main()
{
	/* Set both LED's initially ON.  When update_outputs() is called, the
	 * human will see it this way.
	 */
   strcpy(led2,led_on_gif);
   strcpy(led3,led_on_gif);

   sock_init();
   http_init();
   tcp_reserveport(80);

	/*  Configure the I/O ports.  Disable slave port which makes
	 *  Port A an output, and PORT E not have SCS signal.
	 *  Read shadow and set PE1 and PE7 as normal I/O.
	 *  LED's are controlled by PE1 and PE7, so make them outputs.
	 */
	WrPortI(SPCR, NULL, 0x84);
	WrPortI(PEFR,  & PEFRShadow,  ~((1<<7)|(1<<1)) & PEFRShadow);
	WrPortI(PEDDR, & PEDDRShadow, (1<<7)|(1<<1));

   while (1) {
   	update_outputs();
      http_handler();
   }
}
Exemplo n.º 2
0
// C programs require a main() function
void main()
{
    int j;	// define an integer j to serve as a loop counter
    int k;	// define a counter k to test the watch expression with


    // set lowest 2 bits of port D as outputs
    WrPortI(PDDDR, &PDDDRShadow, 0x03);
    // set all ports D outputs to not be open drain
    WrPortI(PDDCR, &PDDCRShadow, 0x00);

    k=0;		// initialize k to zero


    while(1) {  // begin an endless loop

        BitWrPortI(PDDR, &PDDRShadow, 0x00, 0);   // turn led on output 1 off

        for(j=0; j<25000; j++)
            ; // time delay loop

        BitWrPortI(PDDR, &PDDRShadow, 0xFF, 0);   // turn led on output 0 on

        for(j=0; j<25000; j++)
            ; // time delay loop

        k++;					// increment k

        // update watch expressions for Dynamic C to read
        runwatch();

    }	// end while loop

} // end program
Exemplo n.º 3
0
void blink_leds()
{
	WrPortI(PGDR, &PGDRShadow, 0x80);
	delayloop();
	WrPortI(PGDR, &PGDRShadow, 0x40);
	delayloop();
}
Exemplo n.º 4
0
// C programs require a main() function. This one returns no value.
void main()
{
	int j;	// define an integer j to serve as a loop counter
	int k;   // define a counter k with which to test the watch expression

	// Write 84 hex to slave port control register that initializes parallel
	// port A as an output port (port A drives the LEDs on the Prototyping Board).

	WrPortI(SPCR, &SPCRShadow, 0x84);

	k=0;     // initialize k to 0

	// now write all ones to port A which sets outputs high and LEDs off
  
	WrPortI(PADR, &PADRShadow, 0xff);
  
	while(1) {  // begin an endless loop

		BitWrPortI(PADR, &PADRShadow, 1, 1);  // turn LED DS3 off

		for(j=0; j<32000; j++)
			; // time delay loop
			
		BitWrPortI(PADR, &PADRShadow, 0, 1);  // turn LED DS3 on

		for(j=0; j<1000; j++)
			; // time delay loop

		k++;         // increment k
		runwatch();  // update watch expressions for Dynamic C to read

	}	// end while loop
  
} // end program
Exemplo n.º 5
0
void dprint_init_ports() {
	//set PA0:PA7 as outputs, disable slave port
	WrPortI(SPCR, & SPCRShadow, 0x84);
	//set PE0 for output ()
	WrPortI(PEDDR, & PEDDRShadow, 0x01 | PEDDRShadow);
	WrPortI(PEFR, & PEFRShadow, 0x00);
	//write zero to start with...
	WrPortI(DATA_PORT, & DATA_PORT_SHADOW, 0x00);
	WrPortI(DISPLAY_E, NULL, 0x00);
}
Exemplo n.º 6
0
void main()
{
	auto int	done;

	WrPortI(PGCR, &PGCRShadow, 0x00);
	WrPortI(PGFR, &PGFRShadow, 0x00);
	WrPortI(PGDCR, &PGDCRShadow, 0x00);
	WrPortI(PGDDR, &PGDDRShadow, 0xC0);

	done = FALSE;
	while (!done) {

		costate {
			// full processor clock
			useMainOsc();
			waitfor(DelaySec(STEPDELAY));

			// 1/2 processor clock
			useClockDivider3000(CLKDIV_2);
			waitfor(DelaySec(STEPDELAY));

			// 1/4 processor clock
			useClockDivider3000(CLKDIV_4);
			waitfor(DelaySec(STEPDELAY));

			// 1/6 processor clock
			useClockDivider3000(CLKDIV_6);
			waitfor(DelaySec(STEPDELAY));

			// 1/8 processor clock
			useClockDivider3000(CLKDIV_8);
			waitfor(DelaySec(STEPDELAY));

         // run processor clock off 32kHz oscillator
         use32kHzOsc();
            // waitfor() will not work when running off the
            // 32kHz oscillator (the periodic interrupt is
            // disabled).  Instead we'll just call the
            // LED-blinking code once, which should be enough
            // (note that it will take one the order of
            // half a minute to finish).
         blink_leds();

			// full processor clock
			useMainOsc();
			waitfor(DelaySec(STEPDELAY));
			done = TRUE;
		}

		costate {
			blink_leds();
		}
	}

}
Exemplo n.º 7
0
// Setup timer c and parallel port D alternate outputs.
void timerc_setup()
{
	unsigned int tc_div;
   // The Timer C divisor affects how far apart the pulses are.  This
   // effectively controls the volume by changing the average voltage
   // between a certain range.  Too high and the pulses get very far apart
   // and start to produce a high pitched noise.  Too low and the pulses
   // get too close together and the wav becomes inaudible.
	tc_div  = 0x0100;

   // setup PE0 for alternate output TMRC[0]
	WrPortI(PEDDR, &PEDDRShadow, PEDDRShadow | 0x01);
   WrPortI(PEALR, &PEALRShadow, (PEALRShadow & 0xFC) | 0x02);
   WrPortI(PEFR,  &PEFRShadow, PEFRShadow | 0x01);

   // setup timer c
   WrPortI(TCS0HR, NULL, 0x00);	// SET value MSB
   WrPortI(TCS0LR, NULL, 0x00);	// SET value LSB
   WrPortI(TCR0HR, NULL, 0x00);	// RESET value MSB (LSB set by DMA later)

	// Timer C Divider
   WrPortI(TCDLR, NULL, (char)tc_div);
   WrPortI(TCDHR, NULL, (char)(tc_div >> 8));

	// Timer C Control registers
   WrPortI(TCCR,  &TCCRShadow,  0x00);	  // interrupts disabled for timer c
   WrPortI(TCCSR, &TCCSRShadow, 0x01);   // enable main clock for timer c
}
Exemplo n.º 8
0
   pop	hl
	ipres
   ret
#endasm

// Generate an interrupt by toggling PB3
void generate_interrupt()
{
	WrPortI(PBDR, &PBDRShadow, PBDRShadow & ~0x08);
   WrPortI(PBDR, &PBDRShadow, PBDRShadow |  0x08);
}
Exemplo n.º 9
0
void main()
{
	int vswitch;		// state of virtual switch controlled by button S1


	// set lowest 2 bits of port D as outputs, the rest as inputs
  	WrPortI(PDDDR, &PDDDRShadow, 0x03);
	// set all port D outputs to not be open drain
	WrPortI(PDDCR, &PDDCRShadow, 0x00);

   vswitch=0;				   // initialize virtual switch as off

	while (1) {					// endless loop

     // First task will flash LED #4 for 200ms once per second.
     costate {

		 BitWrPortI(PDDR, &PDDRShadow, 0xFF, 1);	// turn LED on
       waitfor(DelayMs(200));		// wait 200 milliseconds
		 BitWrPortI(PDDR, &PDDRShadow, 0x00, 1);	// turn LED off
       waitfor(DelayMs(800));		// wait 800 milliseconds
     }


     // Second task will debounce switch #1 and toggle virtual switch vswitch.
     // also check button 1 and toggle vswitch on or off
     costate {
         if (!BitRdPortI(PDDR, 2))
         	abort;				// if button not down skip out of costatement

         waitfor(DelayMs(50));		// wait 50 ms

         if(!BitRdPortI(PDDR, 2))
         	abort;				// if button not still down skip out

         vswitch = !vswitch;	// toggle virtual switch since button was down 50 ms

         // now wait for the button to be up for at least 200 ms before considering another toggle
         while (1) {
           waitfor(!BitRdPortI(PDDR, 2));		// wait for button to go up
           waitfor(DelayMs(200));				// wait additional 200 milliseconds
           if (!BitRdPortI(PDDR, 2))
           		break;				// if button still up break out of while loop
			}
      } // end of costate

		// make LED agree with vswitch
			BitWrPortI(PDDR, &PDDRShadow, vswitch, 0);

	}  // end of while loop

}  // end of main
Exemplo n.º 10
0
void main()
{
	int vswitch;		// state of virtual switch controlled by button S1

   WrPortI(SPCR, &SPCRShadow, 0x84);	// setup parallel port A as output
   WrPortI(PADR, &PADRShadow, 0xff);		// turn off all LED's
   

   vswitch=0;				   // initialize virtual switch as off
       
	while (1) {					// endless loop
	
     // First task will flash LED DS4 for 200ms once per second.
     costate {    
       BitWrPortI(PADR, &PADRShadow, 0, 1);		// turn LED on
       waitfor(DelayMs(200));							// wait 200 milliseconds
       BitWrPortI(PADR, &PADRShadow, 1, 1);		// turn LED off
       waitfor(DelayMs(800)); 						// wait 800 milliseconds
     }

          
     // Second task will debounce switch S1 and toggle virtual switch vswitch.
     // also check button 1 and toggle vswitch on or off
     costate {
         if (BitRdPortI(PBDR, 2))
         	abort;				// if button not down skip out of costatement

         waitfor(DelayMs(50));		// wait 50 ms

         if(BitRdPortI(PBDR,2))
         	abort;				// if button not still down skip out
         
         vswitch = !vswitch;	// toggle virtual switch since button was down 50 ms
  
         // now wait for the button to be up for at least 200 ms before considering another toggle
         while (1) {
           waitfor(BitRdPortI(PBDR, 2));		// wait for button to go up
           waitfor(DelayMs(200));				// wait additional 200 milliseconds
           if (BitRdPortI(PBDR,2))
           		break;				// if button still up break out of while loop
			}
      } // end of costate
               
		// make led agree with vswitch if vswitch has changed
		if( (PADRShadow & 1) == vswitch)
			BitWrPortI(PADR, &PADRShadow, !vswitch, 0);
     
	}  // end of while loop

}  // end of main
Exemplo n.º 11
0
//use low four
void dprint_write_nibble(char d,int instr){
	int i;
	char fixed_data;
	//write the nibble
	fixed_data = 0;
	if(instr==1) fixed_data = d & 0x0F;	//just the low four
	else fixed_data = d & 0x4F;
	WrPortI(DATA_PORT, & DATA_PORT_SHADOW, fixed_data);
	//toggle E
	WrPortI(DISPLAY_E, NULL, 0xFF);
	delay_us(20);
	WrPortI(DISPLAY_E, NULL, 0x00);
	delay_us(200);
	//printf("  wrote nibble 0x%02x (0x%02x)\n",d,fixed_data);
}
Exemplo n.º 12
0
void main()
{
	int i;
	reg_write_t reg_write;

   // Register user defined syscall.
	_sys_register_usersyscall(systemmode_test);

	// Set PB3 to output
	WrPortI(PBDDR, &PBDDRShadow, PBDDRShadow | 0x08);
   // Set PE4 to input
   WrPortI(PEDDR, &PEDDRShadow, PEDDRShadow & ~0x10);
	// Set interrupt handler for external INT0
   SetVectExtern3000(0, ext_int0_isr);
   // Enable external INT0 on PE4, rising edge, priority 1
   WrPortI(I0CR, &I0CRShadow, 0x21);

	while(1)
   {
   	// Call user syscall to enable use of parallel port B through its user
      // enable register, generate interrupts and show the number of interrupts
      // handled.
	   _sys_usersyscall(ENABLE_PORT_B, NULL);
   	interrupt_count = 0;
		for(i = 0; i < 2000; i++)
      {
			generate_interrupt();
      }
      printf("Port B enabled: %d\n", interrupt_count);

		// Call user syscall to disable use of parallel port B through its user
      // enable register and attempt to generate interrupts.  Since the parallel
      // port B user enable register is not set, no interrupts will be generated
      // and the count will be zero at the end of this loop.
		// Note that disabling of PBUER is handled differently than above.  This
      // is purely for demonstration purposes to show the use of the parameter
      // that can be passed to the user defined syscall.
      reg_write.port = PBUER;
      reg_write.data = 0x00;
	   _sys_usersyscall(REGISTER_WRITE, (void*)&reg_write);
   	interrupt_count = 0;
		for(i = 0; i < 2000; i++)
      {
	   	generate_interrupt();
      }
      printf("Port B disabled: %d\n", interrupt_count);
   }
}
Exemplo n.º 13
0
int main()
{
	int count, err;
   unsigned int dma_div, flags;
   dma_chan_t handle;

	// The dma divisor determines how fast the data sent to TCR0LR changes.
	// The larger this number is, the slower the wav file will play.
	dma_div = 0x0F00;

	src = xmem_src + sizeof(long);
	xmem2root((void *)&wav_size, xmem_src, 4);
	timerc_setup();

   // Set the DMA to use 50% of the CPU resources.
	err = DMAsetParameters(0, 0, DMA_IDP_FIXED, 2, 50);
	if(err){
   	printf("Error: DMAsetParameters.\n");
		exit(err);
   }

   handle = DMAalloc(DMA_CHANNEL_ANY, 0);
   if(handle == DMA_CHANNEL_NONE){
      printf("Error: DMAalloc.\n");
      exit(EINVAL);
   }

   printf("Playing wav file...\n");
	for(count = 0; count < 5 && !kbhit(); count++){			// play the wav 5 times.
		printf(" Count = %d.\n", count + 1);

		// This function sets up the timer.  To use the timer, the flag values
      // must be set correctly as well.
      DMAtimerSetup(dma_div);

      // if the wav_size were larger than 32765 bytes, more than one transfer
      // would be necessary.
      flags = DMA_F_TIMER | DMA_F_TIMER_1BPR;
	   err = DMAmem2ioi(handle, TCR0LR, src, (int)wav_size, flags);
	   if(err){
			printf("Error: DMAmem2ioi.\n");
         exit(err);
	   }

	   while(!DMAcompleted(handle, NULL))
	      ;

   }

   WrPortI(TCCSR, NULL, 0x00);   // disable the main clock for timer c

   err = DMAunalloc(handle);
   if(err){
      printf("Error: DMAunalloc.\n");
      exit(err);
   }
}
Exemplo n.º 14
0
pinginled(int what)
{
	if (what==LEDON)
		ledstatus&=0x7F;				//turn DS2 on
	else
		ledstatus|=0x80;				//turn DS2 off

	WrPortI(PDDR, NULL, ledstatus);
}
Exemplo n.º 15
0
pingoutled(int what)
{
	if (what==LEDON)
		ledstatus&=0xBF;				//turn DS1 on
	else
		ledstatus|=0x40;				//turn DS1 off

	WrPortI(PDDR, NULL, ledstatus);
}
Exemplo n.º 16
0
/*  Update all LED's to reflect string values. */
void update_outputs()
{
	int  value;

	/*  update DS2 */
	value = (1<<1);		/* PE1 */
	if( !strcmp(led2,led_on_gif) ) {
		value = 0;
   }
   WrPortI(PEB1R, NULL, value);

   /* update DS3 */
   value = (1<<7);		/* PE7 */;
	if( !strcmp(led3,led_on_gif) ) {
		value = 0;
   }
	WrPortI(PEB7R,NULL,value);
}  /* end update_outputs() */
void main() {
  void brdInit();                              // Enable development board
  WrPortI(SPCR, NULL, 0x84);                   // Set Rabbit port A to output
  WrPortI(PADR, &PADRShadow, 0x0);             // Zero out all bits of port A
  WrPortI(PBDDR, &PBDDRShadow, 0xFF);          // Set port B to output

  LcdWrite(0, 0x30);
  MsDelay(4);
  LcdWrite(0, 0x30);
  LcdWrite(0, 0x30);
  LcdWrite(0, 0x38);                           // Send cmd "8bit, 2 lines, 5x7 font"
  LcdWrite(0, 0x06);                           // Send cmd "Entry mode, increment move"
  LcdWrite(0, 0x10);                           // Send cmd "display and cursor shift"
  LcdWrite(0, 0x0E);                           // Send cmd "display and cursor on"
  LcdWrite(0, 0x01);                           // Send cmd "LCD clear, jump to zero

  LcdWrite(1, 0x48);                           // Send data 'H'
  LcdWrite(1, 0x69);                           // Send data 'i'
}
void LcdWrite(int mode, char hex) {
  BitWrPortI(PBDR, &PBDRShadow, mode, RSADDR); // Choose command or data mode
  BitWrPortI(PBDR, &PBDRShadow, 0,    RWADDR); // Set LCD write mode
  WrPortI(PADR, &PADRShadow, hex);             // Set LCD command on port A

  MsDelay(1);
  BitWrPortI(PBDR, &PBDRShadow, 1, ENADDR);    // Start sending data
  MsDelay(1);                                  // Wait 1 ms for LCD to receive
  BitWrPortI(PBDR, &PBDRShadow, 0, ENADDR);    // Finish transmission
  MsDelay(1);                                  // Wait 1 ms until next write
}
void LcdCommandWr(char hex) {
  BitWrPortI(PBDR, &PBDRShadow, 0, RSADDR);  // Set LCD command mode
  BitWrPortI(PBDR, &PBDRShadow, 0, RWADDR);  // Set LCD write mode
  WrPortI(PADR, &PADRShadow, hex);	     // Set LCD command on port A

  MsDelay(1);
  BitWrPortI(PBDR, &PBDRShadow, 1, ENADDR);  // Start sending data
  MsDelay(1);                                // Wait 1 ms for LCD to read
  BitWrPortI(PBDR, &PBDRShadow, 0, ENADDR);  // Finish transmission
  MsDelay(1);                                // Wait 1 ms until next write
}
Exemplo n.º 20
0
// C programs require a main() function
void main()
{
	int j;	// define an integer j to serve as a loop counter

	/*  1. Convert the I/O ports.  Disable slave port which makes
	 *     Port A an output, and PORT E not have SCS signal.
	 */
	WrPortI(SPCR, & SPCRShadow, 0x84);

	/*  2. Read function shadow and set PE1 and PE7 as normal I/O.
	 *     LED's are conencted to PE1 and PE7, make them outputs.
	 *     Using shadow register preserves function of other Port E bits.
	 */
	WrPortI(PEFR,  & PEFRShadow,  ~((1<<7)|(1<<1)) & PEFRShadow);
	WrPortI(PEDDR, & PEDDRShadow, (1<<7)|(1<<1));

	/*  3. Turn on DS2 (0 -> PE1) and turn off DS3 (1 -> PE7).
	 */
	WrPortI(PEDR, & PEDRShadow, (1<<7));

	while(1) {  // begin an endless loop

		WrPortI(PEB7R, NULL, 0xff);  // turn LED DS3 off

		for(j=0; j<32000; j++)
			; // time delay loop
			
		WrPortI(PEB7R, NULL, 0);     // turn LED DS3 on

		for(j=0; j<25000; j++)
			; // time delay loop

	}	// end while loop
  
} // end program
Exemplo n.º 21
0
void dprint_write_byte(char d,int instr){
	int i;
	char fixed_data;
	//write the high 4
	fixed_data = d >> 4;
	if(instr==1) fixed_data = fixed_data;
	else fixed_data = fixed_data | 0x40;
	WrPortI(DATA_PORT, & DATA_PORT_SHADOW, fixed_data);
	//toggle E
	WrPortI(DISPLAY_E, NULL, 0xFF);
	delay_us(20);
	WrPortI(DISPLAY_E, NULL, 0x00);
	delay_us(20);
	//printf("  wrote byte 0x%02x (0x%02x",d,fixed_data);
	//write the low 4
	if(instr==1) fixed_data = d & 0x0F;
	else fixed_data = d | 0x40;
	WrPortI(DATA_PORT, & DATA_PORT_SHADOW, fixed_data);
	//toggle E
	WrPortI(DISPLAY_E, NULL, 0xFF);
	delay_us(20);
	WrPortI(DISPLAY_E, NULL, 0x00);
	//for some reason it doesn't work if I take this out :-(
	delay_us(200);
	for(i=0;i<100;i++);
}
Exemplo n.º 22
0
main()
{
    // Initializations
    auto char display[128];
    auto char key;
    brdInit();
    count_TMRA5 = 0;                      // Initialize counters to zero
    count_TMRA6 = 0;                      // Initialize counters to zero
    count_TMRA7 = 0;                      // Initialize counters to zero
    for (i = 0; i < 3; i++)               // Initialize display counters to zero
        display_count[i] = 0;
    // Set up Timer A interrupts
    SetVectIntern(0x0A, Tmr_A_isr);       // Set up timer A interrupt vector
    WrPortI(TAT7R, &TAT7RShadow, 0x3F);   // Set TMRA7 to count down from 63
    WrPortI(TAT6R, &TAT6RShadow, 0x7F);   // Set TMRA6 to count down from 127
    WrPortI(TAT5R, &TAT5RShadow, 0xFF);   // Set TMRA5 to count down from 255
    WrPortI(TAT1R, &TAT1RShadow, 0xFF);   // Set TMRA1 to count down from 255
    WrPortI(TACR,  &TACRShadow,  0xE1);   // Clock TMRA5,TMRA6,TMRA7 by TMRA1. Clock TMRA4 by PCLK/2. Set Timer A to trigger priority 1 interrupts
    WrPortI(TACSR, &TACSRShadow, 0xE1);   // Enable interrupts for TMRA5,TMRA6,TMRA7 only. Enable main clock for Timer A
    DispStr(5, 10, "<-PRESS 'Q' TO QUIT->");
    // This is the background process. It repeatedly updates the computer monitor with the values in the display_count array
    while (1) {
        for(i = 0; i < 3; i++) {
            display[0] = '\0';
            sprintf(display, "Number of TMRA%d interrupts: %d\  (x100)", i+5, display_count[i]);
            DispStr(5, i+1, display);
        }
        if (kbhit()) {                       // Check if any key has been pressed
            key = getchar();
            if (key == 0x71 || key == 0x51)  // Check if it's the key 'q' or 'Q'
                exit(0);
        }
    }
}
Exemplo n.º 23
0
/* START FUNCTION DESCRIPTION ********************************************
tmpnam                                                           <stdio.h>

SYNTAX:	char *tmpnam( char *s)

DESCRIPTION:	Generates a string that is a valid file name and that is not the
same as the name of an existing file.

The tmpnam function generates a different string each time it
is called, up to TMP_MAX times.

In the current implementation, uses the pattern A:TEMP####.TMP
to generate filenames.

PARAMETER 1:	Buffer to hold the filename.  Must be at least L_tmpnam
characters.

If NULL, tmpnam() will store the name in a static buffer.
Subsequent calls to tmpnam() may modify that buffer, making
it a less-robust method than passing in a buffer to use.

RETURN VALUE:	Buffer containing filename (either the first parameter or
a static buffer if the first parameter is NULL).

END DESCRIPTION **********************************************************/
_stdio_fat_debug
char *tmpnam( char *s)
{
    static char static_name[L_tmpnam];
    static word lastnum = 0xFFFF;

    int 			status;
    fat_part		*part;
    char			*fn;
    fat_dirent	dirent;		// dummy entry used during check for file

    // use a static var to keep track of last number used to generate file
    // first time through, use lower bits of RTC to seed random generator
    if (lastnum == 0xFFFF)
    {
        WrPortI( RTC0R, NULL, 0);
        lastnum = RdPortI16( RTC0R) & 0x03FF;	// lastnum 0 to 1023
    }

    if (s == NULL)
    {
        s = static_name;
    }

    // <s> will be "A:
    TEMP####.TMP".  <part> is the partition, <fn> is the
    // filename (the "TEMP####.TMP" part of <s>).
    part = fat_part_mounted[0];
strcpy( s, "A:");
    fn = &s[2];

    do {
    // lastnum ranges from 0 to 9999
    if (++lastnum > 9999)
    {
    lastnum = 0;
}
    sprintf( fn, "
    TEMP%04u.TMP", lastnum);
    do {
    status = fat_Status( part, fn, &dirent);
} while (status == -EBUSY);
#ifdef STDIO_FAT_VERBOSE
fprintf( stderr, "%s:
    %s %s\n", __FUNCTION__, s,
    status ? "is available" : "exists");
#endif
} while (status == 0);

    return s;
}
Exemplo n.º 24
0
///// write character to lcd
void lcdPutc (char cData)
{
	WrPortI ( PADR,&PADRShadow,(cData&0xF0)|0x04|(PADRShadow&0x01) );
	WrPortI ( PADR,&PADRShadow,PADRShadow|0x02 );					//	Strobe Write
	WrPortI ( PADR,&PADRShadow,PADRShadow&0xFD );
																					//	Ready Lower Nibble
	WrPortI ( PADR,&PADRShadow,((cData<<4)&0xF0)|0x04|(PADRShadow&0x01) );
	WrPortI ( PADR,&PADRShadow,PADRShadow|0x02 );					//	Strobe Write
	WrPortI ( PADR,&PADRShadow,PADRShadow&0xFD );
	WrPortI ( PADR,&PADRShadow,(PADRShadow&0x01) );	//	Restore Contrast
	delay ( 4 );												//	Wait 40 uSec
}
Exemplo n.º 25
0
void main()
{
	count0 = 0;
	count1 = 0;

	WrPortI(PEDDR, &PEDDRShadow, 0x00);	// set port E as all inputs

#if __SEPARATE_INST_DATA__ && (_RK_FIXED_VECTORS)
	interrupt_vector ext0_intvec my_isr0;
	interrupt_vector ext1_intvec my_isr1;
#else
	SetVectExtern3000(0, my_isr0);
	SetVectExtern3000(1, my_isr1);
   // re-setup ISR's to show example of retrieving ISR address using GetVectExtern3000
	SetVectExtern3000(0, GetVectExtern3000(0));
	SetVectExtern3000(1, GetVectExtern3000(1));
#endif

	WrPortI(I0CR, &I0CRShadow, 0x09);		// enable external INT0 on PE0, rising edge, priority 1
	WrPortI(I1CR, &I1CRShadow, 0x09);		// enable external INT1 on PE1, rising edge, priority 1


	while ((count0 < 20) && (count1 < 20)) {

		// output the interrupt count every second
		costate {
			printf("counts = %3d  %3d\n", count0, count1);
			waitfor(DelaySec(1));
		}
	}

	WrPortI(I0CR, &I0CRShadow, 0x00);				// disable external interrupt 0
	WrPortI(I1CR, &I1CRShadow, 0x00);				// disable external interrupt 1

	// final counts
	printf("counts = %3d  %3d\n", count0, count1);
}
void LcdPutChar(char displayChar) {
  char * lcdChar;
  lcdChar = AsciiCharLookup(displayChar);
  if(lcdChar==NULL) return;

  BitWrPortI(PBDR, &PBDRShadow, 1, RSADDR);  // Set LCD data mode
  BitWrPortI(PBDR, &PBDRShadow, 0, RWADDR);  // Set LCD write mode
  WrPortI(PADR, &PADRShadow, *lcdChar);      // Set the display data on port A

  MsDelay(1);
  BitWrPortI(PBDR, &PBDRShadow, 1, ENADDR);  // Start sending data
  MsDelay(1);                                // Wait 1 ms for LCD to read
  BitWrPortI(PBDR, &PBDRShadow, 0, ENADDR);  // Finish transmission
  MsDelay(1);
}
Exemplo n.º 27
0
void main (	void	)
{

	///// initialize keypad
	WrPortI ( PDFR,NULL,0x00 );			//	parallel Port D All I/O
	WrPortI ( PDDCR,NULL,0xC0 );			//	PD7..PD6 Open Collector
	WrPortI ( PDDDR,NULL,0xC0 );			//	PD7..PD6 Output

	///// initialize lcd
	WrPortI ( PADR,&PADRShadow,0x00 );	//	Assure Outputs are Low
	WrPortI ( SPCR,&SPCRShadow,0x84 );	//	parallel Port A = Outputs

	WrPortI ( PADR,&PADRShadow,PADRShadow&0x01 ); // Set Contrast at GND
	delay ( 1500 );						//	Wait 15 mSec (LCD to Stabilize)
	lcdCmd4 ( 0x30 );						//	Set to 8-Bit Interface
	delay ( 410 );							//	Wait 4.1 mSec
	lcdCmd4 ( 0x30 );						//	Set 8-Bit Interface
	delay ( 10 );							//	Wait 100 uSec
	lcdCmd4 ( 0x30 );						//	Set 8-Bit Interface
	lcdCmd4 ( 0x20 );						//	Set 8-Bit Interface
	lcdCmd ( 0x28 );						//	Set Dual Line Display
	lcdCmd ( 0x06 );						//	Disable Display Shift
	lcdCmd ( 0x0C );						//	Display On, Cursor Off
	lcdCmd ( 0x01 );						//	Clear Screen, Home Cursor, Backlight On
	delay ( 164 );							//	Wait 1.64 mSec

	for (;;) {
		WrPortI ( PDDR,NULL,0x40 );	//	Scan Row 0
		lcdGoto ( 0,0 );					//	Cursor on column 0, row 0
		keyCol ();							// Scan for keypress

		WrPortI ( PDDR,NULL,0x80 );	//	Scan Row 1
		lcdGoto ( 0,1 );					//	Cursor on column 0, row 1
		keyCol ();							// Scan for keypress
		}
}
Exemplo n.º 28
0
// Helper functions
void InitTimerInt()
{
    auto UBYTE i;
    count_TMRA5 = 0;
    count_TMRA6 = 0;
    count_TMRA7 = 0;
    for (i = 0; i < N_TASKS; i++)
        display_count[i] = 0;
    // Setup internal interrupt and set up timer A 
    SetVectIntern(0x0A, Tmr_A_isr);      // Set up timer A interrupt vector
    WrPortI(TAT7R, &TAT7RShadow, 0x3F);  // Set TMRA7 to count down from 63
    WrPortI(TAT6R, &TAT6RShadow, 0x7F);  // Set TMRA6 to count down from 127
    WrPortI(TAT5R, &TAT5RShadow, 0xFF);  // Set TMRA5 to count down from 255
    WrPortI(TAT1R, &TAT1RShadow, 0xFF);  // Set TMRA1 to count down from 255
    WrPortI(TACR,  &TACRShadow,  0xE1);  // Clock TMRA5-7 by TMRA1 and set interrupt priority to 1
    WrPortI(TACSR, &TACSRShadow, 0xE1);  // Enable TMRA5-7 and main clock for Timer A
}
void main() {
  void brdInit();                            // Enable development board
  SetPortAOut();                             // Set port A as output port
  WrPortI(PBDDR, &PBDDRShadow, 0xFF);        // Set port B as output port

  Lcd_Config();
  pause(5);

  LcdWriteStr(1,"Rabbit-RCM4010:");
  pause(5);

  LcdWriteStr(2,"[\"Hello World!\"]");
  pause(10);

  Lcd_Clear();
  Lcd_noCursor_On();
  LcdWriteStr(1,"LCD off in 5 sec");
  LcdCommandWr(0xA8);
  MsDelay(300); LcdPutChar('5');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('4');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('3');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('2');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('1');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('.');
  MsDelay(300); LcdPutChar('0');
  MsDelay(300); Lcd_Off();
}
Exemplo n.º 30
0
///// 4-bit lcd command
void lcdCmd4 (char cmd4)
{
	WrPortI ( PADR,&PADRShadow,(cmd4&0xF1)|(PADRShadow&1) );		//	Ready Nibble
	WrPortI ( PADR,&PADRShadow,PADRShadow|0x02 );					//	Write Nibble
	WrPortI ( PADR,&PADRShadow,PADRShadow&0xFD );
}