This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 编译器:WSN430编译问题

Guru**** 1810550 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/803587/compiler-wsn430-compilation-problem

工具/软件:TI C/C++编译器

大家好!

当我想编译一个教程程序时遇到了一些问题...

#include 
#include 
#include 
#include 

/*项目包括*/
#include "clock.h"
#include "LEDs.h"
#include "uart0.h"
#include "tsl2550.h"
#include "ds1722.h"
#include "ds2411.h"
#include "timerA.h"

#include "mac.h"


//选择通道






警报[0-20] intchar 函数/inttchar t intrath (int16

)/inttchar intt_int16) intrath (intchar intc_static t_int16)/intt/intt_intchar intt intrat_int16


返回 uart0_putchar (c);
}

/*全局变量*/
//存储从 UART 接收到的字符的值(由主函数分析
)// volatile 是防止对其进行优化所必需的。
volatile INT8_t cmd = 0;
//每秒打印帮助
volatile INT8_t print_help = 1;

enum{
NO_EVENT = 0、
RX_PKT、
TX_PKT、
TX_PKT_ERROR
、};

//获取无线电事件
易失性结构{
int8_t GUST_EVENT;

uint8_t packet[256];
uint16_t length;
uint16_t addr;
int16_t RSSI;
}radio ={0};

/**
*序列号
*/
static void serial_number ()
{
uint16_t node_addr =(((uint16_t) ds2411_id.serial1)<<8)+(ds2411_id.serial0);
printf ("唯一标识符:%x\n"、node_addr);
}

/**
*传感器
*/
静态空 tempature_sensor ()
{
int16_t value_0、value_1;

value_0 = ds1722_read_msb ();
Value_1 = ds1722_read_LSB ();
Value_1 >=5;
Value_1 *= 125;

printf ("温度测量:%I.%i\n"、value_0、value_1);
}

静态空 lIGHT_SENSOR ()
{
int16_t value_0、value_1;
tsl2550_init();
value_0 = tsl2550_read_ADC0 ();
Value_1 = tsl2550_read_adc1 ();

/*恢复串行的 UART0配置*/
uart0_init (UART0_CONFIG_1MHz_115200);
uart0_register_callback (char_Rx);

printf ("亮度度量:%i:%i\n"、value_0、value_1);
}

//
*无线电配置
*/

静态 void send_packet ()
{
uint16_t ret;
静态 uint8_t num = 0;

//最大 pktt 长度<= max (CC2420、CC1101)
snprintf ((char*) radio.packet、58、"Hello World!:%u"、num);
radio.length = 1 + strlen ((char*) radio.packet);
radio.addr = MAC_broadcast;

RET = mac_send (((uint8_t *) radio.packet、radio.length、radio.addr);
num++;

IF (RET)
printf ("mac_send ret %u\n"、ret);
}

静态 uint16_t mac_Rx_ISR (uint8_t packet[]、uint16_t length、
uint16_t src_addr、int16_t RSSI)
{
radio.GOT_EVENT = RX_PKT;

strcpy((char*)radio.packet、(char*)packet);
radio.length =长度;
radio.addr = src_addr;
radio.RSSI = RSSI;
返回1;
}

静态 uint16_t mac_TX_DONE_ISR ()
{
radio.GOT_EVENT = TX_PKT;
返回1;
}
静态 uint16_t Mac_TX_FAIL_ISR ()
{
radio.GOT_EVENT = TX_PKT_ERROR;
返回1;
}

//*
帮助
*/
静态 void print_usage()
{
printf ("\n\n\not-lab 简单演示程序\n"\});
printf ("类型命令\n");
printf ("\th:\tprint this help\n");
printf ("\tt:\ttemperature measure\n");
printf ("\tl:\tluminity measure\n");
printf ("\tu:\tprint uid\n");
printf ("\ts:\tsend a radio packet\n");
如果(print_help)
printf ("\n 键入 Enter 以停止打印此帮助\n"\};
printf ("\n");
}



静态 void hardware_init()
{
//停止看门狗计时器。
WDTCTL = WDTPW + WDTHOLD;

//设置 MCLK 8MHz 和 SMCLK 1MHz
SET_MCU_SPEED_XT2_MCLK_8MHz_smclk_1MHz ();
SET_aclk_div (8);// ACKL 为4096Hz

//初始化 LED
LED_INIT();
LED_OFF ();

//初始化温度传感器
ds1722_init();
ds1722_set_res (12);
ds1722_sample_cont();

//初始化亮度传感器
tsl2550_init();
tsl2550_powerup();
tsl2550_set_standard();

//初始化序列号
DS2411_init();

// Init CSMA 无线电 MAC 层
Mac_init (通道);
MAC_SET_Rx_CB (MAC_Rx_ISR);
MAC_SET_SENT_CB (Mac_TX_DONE _ISR);
MAC_SET_ERROR_CB (Mac_TX_FAIL_ISR);

//初始化 UART0
uart0_init (UART0_CONFIG_1MHz_115200);//我们需要115k 波特、
//和 SMCLK 以1MHz 运行
uart0_register_callback (char_Rx);//设置 UART 回调函数
//每次 a 都将调用它
//接收字符。


//启用中断
eint();

//初始化 LED 的计时器
timerA_init();
timerA_start_ACLK_div (TIMERA_DIV_8);// TimerA 时钟频率为512Hz
timerA_set_alarm_far_fin_now (TIMERA_alarm_CCR0、512、512);// 1s 周期
timerA_register_CB (TIMERA_alarm_CCR0、alarm);
}

静态空 handle_cmd (uint8_t cmd)
{
开关(cmd){
案例"t":
temater_sensor();
中断;
案例'l':
light_sensor();
中断;
案例"u":
serial_number();
中断;
案例"S":
send_packet();
中断;
案例'\n':
中断;
案例"h":
默认值:
print_usage();
中断;
}
}

静态空 handle_radio()
{
如果(radio.GOT 事件== NO_EVENT)
返回;

printf ("\nradio >");

switch (radio.Got_event){
RX_PKT 案例:
printf ("从%x 获取数据包 Len:%u RSSI:%d:'%s'\n"、
radio.addr、radio.length、radio.RSSI、(char*) radio.packet);
中断;
案例 TX_PKT:
printf ("发送的数据包\n");
中断;
案例 TX_PKT_ERROR:
printf ("发送的数据包失败\n");
中断;
默认值:
printf ("已知事件");
中断;
}
}

int main( void ){

hardware_init();

while (1){
while ((cmd =0)&&(radio.GK_event =0))
LPM0;//低功耗模式1:SMCLK 对于 UART 保持有效

如果(cmd){
handle_cmd (cmd);
CMD = 0;
}
if (radio.Got_event){
//禁用帮助消息
print_help = 0;

handle_radio();
radio.GOT 事件= 0;
}
printf ("cmd >");
}
返回0;
}


静态 uint16_t char_rx (uint8_t c){
//接收字符后禁用帮助消息
print_help = 0;

if (c='t'|| c='l'|| c='h'|| c='u'|| c='s'|| c='s'|| c='\n'){
//将接收到的字符复制到 cmd 变量。
CMD = c;
//返回非零来唤醒 CPU。
返回1;
}

//如果不是有效的命令,则不会唤醒 CPU。
返回0;
}

静态 uint16_t alarm (void){
LED_RED_TOGGLE ();
LED_blue_toggle ();
LED_GREEN_TOGGLE ();

/*在获得第一个实数之前打印帮助\n */
if (print_help){
CMD ='h';
返回1;
}
返回0;
}

您可以在以下网站上找到该库: https://github.com/iot-lab/wsn430

我无法运行 program...ca、您可以帮我吗?

科迪里

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我不熟悉 WSN430系统。  据我所知、它使用 TI 的组件、但不是由 TI 制造、销售或支持的。  在这种情况下、我们无法为您提供帮助。

    [引用 user="Jean ley]您可以在以下网站上找到库: https://github.com/iot-lab/wsn430

    该链接包含一个 wiki、其中包含一些教程。  考虑从其中一个开始。

    谢谢、此致、

    乔治