Example #1
0
//
// Intialize the data ports
//
void VTinitialize_ports() {
   // In the LCD GPIO, the 2nd port contains the outputs 
   // MSB to LSB {LCD_E, LCD_RS, LCD_RW, 0}
   XGpio_mSetDataDirection(XPAR_LCD_BASEADDR, 2, 0x0);
   // The first contains the bidirectional 4-bit data bus
   XGpio_mSetDataDirection(XPAR_LCD_BASEADDR, 1, 0xffffffff);
}
/*
 * Setup the IO for the LED outputs.
 */
void vParTestInitialise( void )
{
	/* Set both sets of LED's on the demo board to outputs. */
	XGpio_mSetDataDirection( XPAR_LEDS_8BIT_BASEADDR, partstCHANNEL_1, partstALL_AS_OUTPUT );
	XGpio_mSetDataDirection( XPAR_LEDS_POSITIONS_BASEADDR, partstCHANNEL_1, partstALL_AS_OUTPUT );

	/* Start with all outputs off. */
	uxCurrentOutput8Bit = 0;
	XGpio_mSetDataReg( XPAR_LEDS_8BIT_BASEADDR, partstCHANNEL_1, 0x00 );
	uxCurrentOutput5Bit = 0;
	XGpio_mSetDataReg( XPAR_LEDS_POSITIONS_BASEADDR, partstCHANNEL_1, 0x00 );
}
Example #3
0
//
// Write to LCD display
//   c: 8-bit character to write
// mode: 'odd'=data, 'even'=instruction.  If mode > 4, 4-bit write only.
//
void VTlcd_write( char c, char mode ) 
{
   pthread_mutex_lock( &vt_lcd_mutex );
   char chigh = c >> 4; 

   // Set LCD data bus to output
   XGpio_mSetDataDirection(XPAR_LCD_BASEADDR, 2, 0);

   XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, 0);
   // Transfer high nibble before low nibble
   XGpio_mWriteReg(XPAR_LCD_BASEADDR, 8, chigh);
   // Strobe E
   XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, 8|mode);
   XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, mode);
   sleep( 1 );
   if (mode < 16) {
      XGpio_mWriteReg(XPAR_LCD_BASEADDR, 8, c);
      // Strobe E
      XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, 8|mode); 
      XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, mode);
      sleep( 1 );
   }
   pthread_mutex_unlock( &vt_lcd_mutex );
}