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

📄 bench.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           : bench.c
//* Object              : bench
//*
//* 1.0 15/05/01 JPP    : Creation
//*----------------------------------------------------------------------------

#include    "parts/r40807/lib_r40807.h"
#include    "targets/eb40/eb40.h"
#include     "com.h"

#include     <stdio.h>

extern void at91_tc_open_count( const TCBlockDesc *TC_pt );
extern void at91_tc_start( const TCBlockDesc *TC_pt );
extern u_int at91_tc_stop( const TCBlockDesc *TC_pt );
extern void testloop(int Number_Of_Runs) ;
extern void testloop1(void) ;

#define MCKI            32768000
#define BAUD_RATE       38400

char message[512];
ComDesc COM;
static const char atmel_header[]=
{
"\n\r    *** ATMEL USART BENCHMARK ***\n\r"
"Copyright (C) 2001 ATMEL Version 1.0\n\r"
};
	u_int result_out,result ;


//*----------------------------------------------------------------------------
//* Function Name       : main
//* Object              : Main function of the led blink
//* Input Parameters    : none
//* Output Parameters   : TRUE
//*----------------------------------------------------------------------------
int  main( void )
//* Begin
{
    u_short cd_baud;
	u_int result_out,result ;
	u_int cmpt;
//* Init
    //* define led at PIO output
    at91_pio_open ( &PIO_DESC, LED_MASK, PIO_OUTPUT );

     //* Init LED state
    at91_pio_write ( &PIO_DESC, LED_MASK, PIO_CLEAR_OUT );

    //* define switch at PIO input
    at91_pio_open ( &PIO_DESC, SW_MASK, PIO_INPUT );

    //* Init timer

    //* open terminal for console
    COM.usart=&USART0_DESC;
    cd_baud = at91_baud_com(MCKI, BAUD_RATE);
    //* open com
    at91_open_com(&COM,(COM_8_BIT|COM_PAR_NONE|COM_NBSTOP_1|COM_FLOW_CONTROL_NONE), cd_baud);
    at91_print(&COM,message);
    at91_print_frame(&COM,(char *)atmel_header,sizeof(atmel_header));

for (;;)
    {
	    //* check switch SW5 is push wait
		if (( at91_pio_read ( &PIO_DESC) & SW5_MASK ) == SW5_MASK )
		{ 	// if switch
   			at91_print(&COM,"** Mearsure **\n\r");
			at91_pio_write ( &PIO_DESC, LED1, PIO_SET_OUT );
			// open timer &TCB0_DESC
			at91_tc_open_count(&TCB_DESC);
			//* Start timer
			at91_tc_start(&TCB_DESC);

			//* Stop timer
			result_out= at91_tc_stop(&TCB_DESC );
			sprintf(message,"- Out test %d \n\r",result_out);
			at91_print(&COM,message);
			// open timer &TCB0_DESC
			at91_tc_open_count(&TCB_DESC);
			//* Start timer
			at91_tc_start(&TCB_DESC);
			cmpt++;
			result= at91_tc_stop(&TCB_DESC );
			sprintf(message,"- cmpt++ test total:%d test:%d\n\r",result,result-result_out);
   			at91_print(&COM,message);

			// open timer &TCB0_DESC
			at91_tc_open_count(&TCB_DESC);
	     	//* Start timer
			at91_tc_start(&TCB_DESC);

			// start test
			testloop(10000);

			result= at91_tc_stop(&TCB_DESC );
			sprintf(message,"- testloop  total %d testloop %d\n\r",result,result-result_out);
   			at91_print(&COM,message);

		// send result
		at91_pio_write ( &PIO_DESC, LED1, PIO_CLEAR_OUT );
		}
    }

//* End
}

⌨️ 快捷键说明

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