URL
https://opencores.org/ocsvn/phr/phr/trunk
Subversion Repositories phr
Compare Revisions
- This comparison shows the changes necessary to convert path
/phr/trunk/codigo/demos
- from Rev 262 to Rev 263
- ↔ Reverse comparison
Rev 262 → Rev 263
/projects/ublaze/TestApp/src/TestApp.c
0,0 → 1,180
/*----------------------------------------------------------------------------- |
// |
// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" |
// SOLELY FOR USE IN DEVELOPING PROGRAMS AND SOLUTIONS FOR |
// XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION |
// AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION |
// OR STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS |
// IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT, |
// AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE |
// FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY |
// WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE |
// IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR |
// REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF |
// INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
// FOR A PARTICULAR PURPOSE. |
// |
// (c) Copyright 2003 Xilinx, Inc. |
// All rights reserved. |
// |
//---------------------------------------------------------------------------*/ |
|
#include "xparameters.h" |
#include <mb_interface.h> |
#include "xutil.h" |
#include "xgpio_l.h" |
#define DLYVAL 28025 |
|
/* |
* Routine to used as a "wait states" |
*/ |
void wait(int x) { |
int y; |
|
for (y = 0; y < x; y++); |
|
} |
|
/* |
* Routine to write a pattern out to a GPIO |
* which is configured as an output |
* PARAMETER C_ALL_INPUTS = 0 |
*/ |
void WriteToGPOutput(Xuint32 BaseAddress, int gpio_width) { |
int i=0, j=0, k=0; |
int numTimes = 1; |
|
XGpio_mSetDataDirection(BaseAddress, 0x00000000); /* Set as outputs */ |
while (numTimes > 0) { |
j = 1; |
for(i=0; i<(gpio_width-1); i++) { |
XGpio_mSetDataReg(BaseAddress, j); |
j = j << 1; |
for (k=0; k<1000000; k++) { |
; //wait |
} |
} |
j = 1; |
j = ~j; |
for(i=0; i<(gpio_width-1); i++) { |
XGpio_mSetDataReg(BaseAddress, j); |
j = j << 1; |
for (k=0; k<1000000; k++) { |
; //wait |
} |
} |
numTimes--; |
} |
} |
|
|
/* |
* Routine to read data from a GPIO |
* which is configured as an input |
* PARAMETER C_ALL_INPUTS = 1 |
*/ |
Xuint32 ReadFromGPInput(Xuint32 BaseAddress) { |
Xuint32 data = XGpio_mGetDataReg(BaseAddress); |
return data; |
} |
|
//==================================================== |
|
int main (void) { |
unsigned int input, data; |
int qwe; |
|
print("-- Entering main() --\n\r"); |
|
|
//vga_test(); |
scr_init(); |
|
//draws a grid coordinate for the character map on the VGA port for a 800x600 screen |
for(qwe=0;qwe<100;qwe++) |
{ |
scr_write_char(qwe,2,'0'+(qwe%10),'b'); |
if(qwe%10==0) |
scr_write_char(qwe,1,'0'+(qwe/10),'b'); |
if(qwe<73) |
scr_write_char(2,qwe,'0'+(qwe%10),'a'); |
if(qwe%10==0) |
scr_write_char(1,qwe,'0'+(qwe/10),'a'); |
} |
|
// Writes "Spartan-3 Starter Kit Board!" to the VGA screen starting at |
// row 10 column 10 and goes increase colum numbers as it changes colors |
// to show all 8 colors |
for(qwe=0;qwe<8;qwe++) |
{ |
scr_write_chars(10, (10+qwe), ('a'+qwe), "Spartan-3 Starter Kit Board!", 28); |
} |
|
//draws a horizontal line start at grid coordiate(x,y) 5,5 and spans for 15 characters |
scr_draw_horiz_line (5, 5, 'd', 15); |
|
//draws a vertical line start at grid coordiate(x,y) 8,8 and spans for 17 characters |
scr_draw_vert_line (8, 8, 'e', 17); |
|
// shows how to use the character fill driver displaying SPARTAN-3 15 times |
// vertically with every letter in a different color starting at coordinate (20,20) |
// color |
// NOte the color 'h' is black and cannot be seen with a black background. |
{ |
scr_fill_char (20, 20, 'S', 'a', 15); |
scr_fill_char (21, 21, 'P', 'b', 15); |
scr_fill_char (22, 22, 'A', 'c', 15); |
scr_fill_char (23, 23, 'R', 'd', 15); |
scr_fill_char (24, 24, 'T', 'e', 15); |
scr_fill_char (25, 25, 'A', 'f', 15); |
scr_fill_char (26, 26, 'N', 'g', 15); |
scr_fill_char (27, 27, '-', 'h', 15); |
scr_fill_char (28, 28, '3', 'i', 15); |
|
} |
|
// Writes "Spartan-3 Starter Kit Board!" to the VGA screen starting at |
// row 60 column 60 and goes increase colum numbers as it changes colors |
// to show all 8 colors |
|
for(qwe=0;qwe<8;qwe++) |
{ |
scr_write_chars(60, (60+qwe), ('a'+qwe), "Spartan-3 Starter Kit Board!", 28); |
} |
|
//reads button values and outputs the value to the UART |
{ |
Xuint32 dataA = ReadFromGPInput(XPAR_PUSH_BUTTONS_3BIT_BASEADDR); |
xil_printf("Data read from Push_Buttons_3Bit: 0x%x\n\r\n\r", dataA); |
} |
|
//reads the switch value and outputs values to the screen |
{ |
Xuint32 dataB = ReadFromGPInput(XPAR_DIP_SWITCHES_8BIT_BASEADDR); |
xil_printf("Data read from DIP_Switches_8Bit: 0x%x\n\r\n\r", dataB); |
} |
|
//testing RS232 input |
// reads a number from the RS232 (UART) port and diplays it to the 7-segment display |
print("-- Please enter any number to test the input of the RS232 --\n\r"); |
input = XUartLite_RecvByte(XPAR_RS232_BASEADDR); |
|
//displays number read from RS232 port to the 7-segment display. |
//note that 48 is subtracted to conver the numebr from its ascii equivalent to |
//a decimal number |
dispLED(input-48, 0); |
|
print("The number entered in the RS232 port should be displayed on the 7-segment display.\n\r\n\r"); |
|
// testing PS/2 port |
{ |
print("-- Please enter any number or character on the PS/2 keyboard --\n\r"); |
data = inbyte(); |
dispLED(data, 0); |
xil_printf("pressed %c on ythe PS/2 Keyboard\n\r",data); |
} |
|
print("-- Exiting main() --\n\r"); |
return 0; |
} |
|
projects/ublaze/TestApp/src/TestApp.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: projects/ublaze/TestApp/src/vga.h
===================================================================
--- projects/ublaze/TestApp/src/vga.h (nonexistent)
+++ projects/ublaze/TestApp/src/vga.h (revision 263)
@@ -0,0 +1,50 @@
+/*-----------------------------------------------------------------------------
+//
+// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
+// SOLELY FOR USE IN DEVELOPING PROGRAMS AND SOLUTIONS FOR
+// XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION
+// AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION
+// OR STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS
+// IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
+// AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
+// FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
+// WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
+// IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
+// REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
+// INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE.
+//
+// (c) Copyright 2003 Xilinx, Inc.
+// All rights reserved.
+//
+//---------------------------------------------------------------------------*/
+#ifndef _SCR_H
+#define _SCR_H
+
+#define CLR_R 1
+#define CLR_G 2
+#define CLR_B 4
+
+#define SCR_X_PIXELS 800
+#define SCR_Y_PIXELS 600
+#define SCR_X 100
+#define SCR_Y 75
+
+#define BLANK_CHAR 0
+#define HORIZ_LINE_CHAR 128
+#define VERT_LINE_CHAR 129
+#define HORIZ_BARRED_LINE_CHAR 130
+#define SOLID_SQUARE_CHAR 131
+
+void scr_init ();
+void scr_clr ();
+void scr_clr_region (int sx, int sy, int ex, int ey);
+void scr_write_char (int x, int y, char c, char color);
+void scr_write_chars(int x, int y, char color, char *buf, int count);
+void scr_read_char (int x, int y, char *c, char *color);
+void scr_fill_char (int x, int y, char c, char color, int count);
+void scr_redefine_char (unsigned char c, unsigned int *defptr);
+void scr_draw_horiz_line (int x, int y, char color, int linelen);
+void scr_draw_vert_line (int x, int y, char color, int linelen);
+
+#endif /* _SCR_H */
projects/ublaze/TestApp/src/vga.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Index: projects/ublaze/TestApp/src/vga.c
===================================================================
--- projects/ublaze/TestApp/src/vga.c (nonexistent)
+++ projects/ublaze/TestApp/src/vga.c (revision 263)
@@ -0,0 +1,248 @@
+/*-----------------------------------------------------------------------------
+//
+// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
+// SOLELY FOR USE IN DEVELOPING PROGRAMS AND SOLUTIONS FOR
+// XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION
+// AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION
+// OR STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS
+// IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
+// AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
+// FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
+// WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
+// IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
+// REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
+// INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE.
+//
+// (c) Copyright 2003 Xilinx, Inc.
+// All rights reserved.
+//
+//---------------------------------------------------------------------------*/
+#include "defs.h"
+#include "xio.h"
+#include "xparameters.h"
+#include "vga.h"
+
+/*
+ * Screen driver for the character-mode display controller - opb_color_video_ctrl
+ * Please modify vga.h if you would like to change paramters of the video controller
+ */
+
+/*
+Character color mapping used by this driver
+-------------------------------------------
+'a' red
+'b' green
+'c' yellow
+'d' blue
+'e' magenta
+'f' cyan
+'g' white
+'h' black
+*/
+
+#define SCR_BUF_BASEADDR (XPAR_OPB_COLOR_VIDEO_CTRL_0_BASEADDR)
+#define SCR_CTRL_REG_BASEADDR (XPAR_OPB_COLOR_VIDEO_CTRL_0_BASEADDR + 0xA000)
+#define SCR_CHAR_MAP_BASEADDR (XPAR_OPB_COLOR_VIDEO_CTRL_0_BASEADDR + 0xC000)
+#define xy2scroffset(x, y) (((y * SCR_X) + x) << 2)
+#define out32 XIo_Out32
+#define pack_scr_char(c, clr) ((((unsigned int)clr) << 8) | (c & 0xff))
+
+static unsigned int null_char[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static unsigned int solid_square_char[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+static unsigned int horiz_line[8] = { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static unsigned int horiz_barred_line[8] = { 0xff, 0xff, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00 };
+static unsigned int vert_line[8] = { 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 };
+
+
+/*****************************************************************************
+* Function name : scr_init(void)
+* returns : Void
+* Created by : SUS
+* Date Created : 06/21/2004
+* Description : Initialize a VGA controller
+* Input/Output : None
+* :
+*****************************************************************************/
+void scr_init ()
+{
+ out32 (SCR_CTRL_REG_BASEADDR, 0x2); // Enable the character mode in the control register of the videocontroller
+ scr_redefine_char (BLANK_CHAR, null_char);
+ scr_redefine_char (HORIZ_LINE_CHAR, horiz_line);
+ scr_redefine_char (VERT_LINE_CHAR, vert_line);
+ scr_redefine_char (HORIZ_BARRED_LINE_CHAR, horiz_barred_line);
+ scr_redefine_char (SOLID_SQUARE_CHAR, solid_square_char);
+}
+
+/*****************************************************************************
+* Function name : scr_clr(void)
+* returns : Void
+* Created by : SUS
+* Date Created : 06/21/2004
+* Description : Clears the VGA screen
+* Input/Output : None
+* :
+*****************************************************************************/
+void scr_clr ()
+{
+ unsigned int *scr_buf_start = (unsigned int*)(SCR_BUF_BASEADDR);
+ unsigned int *scr_buf_end = (unsigned int*)(SCR_BUF_BASEADDR + xy2scroffset (SCR_X, SCR_Y));
+ unsigned int *bufp;
+
+ bufp = scr_buf_start;
+ while (bufp <= scr_buf_end)
+ *bufp++ = 0x0;
+
+}
+
+/*****************************************************************************
+* Function name : scr_clr_region(int sx, int sy, int ex, int ey)
+* returns : Void
+* Created by : SUS
+* Date Created : 06/21/2004
+* Description : Clears the VGA screen for a set region (rows) set by
+* the X,Y parameters.
+* Input/Output : int sx => starting X coordinate
+* : int sy => starting Y coordinate
+* : int ex => ending X coordinate
+* : int ey => ending Y coordinate
+* :
+*****************************************************************************/
+void scr_clr_region (int sx, int sy, int ex, int ey)
+{
+ unsigned int *scr_buf_start = (unsigned int*)(SCR_BUF_BASEADDR + xy2scroffset (sx, sy));
+ unsigned int *scr_buf_end = (unsigned int*)(SCR_BUF_BASEADDR + xy2scroffset (ex, ey));
+ unsigned int *bufp;
+
+ bufp = scr_buf_start;
+ while (bufp <= scr_buf_end)
+ *bufp++ = 0x0;
+
+}
+
+/*****************************************************************************
+* Function name : scr_draw_horiz_line(int x, int y, char color, int linelen)
+* returns : Void
+* Created by : SUS
+* Date Created : 06/21/2004
+* Description : Draws a horizontal line starting at the (x,y) coordinate
+* in the color with a length of linelen
+* Input/Output : x => starting X coordinate (0 to SCR_X)
+* : y => starting Y coordinate (0 to SCR_Y)
+* : color => 'a' to g' (see top for color mapping to character)
+* : linelen => length of horzontal line
+* :
+*****************************************************************************/
+void scr_draw_horiz_line (int x, int y, char color, int linelen)
+{
+ int i;
+ unsigned int *basep = (unsigned int*)(SCR_BUF_BASEADDR + xy2scroffset (x,y));
+
+ for (i=0; i starting X coordinate (0 to SCR_X)
+* : y => starting Y coordinate (0 to SCR_Y)
+* : color => 'a' to g' (see top for color mapping to character)
+* : linelen => length of vertical line
+* :
+*****************************************************************************/
+void scr_draw_vert_line (int x, int y, char color, int linelen)
+{
+ int i;
+ unsigned int *scrp = (unsigned int*)(SCR_BUF_BASEADDR + xy2scroffset (x,y));
+
+ for (i=0; i starting X coordinate (0 to SCR_X)
+* : y => starting Y coordinate (0 to SCR_Y)
+* : c => ASCII character displayed 'a'..'Z', '0'..'9'
+* : color => 'a' to g' (see top for color mapping to character)
+* : count => number of times character c is repeated
+* :
+*****************************************************************************/
+void scr_fill_char (int x, int y, char c, char color, int count)
+{
+ int i;
+ unsigned int *basep = (unsigned int*)(SCR_BUF_BASEADDR + xy2scroffset (x,y));
+
+ for (i=0; i starting X coordinate (0 to SCR_X)
+* : y => starting Y coordinate (0 to SCR_Y)
+* : c => string of ASCII character displayed 'a'..'Z', '0'..'9'
+* : color => 'a' to g' (see top for color mapping to character)
+* : count => # characters in the string
+* :
+*****************************************************************************/
+void scr_write_chars (int x, int y, char color, char *buf, int count)
+{
+ int i;
+ unsigned int *basep = (unsigned int*)(SCR_BUF_BASEADDR + xy2scroffset (x,y));
+
+ for (i=0; i starting X coordinate (0 to SCR_X)
+* : y => starting Y coordinate (0 to SCR_Y)
+* : c => ASCII character displayed 'a'..'Z', '0'..'9'
+* : color => 'a' to g' (see top for color mapping to character)
+* :
+*****************************************************************************/
+
+void scr_write_char (int x, int y, char c, char color)
+{
+ XIo_Out32((SCR_BUF_BASEADDR + xy2scroffset (x,y)), pack_scr_char (c, color));
+}
+
+
+void scr_redefine_char (unsigned char c, unsigned int *defptr)
+{
+ unsigned int *charp = (unsigned int*)(SCR_CHAR_MAP_BASEADDR + (unsigned int)(((unsigned int)c)<<5));
+
+ *charp++ = *defptr++;
+ *charp++ = *defptr++;
+ *charp++ = *defptr++;
+ *charp++ = *defptr++;
+ *charp++ = *defptr++;
+ *charp++ = *defptr++;
+ *charp++ = *defptr++;
+ *charp++ = *defptr++;
+}
\ No newline at end of file
projects/ublaze/TestApp/src/vga.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property