![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
test
Fork of HelloWorld by
Diff: main.cpp
- Revision:
- 29:3acc071af432
- Parent:
- 28:f56de0b0764e
- Child:
- 30:5881c661b0bb
--- a/main.cpp Fri Sep 08 05:50:44 2017 +0000 +++ b/main.cpp Fri Sep 29 16:34:22 2017 +0000 @@ -1,76 +1,37 @@ /**** Vincent Labbé - labv2507 *****/ -/**** Karan Kalsi - *****/ +/**** Karan Kalsi - kalk2701 *****/ #include "mbed.h" #include "MMA8452Q.h" +Serial xbee1(p13,p14); Serial pc(USBTX, USBRX); // tx, rx -//SPI spi(p11,p12,p13); -//DigitalOut cs(p14); -// Communication I2C -//I2C i2c(p9,p10); // sda, scl - -//int main() { - // } - - - -// on utilise l'afficheur 7 SEG en mode SPI pour la mise au point -SPI spi(p5, p6, p7); // mosi, miso, sclk -DigitalOut cs(p8); - -AnalogOut signal(p18); -AnalogIn ain(p20); -BusOut myleds(LED1, LED2, LED3, LED4); // for display 4 leds in hex format -unsigned short value; -Ticker display; +DigitalOut rst1(p8); //Digital reset for the XBee, 200ns for reset -short table[16] = { 0x00, // 0 0 - 1/16 - 0x00, // 1 1/16 - 1/8 - 0x01, // 2 1/8 - 3/16 - 0x01, // 3 3/16 - 1/4 - 0x01, // 4 1/4 - 5/16 - 0x01, // 5 5/16 - 3/8 - 0x03, // 6 3/8 - 7/16 - 0x03, // 7 7/16 - 1/2 - 0x03, // 8 1/2 - 9/16 - 0x03, // 9 9/16 - 5/8 - 0x07, // a 5/8 - 11/16 - 0x07, // b 11/16 - 3/4 - 0x07, // c 3/4 - 13/16 - 0x07, // d 13/16 - 7/8 - 0x0f, // e 7/8 - 15/16 - 0x0f}; // f 15/16 - 1 +int main() { + + rst1 = 0; //Set reset pin to 0 + wait_ms(400);//Wait at least one millisecond + rst1 = 1;//Set reset pin to 1 + //wait_ms(400);//Wait another millisecond + int Y; + + while (1) //Neverending Loop + { + + //uart vers pc + + if(xbee1.readable()) + { + pc.putc(xbee1.getc()); + } -void disp() { - short i; - value = ain.read_u16(); // read input - i = (value >> 12) & 0x000f; // transform to hex - - cs = 0; // affichage 7 SEG via SPI - wait_us(5); - spi.write(i); - wait_us(5); - cs = 1; - - myleds = table[i]; // affichage sur les LEDs -} + if(pc.readable()) + { + xbee1.putc(pc.getc()); + } -int main() { - spi.format(8,0); // initialisation du port SPI pour l'afficheur - spi.frequency(100000); - - cs = 0; - wait_us(5); - spi.write(0x76); //clear - wait_us(5); - cs = 1; - - display.attach(&disp, 0.1); // connexion de la fonction périodique aux 1/10 de seconde // roule constamment - while (1){ - } - -} + }