You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					40 lines
				
				1.3 KiB
			
		
		
			
		
	
	
					40 lines
				
				1.3 KiB
			| 
								 
											3 weeks ago
										 
									 | 
							
								#pragma once
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// ***************************** Definitions *****************************
							 | 
						||
| 
								 | 
							
								#define FIFO_SIZE_INT 0x400U
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct uart_ring {
							 | 
						||
| 
								 | 
							
								  volatile uint16_t w_ptr_tx;
							 | 
						||
| 
								 | 
							
								  volatile uint16_t r_ptr_tx;
							 | 
						||
| 
								 | 
							
								  uint8_t *elems_tx;
							 | 
						||
| 
								 | 
							
								  uint32_t tx_fifo_size;
							 | 
						||
| 
								 | 
							
								  volatile uint16_t w_ptr_rx;
							 | 
						||
| 
								 | 
							
								  volatile uint16_t r_ptr_rx;
							 | 
						||
| 
								 | 
							
								  uint8_t *elems_rx;
							 | 
						||
| 
								 | 
							
								  uint32_t rx_fifo_size;
							 | 
						||
| 
								 | 
							
								  USART_TypeDef *uart;
							 | 
						||
| 
								 | 
							
								  void (*callback)(struct uart_ring*);
							 | 
						||
| 
								 | 
							
								  bool overwrite;
							 | 
						||
| 
								 | 
							
								} uart_ring;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// ***************************** Function prototypes *****************************
							 | 
						||
| 
								 | 
							
								void debug_ring_callback(uart_ring *ring);
							 | 
						||
| 
								 | 
							
								void uart_tx_ring(uart_ring *q);
							 | 
						||
| 
								 | 
							
								uart_ring *get_ring_by_number(int a);
							 | 
						||
| 
								 | 
							
								// ************************* Low-level buffer functions *************************
							 | 
						||
| 
								 | 
							
								bool get_char(uart_ring *q, char *elem);
							 | 
						||
| 
								 | 
							
								bool injectc(uart_ring *q, char elem);
							 | 
						||
| 
								 | 
							
								bool put_char(uart_ring *q, char elem);
							 | 
						||
| 
								 | 
							
								void clear_uart_buff(uart_ring *q);
							 | 
						||
| 
								 | 
							
								// ************************ High-level debug functions **********************
							 | 
						||
| 
								 | 
							
								void putch(const char a);
							 | 
						||
| 
								 | 
							
								void print(const char *a);
							 | 
						||
| 
								 | 
							
								void puthx(uint32_t i, uint8_t len);
							 | 
						||
| 
								 | 
							
								void puth(unsigned int i);
							 | 
						||
| 
								 | 
							
								#if defined(DEBUG_SPI) || defined(BOOTSTUB) || defined(DEBUG)
							 | 
						||
| 
								 | 
							
								static void puth4(unsigned int i);
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								#if defined(DEBUG_SPI) || defined(DEBUG_USB) || defined(DEBUG_COMMS)
							 | 
						||
| 
								 | 
							
								static void hexdump(const void *a, int l);
							 | 
						||
| 
								 | 
							
								#endif
							 |