diff --git a/platform/msb430/buildscripts/Makefile.win b/platform/msb430/buildscripts/Makefile.win index edf3b615d..b3c8eabab 100644 --- a/platform/msb430/buildscripts/Makefile.win +++ b/platform/msb430/buildscripts/Makefile.win @@ -1,7 +1,7 @@ %.u: %.ihex - msp430-jtag -eI $^ + msp430-jtag --lpt=TIUSB -mI $^ #CW=cw23 #%.u: %.ihex -# $(CW) -d f430p $^ +# $(CW) -d f430p $^ \ No newline at end of file diff --git a/platform/msb430/contiki-msb430-main.c b/platform/msb430/contiki-msb430-main.c index 865f9bca5..cb16e66b7 100644 --- a/platform/msb430/contiki-msb430-main.c +++ b/platform/msb430/contiki-msb430-main.c @@ -53,8 +53,22 @@ #include "net/mac/nullmac.h" #include "net/mac/xmac.h" +#include "dev/slip.h" + SENSORS(NULL); +#if WITH_UIP +static struct uip_fw_netif slipif = +{UIP_FW_NETIF(192,168,1,2, 255,255,255,255, slip_send)}; +#else +int +putchar(int c) +{ + rs232_send(c); + return c; +} +#endif /* WITH_UIP */ + static void set_rime_addr(void) { @@ -117,30 +131,46 @@ main(void) uart_lock(UART_MODE_RS232); uart_unlock(UART_MODE_RS232); - //slip_arch_init(BAUD2UBR(115200)); - - cc1020_init(cc1020_config_19200); - - // network configuration - node_id_restore(); - - nullmac_init(&cc1020_driver); - rime_init(&nullmac_driver); - set_rime_addr(); +#if WITH_UIP + slip_arch_init(BAUD2UBR(115200)); +#endif /* System services */ process_start(&etimer_process, NULL); //process_start(&sensors_process, NULL); + //cc1020_init(cc1020_config_19200); + + // network configuration + node_id_restore(); + +#if WITH_UIP + uip_init(); + uip_sethostaddr(&slipif.ipaddr); + uip_setnetmask(&slipif.netmask); + uip_fw_default(&slipif); /* Point2point, no default router. */ + tcpip_set_forwarding(0); +#endif /* WITH_UIP */ + + nullmac_init(&cc1020_driver); + rime_init(&nullmac_driver); + set_rime_addr(); + +#if WITH_UIP + process_start(&tcpip_process, NULL); + process_start(&uip_fw_process, NULL); /* Start IP output */ + process_start(&slip_process, NULL); +#endif /* WITH_UIP */ + leds_off(LEDS_ALL); - - printf("Autostarting processes\n"); + lpm_on(); autostart_start((struct process **) autostart_processes); for (;;) { - while (process_run()); - if (process_nevents() == 0) - LPM1; + while (process_run() > 0); + if (process_nevents() == 0) { + LPM_SLEEP(); + } } return 0; diff --git a/platform/msb430/dev/cc1020.c b/platform/msb430/dev/cc1020.c index d020bfead..b74e312c2 100644 --- a/platform/msb430/dev/cc1020.c +++ b/platform/msb430/dev/cc1020.c @@ -552,7 +552,6 @@ cc1020_reset(void) static int cc1020_calibrate(void) { - unsigned char tmp; unsigned int timeout_cnt; // Turn off PA to avoid spurs during calibration in TX mode @@ -561,22 +560,20 @@ cc1020_calibrate(void) // Start calibration cc1020_write_reg(CC1020_CALIBRATE, 0xB5); clock_delay(1200); - while ((tmp = cc1020_read_reg(CC1020_STATUS) & CAL_COMPLETE) == 0); + while ((cc1020_read_reg(CC1020_STATUS) & CAL_COMPLETE) == 0); clock_delay(800); // Monitor lock - timeout_cnt = LOCK_TIMEOUT; - - do { - tmp = cc1020_read_reg(CC1020_STATUS); - } while (tmp & LOCK_CONTINUOUS && --timeout_cnt > 0); + for (timeout_cnt = LOCK_TIMEOUT; timeout_cnt > 0; timeout_cnt--) { + if (cc1020_read_reg(CC1020_STATUS) & LOCK_CONTINUOUS) + break; + } // Restore PA_POWER cc1020_write_reg(CC1020_PA_POWER, cc1020_pa_power); // Return state of LOCK_CONTINUOUS bit - return (cc1020_read_reg(CC1020_STATUS) & LOCK_CONTINUOUS) == - LOCK_CONTINUOUS; + return (cc1020_read_reg(CC1020_STATUS) & LOCK_CONTINUOUS) == LOCK_CONTINUOUS; } static int