⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bo_load.c

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 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 for EB40A
//*
//* Imported resources  :
//* Exported resources  : BootLoad
//*
//* 1.0 06/11/01   PFi  : Creation
//*--------------------------------------------------------------------------------------

#include "periph/stdc/std_c.h"
#include "parts/r40008/lib_r40008.h"
#include "targets/eb40a/eb40a.h"
#include "periph/usart/lib_usart.h"
#include "periph/pio/lib_pio.h"

/* Hardware description */
#define SSRAM_ADDR      0x100
#define BUFFER_SIZE     0x0FFFF

/* ------------------------ */
/* USART BAUD RATE          */
/* ------------------------ */
#define BD_115200       (66000000 / (16 * 115200))      /* CD = 36 */

//*--------------------------------------------------------------------------------------
//* 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 , 1000 ) ;

    //* 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 , 1000 ) ;

    //* Wait for any button pushed
    end = FALSE ;
    while ( !end )
    {
        //* If Any button pressed, Exit from SRAM Loader
        if ( ( (at91_pio_read(&PIO_DESC)& SW_MASK) !=SW_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 (&PIO_DESC, LED2, LED_OFF) ;

    return ( SSRAM_ADDR ) ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -