Merge branch 'master' of github.com:HiFiPhile/tinyusb into vendor_fifo
This commit is contained in:
		
							
								
								
									
										48
									
								
								src/class/vendor/vendor_device.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										48
									
								
								src/class/vendor/vendor_device.c
									
									
									
									
										vendored
									
									
								
							| @@ -202,27 +202,63 @@ uint32_t tud_vendor_n_write_available (uint8_t itf) | ||||
| //--------------------------------------------------------------------+ | ||||
| // USBD Driver API | ||||
| //--------------------------------------------------------------------+ | ||||
| void vendord_init(void) | ||||
| { | ||||
| void vendord_init(void) { | ||||
|   tu_memclr(_vendord_itf, sizeof(_vendord_itf)); | ||||
|  | ||||
|   for(uint8_t i=0; i<CFG_TUD_VENDOR; i++) | ||||
|   { | ||||
|   for(uint8_t i=0; i<CFG_TUD_VENDOR; i++) { | ||||
| #if CFG_TUD_VENDOR_RX_BUFSIZE > 0 || CFG_TUD_VENDOR_TX_BUFSIZE > 0 | ||||
|     vendord_interface_t* p_itf = &_vendord_itf[i]; | ||||
| #endif | ||||
|     // config fifo | ||||
| #if CFG_TUD_VENDOR_RX_BUFSIZE > 0 | ||||
|     tu_fifo_config(&p_itf->rx_ff, p_itf->rx_ff_buf, CFG_TUD_VENDOR_RX_BUFSIZE, 1, false); | ||||
|     tu_fifo_config_mutex(&p_itf->rx_ff, NULL, osal_mutex_create(&p_itf->rx_ff_mutex)); | ||||
|  | ||||
|     #if OSAL_MUTEX_REQUIRED | ||||
|     osal_mutex_t mutex_rd = osal_mutex_create(&p_itf->rx_ff_mutex); | ||||
|     TU_ASSERT(mutex_rd,); | ||||
|     tu_fifo_config_mutex(&p_itf->rx_ff, NULL, mutex_rd); | ||||
|     #endif | ||||
| #endif | ||||
| #if CFG_TUD_VENDOR_TX_BUFSIZE > 0 | ||||
|     tu_fifo_config(&p_itf->tx_ff, p_itf->tx_ff_buf, CFG_TUD_VENDOR_TX_BUFSIZE, 1, false); | ||||
|     tu_fifo_config_mutex(&p_itf->tx_ff, osal_mutex_create(&p_itf->tx_ff_mutex), NULL); | ||||
|  | ||||
|     #if OSAL_MUTEX_REQUIRED | ||||
|     osal_mutex_t mutex_wr = osal_mutex_create(&p_itf->tx_ff_mutex); | ||||
|     TU_ASSERT(mutex_wr,); | ||||
|     tu_fifo_config_mutex(&p_itf->tx_ff, mutex_wr, NULL); | ||||
|     #endif | ||||
| #endif | ||||
|   } | ||||
| } | ||||
|  | ||||
| bool vendord_deinit(void) { | ||||
| #if OSAL_MUTEX_REQUIRED | ||||
|   #if CFG_TUD_VENDOR_RX_BUFSIZE > 0 | ||||
|   for(uint8_t i=0; i<CFG_TUD_VENDOR; i++) { | ||||
|     vendord_interface_t* p_itf = &_vendord_itf[i]; | ||||
|     osal_mutex_t mutex_rd = p_itf->rx_ff.mutex_rd; | ||||
|  | ||||
|     if (mutex_rd) { | ||||
|       osal_mutex_delete(mutex_rd); | ||||
|       tu_fifo_config_mutex(&p_itf->rx_ff, NULL, NULL); | ||||
|     } | ||||
|   } | ||||
|   #endif | ||||
|   #if CFG_TUD_VENDOR_TX_BUFSIZE > 0 | ||||
|   for(uint8_t i=0; i<CFG_TUD_VENDOR; i++) { | ||||
|     vendord_interface_t* p_itf = &_vendord_itf[i]; | ||||
|     osal_mutex_t mutex_wr = p_itf->tx_ff.mutex_wr; | ||||
|  | ||||
|     if (mutex_wr) { | ||||
|       osal_mutex_delete(mutex_wr); | ||||
|       tu_fifo_config_mutex(&p_itf->tx_ff, NULL, NULL); | ||||
|     } | ||||
|   } | ||||
|   #endif | ||||
| #endif | ||||
|   return true; | ||||
| } | ||||
|  | ||||
| void vendord_reset(uint8_t rhport) | ||||
| { | ||||
|   (void) rhport; | ||||
|   | ||||
							
								
								
									
										1
									
								
								src/class/vendor/vendor_device.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								src/class/vendor/vendor_device.h
									
									
									
									
										vendored
									
									
								
							| @@ -161,6 +161,7 @@ static inline uint32_t tud_vendor_write_available (void) | ||||
| // Internal Class Driver API | ||||
| //--------------------------------------------------------------------+ | ||||
| void     vendord_init(void); | ||||
| bool     vendord_deinit(void); | ||||
| void     vendord_reset(uint8_t rhport); | ||||
| uint16_t vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len); | ||||
| bool     vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 HiFiPhile
					HiFiPhile