boart test board
Dependencies: USBDevice mbed-dev lwip
Fork of USBSerial_HelloWorld by
main.cpp
- Committer:
- ua1arn
- Date:
- 2018-07-24
- Revision:
- 16:07f39e7a1cc2
- Parent:
- 15:825cce18de03
- Child:
- 19:8b7595ced647
File content as of revision 16:07f39e7a1cc2:
#include "mbed.h" #include "USBSerial.h" static USBSerial pc(0xFFFF, 0x0002, 0x0001); //static DigitalOut beep(PB_11); static PwmOut beep(PB_11); /**TIM3 GPIO Configuration PA7 ------> TIM3_CH2 PB0 ------> TIM3_CH3 !!!! PB1 ------> TIM3_CH4 PB4 ------> TIM3_CH1 */ /**TIM4 GPIO Configuration PD12 ------> TIM4_CH1 PD13 ------> TIM4_CH2 */ static DigitalIn button(PE_2); static DigitalIn opn_sw(PD_7); /* static DigitalOut din(PA_7); static DigitalOut din_light(PB_1); static DigitalOut ud_pwm(PD_12); static DigitalOut lr_pwm(PD_13); */ static Serial bt(PG_14, PG_9, 9600); // tx, rx USART6 work static Serial rfid(PD_5, PD_6, 9600); // tx, rx USART2 work static Serial wifi(PA_9, PA_10, 9600); // tx, rx USART1 work static Serial fifi2(PB_10, PC_5, 9600); // tx, rx USART3 - overlap with STDIO USART #define I2CADDR1 0xBE // 7 bits: 0x5F #define I2CADDR2 0xD6 // 7 bits: 0x6B // LwIP timers support extern "C" uint32_t sys_now() { return 0; } static I2C i2c(PB_9, PB_8); int main(void) { //wifi.baud(115200); //wifi2.baud(115200); beep.period_us(20000); beep.write((float) 0.01); // duty /* din = 1; din_light = 1; ud_pwm = 1; lr_pwm = 1; */ int i = 1; int devices_found; uint8_t curr_addr; char data[1] = {'\0'}; pc.printf("\r\n"); pc.printf("Program begin\r\n"); wait(1) ; while(0) { devices_found = 0; //beep = !beep; for (i = 0; i < 128; i++) { curr_addr = i << 1; if (!i2c.write(curr_addr, data, 1)) { pc.printf("found device at 0x%x\r\n", curr_addr); devices_found++; } wait(0.2); } pc.printf("%d devices found\r\n", devices_found); wait(2) ; } while(1) { beep.period_us(20000); pc.printf("I am a virtual serial port - phase a1, btn=%d\r\n", (int) opn_sw.read()); wait((float)0.2) ; beep.period_us(5000); pc.printf("I am a virtual serial port - phase a2, btn=%d\r\n", (int) opn_sw.read()); wait((float)0.2) ; } }