⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib_lcd.c

📁 AT91RM3400芯片 ROM引导程序
💻 C
字号:
//*----------------------------------------------------------------------------
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : main.c
//* Object              : main application written in C
//* Creation            : FB   26/11/2002
//*
//*----------------------------------------------------------------------------
#include <stdio.h>

#include "..\drv_lcd\lcd.h"
#include "..\includes\main.h"
#define SP_PCSDEC_PCS0_LCD_COMMAND          0x01    /* Chip Select Register 0 (NPCS0 %1110) with Chip Select 1 (CS)  */ 
#define SP_PCSDEC_PCS0_LCD_DATA     	    0x03    /* Chip Select Register 0 (NPCS0 %1110) with Chip Select 3 (CS) */

#define MASTER_CLOCK						48000000

const char LCD_Display[AT91C_NUMBER_OF_PAGES][CHAR_MAX_PER_LINE] = 
{
	" ATMEL Rousset",
	"   AT91 Team",
	"   ARM-based",
	"   Products",
	"Wish you a nice",
	"     day !",
	" push a key to",
	" show an image",
};

//* External Functions
extern void	AT91F_DBGU_Printk(char *);
extern void AT91F_Lcd_put_string(unsigned char,char *);
extern void AT91F_Lcd_init(void);
extern void AT91F_LcdClear(void);
extern void AT91F_LcdDisplayImage(unsigned char *);

//* External Array

//*----------------------------------------------------------------------------
//* \fn    AT91F_Tempo
//* \brief Tempo with a simple loop in order to see display on LCD
//*----------------------------------------------------------------------------
void AT91F_Tempo (unsigned int loop)
{
	int tmp ;
	
	for(tmp=0; tmp<loop; tmp++)
	{};
}	

//*----------------------------------------------------------------------------
//* \fn    AT91F_SPI_CfgSPI
//* \brief Config SPI IP
//*----------------------------------------------------------------------------
void  AT91F_SPI_CfgSPILCD(void)
{
	//* Reset the SPI
	AT91F_SPI_Reset(AT91C_BASE_SPI);

    //* Configure SPI in Master Mode and PCSDEC = 1 (Decodeur activated) with No CS selected !!!  
	AT91F_SPI_CfgMode(AT91C_BASE_SPI, AT91C_SPI_MSTR | AT91C_SPI_MODFDIS | AT91C_SPI_PCSDEC | AT91C_SPI_PCS);

	//* Configure SPI CS0 for LCD Controller
	AT91F_SPI_CfgCs(0, AT91C_SPI_CPOL | (AT91C_SPI_DLYBS & 0x100000) | ((MASTER_CLOCK / (2*AT91C_LCD_CLK)) << 8));

    //* Enable the SPI
    AT91F_SPI_Enable(AT91C_BASE_SPI);
}

//*----------------------------------------------------------------------------
//* \fn    AT91F_CfgSPIForLCD
//* \brief This function initialize SPI for the LCD on CS0 and PCSDEC = 1 
//*----------------------------------------------------------------------------
void AT91F_CfgSPIForLCD()
{
	// ============================= Init SPI Interface =============================
	//AT91F_DBGU_Printk("\n\rInit SPI Interface\n\r");
	
	// Init SPI for DataFlash interface
	AT91F_SPI_CfgPIO();	
	AT91F_SPI_CfgPMC();
	AT91F_SPI_CfgSPILCD();
	AT91F_PDC_Open(AT91C_BASE_PDC_SPI);
}

//*----------------------------------------------------------------------------
//* \fn    open
//* \brief main function
//*----------------------------------------------------------------------------
int AT91F_LCD_open()
{
	//* Init SPI for LCD
	AT91F_CfgSPIForLCD();

	//* Switch on CSR0 and CS1 (Chip Select Decode Enabled) <=> LCD Command
	AT91F_SPI_CfgPCS(AT91C_BASE_SPI,SP_PCSDEC_PCS0_LCD_COMMAND);

	//* Init LCD
	AT91F_Lcd_init();

	AT91F_LcdClear();	

	return 0;

}
//*----------------------------------------------------------------------------
//* \fn    show banner
//* \brief 
//*----------------------------------------------------------------------------
void AT91F_LCD_show_banner(){
int i;
	for(i=0;i<8;i++){
		//* Display First Line
		AT91F_Lcd_put_string(i,(char*) LCD_Display[i]);
		//* Wait 
		AT91F_Tempo(1*SECONDE);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -