This program is a initial connection test of mBed and Texas Instruments EZ430 Chronos Watch. The Chronos RF Access Point radio dongle is connected to mBed usb port , and it's configured as a usb host. The program uses the USBHostSerial library.
Chronos Test
- This program is a successful connection test between mBed and the watch EZ430 Chronos Development Tool from texas Instruments.
- The RF Access Point usb dongle, that comes with the watch, emulates a usb serial port when connected to a PC. I connected it to the mBed usb port , configured as host ( two 10 K ohms resistors from D+,D- to gnd , I know the recommended value is 15k ) and based the development on the USBHostSerial HelloWorld example program.
- The mBed leds are activated based on the button received from the watch : led2 goes on when the "*" button is pressed , led3 when the "#" button is pressed and led4 when the "up"button is pressed .
- In order to function , you have to select the "ppt control" mode on the chronos watch and after that , start the transmission pressing the "down" button on the watch.
Diff: main.cpp
- Revision:
- 0:54aa44094993
- Child:
- 1:461ba80810ce
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 30 02:07:46 2014 +0000 @@ -0,0 +1,84 @@ +#include "mbed.h" +#include "USBHostSerial.h" + +DigitalOut led(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +Serial pc(USBTX, USBRX); +int chronos_answer[10] ; + +void serial_task(void const*) { + USBHostSerial serial; + + + while(!serial.connect()) + Thread::wait(500); + + serial.baud(115200) ; + + pc.printf("chronos init ...\n") ; + + serial.putc(0xff) ; + serial.putc(0x07) ; + serial.putc(0x03) ; + pc.printf("chronos init completed ...\n") ; + + + while(1) { + while (1) { + + // send read request to chronos + serial.putc(0xFF); + serial.putc(0x08); + serial.putc(0x07); + serial.putc(0x00); + serial.putc(0x00); + serial.putc(0x00); + serial.putc(0x00); + Thread::wait(15); + + + // put received characters on an array + int i = 0 ; + while (serial.available()) { + int c_in = serial.getc() ; + chronos_answer[i++] = c_in ; + } + int button = chronos_answer[3] ; + if(button != 255) { + printf("Button received : %d\n", button ) ; + switch(button) { + case 18 : // * button + led2 = 1 ; + led3 = 0 ; + led4 = 0 ; + break ; + case 50 : // up button + led2 = 0 ; + led3 = 1 ; + led4 = 0 ; + break ; + case 34 : // # button + led2 = 0 ; + led3 = 0 ; + led4 = 1 ; + break ; + + } + } + + + Thread::wait(50); + } + } +} + +int main() { + Thread serialTask(serial_task, NULL, osPriorityNormal, 256 * 4); + while(1) { + led=!led; + Thread::wait(500); + } +} \ No newline at end of file