20 #include "nrf_assert.h"
59 *p_vrect_high = has_dynamic_vrect_high ?
63 *p_vrect_min = has_dynamic_vrect_min ?
75 bool * p_reduced_positive_step_size,
76 bool * p_reduced_negative_step_size)
85 *p_reduced_positive_step_size =
true;
90 *p_reduced_negative_step_size =
true;
102 bool * p_reduced_positive_step_size,
103 bool * p_reduced_negative_step_size)
112 *p_reduced_negative_step_size =
true;
113 *p_reduced_positive_step_size =
true;
129 static void m_pru_scan_all(
bool * p_reduced_positive_step_size,
bool * p_reduced_negative_step_size,
bool * p_increased_step_size)
133 bool high_voltage_f =
false;
134 bool low_voltage_f =
false;
135 uint8_t l_putil_max = 0;
136 int8_t dominant_pru_index = -1;
138 *p_reduced_positive_step_size =
false;
139 *p_reduced_negative_step_size =
false;
140 *p_increased_step_size =
true;
142 for(uint8_t i = 0; i < n_reg_devices; ++i)
146 if(registered_devices[i]->prev_pru_dynamic.putil > l_putil_max)
149 dominant_pru_index = i;
154 *p_increased_step_size =
false;
162 high_voltage_f =
true;
167 low_voltage_f =
true;
175 else if(low_voltage_f)
184 if(dominant_pru_index >= 0)
189 p_reduced_positive_step_size,
190 p_reduced_negative_step_size);
202 if(reduced_step_size)
207 else if(increased_step_size)
224 uint16_t level_to_set;
225 uint16_t current_level;
230 if(err_code != NRF_SUCCESS)
235 step_size =
m_get_step_size(reduced_positive_step_size, increased_step_size);
244 level_to_set = current_level + step_size;
258 uint16_t level_to_set;
259 uint16_t current_level;
264 if(err_code != NRF_SUCCESS)
269 step_size =
m_get_step_size(reduced_negative_step_size, increased_step_size);
278 level_to_set = current_level - step_size;
295 bool reduced_positive_step_size;
296 bool reduced_negative_step_size;
297 bool increased_step_size;
299 m_pru_scan_all(&reduced_positive_step_size, &reduced_negative_step_size, &increased_step_size);
310 APP_ERROR_CHECK(err_code);
315 APP_ERROR_CHECK(err_code);
322 APP_ERROR_CHECK(err_code);
328 APP_ERROR_CHECK(err_code);
#define PTU_POWERAMP_INPUT_STEP_SIZE_INCREASED
#define PTU_POWERAMP_INPUT_TEST_STEP_SIZE
static void m_find_vrect_high_and_min(ptu_reg_item_t const *p_reg_item, uint16_t *p_vrect_high, uint16_t *p_vrect_min)
Inspect registry item and find the current value of VRECT_MIN and VRECT_HIGH.
#define PTU_DOMINANT_PRU_LOWER_LIMIT_VRECTSET_MULTIPLIER_FOR_REDUCTION_IN_STEP_SIZE
#define PTU_POWERAMP_INPUT_MAX
uint8_t ptu_reg_registered_devices_get(ptu_reg_item_t **registered_devices)
Get handles for all registered devices.
void ptu_power_ctrl_adjust(void)
Perform power control adjustments.
power_transfer_substates_t
Definition of power transfer substates.
#define BLE_WPTS_PRU_DYNAMIC_OPTION_VRECT_MIN_DYN_BITPOS
#define PTU_POWERAMP_INPUT_STEP_SIZE_REDUCED
#define BLE_WPTS_PRU_CATEGORY_4
static uint32_t m_get_step_size(bool reduced_step_size, bool increased_step_size)
Find step size to be used given permissions to use reduced and/or increased step size.
static power_transfer_substates_t m_substate
static uint32_t m_poweramp_input_step_down(bool reduced_negative_step_size, bool increased_step_size)
Decrease PTU poweramp output.
uint32_t ptu_power_ctrl_set_poweramp_input(uint16_t level)
Perform power control adjustments.
#define PTU_POWERAMP_INPUT_NOMINAL
uint32_t ptu_tmux_poweramp_level_set(uint16_t level)
Test wrapper for ptu_hal_poweramp_level_set().
#define PTU_VRECT_HIGH_OFFSET
void ptu_power_ctrl_set_disable_power_amplifier_adjustments(bool val)
Enable/Disable adjustments of power amplifier (I_TX_COIL).
uint16_t vrect_high_static
#define BLE_WPTS_PRU_DYNAMIC_OPTION_VRECT_HIGH_DYN_BITPOS
PRU Static Parameter structure.
#define PTU_ALLOWED_REDUCED_POSITIVE_ITX_COIL_ADJUSTMENT_MULTIPLIER
pru_static_t prev_pru_static
#define BLE_WPTS_PRU_DYNAMIC_OPTION_VRECT_MIN_DYN_BITMSK
static void m_update_power_amplifier_adjustment_step_size_for_dominant_pru(ptu_reg_item_t const *p_dominant_pru_reg_item, bool *p_reduced_positive_step_size, bool *p_reduced_negative_step_size)
Inspect registry item for dominant PRU and see if reduced step size is allowed for negative and posit...
ptu_reg_item_t * ptu_reg_item_get_from_conn_handle(uint16_t conn_handle)
Get registry item from connection handle.
uint16_t vrect_min_static
pru_dynamic_t prev_pru_dynamic
#define PTU_ALLOWED_REDUCED_NEGATIVE_ITX_COIL_ADJUSTMENT_MULTIPLIER
static void m_update_power_amplifier_adjustment_step_size(ptu_reg_item_t const *p_reg_item, bool *p_reduced_positive_step_size, bool *p_reduced_negative_step_size)
Inspect registry item and see if reduced step size is allowed for increase and/or decrease...
#define PTU_POWER_TRANSFER_HYSTERISIS
static uint16_t m_conn_handle_dominant
ptu_tester_command_t
PTU Tester commands.
uint32_t ptu_tmux_poweramp_level_get(uint16_t *p_level)
Test wrapper for ptu_hal_poweramp_level_get().
static bool m_itx_adj_disabled
#define PTU_MAX_CONNECTIONS
#define BLE_WPTS_PRU_DYNAMIC_OPTION_VRECT_HIGH_DYN_BITMSK
#define BLE_WPTS_BITFIELD_READ(bitfield, msk, pos)
Read bitfield.
void ptu_power_ctrl_set_itx_val(ptu_tester_command_t cmd)
Handle PTU tester power adjustment command.
static uint32_t m_poweramp_input_step_up(bool reduced_positive_step_size, bool increased_step_size)
Increase PTU poweramp output.
#define PTU_POWERAMP_INPUT_STEP_SIZE
PRU Dynamic Parameter structure.
#define PTU_DOMINANT_PRU_UPPER_LIMIT_VRECTSET_MULTIPLIER_FOR_REDUCTION_IN_STEP_SIZE
static void m_pru_scan_all(bool *p_reduced_positive_step_size, bool *p_reduced_negative_step_size, bool *p_increased_step_size)
Scan through dynamic and static parameters received from all connected PRUs.