One wire slave: fix presence timing, disable irq early (#348)
This commit is contained in:
		
							parent
							
								
									d2200a00d1
								
							
						
					
					
						commit
						da91482b7d
					
				@ -256,24 +256,23 @@ bool OneWireSlave::bus_start(void) {
 | 
			
		||||
    if(device == nullptr) {
 | 
			
		||||
        result = false;
 | 
			
		||||
    } else {
 | 
			
		||||
        __disable_irq();
 | 
			
		||||
        pin_init_opendrain_in_isr_ctx();
 | 
			
		||||
        error = OneWireSlaveError::NO_ERROR;
 | 
			
		||||
 | 
			
		||||
        if(show_presence()) {
 | 
			
		||||
            __disable_irq();
 | 
			
		||||
 | 
			
		||||
            // TODO think about multiple command cycles
 | 
			
		||||
            receive_and_process_cmd();
 | 
			
		||||
            result =
 | 
			
		||||
                (error == OneWireSlaveError::NO_ERROR ||
 | 
			
		||||
                 error == OneWireSlaveError::INCORRECT_ONEWIRE_CMD);
 | 
			
		||||
 | 
			
		||||
            __enable_irq();
 | 
			
		||||
        } else {
 | 
			
		||||
            result = false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        pin_init_interrupt_in_isr_ctx();
 | 
			
		||||
        __enable_irq();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return result;
 | 
			
		||||
 | 
			
		||||
@ -41,7 +41,7 @@ public:
 | 
			
		||||
    constexpr static const OneWiteTimeType RESET_MAX = 960;
 | 
			
		||||
 | 
			
		||||
    constexpr static const OneWiteTimeType PRESENCE_TIMEOUT = 20;
 | 
			
		||||
    constexpr static const OneWiteTimeType PRESENCE_MIN = 160;
 | 
			
		||||
    constexpr static const OneWiteTimeType PRESENCE_MIN = 100;
 | 
			
		||||
    constexpr static const OneWiteTimeType PRESENCE_MAX = 480;
 | 
			
		||||
 | 
			
		||||
    constexpr static const OneWiteTimeType MSG_HIGH_TIMEOUT = 15000;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user