Nordic Semiconductor nRF5 AirFuel SDK
version 2.2.0
|
API. | |
uint32_t | ptu_sensors_init (ptu_sm_handler_t sm_handler) |
Initialize PTU Sensors. This function must be called before any other PTU Sensors function can be called. More... | |
uint32_t | ptu_sensors_read (void) |
Read sensors. This function should typically be called regularly by a timer and can generate events by calling ptu_evt_handler(). More... | |
uint32_t | ptu_sensors_data_get (const ptu_sensor_data_t **sensors_data) |
Get the latest data read from the PTU sensors. More... | |
void | ptu_sensors_clear_long_beacon_extension_load_variation_buffer (void) |
Empty buffer containing load variation sample data for Long Beacon Extension. | |
bool | ptu_sensors_valid_long_beacon_extension_load_variation_found (void) |
Check if a valid PTX load variation has occured. More... | |
uint32_t ptu_sensors_init | ( | ptu_sm_handler_t | sm_handler | ) |
Initialize PTU Sensors. This function must be called before any other PTU Sensors function can be called.
sm_handler | State machine event handler |
Definition at line 284 of file ptu_sensors.c.
uint32_t ptu_sensors_read | ( | void | ) |
Read sensors. This function should typically be called regularly by a timer and can generate events by calling ptu_evt_handler().
NRF_SUCCESS | Sensor readings updated successfully. |
Definition at line 303 of file ptu_sensors.c.
uint32_t ptu_sensors_data_get | ( | const ptu_sensor_data_t ** | sensors_data | ) |
Get the latest data read from the PTU sensors.
[out] | sensors_data | is a pointer to where a pointer to the latest read sensor data shall be written. |
Definition at line 404 of file ptu_sensors.c.
bool ptu_sensors_valid_long_beacon_extension_load_variation_found | ( | void | ) |
Check if a valid PTX load variation has occured.
Once called, this function will store a touple containing the current ticks value, and the current PTX value to a list of samples. This list of samples is then checked to see whether or not a valid load variation can be found. The overall algorithm is: Find the first top, find the bottom, find the second top, is the time between the two tops OK?
Finding the first top: This is done by simply comparing the value at the a point with the next sample value, if the next value is smaller we have a valid top.
Finding the bottom: We jump to the next sample as long as the difference between the value at the current sample and the first top is NOT sufficient (smaller than 0.5W). Note that when we have found the bottom, we will still check whether or not a LOWER bottom exists, in which case the bottom-pointer will be updated.
Finding the second top: The second top does not need to be a top, just a point that is sufficiently higher than bottom (0.5W above). NOTE: This implementation will accept a load where the second top is lower than the first top, as long as its delta from the bottom is sufficient.
Checking the time is a simple check of the time delta between the first top and the second top. If its accepted, the function will report that a valid PTX load variation has been found.
Definition at line 417 of file ptu_sensors.c.