📄 lcd_x_nios.c
字号:
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* 礐/GUI is protected by international copyright laws. Knowledge of the
* source code may not be used to write a similar product. This file may
* only be used in accordance with a license and should not be redistributed
* in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File : LCD_X_Nios.c
Purpose : Port routines
Author : Modified By Jim Yang (based on demo version)
----------------------------------------------------------------------
*/
#include "system.h"
#include "altera_avalon_pio_regs.h"
#include <stdio.h>
#include <unistd.h>
void LCD_X_Init(void);
unsigned char LCD_X_Read00(void);
unsigned char LCD_X_Read01(void);
void LCD_X_Write00(unsigned char c);
void LCD_X_Write01(unsigned char c);
/*********************************************************************
*
* Initialisation
*
**********************************************************************
This routine should be called from your application program
to set port pins to their initial values
*/
void LCD_X_Init(void) {
int i;
//system reset
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_RST_BASE, 0); //set RST=0
i = 0;
while (i<10000) i++;
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_RST_BASE, 1); //set RST=0
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_CS_BASE, 0); //set CS=0
}
/*********************************************************************
*
* Access routines, controller 0
*
**********************************************************************
Usually, there is no need to modify these routines.
It should be sufficient ot modify the low-level macros
above.
*/
/* Read from controller 0, with A0 = 0, CS0 = 0 */
unsigned char LCD_X_Read00(void) {
unsigned char c;
// IOWR_ALTERA_AVALON_PIO_DATA(SED1335_CS_BASE, 0); //set CS=0
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_A_BASE, 0); //set A=0
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_RD_BASE, 0); //set RD=0
IOWR_ALTERA_AVALON_PIO_DIRECTION(SED1335_DATA_BASE, 0); //set dir as input
c = IORD_ALTERA_AVALON_PIO_DATA(SED1335_DATA_BASE); //read data
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_RD_BASE, 1); //set RD=1
// IOWR_ALTERA_AVALON_PIO_DATA(SED1335_CS_BASE, 1); //set CS=1
return c;
}
/* Read from controller 0, with A0 = 1, CS0 = 0 */
unsigned char LCD_X_Read01(void) {
char c;
// IOWR_ALTERA_AVALON_PIO_DATA(SED1335_CS_BASE, 0); //set CS=0
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_A_BASE, 1); //set A=1
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_RD_BASE, 0); //set RD=0
IOWR_ALTERA_AVALON_PIO_DIRECTION(SED1335_DATA_BASE, 0); //set dir as input
c = IORD_ALTERA_AVALON_PIO_DATA(SED1335_DATA_BASE); //read data
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_RD_BASE, 1); //set RD=1
// IOWR_ALTERA_AVALON_PIO_DATA(SED1335_CS_BASE, 1); //set CS=1
return c;
}
/* Write to controller 0, with A0 = 0, CS0 = 0 */
void LCD_X_Write00(unsigned char c) {
// IOWR_ALTERA_AVALON_PIO_DATA(SED1335_CS_BASE, 0); //set CS=0
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_A_BASE, 0); //set A=0
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_WR_BASE, 0); //set WR=0
IOWR_ALTERA_AVALON_PIO_DIRECTION(SED1335_DATA_BASE, 0xff); //set dir as output
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_DATA_BASE, c); //write data
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_WR_BASE, 1); //set WR=1
// IOWR_ALTERA_AVALON_PIO_DATA(SED1335_CS_BASE, 1); //set CS=1
}
/* Write to controller 0, with A0 = 1, CS0 = 0 */
void LCD_X_Write01(unsigned char c) {
// IOWR_ALTERA_AVALON_PIO_DATA(SED1335_CS_BASE, 0); //set CS=0
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_A_BASE, 1); //set A=1
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_WR_BASE, 0); //set WR=0
IOWR_ALTERA_AVALON_PIO_DIRECTION(SED1335_DATA_BASE, 0xff); //set dir as output
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_DATA_BASE, c); //write data
IOWR_ALTERA_AVALON_PIO_DATA(SED1335_WR_BASE, 1); //set WR=1
// IOWR_ALTERA_AVALON_PIO_DATA(SED1335_CS_BASE, 1); //set CS=1
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -