2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* @attention
|
|
|
|
*
|
|
|
|
* <h2><center>© COPYRIGHT 2020 STMicroelectronics</center></h2>
|
|
|
|
*
|
|
|
|
* Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.st.com/myliberty
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
|
|
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PROJECT: ST25R391x firmware
|
|
|
|
* $Revision: $
|
|
|
|
* LANGUAGE: ISO C99
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file rfal_dpo.h
|
|
|
|
*
|
|
|
|
* \author Martin Zechleitner
|
|
|
|
*
|
|
|
|
* \brief Dynamic Power adjustment
|
|
|
|
*
|
|
|
|
* This module provides an interface to perform the power adjustment dynamically
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* \addtogroup RFAL
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* \addtogroup RFAL-HAL
|
|
|
|
* \brief RFAL Hardware Abstraction Layer
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* \addtogroup DPO
|
|
|
|
* \brief RFAL Dynamic Power Module
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RFAL_DPO_H
|
|
|
|
#define RFAL_DPO_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* INCLUDES
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
#include "platform.h"
|
|
|
|
#include "st_errno.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* GLOBAL DEFINES
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2022-01-05 19:10:18 +03:00
|
|
|
#define RFAL_DPO_TABLE_SIZE_MAX 15U /*!< Max DPO table size */
|
|
|
|
#define RFAL_DPO_TABLE_PARAMETER 3U /*!< DPO table Parameter length */
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* GLOBAL TYPES
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! DPO table entry struct */
|
|
|
|
typedef struct {
|
|
|
|
uint8_t rfoRes; /*!< Setting for the resistance level of the RFO */
|
2022-01-05 19:10:18 +03:00
|
|
|
uint8_t inc; /*!< Threshold for incrementing the output power */
|
|
|
|
uint8_t dec; /*!< Threshold for decrementing the output power */
|
|
|
|
} rfalDpoEntry;
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/*! Function pointer to methode doing the reference measurement */
|
|
|
|
typedef ReturnCode (*rfalDpoMeasureFunc)(uint8_t*);
|
|
|
|
|
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* GLOBAL FUNCTION PROTOTYPES
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
*****************************************************************************
|
|
|
|
* \brief Initialize dynamic power table
|
|
|
|
*
|
|
|
|
* This function sets the internal dynamic power table to the default
|
|
|
|
* values stored in rfal_DpoTbl.h
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
|
|
|
*/
|
2022-01-05 19:10:18 +03:00
|
|
|
void rfalDpoInitialize(void);
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
*****************************************************************************
|
|
|
|
* \brief Set the measurement methode
|
|
|
|
*
|
|
|
|
* This function sets the measurement method used for reference measurement.
|
|
|
|
* Based on the measurement the power will then be adjusted
|
|
|
|
*
|
|
|
|
* \param[in] dpoMeasureFunc: callback of measurement function
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
|
|
|
*/
|
2022-01-05 19:10:18 +03:00
|
|
|
void rfalDpoSetMeasureCallback(rfalDpoMeasureFunc dpoMeasureFunc);
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
*****************************************************************************
|
|
|
|
* \brief Write dynamic power table
|
|
|
|
*
|
|
|
|
* Load the dynamic power table
|
|
|
|
*
|
|
|
|
* \param[in] powerTbl: location of power Table to be loaded
|
|
|
|
* \param[in] powerTblEntries: number of entries of the power Table to be loaded
|
|
|
|
*
|
|
|
|
* \return ERR_NONE : No error
|
|
|
|
* \return ERR_PARAM : if configTbl is invalid
|
|
|
|
* \return ERR_NOMEM : if the given Table is bigger exceeds the max size
|
|
|
|
*****************************************************************************
|
|
|
|
*/
|
2022-01-05 19:10:18 +03:00
|
|
|
ReturnCode rfalDpoTableWrite(rfalDpoEntry* powerTbl, uint8_t powerTblEntries);
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
*****************************************************************************
|
|
|
|
* \brief Dynamic power table Read
|
|
|
|
*
|
|
|
|
* Read the dynamic power table
|
|
|
|
*
|
|
|
|
* \param[out] tblBuf: location to the rfalDpoEntry[] to place the Table
|
|
|
|
* \param[in] tblBufEntries: number of entries available in tblBuf to place the power Table
|
|
|
|
* \param[out] tableEntries: returned number of entries actually written into tblBuf
|
|
|
|
*
|
|
|
|
* \return ERR_NONE : No error
|
|
|
|
* \return ERR_PARAM : if configTbl is invalid or parameters are invalid
|
|
|
|
*****************************************************************************
|
|
|
|
*/
|
2022-01-05 19:10:18 +03:00
|
|
|
ReturnCode rfalDpoTableRead(rfalDpoEntry* tblBuf, uint8_t tblBufEntries, uint8_t* tableEntries);
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
*****************************************************************************
|
|
|
|
* \brief Dynamic power adjust
|
|
|
|
*
|
|
|
|
* It measures the current output and adjusts the power accordingly to
|
|
|
|
* the dynamic power table
|
|
|
|
*
|
|
|
|
* \return ERR_NONE : No error
|
|
|
|
* \return ERR_PARAM : if configTbl is invalid or parameters are invalid
|
|
|
|
* \return ERR_WRONG_STATE : if the current state is valid for DPO Adjustment
|
|
|
|
*****************************************************************************
|
|
|
|
*/
|
2022-01-05 19:10:18 +03:00
|
|
|
ReturnCode rfalDpoAdjust(void);
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
*****************************************************************************
|
|
|
|
* \brief Get Current Dynamic power table entry
|
|
|
|
*
|
|
|
|
* Return current used DPO power table entry settings
|
|
|
|
*
|
|
|
|
* \return ERR_NONE : Current DpoEntry. This includes d_res, inc and dec
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
|
|
|
*/
|
|
|
|
rfalDpoEntry* rfalDpoGetCurrentTableEntry(void);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
*****************************************************************************
|
|
|
|
* \brief Dynamic power set enabled state
|
|
|
|
*
|
|
|
|
* \param[in] enable: new active state
|
|
|
|
*
|
|
|
|
* Set state to enable or disable the Dynamic power adjustment
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
|
|
|
*/
|
2022-01-05 19:10:18 +03:00
|
|
|
void rfalDpoSetEnabled(bool enable);
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
*****************************************************************************
|
|
|
|
* \brief Get the Dynamic power enabled state
|
|
|
|
*
|
|
|
|
* Get state of the Dynamic power adjustment
|
|
|
|
*
|
|
|
|
* \return true : enabled
|
|
|
|
* \return false : disabled
|
|
|
|
*****************************************************************************
|
|
|
|
*/
|
|
|
|
bool rfalDpoIsEnabled(void);
|
|
|
|
|
|
|
|
#endif /* RFAL_DPO_H */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|