STM32 V5 source code
guowenxue
2018-05-16 a22d9c106276bb1819e583012d7ea41b6529b318
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
58
59
60
/****************************************************************************
*   Copyright: (C)2014 Î人ÁèÔÆÇ¶ÈëʽʵÑéÊÒ www.emblinux.com
*      Author: GuoWenxue<guowenxue@gmail.com> QQ: 281143292
* Description: ·Ü¶·STM32v5¿ª·¢°åcontiki²Ù×÷ϵͳÈë¿Ú³ÌÐò
*   ChangeLog:
*        °æ±¾ºÅ     ÈÕÆÚ       ×÷Õß      ËµÃ÷
*        V1.0.0  2014.08.25  GuoWenxue   ·¢²¼¸Ã°æ±¾
****************************************************************************/
 
#include"stm32f10x.h"
#include "stm32v5_led.h"
#include "debug-uart.h"
#include "contiki.h"
#include <stdio.h>
 
PROCESS(led_blink_process, "LED blink process");
AUTOSTART_PROCESSES(&led_blink_process);
 
PROCESS_THREAD(led_blink_process, ev, data)
{
  PROCESS_BEGIN();
 
    while(1)  
    {
            static struct etimer et;
            
            etimer_set(&et, CLOCK_SECOND);
            PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));    
            printf("Turn LED1 on\n");            
            turn_led(LED1, ON);
            
            etimer_set(&et, CLOCK_SECOND);
            PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
            printf("Turn LED1 off\n");    
            turn_led(LED1, OFF);                
    }
 
  PROCESS_END();
}
 
int main(void)
{
    init_led_gpio();    
    dbg_setup_uart();
    clock_init();
 
  process_init();
  process_start(&etimer_process, NULL);
  autostart_start(autostart_processes);
    printf("Processes running\n");
 
    while(1) 
    {
       do {  } while(process_run() > 0);  /* Let process running */
         /*Comes here means CPU is Idel*/
    }
    
    return 0;
}