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

📄 lib_st.c

📁 ARM9200开发板的ROM boot程序源码1.0
💻 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           : lib_st.c
//* Object              : System Timer Library.
//*
//* 1.0 03/10/01  HI    : Creation
//*----------------------------------------------------------------------------

#include    "periph/system_timer/lib_st.h"


//*----------------------------------------------------------------------------
//* Function Name       : AT91_STinit
//* Object              : the period interval is 1 ms
//* Input Parameters    :period :Number of 33 micosec
//* Output Parameters   :
//*----------------------------------------------------------------------------

void AT91_STinit(AT91S_STDesc const *pSysTimer, unsigned int period)
{
	u_int status;

	pSysTimer->st_base->ST_IDR = 0x01;						/* Interrupt disable Register */
    pSysTimer->st_base->ST_PIMR = 0;   						/* Period Interval Mode Register == timer interval = 1ms*/
    status = pSysTimer->st_base->ST_SR;						/* Dummy Read status register */

    pSysTimer->st_base->ST_CR = 0;     						/* Control Register */
    pSysTimer->st_base->ST_WDMR = 0;   						/* Watchdog Mode Register */
    pSysTimer->st_base->ST_RTMR = 0;		   					/* Real Time Mode Register */
    pSysTimer->st_base->ST_RTAR = 0 ;						/* Real Time Alarm Register */

	status = pSysTimer->st_base->ST_SR;						/* Read status register */
    pSysTimer->st_base->ST_PIMR = period;   				/* Period Interval Mode Register == timer interval = 1ms*/
    pSysTimer->st_base->ST_IER = 0x01 ;						/* Interrupt Enable Register */
}


//*----------------------------------------------------------------------------
//* Function Name       : AT91_GetSTperiod
//* Object              : Return the correct value for ST_PIMR
//* Input Parameters    : period in microseconds
//* Output Parameters   :
//*----------------------------------------------------------------------------
unsigned int AT91_GetSTperiod(unsigned int period)
{
	if (period < 33)
		return 0;
	return (period / 33);
}

⌨️ 快捷键说明

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