/**************************************************************************** * Copyright: (C)2018 Î人ÁèÔÆÎïÍøÖÇ¿ÆÊµÑéÊÒ www.iot-yun.com * Author: GuoWenxue QQ: 281143292 * Description: ·Ü¶·STM32v5¿ª·¢°å systick ²Ù×÷º¯Êý½Ó¿Ú * * ChangeLog: * °æ±¾ºÅ ÈÕÆÚ ×÷Õß ËµÃ÷ * V1.0.0 2018.05.10 GuoWenxue ·¢²¼¸Ã°æ±¾ ****************************************************************************/ #ifndef __STM32V5_SYSTICK_H #define __STM32V5_SYSTICK_H #define TICKS_PER_MSECOND 1000 /* ʱÖÓ½ÚÅÄÖжÏΪ1msÒ»´Î */ #define TICKS_PER_USECOND 1000000 /* ʱÖÓ½ÚÅÄÖжÏΪ1usÒ»´Î */ extern __IO uint32_t jiffies; /* * These inlines deal with timer wrapping correctly. You are strongly encouraged to use them * 1. Because people otherwise forget * 2. Because if the timer wrap changes in future you won't have to alter your driver code. * * time_after(a,b) returns true if the time a is after time b. * * Do this with "<0" and ">=0" to only test the sign of the result. A * good compiler would generate better code (and a really good compiler * wouldn't care). Gcc is currently neither. */ #define time_after(a,b) ((int32_t)(b) - (int32_t)(a) < 0) #define time_before(a,b) time_after(b,a) #define time_after_eq(a,b) ((int32_t)(a) - (int32_t)(b) >= 0) #define time_before_eq(a,b) time_after_eq(b,a) /* Timeout happened, x should be last jiffies+timeout value */ #define timeout_happened(x) (time_after_eq(jiffies, x)) /* ʹÓÃʵÀý´úÂë: ÔÚ100msÄÚ´òÓ¡"#" start_time = jiffies; while( time_before(jiffies, start_time+100) ) printf("#"); */ /* ³õʼ»¯Systick, ÿ¸ô 1ms ²úÉúÒ»´ÎÖÐ¶Ï */ extern void init_systick(void); /* SystickÖжϴ¦Àíº¯Êý: ÑÓʱʱ¼ä×Ô¼õ ºÍ jiffies ×Ô¼Ó */ extern void systick_irq_proc(void); /* sleep msºÁÃë */ extern void msleep(__IO uint32_t ms); #endif