add vendor peek, change cdc peek signature, change cdc read_char() return from signed char to int32_t
This commit is contained in:
		
							
								
								
									
										6
									
								
								src/class/vendor/vendor_device.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								src/class/vendor/vendor_device.c
									
									
									
									
										vendored
									
									
								
							| @@ -62,7 +62,6 @@ CFG_TUSB_MEM_SECTION static vendord_interface_t _vendord_itf[CFG_TUD_VENDOR]; | ||||
| #define ITF_MEM_RESET_SIZE   offsetof(vendord_interface_t, rx_ff) | ||||
|  | ||||
|  | ||||
|  | ||||
| bool tud_vendor_n_mounted (uint8_t itf) | ||||
| { | ||||
|   return _vendord_itf[itf].ep_in && _vendord_itf[itf].ep_out; | ||||
| @@ -73,6 +72,11 @@ uint32_t tud_vendor_n_available (uint8_t itf) | ||||
|   return tu_fifo_count(&_vendord_itf[itf].rx_ff); | ||||
| } | ||||
|  | ||||
| bool tud_vendor_n_peek(uint8_t itf, int pos, uint8_t* u8) | ||||
| { | ||||
|   return tu_fifo_peek_at(&_vendord_itf[itf].rx_ff, pos, u8); | ||||
| } | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // Read API | ||||
| //--------------------------------------------------------------------+ | ||||
|   | ||||
							
								
								
									
										36
									
								
								src/class/vendor/vendor_device.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										36
									
								
								src/class/vendor/vendor_device.h
									
									
									
									
										vendored
									
									
								
							| @@ -34,14 +34,6 @@ | ||||
| #define CFG_TUD_VENDOR_EPSIZE     64 | ||||
| #endif | ||||
|  | ||||
| #ifndef CFG_TUD_VENDOR_RX_BUFSIZE | ||||
| #define CFG_TUD_VENDOR_RX_BUFSIZE 0 | ||||
| #endif | ||||
|  | ||||
| #ifndef CFG_TUD_VENDOR_TX_BUFSIZE | ||||
| #define CFG_TUD_VENDOR_TX_BUFSIZE 0 | ||||
| #endif | ||||
|  | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| #endif | ||||
| @@ -49,21 +41,24 @@ | ||||
| //--------------------------------------------------------------------+ | ||||
| // Application API (Multiple Interfaces) | ||||
| //--------------------------------------------------------------------+ | ||||
| bool     tud_vendor_n_mounted    (uint8_t itf); | ||||
| uint32_t tud_vendor_n_available  (uint8_t itf); | ||||
| uint32_t tud_vendor_n_read       (uint8_t itf, void* buffer, uint32_t bufsize); | ||||
| uint32_t tud_vendor_n_write      (uint8_t itf, void const* buffer, uint32_t bufsize); | ||||
| bool     tud_vendor_n_mounted   (uint8_t itf); | ||||
| uint32_t tud_vendor_n_available (uint8_t itf); | ||||
| uint32_t tud_vendor_n_read      (uint8_t itf, void* buffer, uint32_t bufsize); | ||||
| bool     tud_vendor_n_peek      (uint8_t itf, int pos, uint8_t* u8); | ||||
| uint32_t tud_vendor_n_write     (uint8_t itf, void const* buffer, uint32_t bufsize); | ||||
|  | ||||
| static inline uint32_t tud_vendor_n_write_str  (uint8_t itf, char const* str); | ||||
| static inline | ||||
| uint32_t tud_vendor_n_write_str (uint8_t itf, char const* str); | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // Application API (Single Port) | ||||
| //--------------------------------------------------------------------+ | ||||
| static inline bool     tud_vendor_mounted    (void); | ||||
| static inline uint32_t tud_vendor_available  (void); | ||||
| static inline uint32_t tud_vendor_read       (void* buffer, uint32_t bufsize); | ||||
| static inline uint32_t tud_vendor_write      (void const* buffer, uint32_t bufsize); | ||||
| static inline uint32_t tud_vendor_write_str  (char const* str); | ||||
| static inline bool     tud_vendor_mounted   (void); | ||||
| static inline uint32_t tud_vendor_available (void); | ||||
| static inline uint32_t tud_vendor_read      (void* buffer, uint32_t bufsize); | ||||
| static inline bool     tud_vendor_peek      (int pos, uint8_t* u8); | ||||
| static inline uint32_t tud_vendor_write     (void const* buffer, uint32_t bufsize); | ||||
| static inline uint32_t tud_vendor_write_str (char const* str); | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // Application Callback API (weak is optional) | ||||
| @@ -96,6 +91,11 @@ static inline uint32_t tud_vendor_read (void* buffer, uint32_t bufsize) | ||||
|   return tud_vendor_n_read(0, buffer, bufsize); | ||||
| } | ||||
|  | ||||
| static inline bool tud_vendor_peek (int pos, uint8_t* u8) | ||||
| { | ||||
|   return tud_vendor_n_peek(0, pos, u8); | ||||
| } | ||||
|  | ||||
| static inline uint32_t tud_vendor_write (void const* buffer, uint32_t bufsize) | ||||
| { | ||||
|   return tud_vendor_n_write(0, buffer, bufsize); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 hathach
					hathach