📄 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 :
//* Exported resources : BootLoad
//*
//* 1.0 18/07/00 PF : Creation
//* 1.1 29/01/02 PFi : Clean up. The include of <stdio.h> has been removed.
//*----------------------------------------------------------------------------
#include "periph\stdc\std_c.h"
#include "parts\m55800\lib_m55800.h"
#include "periph\usart\lib_usart.h"
#include "periph\pio\lib_pio.h"
#include "targets\eb55\eb55.h"
/* Hardware description */
#define NB_USART 2
#define PIO_IRQ0 9
#define SSRAM_ADDR 0x02000000
#define BUFFER_SIZE 0x0FFFF
#define SW134_MASK (0x1A<<16)
/* ------------------------ */
/* USART BAUD RATE */
/* ------------------------ */
#define BD_115200 (32000000 / (16 * 115200)) /* CD = 0x11 */
//*----------------------------------------------------------------------------------
//* 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
//*----------------------------------------------------------------------------------
u_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 , BD_115200 , 0x0 ) ;
at91_usart_receive_frame ( &USART0_DESC, (char *)SSRAM_ADDR, BUFFER_SIZE , 0 ) ;
//* Open USART 1 and initialize PDC Reception
at91_usart_open ( &USART1_DESC , US_ASYNC_MODE , BD_115200 , 0x0 ) ;
at91_usart_receive_frame ( &USART1_DESC, (char *)SSRAM_ADDR, BUFFER_SIZE , 0 ) ;
//* Wait for any button pushed
end = FALSE ;
while ( !end )
{
//* If Any button pressed, Exit from SRAM Loader
if (((at91_pio_read(&PIOB_DESC)& SW134_MASK) !=SW134_MASK) || ((at91_pio_read(&PIOA_DESC)& SW2_MASK)!=SW2_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 ( SSRAM_ADDR ) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -