Hack STM32F405 on the PHS Shield

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002  * select: Nucleo F401RE
00003  */
00004 #include "mbed.h"
00005 
00006 Serial pc(PB_6, PB_7);
00007 
00008 Serial phs(PA_2, PA_3);
00009 DigitalOut rts(PA_1);
00010 DigitalIn cts(PA_0);
00011 
00012 DigitalOut led1(PC_6), led2(PC_7);
00013 DigitalOut pwr1(PC_9);
00014 DigitalIn pwr2(PA_8);
00015 
00016 
00017 int main() {
00018     pc.baud(115200);
00019     phs.baud(120000);
00020     pwr1 = 0; // DCDC enable
00021     pwr2.mode(PullUp);
00022     GPIOB->MODER = (GPIOB->MODER & ~(3<<22)) | (1<<22); // PB_11 output
00023     GPIOB->OTYPER = (1<<11); // open drain
00024     GPIOB->ODR &= ~(1<<11); // reser=0
00025 //    phs.set_flow_control(Serial::RTSCTS, PA_1, PA_0);
00026     cts.mode(PullUp);
00027     rts = 0;
00028     wait_ms(100);
00029     GPIOB->MODER &= ~(3<<22); // PB_11 input
00030     GPIOB->PUPDR = (GPIOB->MODER & ~(3<<22)) | (1<<22); // pullup
00031 
00032     pc.printf("*** PHSShield STM32F405\r\n");    
00033 
00034     for (;;) {
00035         if (phs.readable()) {
00036             pc.putc(phs.getc());
00037         }
00038         if (pc.readable()) {
00039             phs.putc(pc.getc());
00040         }
00041         led2 = cts;
00042     }
00043 }