Nordic Semiconductor nRF5 AirFuel SDK
version 2.2.0
|
#include <stdint.h>
#include <string.h>
#include <math.h>
#include "nrf_assert.h"
#include "ptu_conn_man.h"
#include "ptu_power_sharing.h"
Go to the source code of this file.
Functions | |
API implementation. | |
uint32_t | ptu_power_sharing_init (ptu_sm_handler_t sm_handler) |
Initialize power sharing module. More... | |
void | ptu_power_sharing_temperature_warning_set (bool warning) |
Inform power control module that PTU is having a high temperature warning. When this occurs the power control module will instruct PRUs to lower their power consumption. More... | |
void | ptu_power_sharing_on_wpt_service_evt (ble_wpts_c_t *p_wpts_c, ble_wpts_c_evt_t *const p_wpts_c_evt) |
Handle service events. More... | |
Static funcitons and variables. | |
#define | REG_DEVICE_CAN_ADJUST_POWER(DEV) |
Check if a device is capable of receiving power adjust commands. More... | |
static ptu_pctl_status_t | m_pctl_status |
static ptu_sm_handler_t | m_sm_handler |
static void | m_ble_wpts_c_send_pru_control_wait_buffer (ptu_reg_item_t *reg_item_p) |
Sends the control packet in prev_ctl to a PRU. More... | |
static uint8_t | m_get_prect (uint8_t prect_max, ctl_adj_power_t power_adjust) |
Get truncated value for adjusted power. More... | |
static uint8_t | m_prect_max_get (ptu_reg_item_t *reg_item) |
Get the maximum Prect in [100 mW] for a PRU. More... | |
static uint8_t | m_prect_diff_after_inc_get (ptu_reg_item_t *reg_item) |
Get the maximum increased Prect if we step up the allowed Prect for the PRU with one step. More... | |
static void | m_send_power_adjust_command (ptu_reg_item_t *reg_item) |
Transmits a PRU control packet, and performs all required bookkeeping related to performing the power ajust process. More... | |
static bool | m_pru_decrease_power () |
Search for PRUs having "adjust power" capability and send control packet instructing the PRU to reduce power. More... | |
static bool | m_pru_increase_power () |
Search for PRUs having "adjust power" capability and send control packet allowing the PRU to increase power. More... | |
static bool | m_pru_deny_power () |
Search for PRUs being permitted to enable charge output and send control packet denying the PRU to do so. More... | |
static bool | m_max_number_of_devices_is_being_charged (void) |
Check if the maximum number of PRUs is being charged. More... | |
static bool | m_pru_allow_power () |
Search for PRUs not being permitted to enable charge output and send control packet allowing the PRU to do so if the PTU can tolerate this increased power draw. More... | |
static ctl_adj_power_t | m_attempt_to_get_prect_within_available_resources (ptu_reg_item_t *new_reg_item_p) |
See if it is possible to adjust power drain from a not yet registerred PRU so that it fits within the current remaining power of the PTU. More... | |
static void | m_status_update (void) |
Collect status information from all PRUs and update m_pctl_status. | |
static void | m_charge_disable_all () |
Disable PRU output for all connected PRUs. | |
static void | m_charge_complete_update (ptu_reg_item_t *p_reg_item, ble_wpts_c_evt_t *const p_wpts_c_evt) |
Check if all PRUs are done charging, in which case all will be disabled. | |
static bool | m_adjusted_power_sensed (ptu_reg_item_t *item) |
See if PRU has adjusted power by looking at the I_RECT and V_RECT values from PRU dynamic params. More... | |
static void | m_update_pru_p_adj_status (void) |
Update cooldown values for all PRUs which has received a power adjust command recently. Also checks for PRUs that does not respond with power adjust bit correctly after being sent a power adjust command. | |
static void | m_allow_pru_to_charge (ptu_reg_item_t *reg_item_p) |
Update registry item and issue control packet for allowing PRU to charge. More... | |
static void | m_deny (ptu_reg_item_t *reg_item_p, ctl_perm_t permissions) |
Update registry item and issue control packet for denying PRU charge. Will remove device from registry. More... | |
static void | m_permit_with_waiting_time_and_adjust (ptu_reg_item_t *reg_item_p) |
Allow PRU to charge with adjusted power draw. Update registry item and issue control packet indicating the required adjustment. More... | |
static void | m_handle_new_device (ptu_reg_item_t *reg_item_p) |
Handle the power sharing of a new PRU. More... | |
#define REG_DEVICE_CAN_ADJUST_POWER | ( | DEV | ) |
Check if a device is capable of receiving power adjust commands.
Definition at line 29 of file ptu_power_sharing.c.
|
static |
Sends the control packet in prev_ctl to a PRU.
reg_item_p | registry entry for PRU to which to send control packet. |
Definition at line 53 of file ptu_power_sharing.c.
|
static |
Get truncated value for adjusted power.
prect_max | The PRUs PRECT_MAX value. |
power_adjust | The power adjustment to apply. |
Truncated | value of the resulting PRECT. |
Definition at line 81 of file ptu_power_sharing.c.
|
static |
Get the maximum Prect in [100 mW] for a PRU.
reg_item | registry item for the PRU. |
The | maximum Prect in [100 mW] for the PRU. |
Definition at line 112 of file ptu_power_sharing.c.
|
static |
Get the maximum increased Prect if we step up the allowed Prect for the PRU with one step.
reg_item | registry item for the PRU. |
Increase | in Prect in [100 mW]. |
Definition at line 132 of file ptu_power_sharing.c.
|
static |
Transmits a PRU control packet, and performs all required bookkeeping related to performing the power ajust process.
reg_item | registry item for the PRU. |
Definition at line 165 of file ptu_power_sharing.c.
|
static |
Search for PRUs having "adjust power" capability and send control packet instructing the PRU to reduce power.
true | if a PRU was instructed to reduce power. |
Definition at line 182 of file ptu_power_sharing.c.
|
static |
Search for PRUs having "adjust power" capability and send control packet allowing the PRU to increase power.
true | if a PRU was allowed to increase power. |
Definition at line 249 of file ptu_power_sharing.c.
|
static |
Search for PRUs being permitted to enable charge output and send control packet denying the PRU to do so.
true | if a PRU was instructed disable charge output. |
Definition at line 318 of file ptu_power_sharing.c.
|
static |
Check if the maximum number of PRUs is being charged.
true | if a PRU was instructed disable charge output. |
Definition at line 344 of file ptu_power_sharing.c.
|
static |
Search for PRUs not being permitted to enable charge output and send control packet allowing the PRU to do so if the PTU can tolerate this increased power draw.
true | if a PRU was allowed to enable charge output. |
Definition at line 367 of file ptu_power_sharing.c.
|
static |
See if it is possible to adjust power drain from a not yet registerred PRU so that it fits within the current remaining power of the PTU.
new_reg_item_p | registry item for the PRU. |
The | power adjustment required for PRU to be within power limit. CTL_ADJ_POWER_MAX_VAL if it is not possible to get PRU within limit. |
Definition at line 402 of file ptu_power_sharing.c.
|
static |
See if PRU has adjusted power by looking at the I_RECT and V_RECT values from PRU dynamic params.
item | The PRU item to check. |
Has | PRU adjusted power. |
Definition at line 518 of file ptu_power_sharing.c.
|
static |
Update registry item and issue control packet for allowing PRU to charge.
[in] | reg_item_p | Pointer to registry item that should be allowed to charge. |
Definition at line 574 of file ptu_power_sharing.c.
|
static |
Update registry item and issue control packet for denying PRU charge. Will remove device from registry.
[in] | reg_item_p | Pointer to registry item that should be denied charge. |
permissions | Reason for being denied. |
Definition at line 589 of file ptu_power_sharing.c.
|
static |
Allow PRU to charge with adjusted power draw. Update registry item and issue control packet indicating the required adjustment.
[in] | reg_item_p | Pointer to registry item that should be allowed adjusted charge. |
Definition at line 609 of file ptu_power_sharing.c.
|
static |
Handle the power sharing of a new PRU.
[in] | reg_item_p | Pointer to registry item for new PRU. |
Definition at line 621 of file ptu_power_sharing.c.