code beautify
This commit is contained in:
		| @@ -67,7 +67,7 @@ TUSB_CFG_ATTR_USBRAM static uint8_t serial_tx_buffer[CDCD_APP_BUFFER_SIZE]; | ||||
| FIFO_DEF(fifo_serial, CDCD_APP_BUFFER_SIZE, uint8_t, true); | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // tinyusb Callbacks | ||||
| // tinyusb callbacks | ||||
| //--------------------------------------------------------------------+ | ||||
| void tusbd_cdc_mounted_cb(uint8_t coreid) | ||||
| { | ||||
|   | ||||
| @@ -56,7 +56,7 @@ OSAL_TASK_DEF(keyboard_device_app_task, 128, KEYBOARD_APP_TASK_PRIO); | ||||
| TUSB_CFG_ATTR_USBRAM hid_keyboard_report_t keyboard_report; | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // tinyusb Callbacks | ||||
| // tinyusb callbacks | ||||
| //--------------------------------------------------------------------+ | ||||
| void tusbd_hid_keyboard_mounted_cb(uint8_t coreid) | ||||
| { | ||||
|   | ||||
| @@ -56,7 +56,7 @@ OSAL_TASK_DEF(mouse_device_app_task, 128, MOUSE_APP_TASK_PRIO); | ||||
| TUSB_CFG_ATTR_USBRAM hid_mouse_report_t mouse_report; | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // tinyusb Callbacks | ||||
| // tinyusb callbacks | ||||
| //--------------------------------------------------------------------+ | ||||
| void tusbd_hid_mouse_mounted_cb(uint8_t coreid) | ||||
| { | ||||
|   | ||||
| @@ -87,11 +87,7 @@ static scsi_mode_parameters_t const msc_dev_mode_para = | ||||
| }; | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // INTERNAL OBJECT & FUNCTION DECLARATION | ||||
| //--------------------------------------------------------------------+ | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // tinyusb callback (ISR context) | ||||
| // tinyusb callbacks | ||||
| //--------------------------------------------------------------------+ | ||||
| void tusbd_msc_mounted_cb(uint8_t coreid) | ||||
| { | ||||
| @@ -158,7 +154,7 @@ msc_csw_status_t tusbd_msc_scsi_cb (uint8_t coreid, uint8_t lun, uint8_t scsi_cm | ||||
| } | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // IMPLEMENTATION | ||||
| // APPLICATION CODE | ||||
| //--------------------------------------------------------------------+ | ||||
| OSAL_TASK_FUNCTION( msc_device_app_task , p_task_para) | ||||
| { // no need to implement the task yet | ||||
|   | ||||
| @@ -57,7 +57,7 @@ TUSB_CFG_ATTR_USBRAM static uint8_t serial_out_buffer[32]; | ||||
| static uint8_t received_bytes; // set by transfer complete callback | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // tinyusb Callbacks | ||||
| // tinyusb callbacks | ||||
| //--------------------------------------------------------------------+ | ||||
| void tusbh_cdc_mounted_cb(uint8_t dev_addr) | ||||
| { // application set-up | ||||
| @@ -76,6 +76,7 @@ void tusbh_cdc_unmounted_cb(uint8_t dev_addr) | ||||
|   printf("\na CDC device (address %d) is unmounted \n", dev_addr); | ||||
| } | ||||
|  | ||||
| // invoked ISR context | ||||
| void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) | ||||
| { | ||||
|   (void) dev_addr; // compiler warnings | ||||
|   | ||||
| @@ -62,7 +62,7 @@ static inline uint8_t keycode_to_ascii(uint8_t modifier, uint8_t keycode) ATTR_C | ||||
| static inline void process_kbd_report(hid_keyboard_report_t const * report); | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // tinyusb callback (ISR context) | ||||
| // tinyusb callbacks | ||||
| //--------------------------------------------------------------------+ | ||||
| void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr) | ||||
| { | ||||
| @@ -79,6 +79,7 @@ void tusbh_hid_keyboard_unmounted_cb(uint8_t dev_addr) | ||||
|   printf("\na Keyboard device (address %d) is unmounted\n", dev_addr); | ||||
| } | ||||
|  | ||||
| // invoked ISR context | ||||
| void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event) | ||||
| { | ||||
|   switch(event) | ||||
| @@ -132,9 +133,8 @@ OSAL_TASK_FUNCTION( keyboard_host_app_task, p_task_para) | ||||
| //--------------------------------------------------------------------+ | ||||
| // HELPER | ||||
| //--------------------------------------------------------------------+ | ||||
|  | ||||
| // look up new key in previous keys | ||||
| static inline bool is_key_in_report(hid_keyboard_report_t const *p_report, uint8_t keycode) | ||||
| static inline bool find_key_in_report(hid_keyboard_report_t const *p_report, uint8_t keycode) | ||||
| { | ||||
|   for(uint8_t i=0; i<6; i++) | ||||
|   { | ||||
| @@ -153,12 +153,12 @@ static inline void process_kbd_report(hid_keyboard_report_t const *p_new_report) | ||||
|   { | ||||
|     if ( p_new_report->keycode[i] ) | ||||
|     { | ||||
|       if ( is_key_in_report(&prev_report, p_new_report->keycode[i]) ) | ||||
|       if ( find_key_in_report(&prev_report, p_new_report->keycode[i]) ) | ||||
|       { | ||||
|         // exist in previous report means the current key is holding | ||||
|       }else | ||||
|       { | ||||
|         // not exist in previous report means the current key is pressed | ||||
|         // not existed in previous report means the current key is pressed | ||||
|         uint8_t ch = keycode_to_ascii(p_new_report->modifier, p_new_report->keycode[i]); | ||||
|         putchar(ch); | ||||
|         if ( ch == '\r' ) putchar('\n'); // added new line for enter key | ||||
|   | ||||
| @@ -61,7 +61,7 @@ TUSB_CFG_ATTR_USBRAM static hid_mouse_report_t usb_mouse_report; | ||||
| static inline void process_mouse_report(hid_mouse_report_t const * p_report); | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // tinyusb callback (ISR context) | ||||
| // tinyusb callbacks | ||||
| //--------------------------------------------------------------------+ | ||||
| void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr) | ||||
| { | ||||
| @@ -78,6 +78,7 @@ void tusbh_hid_mouse_unmounted_cb(uint8_t dev_addr) | ||||
|   printf("\na Mouse device (address %d) is unmounted\n", dev_addr); | ||||
| } | ||||
|  | ||||
| // invoked ISR context | ||||
| void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event) | ||||
| { | ||||
|   switch(event) | ||||
| @@ -97,7 +98,7 @@ void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event) | ||||
| } | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // APPLICATION | ||||
| // APPLICATION CODE | ||||
| // NOTICE: MOUSE REPORT IS NOT CORRECT UNTIL A DECENT HID PARSER IS | ||||
| // IMPLEMENTED, MEANWHILE IT CAN MISS DISPLAY BUTTONS OR X,Y etc | ||||
| //--------------------------------------------------------------------+ | ||||
|   | ||||
| @@ -60,7 +60,7 @@ OSAL_TASK_DEF(msc_host_app_task, 512, MSC_APP_TASK_PRIO); | ||||
| TUSB_CFG_ATTR_USBRAM static FATFS fatfs[TUSB_CFG_HOST_DEVICE_MAX]; | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // tinyusb callback (ISR context) | ||||
| // tinyusb callbacks | ||||
| //--------------------------------------------------------------------+ | ||||
| void tusbh_msc_mounted_cb(uint8_t dev_addr) | ||||
| { | ||||
| @@ -130,6 +130,7 @@ void tusbh_msc_unmounted_cb(uint8_t dev_addr) | ||||
|   } | ||||
| } | ||||
|  | ||||
| // invoked ISR context | ||||
| void tusbh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes) | ||||
| { | ||||
|   (void) dev_addr; | ||||
| @@ -138,7 +139,7 @@ void tusbh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes) | ||||
| } | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // IMPLEMENTATION | ||||
| // APPLICATION CODE | ||||
| //--------------------------------------------------------------------+ | ||||
| void msc_host_app_init(void) | ||||
| { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 hathach
					hathach