static int AOA_Host_getchar(FILE* Stream) { int16_t ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream)); if (ReceivedByte < 0) return _FDEV_EOF; return ReceivedByte; }
/** Task to manage an enumerated USB Android Accessory device once connected, to print received data * from the device to the serial port. */ void AOAHost_Task(void) { if (USB_HostState != HOST_STATE_Configured) return; if (AOA_Host_BytesReceived(&AndroidDevice_AOA_Interface)) { /* Echo received bytes from the attached device through the USART */ int16_t ReceivedByte = AOA_Host_ReceiveByte(&AndroidDevice_AOA_Interface); if (!(ReceivedByte < 0)) putchar(ReceivedByte); } }
static int AOA_Host_getchar_Blocking(FILE* Stream) { int16_t ReceivedByte; while ((ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream))) < 0) { if (USB_HostState == HOST_STATE_Unattached) return _FDEV_EOF; AOA_Host_USBTask((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream)); USB_USBTask(); } return ReceivedByte; }
/** Task to manage an enumerated USB Android Accessory device once connected, to print received data * from the device to the serial port. */ void AOAHost_Task(void) { if (USB_HostState != HOST_STATE_Configured) return; if (AOA_Host_BytesReceived(&AndroidDevice_AOA_Interface)) { /* Echo received bytes from the attached device through the USART */ int16_t ReceivedByte = AOA_Host_ReceiveByte(&AndroidDevice_AOA_Interface); if (!(ReceivedByte < 0)) { /* Turn on and off LED1 based on the bytes received */ LEDs_ChangeLEDs(LEDS_LED1, ReceivedByte ? LEDS_LED1 : LEDS_NO_LEDS); putchar(ReceivedByte); } } }