调试时间两天多,换了六七个版本的contiki,最后还是拿着例子按照减法的方式一步一步减掉然后差不多是成了,现在觉得是Makefile设定的问题了,真的很迷,官方wiki,教程和README一点都没有提及!
官方的wiki看起来很久没有更新,带来了很大的困扰。
花费了两个一整天都在搞串口传入问题,不解决这个问题后面的shell,ELF和Coffee等一大堆都没有办法实现,官方做的真的有点糟糕。
成功实现串口传入后回传这一功能的文件
主文件:cc2538-demo.c
#include "contiki.h"
#include "cpu.h"
#include "sys/etimer.h"
#include "sys/rtimer.h"
#include "dev/leds.h"
#include "dev/uart.h"
#include "dev/cc2538-sensors.h"
#include "dev/button-sensor.h"
#include "dev/als-sensor.h"
#include "dev/watchdog.h"
#include "dev/serial-line.h"
#include "dev/sys-ctrl.h"
#include "net/rime/broadcast.h"
#include
#include
#define LEDS_PERIODIC
LEDS_RED
static struct etimer et;
static struct rtimer rt;
static uint16_t counter;
PROCESS(cc2538_demo_process, "cc2538 demo process");
AUTOSTART_PROCESSES(&cc2538_demo_process);
void
rt_callback(struct rtimer *t, void *ptr)
{
leds_off(LEDS_PERIODIC);
}
PROCESS_THREAD(cc2538_demo_process, ev, data)
{
PROCESS_BEGIN();
while(1) {
PROCESS_YIELD();
if(ev == serial_line_event_message)
{
printf("Data Receive\n");
printf("Receive data is:%s\n",data);
}
}
PROCESS_END();
}
Makefile文件:
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
CONTIKI_PROJECT = cc2538-demo timer-test
all: $(CONTIKI_PROJECT)
CONTIKI = ../../..
CONTIKI_WITH_RIME = 1
CONTIKI_WITH_IPV4 = 1
CONTIKI_WITH_IPV6 = 0
include $(CONTIKI)/Makefile.include
project-conf.h文件:
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define NETSTACK_CONF_RDC
nullrdc_driver
#endif
转载请注明原文地址: https://ju.6miu.com/read-201.html