Fix AVR SPI parameter configuration, remove timeouts due to sync protocol. (#8775)
This commit is contained in:
		
							parent
							
								
									157d121c71
								
							
						
					
					
						commit
						46e4493761
					
				
					 4 changed files with 94 additions and 88 deletions
				
			
		| 
						 | 
				
			
			@ -152,7 +152,7 @@ static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) {
 | 
			
		|||
    bool     ready      = false;
 | 
			
		||||
 | 
			
		||||
    do {
 | 
			
		||||
        ready = spi_write(msg->type, 100) != SdepSlaveNotReady;
 | 
			
		||||
        ready = spi_write(msg->type) != SdepSlaveNotReady;
 | 
			
		||||
        if (ready) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -165,7 +165,7 @@ static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) {
 | 
			
		|||
 | 
			
		||||
    if (ready) {
 | 
			
		||||
        // Slave is ready; send the rest of the packet
 | 
			
		||||
        spi_transmit(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload)) + msg->len, 100);
 | 
			
		||||
        spi_transmit(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload)) + msg->len);
 | 
			
		||||
        success = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -205,7 +205,7 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
 | 
			
		|||
 | 
			
		||||
        do {
 | 
			
		||||
            // Read the command type, waiting for the data to be ready
 | 
			
		||||
            msg->type = spi_read(100);
 | 
			
		||||
            msg->type = spi_read();
 | 
			
		||||
            if (msg->type == SdepSlaveNotReady || msg->type == SdepSlaveOverflow) {
 | 
			
		||||
                // Release it and let it initialize
 | 
			
		||||
                spi_stop();
 | 
			
		||||
| 
						 | 
				
			
			@ -215,11 +215,11 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
 | 
			
		|||
            }
 | 
			
		||||
 | 
			
		||||
            // Read the rest of the header
 | 
			
		||||
            spi_receive(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload)), 100);
 | 
			
		||||
            spi_receive(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload)));
 | 
			
		||||
 | 
			
		||||
            // and get the payload if there is any
 | 
			
		||||
            if (msg->len <= SdepMaxPayload) {
 | 
			
		||||
                spi_receive(msg->payload, msg->len, 100);
 | 
			
		||||
                spi_receive(msg->payload, msg->len);
 | 
			
		||||
            }
 | 
			
		||||
            success = true;
 | 
			
		||||
            break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue