?? main.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 : main.c
//* Object : Test DAC and ADC for the AT91EB55
//*
//* 1.0 25/08/00 JPP : Creation
//*----------------------------------------------------------------------------
#ifndef AT91_DEBUG_NONE
#include <stdio.h>
#endif
#include "parts/m55800/lib_m55800.h"
#include "targets/eb55/eb55.h"
#include "drivers/com/com.h"
#include "drivers/analog/analog.h"
#include "lib_tools.h"
//* for Mcki calculation
#include "drivers/time_rtc/time_rtc.h"
extern void menu_adc_it(void);
extern void menu_sinus(void);
extern void menu_val(void);
extern void menu_adc(void);
//* Global Variable
//* menu management
char message[512];
ComDesc COM;
manage_timer timer_base;
u_int mcki;
//* input / ouput table
u_short sinus_table[4096*2];
u_short input_val[1024] ;
//* ADC and DAC descriptor for polling and interrupt
AnalogAdcIrqDesc it_adc;
AnalogDescAdc desc_analog_adc;
AnalogDACTimerIrqDesc it_timer;
AnalogDescDac AnalogDac;
//* project value for IT management
GetTestValue timer_interrup;
// * Local variable
static const char atmel_header[]=
{
"\n\r\n\r *** ATMEL DAC And ADC test ***\n\r"
"Copyright (C) 1999 ATMEL Corporations Version: 1.5\n\r"
};
static const char main_menu[]=
{
"\n\r COMMAND MENU: Base \n\r"
" 0) Info\n\r"
" 1) DAC Wave Generation \n\r"
" 2) DAC Value Generation \n\r"
" 3) ADC \n\r"
" 4) ADC It\n\r"
" 5) Timer config \n\r"
"Enter command to execute: "
};
//*----------------------------------------------------------------------------
//* Function Name : Get_Command
//* Object : Get command val
//* Input Parameters : None
//* Output Parameters : int : Command num
//*----------------------------------------------------------------------------
int Get_Command(void)
{
int command;
at91_print_frame(&COM,(char *)main_menu,sizeof(main_menu));
at91_scanf(&COM,"%d", &command);
at91_print_crlf(&COM);
return command;
}
//*----------------------------------------------------------------------------
//* Function Name : menu
//* Object : check general menu
//* Input Parameters : None
//* Output Parameters : None
//*----------------------------------------------------------------------------
void menu(void)
{
int command = 0;
for(;;)
{
command = Get_Command();
switch(command)
{
case 0: /* dac Sinus */
print_timer_manage();
at91_print(&COM,"Eb55 hard\n\r");
at91_print(&COM,"loop DAC0 <-> ADC1 ch 0 & DAC1 <-> ADC0 ch 0\n\r");
at91_print(&COM,"AD0 TRIG <- TIOA4 & AD1 TRIG <- TIOA5\n\r");
break;
case 1: /* dac Sinus */
menu_sinus();
break;
case 2: /* dac const value */
menu_val();
break;
case 3: /* ADC */
menu_adc();
break;
case 4: /* ADC */
menu_adc_it();
break;
case 5: /* Timer */
get_timer_manage();
break;
default: /* invalid command */
at91_print(&COM,"Invalid command entered. Please enter again!\n\r");
}
}
}
//*----------------------------------------------------------------------------
//* Function Name : main
//* Object : Main function of sinus with led blink
//* Input Parameters : none
//* Output Parameters : True
//*----------------------------------------------------------------------------
int main( void )
//* Begin
{
TimeDescRtc rtc;
u_short cd_baud,error;
//* open terminal for console
COM.usart=&USART0_DESC;
error=0;
//* Open the RTC time
rtc.rtc_desc=&RTC_DESC;
at91_time_rtc_open(&rtc);
// get the mcki
mcki = at91_time_rtc_mcki(&rtc, &TCB0_DESC );
cd_baud = at91_baud_com(mcki, 115200);
error = at91_error_baud_com(mcki, 115200);
at91_open_com(&COM,(COM_7_BIT|COM_PAR_NONE|COM_NBSTOP_1|COM_FLOW_CONTROL_NONE), cd_baud);
at91_pio_open ( &PIOB_DESC, LED_MASK, PIO_OUTPUT ) ;
at91_pio_write (&PIOB_DESC, LED_MASK, LED_OFF ) ;
timer_base.TC_adc0= &TC3_DESC;
timer_base.trig_selection_adc0=ADC_TRG_TIOA3;
timer_base.TC_adc1= &TC5_DESC;
timer_base.trig_selection_adc1=ADC_TRG_TIOA5;
timer_base.TC_dac0= &TC1_DESC;
timer_base.trig_selection_dac0=DAC_TRG_TIOA1;
timer_base.TC_dac1= &TC2_DESC;
timer_base.trig_selection_dac1=DAC_TRG_TIOA2;
at91_print_frame(&COM,(char *)atmel_header,sizeof(atmel_header));
at91_pio_write (&PIOB_DESC, LED1 , LED_ON ) ;
menu();
return(TRUE);
//* End
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -