📄 c_handler.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 : c_handler.c
//* Object : Irq C handler definition
//*
//* 1.0 31/08/00 JPP : Creation
//*----------------------------------------------------------------------------
#include "periph/stdc/std_c.h"
#include "periph/timer_counter/lib_tc.h"
#include "drivers/analog/analog.h"
#include <stdio.h>
#include "lib_tools.h"
//*----------------------------------------------------------------------------
//* Function Name : at91_c_handler_check_pdc
//* Object : C handler interrup function called by the interrups
//* assembling routine
//* Input Parameters : <Irq Descriptor> Analog DAC Interrupt descriptor
//* Output Parameters : none
//*----------------------------------------------------------------------------
void at91_c_handler_check_pdc(AnalogDACTimerIrqDesc *desc)
//* Begin
{
u_int tmp;
u_int pt,dhr,dor,cmpt;
if (timer_interrup.echo)
{
pt= desc->dac->dac_base->DAC_DPR;
cmpt = desc->dac->dac_base->DAC_DCR;
dor = desc->dac->dac_base->DAC_DOR;
dhr = desc->dac->dac_base->DAC_DHR;
timer_interrup.cmpt++;
sprintf(message,"%08X %02X %04X %04X %04X\n\r",pt,cmpt,dhr,dor,timer_interrup.cmpt);
at91_print(&COM,message);
}
//* -- Deasert timer interrupt by read Status register (TC_SR)
tmp =desc->timer->tc_base->TC_SR ;
//* End
}
//*----------------------------------------------------------------------------
//* Function Name : at91_c_handler_timer
//* Object : C handler interrup function called by the interrups
//* assembling routine
//* Input Parameters : <Irq Descriptor> Analog DAC Interrupt descriptor
//* Output Parameters : none
//*----------------------------------------------------------------------------
void at91_c_handler_timer(AnalogDACTimerIrqDesc *desc)
//* Begin
{
u_int tmp;
u_int pt,dhr,dor,cmpt;
//* Write the current value in the DAC
desc->dac->dac_base->DAC_DHR = *(desc->pdc.cur_add);
if (desc->pdc.cur_cmpt !=0)
{
desc->pdc.cur_add++;
desc->pdc.cur_cmpt--;
}
else
{
desc->pdc.cur_add = desc->pdc.base_add ;
desc->pdc.cur_cmpt= desc->pdc.base_cmpt;
} //* End Update
if (timer_interrup.echo)
{
pt= desc->dac->dac_base->DAC_DPR;
cmpt = desc->dac->dac_base->DAC_DCR;
dor = desc->dac->dac_base->DAC_DOR;
dhr = desc->dac->dac_base->DAC_DHR;
timer_interrup.cmpt++;
sprintf(message,"%08X %02X %04X %04X %04X\n\r",pt,cmpt,dhr,dor,timer_interrup.cmpt);
at91_print(&COM,message);
}
//* -- Deasert timer interrupt by read Status register (TC_SR)
tmp =desc->timer->tc_base->TC_SR ;
//* End
}
//*----------------------------------------------------------------------------
//* Function Name : at91_c_handler_adc
//* Object : C handler interrup function called by the interrups
//* assembling routine
//* Input Parameters : ADC descriptor ,ADC mode for trig
//* Output Parameters : none
//*----------------------------------------------------------------------------
void at91_c_handler_adc(AnalogAdcIrqDesc *desc)
{
u_short adc_val;
//* Read Channel
adc_val = desc->adc->adc_base->ADC_CDR[desc->adc_channel];
//* check if PDC mode is used
if ( desc->pdc.base_add != 0)
{
//* Write the current value in the Memory
*(desc->pdc.cur_add) =adc_val ;
//* Update the pointer
if (desc->pdc.cur_cmpt !=0)
{
desc->pdc.cur_add++;
desc->pdc.cur_cmpt--;
}
else
{
desc->pdc.cur_add = desc->pdc.base_add ;
desc->pdc.cur_cmpt= desc->pdc.base_cmpt;
} //* End Update
} //* End of PDC
//* check if loop mode
if (desc->loop_mode == LOOP_DAC)
at91_dac_write(desc->dac_loop, &adc_val );
//* general information
timer_interrup.read=adc_val;
if (timer_interrup.min > adc_val) timer_interrup.min = adc_val;
if (timer_interrup.max < adc_val) timer_interrup.max = adc_val;
timer_interrup.moy += adc_val;
timer_interrup.nb_read++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -