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.

Dependencies:   USBHost mbed

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.

/media/uploads/jeroavf/img_20140730_101232.jpg

  • 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.
Committer:
jeroavf
Date:
Wed Jul 30 02:16:30 2014 +0000
Revision:
1:461ba80810ce
Parent:
0:54aa44094993
Excluding a redundant while (1) loop

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jeroavf 0:54aa44094993 1 #include "mbed.h"
jeroavf 0:54aa44094993 2 #include "USBHostSerial.h"
jeroavf 1:461ba80810ce 3
jeroavf 0:54aa44094993 4 DigitalOut led(LED1);
jeroavf 0:54aa44094993 5 DigitalOut led2(LED2);
jeroavf 0:54aa44094993 6 DigitalOut led3(LED3);
jeroavf 0:54aa44094993 7 DigitalOut led4(LED4);
jeroavf 0:54aa44094993 8
jeroavf 0:54aa44094993 9 Serial pc(USBTX, USBRX);
jeroavf 1:461ba80810ce 10 int chronos_answer[10] ;
jeroavf 1:461ba80810ce 11
jeroavf 1:461ba80810ce 12 void serial_task(void const*)
jeroavf 1:461ba80810ce 13 {
jeroavf 0:54aa44094993 14 USBHostSerial serial;
jeroavf 1:461ba80810ce 15
jeroavf 0:54aa44094993 16
jeroavf 0:54aa44094993 17 while(!serial.connect())
jeroavf 0:54aa44094993 18 Thread::wait(500);
jeroavf 1:461ba80810ce 19
jeroavf 1:461ba80810ce 20 serial.baud(115200) ;
jeroavf 0:54aa44094993 21
jeroavf 0:54aa44094993 22 pc.printf("chronos init ...\n") ;
jeroavf 0:54aa44094993 23
jeroavf 0:54aa44094993 24 serial.putc(0xff) ;
jeroavf 0:54aa44094993 25 serial.putc(0x07) ;
jeroavf 0:54aa44094993 26 serial.putc(0x03) ;
jeroavf 0:54aa44094993 27 pc.printf("chronos init completed ...\n") ;
jeroavf 1:461ba80810ce 28
jeroavf 1:461ba80810ce 29
jeroavf 0:54aa44094993 30 while(1) {
jeroavf 1:461ba80810ce 31
jeroavf 1:461ba80810ce 32 // send read request to chronos
jeroavf 1:461ba80810ce 33 serial.putc(0xFF);
jeroavf 1:461ba80810ce 34 serial.putc(0x08);
jeroavf 1:461ba80810ce 35 serial.putc(0x07);
jeroavf 1:461ba80810ce 36 serial.putc(0x00);
jeroavf 1:461ba80810ce 37 serial.putc(0x00);
jeroavf 1:461ba80810ce 38 serial.putc(0x00);
jeroavf 1:461ba80810ce 39 serial.putc(0x00);
jeroavf 1:461ba80810ce 40 Thread::wait(15);
jeroavf 1:461ba80810ce 41
jeroavf 0:54aa44094993 42
jeroavf 1:461ba80810ce 43 // put received characters on an array
jeroavf 1:461ba80810ce 44 int i = 0 ;
jeroavf 1:461ba80810ce 45 while (serial.available()) {
jeroavf 1:461ba80810ce 46 int c_in = serial.getc() ;
jeroavf 1:461ba80810ce 47 chronos_answer[i++] = c_in ;
jeroavf 1:461ba80810ce 48 }
jeroavf 1:461ba80810ce 49 int button = chronos_answer[3] ;
jeroavf 1:461ba80810ce 50 if(button != 255) {
jeroavf 1:461ba80810ce 51 printf("Button received : %d\n", button ) ;
jeroavf 1:461ba80810ce 52 switch(button) {
jeroavf 1:461ba80810ce 53 case 18 : // * button
jeroavf 1:461ba80810ce 54 led2 = 1 ;
jeroavf 1:461ba80810ce 55 led3 = 0 ;
jeroavf 1:461ba80810ce 56 led4 = 0 ;
jeroavf 1:461ba80810ce 57 break ;
jeroavf 1:461ba80810ce 58 case 50 : // up button
jeroavf 1:461ba80810ce 59 led2 = 0 ;
jeroavf 1:461ba80810ce 60 led3 = 1 ;
jeroavf 1:461ba80810ce 61 led4 = 0 ;
jeroavf 1:461ba80810ce 62 break ;
jeroavf 1:461ba80810ce 63 case 34 : // # button
jeroavf 1:461ba80810ce 64 led2 = 0 ;
jeroavf 1:461ba80810ce 65 led3 = 0 ;
jeroavf 1:461ba80810ce 66 led4 = 1 ;
jeroavf 1:461ba80810ce 67 break ;
jeroavf 0:54aa44094993 68
jeroavf 0:54aa44094993 69 }
jeroavf 0:54aa44094993 70 }
jeroavf 1:461ba80810ce 71
jeroavf 1:461ba80810ce 72
jeroavf 1:461ba80810ce 73 Thread::wait(50);
jeroavf 1:461ba80810ce 74
jeroavf 0:54aa44094993 75 }
jeroavf 0:54aa44094993 76 }
jeroavf 1:461ba80810ce 77
jeroavf 1:461ba80810ce 78 int main()
jeroavf 1:461ba80810ce 79 {
jeroavf 0:54aa44094993 80 Thread serialTask(serial_task, NULL, osPriorityNormal, 256 * 4);
jeroavf 0:54aa44094993 81 while(1) {
jeroavf 0:54aa44094993 82 led=!led;
jeroavf 0:54aa44094993 83 Thread::wait(500);
jeroavf 0:54aa44094993 84 }
jeroavf 0:54aa44094993 85 }