mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			RF802.11.4 S2LP driver sync with dev repository
Sync with version v1.0.1 in development repository.pull/12481/head
							parent
							
								
									85e85ee93a
								
							
						
					
					
						commit
						a5d85bd927
					
				| 
						 | 
				
			
			@ -209,8 +209,8 @@ static rf_mode_e rf_mode = RF_MODE_NORMAL;
 | 
			
		|||
static bool rf_update_config = false;
 | 
			
		||||
static uint16_t cur_packet_len = 0xffff;
 | 
			
		||||
static uint32_t receiver_ready_timestamp;
 | 
			
		||||
 | 
			
		||||
static int16_t rssi_threshold = RSSI_THRESHOLD;
 | 
			
		||||
static uint32_t tx_start_time = 0;
 | 
			
		||||
 | 
			
		||||
/* Channel configurations for sub-GHz */
 | 
			
		||||
static phy_rf_channel_configuration_s phy_subghz = {
 | 
			
		||||
| 
						 | 
				
			
			@ -276,6 +276,20 @@ static uint32_t rf_get_timestamp(void)
 | 
			
		|||
    return (uint32_t)rf->tx_timer.read_us();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void rf_update_tx_active_time(void)
 | 
			
		||||
{
 | 
			
		||||
    if (device_driver.phy_rf_statistics) {
 | 
			
		||||
        device_driver.phy_rf_statistics->tx_active_time += rf_get_timestamp() - tx_start_time;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void rf_update_rx_active_time(void)
 | 
			
		||||
{
 | 
			
		||||
    if (device_driver.phy_rf_statistics) {
 | 
			
		||||
        device_driver.phy_rf_statistics->rx_active_time += rf_get_timestamp() - rx_time;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void rf_lock(void)
 | 
			
		||||
{
 | 
			
		||||
    platform_enter_critical();
 | 
			
		||||
| 
						 | 
				
			
			@ -739,6 +753,7 @@ static void rf_tx_sent_handler(void)
 | 
			
		|||
    rf_disable_interrupt(TX_DATA_SENT);
 | 
			
		||||
    if (rf_state != RF_TX_ACK) {
 | 
			
		||||
        tx_finnish_time = rf_get_timestamp();
 | 
			
		||||
        rf_update_tx_active_time();
 | 
			
		||||
        TEST_TX_DONE
 | 
			
		||||
        rf_state = RF_IDLE;
 | 
			
		||||
        rf_receive(rf_rx_channel);
 | 
			
		||||
| 
						 | 
				
			
			@ -771,6 +786,7 @@ static void rf_start_tx(void)
 | 
			
		|||
    rf_disable_all_interrupts();
 | 
			
		||||
    rf_poll_state_change(S2LP_STATE_READY);
 | 
			
		||||
    rf_state_change(S2LP_STATE_TX, false);
 | 
			
		||||
    tx_start_time = rf_get_timestamp();
 | 
			
		||||
    // More TX data to be written in FIFO when TX threshold interrupt occurs
 | 
			
		||||
    if (tx_data_ptr) {
 | 
			
		||||
        rf_enable_interrupt(TX_FIFO_ALMOST_EMPTY);
 | 
			
		||||
| 
						 | 
				
			
			@ -805,6 +821,7 @@ static void rf_cca_timer_interrupt(void)
 | 
			
		|||
        }
 | 
			
		||||
        rf_flush_tx_fifo();
 | 
			
		||||
        tx_finnish_time = rf_get_timestamp();
 | 
			
		||||
        rf_update_tx_active_time();
 | 
			
		||||
        if (device_driver.phy_tx_done_cb) {
 | 
			
		||||
            device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_FAIL, 0, 0);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -825,6 +842,9 @@ static void rf_cca_timer_interrupt(void)
 | 
			
		|||
            rf_start_tx();
 | 
			
		||||
            rf_state = RF_TX_STARTED;
 | 
			
		||||
            TEST_TX_STARTED
 | 
			
		||||
            if (device_driver.phy_rf_statistics) {
 | 
			
		||||
                device_driver.phy_rf_statistics->tx_bytes += tx_data_length;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -843,10 +863,12 @@ static void rf_backup_timer_interrupt(void)
 | 
			
		|||
{
 | 
			
		||||
    tx_finnish_time = rf_get_timestamp();
 | 
			
		||||
    if (rf_state == RF_RX_STARTED) {
 | 
			
		||||
        rf_update_rx_active_time();
 | 
			
		||||
        if (device_driver.phy_rf_statistics) {
 | 
			
		||||
            device_driver.phy_rf_statistics->rx_timeouts++;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        rf_update_tx_active_time();
 | 
			
		||||
        if (device_driver.phy_rf_statistics) {
 | 
			
		||||
            device_driver.phy_rf_statistics->tx_timeouts++;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -921,6 +943,9 @@ static void rf_send_ack(uint8_t seq)
 | 
			
		|||
    rf_start_tx();
 | 
			
		||||
    TEST_ACK_TX_STARTED
 | 
			
		||||
    rf_backup_timer_start(ACK_SENDING_TIME);
 | 
			
		||||
    if (device_driver.phy_rf_statistics) {
 | 
			
		||||
        device_driver.phy_rf_statistics->tx_bytes += sizeof(ack_frame);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void rf_handle_ack(uint8_t seq_number, uint8_t pending)
 | 
			
		||||
| 
						 | 
				
			
			@ -928,6 +953,7 @@ static void rf_handle_ack(uint8_t seq_number, uint8_t pending)
 | 
			
		|||
    phy_link_tx_status_e phy_status;
 | 
			
		||||
    if (tx_sequence == (uint16_t)seq_number) {
 | 
			
		||||
        tx_finnish_time = rf_get_timestamp();
 | 
			
		||||
        rf_update_tx_active_time();
 | 
			
		||||
        if (pending) {
 | 
			
		||||
            phy_status = PHY_LINK_TX_DONE_PENDING;
 | 
			
		||||
        } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -966,6 +992,9 @@ static void rf_rx_ready_handler(void)
 | 
			
		|||
                rf_send_ack(rx_buffer[2]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (device_driver.phy_rf_statistics) {
 | 
			
		||||
            device_driver.phy_rf_statistics->rx_bytes += rx_data_length;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        rf_state = RF_IDLE;
 | 
			
		||||
        int8_t rssi = (rf_read_register(RSSI_LEVEL) - RSSI_OFFSET);
 | 
			
		||||
| 
						 | 
				
			
			@ -1072,6 +1101,7 @@ static void rf_irq_task_process_irq(void)
 | 
			
		|||
    if ((irq_status & (1 << TX_FIFO_UNF_OVF)) && (enabled_interrupts & (1 << TX_FIFO_UNF_OVF))) {
 | 
			
		||||
        rf_backup_timer_stop();
 | 
			
		||||
        tx_finnish_time = rf_get_timestamp();
 | 
			
		||||
        rf_update_tx_active_time();
 | 
			
		||||
        TEST_TX_DONE
 | 
			
		||||
        device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_FAIL, 1, 0);
 | 
			
		||||
        rf_send_command(S2LP_CMD_SABORT);
 | 
			
		||||
| 
						 | 
				
			
			@ -1087,6 +1117,7 @@ static void rf_irq_task_process_irq(void)
 | 
			
		|||
        }
 | 
			
		||||
    } else if (rf_state == RF_RX_STARTED) {
 | 
			
		||||
        if ((irq_status & (1 << RX_DATA_READY)) && (enabled_interrupts & (1 << RX_DATA_READY))) {
 | 
			
		||||
            rf_update_rx_active_time();
 | 
			
		||||
            if (!(irq_status & (1 << CRC_ERROR))) {
 | 
			
		||||
                rf_rx_ready_handler();
 | 
			
		||||
            } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -1112,6 +1143,7 @@ static void rf_irq_task_process_irq(void)
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if ((irq_status & (1 << RX_FIFO_UNF_OVF)) && (enabled_interrupts & (1 << RX_FIFO_UNF_OVF))) {
 | 
			
		||||
        rf_update_rx_active_time();
 | 
			
		||||
        TEST_RX_DONE
 | 
			
		||||
        rf_backup_timer_stop();
 | 
			
		||||
        rf_send_command(S2LP_CMD_SABORT);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue