📄 eb40x_lcd.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 : led_swing.c
//* Object : Led Swing for the AT91EB40A
//*
//* 1.0 06/08/01 PF : Creation
//*----------------------------------------------------------------------------
#ifndef AT91_DEBUG_NONE
#include <stdio.h>
#endif
#include "parts/r40008/reg_r40008.h"
#include "parts/r40008/lib_r40008.h"
#include "EB40008.h"
#include "drivers/capture/capture.h"
#include "drivers/wait/wait.h"
#include "../inc/LCD.h"
extern void wake_up_handler (void) ;
void LCD_test(char *buf,int len);
/* Global Variable */
WaitDesc wait_desc = { &TC0_DESC, 0, 0, WAIT_DELAY, wake_up_handler } ;
u_int LedSpeed = 50000 ;
u_int loop_count = 0 ;
const int led_mask[8]= {LED1, LED2, LED3, LED4, LED5, LED6, LED7, LED8};
//*----------------------------------------------------------------------------
//* Function Name : change_speed
//* Object : Adjust led speed depending on SW1 and SW3
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : none
//*----------------------------------------------------------------------------
void change_speed ( void )
//* Begin
{
u_int status = at91_pio_read (&PIO_DESC) ;
if (( status & SW1 ) == 0 )
{
if ( LedSpeed > 100000 ) LedSpeed -=1000 ;
}
if (( status & SW3 ) == 0 )
{
if ( LedSpeed < 20000000 ) LedSpeed +=1000 ;
}
}
//* End
//*----------------------------------------------------------------------------
//* Function Name : main
//* Object : Main function of the led blink
//* Input Parameters : none
//* Output Parameters : True
//* Functions called :
//*----------------------------------------------------------------------------
int main( void )
//* Begin
{
int i = 0 ;
while(1) test_LCD(); // for customer's LCD panel test.
char *buf;buf=(char *)0x02000;
LCD_test(buf,100);
//* -- Set up PIO
at91_pio_open ( &PIO_DESC, LED_MASK, PIO_OUTPUT ) ;
at91_pio_write (&PIO_DESC, LED_MASK, LED_OFF ) ;
//* Detect Master Clock
wait_desc.mcki_khz = 66000 ;
//* Loop forever
for (;;)
{
//* Once a Shot on each led
for ( i=0 ; i < 8 ; i++ )
{
change_speed () ;
at91_pio_write (&PIO_DESC, led_mask[i], LED_ON ) ;
wait_desc.period = LedSpeed ;
at91_wait_open ( &wait_desc ) ;
at91_pio_write (&PIO_DESC, led_mask[i], LED_OFF ) ;
}
//* Once a Shot on each led
for ( i=7 ; i >= 0 ; i-- )
{
change_speed () ;
at91_pio_write (&PIO_DESC, led_mask[i], LED_ON ) ;
at91_wait_open ( &wait_desc ) ;
at91_pio_write (&PIO_DESC, led_mask[i], LED_OFF ) ;
}
#ifdef SEMIHOSTING
printf ( "Loop %d\n", loop_count ) ;
#endif
loop_count ++ ;
}
return(TRUE);
//* End
}
void LCD_test(char *buf,int len)
{
int addr = 0xffe00000;
int port = 0x40000000;
int tmp,lenght = len;
/* EBI_BA = 0x40000000
0x40000000 write command, 0x400000002 write data,
0x40000004 read command, 0x40000006 read data
*/
(*( int *)(addr+0x24)) = 0x00000006; // use EBI_CSR4, compatible the board, ALE in EBI_MCR
(*( int *)(addr+0x10)) = 0x4000251a; // R/W enable, 8-bits,
// EBI_CSEN|EBI_BAT_BYTE_WRITE|EBI_TDF_4|EBI_PAGES_1M|EBI_NWS_5|EBI_WSE)|EBI_DBW_8
while(lenght-=1)
{
(*( char *)addr) =0x55; // write command
addr = port+(1<<2); // R/W control(A2)
tmp = (*( char *)addr); // read command
addr = port+(1<<1); // RS register(A1), write data
(*( char *)port) =*(buf+lenght); // LCD data(D7-D0)
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -