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 ¿ª·¢°å LED¡¢´®¿Ú¡¢Systick µÈ²âÊÔ³ÌÐò
               ¿ª·¢°åÌÔ±¦¹ºÂòµØÖ·£º https://item.taobao.com/item.htm?spm=a1z09.2.0.0.6ff42e8dPmfuKR&id=551780894246&_u=41ifnbo379e
*   ChangeLog:
*        °æ±¾ºÅ     ÈÕÆÚ       ×÷Õß      ËµÃ÷
*        V1.0.0  2018.11.04  GuoWenxue   ·¢²¼¸Ã°æ±¾
****************************************************************************/
 
#include <stdio.h>
#include "stm32_led.h"
#include "stm32_key.h"
#include "stm32_usart.h"
#include "stm32_systick.h"
 
 
void blink_led(uint8_t which, uint32_t ms)
{
    uint32_t       start_time;
    
    start_time = jiffies;
    while( time_before(jiffies, start_time+ms) )
    {
        turn_led(which, ON);
        msleep(100);
 
        turn_led(which, OFF);
        msleep(100);
  }
}
 
int main(void)
{
    init_led_gpio();
    init_systick();
    init_keys_interrupt();
    
    stm32_init_printf(USART_PORT1, 115200);
    
    printf("STM32L151C8T6A CubeMX Board Setup USART1 As Standard Output OK.\n");
    
    printf("Blink test LED in 3000ms\n");
    blink_led(LED1, 3000);
    
    printf("Wakeup Key Interrupt Detected start...\n");
    
    while(1)
    {
        msleep(3000);
        
        turn_led(LED1, ON);
        msleep(150);
        turn_led(LED1, OFF);
    }
}