contiki 开发日记之串口开发

cc2430平台有2个串口uart0(P0_2,P0_3) 和uart1(P0_4,P0_5)

在contiki开发过程中因为牵扯到步骤调试这里有 platform/sensinode-debug.h文件。

里面的putstring即相当于printf在其他编译器中控制台输出功能。

在加入头文件后即可实现printf函数的使用。

其中注意platform/contiki-conf.h头文件。此文件是配置contiki的各种资源。

如果你在使用uart0_init()会报错的情况下,需要设置里面的资源,如下:

/*
 * UARTs: 1=>Enabled, 0=>Disabled. Default: Both Disabled (see uart.h)
 * Disabling UART0 saves ~200 bytes of CODE.
 * Disabling UART1 saves ~500 bytes of CODE but also disables all debugging
 * output. Should be used when nodes are meant to run on batteries
 *
 * On N740, by enabling UART1, you are also enabling an ugly hack which aims
 * to detect the USB connection during execution. It will then turn on/off
 * UART1 RX interrupts accordingly. This seems to work but you have been warned
 * If you start seeing random crashes when on battery, this is where to look.
 */
#ifndef UART_ONE_CONF_ENABLE
#define UART_ONE_CONF_ENABLE  1
#endif
#ifndef UART_ONE_CONF_WITH_INPUT
#define UART_ONE_CONF_WITH_INPUT 0
#endif
#define UART_ZERO_CONF_ENABLE 1                                                                                                                                                                                                                                                                                                                                                                                                   

#ifndef UART_ONE_CONF_HIGH_SPEED
#define UART_ONE_CONF_HIGH_SPEED 0
#endif

/* Are we a SLIP bridge? */
#if SLIP_ARCH_CONF_ENABLE
/* Make sure UART1 is enabled, with interrupts */
#undef UART_ONE_CONF_ENABLE
#undef UART_ONE_CONF_WITH_INPUT
#define UART_ONE_CONF_ENABLE  1
#define UART_ONE_CONF_WITH_INPUT 1
#define UIP_FALLBACK_INTERFACE slip_interface
#endif

你可能感兴趣的:(contiki 开发日记之串口开发)