/** ***************************************************************************** * 系统延时相关的函数 * 详细说明请参考《Cortex-M3权威指南(中文)》第133 ~ 134页 第8章 SysTick定时器介绍 * * (C) Copyright 2000-2020, *** * All Rights Reserved ***************************************************************************** * * @File : delay.h * @By : 陈桂东 * @Version : V1.0 * @Date : 2012 / 10 / 20 * ***************************************************************************** * Update * @Version : V1.0.1 * @By : 陈桂东 * @Date : 2014 / 02 / 26 * @Brief : 增加另外一种延时计算方法 * * @Version : V1.1 * @By : 陈桂东 * @Date : 2014 / 05 / 24 * @Brief : A、增加对C++环境支持 * B、修改在跑ucos时初始化嘀嗒定时器、延时us和ms函数 * * @Version : V1.2 * @By : 陈桂东 * @Date : 2015 / 10 / 03 * @Brief : 优化延时函数 * ***************************************************************************** **/ #ifndef _delay_h #define _delay_h /** ****************************** Support C++ ********************************** **/ #ifdef __cplusplus extern "C" { #endif /** ***************************************************************************** **/ /****************************************************************************** 外部函数头文件 ******************************************************************************/ #include "sys.h" /****************************************************************************** 定义延时时基来源 ******************************************************************************/ #define _USER_OtherDelay 0 //0: 使用的是嘀嗒定时器做延时 //1: 使用其他资源进行延时 /****************************************************************************** 定义其他延时计数资源 ******************************************************************************/ #if _USER_OtherDelay == 1 #define DWT_CTRL *(volatile uint32_t*)0xE0001000 //DWT控制寄存器 #define DWT_CYCCNT *(volatile uint32_t*)0xE0001004 //DWT当前PC采样周期计数寄存器 //详细见:周立功《CM3计数参考手册》第129页介绍 #define DWT_CPICNT *(volatile uint32_t*)0xE0001008 //DWT当前CPI计数寄存器 #define DEM_CTRL *(volatile uint32_t*)0xE000EDFC //调试异常和监控控制寄存器 #endif /****************************************************************************** 外部功能函数 ******************************************************************************/ void delay_init ( void ); //初始化延时函数 void delay_us ( uint32_t nus ); //延时n个us void delay_ms ( uint16_t nms ); //延时n个ms /** ****************************** Support C++ ********************************** **/ #ifdef __cplusplus } #endif /** ***************************************************************************** **/ #endif /* end delay.h */