STM32L151 NB-IoT and FreeRTOS Project
guowenxue
2018-11-09 e5393b5b3d85915600b3579cce9135f71eb93835
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/****************************************************************************
*   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