📄 entry.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 : entry.c
//* Object : Main loop of AT91EB40A test
//*
//* 1.0 06/11/01 PFi : Creation.
//* : Boot Version 1.0
//*-----------------------------------------------------------------------------
#include "parts/r40008/lib_r40008.h"
#include "targets/eb40a/eb40a.h"
#include "drivers/capture/capture.h"
#include "drivers/wait/wait.h"
#include "flash_16x4.h"
#define FLASH_BASE_ADDR (u_short*)0x1000000
#define SRAM_TEST_RESULT_ADDR (u_short*)0x1004000
extern void BootFts ( void ) ;
extern u_int BootLoad ( void ) ;
extern void wake_up_handler ( void ) ;
extern int fmu ( void ) ;
/* Global Variable */
WaitDesc wait_desc = { &TC0_DESC, 0, 0, WAIT_DELAY, wake_up_handler } ;
typedef void (type_pt_angel(u_int clock)) ;
//*-------------------------------------------------------------------------------
//* Function Name : BootEntry
//* Object : Entry point of boot
//* Input Parameters : None
//* Output Parameters : None
//* Functions called : at91_pio_open, at91_pio_write
//*-------------------------------------------------------------------------------
void * main_boot ( void )
//* Begin
{
u_int i ;
u_int led[8] = {LED1, LED2, LED3, LED4, LED5, LED6, LED7, LED8} ;
type_pt_angel *pt_angel ;
pt_angel = (type_pt_angel *)(0x1006000) ;
//* -- Set up PIO
at91_pio_open ( &PIO_DESC, SW2_MASK, PIO_INPUT ) ;
at91_pio_open ( &PIO_DESC, (SW1_MASK|SW3_MASK|SW4_MASK), PIO_INPUT ) ;
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 ;
wait_desc.period = 80000 ;
//* Once a Shot on each led
for ( i=0 ; i <7 ; i++ )
{
at91_pio_write (&PIO_DESC, led[i], LED_ON ) ;
at91_wait_open ( &wait_desc ) ;
at91_pio_write (&PIO_DESC, led[i], LED_OFF ) ;
}
//* Light off all leds
at91_pio_write (&PIO_DESC, LED_MASK, LED_OFF ) ;
//* If SW1 button pressed, Functional Test Software
if (( at91_pio_read( &PIO_DESC ) & SW1_MASK ) == 0 )
{
//* Light on all the leds
at91_pio_write ( &PIO_DESC, LED_MASK, LED_ON ) ;
//* Expect S1 un-pressed
while (( at91_pio_read (&PIO_DESC ) & SW1_MASK) == 0 ) ;
//* Light off all the leds unless led 1
at91_pio_write ( &PIO_DESC, (LED_MASK&~LED1), LED_OFF ) ;
BootFts() ;
} //* EndIf
//* If SW2 button pressed, Load in SRAM
if (( at91_pio_read ( &PIO_DESC ) & SW2_MASK) == 0 )
{
//* Enable USART 1 & PIOB Clock
at91_clock_open (US1_ID | US0_ID) ;
at91_clock_open (PIO_ID) ;
//* Light on all the leds
at91_pio_write ( &PIO_DESC, LED_MASK, LED_ON ) ;
//* Expect S2 un-pressed
while (( at91_pio_read ( &PIO_DESC ) & SW2_MASK) == 0 ) ;
//* Light off all the leds unless led 2
at91_pio_write ( &PIO_DESC, (LED_MASK&~LED2), LED_OFF ) ;
return (void *)BootLoad () ;
//* disable USART 1
at91_clock_close (US1_ID ) ;
at91_pio_write ( &PIO_DESC, LED2, LED_OFF ) ;
}//* EndIf
//* ----------------------------------------------
//* If SW3 button pressed, Load the Flash_uploader
//* ----------------------------------------------
if (( at91_pio_read( &PIO_DESC ) & SW3_MASK ) == 0 )
{
//* Light on all the leds
at91_pio_write ( &PIO_DESC, LED_MASK, LED_ON ) ;
//* Expect S3 un-pressed
while (( at91_pio_read (&PIO_DESC ) & SW3_MASK) == 0 ) ;
//* Light off all the leds unless led 3
at91_pio_write ( &PIO_DESC, (LED_MASK&~LED3), LED_OFF ) ;
fmu();
} //* EndIf
//* -------------------------------------
//* If SW4 button pressed, ShutDown Mode
//* -------------------------------------
//* Reserved for future use
//* Light on the led 1
at91_pio_write (&PIO_DESC, LED1, LED_ON ) ;
//* Enable USART0 Clock
at91_clock_open ( US0_ID ) ;
//* Branch Angel in Flash
pt_angel ( wait_desc.mcki_khz ) ;
//* End
}
/*-------------------------------------------------------------------------------*/
/* Function Name : BootEntry */
/* Object : Entry point of boot */
/* Input Parameters : None */
/* Output Parameters : None */
/* Functions called : at91_pio_open, at91_pio_write */
/*-------------------------------------------------------------------------------*/
int main ( void )
/* Begin */
{
void (*next)(void);
next = (void (*)(void)) main_boot();
(*next)();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -