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

📄 timers.c

📁 str710系列的hdlc协议的通信
💻 C
字号:
/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
* File Name          : timers.c
* Author             : jrl
* Date First Issued  : 1/1/04
* Description        : functions for using the wdog as a gp timer
*********************************************************************************
* History:
* 2/8/04: first issued
*
*********************************************************************************/
#include "71x_lib.h"

//EXT int FindFactors();
  
void wait_us (u32 Time)
	// wait Time(in uS) 
  {
	//WDG_ECFlagClear();
	WDG_PeriodValueConfig ( Time );  
	
	WDG_CntOnOffConfig ( ENABLE );
	while (WDG_ECStatus( ) < 1);
	//while ((WDG->SR & 1) < 1);
	WDG_CntOnOffConfig ( DISABLE );
	WDG_ECFlagClear ( );
	
  }

void wait_ms (u32 Time)
  {
  	u32 i;
	
	for (i=0; i < Time; i++)
	  {
		wait_us (1000);
		
          }
  }

void wait_s (u32 Time)
  {
  	u32 i;
	
	for (i=0; i < Time; i++)
	  {
		wait_ms (1000);
		
          }
  }


void rtcinit (void)
{
  u32 Myprescaler;

  
// Configure RTC prescaler
  Myprescaler = 0x00007d00;  //prescaler for  1 clock per second
  RTC_PrescalerConfig ( Myprescaler );

// Clear Pending Flags
  RTC_FlagClear ( RTC_OWIR );
  RTC_FlagClear ( RTC_AIR  );
  RTC_FlagClear ( RTC_SIR  );
  RTC_FlagClear ( RTC_GIR  );


/////////
// Initialize the XTI 
  XTI_Init();
  // Set Line 15 edge 
  XTI_LineModeConfig(XTI_Line15, XTI_RisingEdge);
  // Enable the External interrupts on line 15 
  XTI_LineConfig(XTI_Line15, ENABLE);
  // Set the XTI mode 
  XTI_ModeConfig(XTI_WakeUp, ENABLE);

  //Configure the P0.15 in INOUT-WeakPP mode 
  GPIO_Config(GPIO0,0x0001<<0x0F,GPIO_INOUT_WP);

///////////////

RTC_AlarmConfig ( RTC_CounterValue () + 65); //wait 65 seconds for alarm


// Enable alarm Interrupt
  RTC_ITConfig( RTC_AIR | RTC_GIR, ENABLE );

// Configure Port 2 pins
 GPIO_Config (GPIO0, 0x1000, GPIO_OUT_PP);
 GPIO0->PD = 0x0000;

}
	
u32 uptime (void)
// return the contents of the rtc in hours assumes rtc clock = 1/second
  {

   u32 hours;

   hours = (RTC_CounterValue ()/3600);

   return (hours);

  }

void delay(u32 clocks)
  {
	u32 i;
	
	for (i=0; i < clocks; i++);

  }

⌨️ 快捷键说明

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