/****************************************************************************
|
* Copyright: (C)2018 Î人ÁèÔÆÎïÍøÖÇ¿ÆÊµÑéÊÒ www.iot-yun.com
|
* Author: GuoWenxue<guowenxue@gmail.com> QQ: 281143292
|
* Description: STM32L151C8T6 CubeMX ¿ª·¢°å systick ÑÓʱº¯Êý¡¢jiffiesʵÏÖº¯Êý
|
*
|
* ChangeLog:
|
* °æ±¾ºÅ ÈÕÆÚ ×÷Õß ËµÃ÷
|
* V1.0.0 2018.11.05 GuoWenxue ·¢²¼¸Ã°æ±¾
|
****************************************************************************/
|
|
#ifndef __STM32_SYSTICK_H_
|
#define __STM32_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_handler_proc(void);
|
|
/* sleep msºÁÃë */
|
extern void msleep(__IO uint32_t ms);
|
|
|
#endif
|