@@ -28,31 +28,31 @@ static usb_error_t handle_usb_event(usb_event_t event, void *event_data,
2828 if ((err = srl_UsbEventCallback (event , event_data , callback_data )) != USB_SUCCESS )
2929 return err ;
3030 /* Enable newly connected devices */
31- if (event == USB_DEVICE_CONNECTED_EVENT && !(usb_GetRole () & USB_ROLE_DEVICE )) {
31+ if (event == USB_DEVICE_CONNECTED_EVENT && !(usb_GetRole () & USB_ROLE_DEVICE )) {
3232 usb_device_t device = event_data ;
3333 printf ("device connected\n" );
3434 usb_ResetDevice (device );
3535 }
3636
3737 /* Call srl_Open on newly enabled device, if there is not currently a serial device in use */
38- if (event == USB_HOST_CONFIGURE_EVENT || (event == USB_DEVICE_ENABLED_EVENT && !(usb_GetRole () & USB_ROLE_DEVICE ))) {
38+ if (event == USB_HOST_CONFIGURE_EVENT || (event == USB_DEVICE_ENABLED_EVENT && !(usb_GetRole () & USB_ROLE_DEVICE ))) {
3939
4040 /* If we already have a serial device, ignore the new one */
41- if (has_srl_device ) return USB_SUCCESS ;
41+ if (has_srl_device ) return USB_SUCCESS ;
4242
4343 usb_device_t device ;
44- if (event == USB_HOST_CONFIGURE_EVENT ) {
44+ if (event == USB_HOST_CONFIGURE_EVENT ) {
4545 /* Use the device representing the USB host. */
4646 device = usb_FindDevice (NULL , NULL , USB_SKIP_HUBS );
47- if (device == NULL ) return USB_SUCCESS ;
47+ if (device == NULL ) return USB_SUCCESS ;
4848 } else {
4949 /* Use the newly enabled device */
5050 device = event_data ;
5151 }
5252
5353 /* Initialize the serial library with the newly attached device */
5454 srl_error_t error = srl_Open (& srl , device , srl_buf , sizeof srl_buf , SRL_INTERFACE_ANY , 9600 );
55- if (error ) {
55+ if (error ) {
5656 /* Print the error code to the homescreen */
5757 printf ("Error %d initting serial\n" , error );
5858 return USB_SUCCESS ;
@@ -63,9 +63,9 @@ static usb_error_t handle_usb_event(usb_event_t event, void *event_data,
6363 has_srl_device = true;
6464 }
6565
66- if (event == USB_DEVICE_DISCONNECTED_EVENT ) {
66+ if (event == USB_DEVICE_DISCONNECTED_EVENT ) {
6767 usb_device_t device = event_data ;
68- if (device == srl .dev ) {
68+ if (device == srl .dev ) {
6969 printf ("device disconnected\n" );
7070 srl_Close (& srl );
7171 has_srl_device = false;
@@ -80,7 +80,7 @@ int main(void) {
8080 const usb_standard_descriptors_t * desc = srl_GetCDCStandardDescriptors ();
8181 /* Initialize the USB driver with our event handler and the serial device descriptors */
8282 usb_error_t usb_error = usb_Init (handle_usb_event , NULL , desc , USB_DEFAULT_INIT_FLAGS );
83- if (usb_error ) {
83+ if (usb_error ) {
8484 usb_Cleanup ();
8585 printf ("usb init error %u\n" , usb_error );
8686 do kb_Scan (); while (!kb_IsDown (kb_KeyClear ));
@@ -92,17 +92,17 @@ int main(void) {
9292
9393 usb_HandleEvents ();
9494
95- if (has_srl_device ) {
95+ if (has_srl_device ) {
9696 char in_buf [64 ];
9797
9898 /* Read up to 64 bytes from the serial buffer */
9999 size_t bytes_read = srl_Read (& srl , in_buf , sizeof in_buf );
100100
101101 /* Check for an error (e.g. device disconneced) */
102- if (bytes_read < 0 ) {
102+ if (bytes_read < 0 ) {
103103 printf ("error %d on srl_Read\n" , bytes_read );
104104 has_srl_device = false;
105- } else if (bytes_read > 0 ) {
105+ } else if (bytes_read > 0 ) {
106106 /* Write the data back to serial */
107107 srl_Write (& srl , in_buf , bytes_read );
108108 }
0 commit comments