//============================================================================= // S E N S I R I O N AG, Laubisruetistr. 50, CH-8712 Staefa, Switzerland //============================================================================= // Project : SHT3x Sample Code (V1.1) // File : system.c (V1.1) // Author : RFU // Date : 6-Mai-2015 // Controller: STM32F100RB // IDE : µVision V5.12.0.0 // Compiler : Armcc // Brief : System functions //============================================================================= //-- Includes ----------------------------------------------------------------- #include "system.h" static __IO uint32_t msCounter; uint32_t msCounterBak; uint32_t oneSecond = 0; uint32_t TimingDelay; //----------------------------------------------------------------------------- //void SystemInit(void) //{ // // no initialization required //} //----------------------------------------------------------------------------- void DelayMicroSeconds(u32t nbrOfUs) /* -- adapt this delay for your uC -- */ { // u32t i; // for(i = 0; i < nbrOfUs; i++) // { // __nop(); // nop's may be added or removed for timing adjustment // __nop(); // __nop(); // __nop(); // } static uint32_t delayTime; while (nbrOfUs > 0) { for (delayTime = 0; delayTime < DELAY_1US_CLOCK; delayTime++) { NOP(); } nbrOfUs--; } } void SysTickConfig(void) { /* Setup SysTick Timer for 10ms interrupts */ if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ while (1); } /* Configure the SysTick handler priority */ NVIC_SetPriority(SysTick_IRQn, 0x0); } //系统滴答定时器中断函数 void SysTick_Handler(void) { if (TimingDelay != 0x00) { TimingDelay--; } } void Delay(uint32_t nTime) { TimingDelay = nTime; while (TimingDelay != 0); } void DelayMs(uint32_t mS) { static uint32_t delayTime; while (mS > 0) { for (delayTime = 0; delayTime < DELAY_MS_CLOCK; delayTime++) { NOP(); } mS--; } } void Delay100Us(uint32_t time) { static uint32_t delayTime; while (time > 0) { for (delayTime = 0; delayTime < DELAY_100US_CLOCK; delayTime++) { NOP(); } time--; } } void Delay10Us(uint32_t time) { static uint32_t delayTime; while (time > 0) { for (delayTime = 0; delayTime < DELAY_10US_CLOCK; delayTime++) { NOP(); } time--; } } void Delay1Us(uint32_t time) { static uint32_t delayTime; while (time > 0) { for (delayTime = 0; delayTime < DELAY_1US_CLOCK; delayTime++) { NOP(); } time--; } }