contiki 開發日記之串口開發

cc2430平臺有2個串口uart0(P0_2,P0_3) 和uart1(P0_4,P0_5)node

在contiki開發過程當中由於牽扯到步驟調試這裏有 platform/sensinode-debug.h文件。dom

裏面的putstring即至關於printf在其餘編譯器中控制檯輸出功能。函數

在加入頭文件後便可實現printf函數的使用。this

其中注意platform/contiki-conf.h頭文件。此文件是配置contiki的各類資源。debug

若是你在使用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
#endiform

相關文章
相關標籤/搜索