Added argument to HardwareSerial.begin to specify whether the logic levels of the UART rx and tx lines should be inverted (#719)
This commit is contained in:
		
							parent
							
								
									cabc4c5bb5
								
							
						
					
					
						commit
						e6a5b68e40
					
				| @ -9,7 +9,7 @@ HardwareSerial Serial(0); | ||||
| 
 | ||||
| HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL) {} | ||||
| 
 | ||||
| void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin) | ||||
| void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert) | ||||
| { | ||||
|     if(0 > _uart_nr || _uart_nr > 2) { | ||||
|         log_e("Serial number is invalid, please use 0, 1 or 2"); | ||||
| @ -30,7 +30,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in | ||||
|         rxPin = 16; | ||||
|         txPin = 17; | ||||
|     } | ||||
|     _uart = uartBegin(_uart_nr, baud, config, rxPin, txPin, 256, false); | ||||
|     _uart = uartBegin(_uart_nr, baud, config, rxPin, txPin, 256, invert); | ||||
| } | ||||
| 
 | ||||
| void HardwareSerial::end() | ||||
|  | ||||
| @ -37,7 +37,7 @@ class HardwareSerial: public Stream | ||||
| public: | ||||
|     HardwareSerial(int uart_nr); | ||||
| 
 | ||||
|     void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1); | ||||
|     void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1, bool invert=false); | ||||
|     void end(); | ||||
|     int available(void); | ||||
|     int peek(void); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user