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

📄 stt.h

📁 包括EPA协议栈
💻 H
字号:
#ifndef _STT_H
#define _STT_H

#include "global.h"
#include "AT91RM9200.h"

typedef void (*PHDLR)(void);

void SttInit(void);

void RegHdlr(uint32 prh, PHDLR hldr);

__inline void PitStart(uint16 piv) {
	
	AT91C_BASE_ST->ST_IER = AT91C_ST_PITS;
	
	AT91C_BASE_ST->ST_PIMR = piv;
}

__inline void WdStart(uint16 wdv) {
	
	AT91C_BASE_ST->ST_WDMR = (wdv & AT91C_ST_WDV | AT91C_ST_RSTEN | AT91C_ST_EXTEN);
}

#define WdReload();           AT91C_BASE_ST->ST_CR = AT91C_ST_WDRST;

/*------------------------------------------------------------------------------*
 *- Operation of real-time alarm
 *-------------
 *- Notice : Make sure not to call these functions while IRQ is disabled or in 
 *-          interrupt process besides Rtt interrupt itself.
 *------------------------------------------------------------------------------*/

#define RttStop();            AT91C_BASE_ST->ST_IDR = AT91C_ST_ALMS;

__inline uint8 RttStart(uint16 pres, uint32 ticks) {
	
	if(ticks > 0xFFFFF) {
		return TIMER_OVERFLOW;
	}

	AT91C_BASE_ST->ST_IER = AT91C_ST_ALMS;
	
	AT91C_BASE_ST->ST_RTAR = ticks;
	
	AT91C_BASE_ST->ST_RTMR = pres;
	
	return TIMER_NO_ERR;
}

__inline uint8 RttReload(uint16 pres, uint32 ticks) {

	if(ticks > 0xFFFFF) {
		return TIMER_OVERFLOW;
	}

	AT91C_BASE_ST->ST_RTAR = ticks & 0xFFFFF;
	
	AT91C_BASE_ST->ST_RTMR = pres;

	return TIMER_NO_ERR;
}

__inline uint32 RttGetValue(void) {
	uint32 ms;
	
	ms = AT91C_BASE_ST->ST_CRTR;
	ms = AT91C_BASE_ST->ST_CRTR;
	
	return (ms & 0xFFFFF);
}

#endif	// _STT_H

⌨️ 快捷键说明

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