Contiki 在STM32 中的移植

来源:互联网 发布:移动硬盘找回数据 编辑:程序博客网 时间:2024/04/29 05:25

使用野火的板子进行Contiki移植:
开发环境:IAR+STM32
代码移植基本上参照xukai871105 前辈的教程,不同之处是使用的是寄存器的操作方式,并没有是用STM32 的库函数。
代码如下:

#include "contiki.h" #include "stm32/usart/usart.h" /* For usart_puts()*/ #include <stdio.h> /* For printf() */ #include "sys/clock.h"#include "sys/process.h"#include "sys/procinit.h"#include "sys/etimer.h"#include "sys/autostart.h"PROCESS(hello_world_process, "Hello world");  /*声明一个函数,该函数是进程的执行体,即进程的thread函数指针所指的函数;定义一个进程 */AUTOSTART_PROCESSES(&hello_world_process);  /*AUTOSTART_PROCESSES宏实际上是定义一个指针数组,存放Contiki系统运行时需自动启动的进程*//*Define the process code*/ PROCESS_THREAD(hello_world_process, ev, data) {     PROCESS_BEGIN();     PROCESS_END(); }unsigned int idle_count = 0;int main(){  clock_init();  uart_init(72,115200);  printf("Initialising\r\n");  process_init();  process_start(&etimer_process, NULL);  autostart_start(autostart_processes);  //process_start(&blink_process,NULL);  printf("Processes running\r\n");  while(1) {    do     {    }     while(process_run() > 0);    idle_count++;    /* Idle! */    /* Stop processor clock */    /* asm("wfi"::); */     printf("idle_count:%d\r\n",idle_count);  }  return 0;}

实现简单的串口发送。在编译过程中出现no definition for “autostart_processes”错误,跟踪代码后发现有如下宏:

#if ! CC_NO_VA_ARGS#if AUTOSTART_ENABLE#define AUTOSTART_PROCESSES(...)                    \struct process * const autostart_processes[] = {__VA_ARGS__, NULL}#else /* AUTOSTART_ENABLE */#define AUTOSTART_PROCESSES(...)                    \extern int _dummy#endif /* AUTOSTART_ENABLE */

便在头文件添加了

#define AUTOSTART_ENABLE 1

但依然解决不了错误;经过百度后知道在前面没有调用宏PROCESS(name, strname) ;AUTOSTART_PROCESSES(…);致使后面的autostart_processes未定义。
最后编译完成后,烧写到板子时提示代码区域有误便使用了ifc 文件便解决问题。

0 0
原创粉丝点击