📄 bo_load.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 : bo_load.c
//* Object : Load program in RAM
//*
//* Imported resources : at91_usart_open, at91_usart_close, receive_frame
//* Exported resources : BootLoad
//*
//* 1.0 06/04/00 JPP : Creation
//* 1.1 17/08/00 PF : Clean up
//*----------------------------------------------------------------------------
#include "periph\stdc\std_c.h"
#include "parts\m63200\lib_m63200.h"
#include "periph\pio\lib_pio.h"
#include "periph\usart\lib_usart.h"
#include "targets\eb63\eb63.h"
#define SRAM_ADDR 0x02000000
#define BUFFER_SIZE 0x0FFFF
#define SW123_MASK 0x38
/* ------------------------ */
/* USART BAUD RATE */
/* ------------------------ */
#define BAUD_RATE (25000000 / (16 * 115200)) //* CD = 14
extern u_int mcki_detect ( void ) ;
//*----------------------------------------------------------------------------------
//* Function Name : BootLoad
//* Object : Main function of the bootloader
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : at91_usart_open, at91_usart_receive_frame
//* : at91_usart_get_status, at91_usart_close
//*----------------------------------------------------------------------------------
int BootLoad ( void )
//* Begin
{
u_int end ;
StructUSART *usart0_pt = USART0_BASE ;
StructUSART *usart1_pt = USART1_BASE ;
//* Open USART 0 and initialize PDC Reception
at91_usart_open ( &USART0_DESC , US_ASYNC_MODE , BAUD_RATE , 0x0 ) ;
at91_usart_receive_frame ( &USART0_DESC, (char *)SRAM_ADDR, BUFFER_SIZE , 1000 ) ;
//* Open USART 1 and initialize PDC Reception
at91_usart_open ( &USART1_DESC , US_ASYNC_MODE , BAUD_RATE , 0x0 ) ;
at91_usart_receive_frame ( &USART1_DESC, (char *)SRAM_ADDR, BUFFER_SIZE , 1000 ) ;
end = FALSE ;
while ( !end )
{
//* If Any button pressed, Exit from SRAM Loader
if (((at91_pio_read(&PIOB_DESC) & SW123_MASK) !=SW123_MASK) || ((at91_pio_read(&PIOA_DESC)& SW4_MASK) !=SW4_MASK))
end = TRUE ;
//* Test the End of receive for USART0
if (( at91_usart_get_status ( &USART0_DESC ) & US_ENDRX ) != 0 )
{
usart0_pt->US_RCR = BUFFER_SIZE ;
}
//* Test the End of receive for USART1
if (( at91_usart_get_status ( &USART1_DESC ) & US_ENDRX ) != 0 )
{
usart1_pt->US_RCR = BUFFER_SIZE ;
}
}
//* Close USART 0 and USART 1
at91_usart_close ( &USART0_DESC ) ;
at91_usart_close ( &USART1_DESC ) ;
at91_pio_write (&PIOB_DESC, LED2, LED_OFF) ;
return ( SRAM_ADDR ) ;
//* End
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -