📄 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 : init_usart, disable_usart, receive_frame
//* Exported resources : BootLoad
//*
//* 1.0 06/04/00 JPP : Creation
//* 2.01 29/05/00 PF : Clean up
//*----------------------------------------------------------------------------
#include "periph\stdc\std_c.h"
#include "periph\pio\pio.h"
#include "periph\usart\usart.h"
#include "parts\r40807\r40807.h"
#include "at91eb40.h" /* AT91EB40 description */
/* Hardware description */
#define NB_USART 2
#define PIO_IRQ0 9
#define SSRAM_ADDR 0x02000000
#define BUFFER_SIZE 0x0FFFF
extern u_int init_usart ( u_int usart_id, u_int mode, u_int speed, u_int timeguard ) ;
extern u_int disable_usart ( u_int usart_id ) ;
extern u_int receive_frame ( u_int usart_id, char *pt_buffer, u_int max_size, u_int timeout ) ;
//*----------------------------------------------------------------------------------
//* Function Name : BootLoad
//* Object : Main function of the bootloader
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : init_usart, disable_usart, receive_frame
//*----------------------------------------------------------------------------------
int BootLoad ( void )
//* Begin
{
u_int end ;
u_int usart_id ;
StructUSART *usart0_pt = USART0_BASE ;
StructUSART *usart1_pt = USART1_BASE ;
//* For each USART
for (usart_id = 0 ; usart_id < NB_USART ; usart_id ++)
{
//* Initialize USART
init_usart (usart_id, US_ASYNC_MODE, (usart_id == 0 ? 18 : 53), 0) ;
//* Initialize PDC Reception
receive_frame (usart_id, (char *)SSRAM_ADDR, BUFFER_SIZE, 1000 ) ;
}
//* Wait for IRQ0 pin asserted
end = FALSE ;
while (!end )
{
if ((PIO_BASE->PIO_PDSR & SW5)!= 0) end = TRUE ;
//* Test the End of receive for USART0
if (( usart0_pt->US_CSR & US_ENDRX ) != 0 )
{
usart0_pt->US_RCR = BUFFER_SIZE ;
}
//* Test the End of receive for USART1
if (( usart1_pt->US_CSR & US_ENDRX ) != 0 )
{
usart1_pt->US_RCR = BUFFER_SIZE ;
}
}
//* For each USART
for (usart_id = 0 ; usart_id < NB_USART ; usart_id ++)
{
//* Disable USART
disable_usart (usart_id);
//* EndFor
}
return(SSRAM_ADDR);
//* End
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -