/*----------------------------------------------------------------------------*/
/* [url=home.php?mod=space&uid=139335]@name[/url] : stm8_interrupt_vector.c */
/* [url=home.php?mod=space&uid=247401]@brief[/url] : */
/* @Include: stm8s105k.h */
/* stm8s105k_led.h */
/*----------------------------------------------------------------------------*/
//============================================================================//
/* include-------------------------------------------------------------------*/
#include "stm8s105k.h"
#include "stm8s105k_led.h"
/* $ 别名定义----------------------------------------------------------------*/
typedef void [url=home.php?mod=space&uid=1095855]@far[/url] (*interrupt_handler_t)(void);
/* $ 结构体定义--------------------------------------------------------------*/
struct interrupt_vector {
unsigned char interrupt_instruction;
interrupt_handler_t interrupt_handler;
};
/* $ 全局变量----------------------------------------------------------------*/
uint16_t adc1_valtage[10]={'\0'};
/* $ 运行标志----------------------------------------------------------------*/
uint8_t ADC1_CONVER_FLAG = 0;
/* $ 中断函数----------------------------------------------------------------*/
[url=home.php?mod=space&uid=1095855]@far[/url] [url=home.php?mod=space&uid=422518]@interrupt[/url] void NonHandledInterrupt (void)
{
/* in order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction
*/
return;
}
[url=home.php?mod=space&uid=1095855]@far[/url] [url=home.php?mod=space&uid=422518]@interrupt[/url] void ISP_ADC1 (void)
{
uint8_t i;
uint8_t *pDBx = &ADC_DB0RH;
uint8_t temp_low,temp_high;
uint16_t temp;
ADC_CR1 &= (uint8_t)~(1<<1);//关闭连续转换
if(!(ADC_CR3 & (uint8_t)(1<<6)))//数据没有溢出,则将结果读出
{//数据右对齐,先读低,后读高
for(i=0;i<10;i++)
{
temp_low = *(pDBx + 1) ;
temp_high = *pDBx ;
temp = ((uint16_t)temp_high<<8)+(uint16_t)temp_low;
adc1_valtage = temp;
pDBx += 2;
}
adc1_valtage[10] = '\0';
ADC1_CONVER_FLAG = 1;
}
else //数据溢出,则从新转换一次
{
ADC_CR3 &= (uint8_t)~(1<<6);//清溢出标志
ADC_CR1 |= (uint8_t) (1<<1);//使能连续转换
ADC_CR1 |= (uint8_t) (1<<0);//开始转换
LED_OFF;
}
ADC_CSR &= (uint8_t)~(1<<7);//清转换结束标志
return;
}
extern void _stext(); /* startup routine */
struct interrupt_vector const _vectab[] = {
{0x82, (interrupt_handler_t)_stext}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 */
{0x82, NonHandledInterrupt}, /* irq1 */
{0x82, NonHandledInterrupt}, /* irq2 */
{0x82, NonHandledInterrupt}, /* irq3 */
{0x82, NonHandledInterrupt}, /* irq4 */
{0x82, NonHandledInterrupt}, /* irq5 */
{0x82, NonHandledInterrupt}, /* irq6 */
{0x82, NonHandledInterrupt}, /* irq7 */
{0x82, NonHandledInterrupt}, /* irq8 */
{0x82, NonHandledInterrupt}, /* irq9 */
{0x82, NonHandledInterrupt}, /* irq10 */
{0x82, NonHandledInterrupt}, /* irq11 */
{0x82, NonHandledInterrupt}, /* irq12 */
{0x82, NonHandledInterrupt}, /* irq13 */
{0x82, NonHandledInterrupt}, /* irq14 */
{0x82, NonHandledInterrupt}, /* irq15 */
{0x82, NonHandledInterrupt}, /* irq16 */
{0x82, NonHandledInterrupt}, /* irq17 */
{0x82, NonHandledInterrupt}, /* irq18 */
{0x82, NonHandledInterrupt}, /* irq19 */
{0x82, NonHandledInterrupt}, /* irq20 */
{0x82, NonHandledInterrupt}, /* irq21 */
{0x82, ISP_ADC1}, /* irq22 */
{0x82, NonHandledInterrupt}, /* irq23 */
{0x82, NonHandledInterrupt}, /* irq24 */
{0x82, NonHandledInterrupt}, /* irq25 */
{0x82, NonHandledInterrupt}, /* irq26 */
{0x82, NonHandledInterrupt}, /* irq27 */
{0x82, NonHandledInterrupt}, /* irq28 */
{0x82, NonHandledInterrupt}, /* irq29 */
};