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) {
 | 
					    if(device == nullptr) {
 | 
				
			||||||
        result = false;
 | 
					        result = false;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
 | 
					        __disable_irq();
 | 
				
			||||||
        pin_init_opendrain_in_isr_ctx();
 | 
					        pin_init_opendrain_in_isr_ctx();
 | 
				
			||||||
        error = OneWireSlaveError::NO_ERROR;
 | 
					        error = OneWireSlaveError::NO_ERROR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(show_presence()) {
 | 
					        if(show_presence()) {
 | 
				
			||||||
            __disable_irq();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // TODO think about multiple command cycles
 | 
					            // TODO think about multiple command cycles
 | 
				
			||||||
            receive_and_process_cmd();
 | 
					            receive_and_process_cmd();
 | 
				
			||||||
            result =
 | 
					            result =
 | 
				
			||||||
                (error == OneWireSlaveError::NO_ERROR ||
 | 
					                (error == OneWireSlaveError::NO_ERROR ||
 | 
				
			||||||
                 error == OneWireSlaveError::INCORRECT_ONEWIRE_CMD);
 | 
					                 error == OneWireSlaveError::INCORRECT_ONEWIRE_CMD);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            __enable_irq();
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            result = false;
 | 
					            result = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pin_init_interrupt_in_isr_ctx();
 | 
					        pin_init_interrupt_in_isr_ctx();
 | 
				
			||||||
 | 
					        __enable_irq();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
 | 
				
			|||||||
@ -41,7 +41,7 @@ public:
 | 
				
			|||||||
    constexpr static const OneWiteTimeType RESET_MAX = 960;
 | 
					    constexpr static const OneWiteTimeType RESET_MAX = 960;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constexpr static const OneWiteTimeType PRESENCE_TIMEOUT = 20;
 | 
					    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 PRESENCE_MAX = 480;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constexpr static const OneWiteTimeType MSG_HIGH_TIMEOUT = 15000;
 | 
					    constexpr static const OneWiteTimeType MSG_HIGH_TIMEOUT = 15000;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user