diff --git a/.gitignore b/.gitignore index 3573714a36..06d1ef0dc6 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ mxc_version.h mxc_version.mk Packetcraft-ADI packetcraft-adi + diff --git a/Libraries/Cordio/controller/sources/ble/lhci/lhci_cmd_vs.c b/Libraries/Cordio/controller/sources/ble/lhci/lhci_cmd_vs.c index 071bc02cbf..a2a901487e 100644 --- a/Libraries/Cordio/controller/sources/ble/lhci/lhci_cmd_vs.c +++ b/Libraries/Cordio/controller/sources/ble/lhci/lhci_cmd_vs.c @@ -93,6 +93,9 @@ bool_t lhciCommonVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf) uint8_t status = HCI_SUCCESS; uint8_t evtParamLen = 1; /* default is status field only */ uint32_t regReadAddr = 0; + uint32_t channel = 0; + + (void)channel; /* Decode and consume command packet. */ @@ -276,8 +279,65 @@ bool_t lhciCommonVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf) } case LHCI_OPCODE_VS_GET_RSSI: { - status = LL_SUCCESS; + #if 0 + channel = pBuf[0]; + + if(channel > LL_DTM_MAX_CHAN_IDX) + { + status = LL_ERROR_CODE_PARAM_OUT_OF_MANDATORY_RANGE; + } + else{ + status = LL_SUCCESS; + } evtParamLen += sizeof(int8_t); + #else + status = LL_ERROR_CODE_CMD_DISALLOWED; + #endif + + break; + } + case LHCI_OPCODE_VS_FGEN: + { + #if 0 + uint8_t enable = pBuf[0]; + + if(enable) + { + int8_t txPower = 0; + uint32_t frequency_khz = pBuf[3] << 16 | pBuf[2] << 8 | pBuf[1]; + PalBbPatternType_t patternType = pBuf[4]; + + status = LlGetAdvTxPower(&txPower); + + if(status != LL_SUCCESS) + { + break; + } + else if(PalBbFgenIsEnabled()) + { + status = LL_ERROR_CODE_CMD_DISALLOWED; + } + else if(!PalBbIsValidPrbsType(patternType)) + { + status = LL_ERROR_CODE_INVALID_HCI_CMD_PARAMS; + } + else{ + const bool freqOk = PalBbEnableFgen(frequency_khz, patternType, txPower); + status = freqOk ? LL_SUCCESS : LL_ERROR_CODE_PARAM_OUT_OF_MANDATORY_RANGE; + } + + + } + else + { + PalBbDisableFgen(); + status = LL_SUCCESS; + } + + #else + status = LL_ERROR_CODE_CMD_DISALLOWED; + #endif + break; } case LHCI_OPCODE_VS_RESET_ADV_STATS: @@ -319,20 +379,34 @@ bool_t lhciCommonVsStdDecodeCmdPkt(LhciHdr_t *pHdr, uint8_t *pBuf) case LHCI_OPCODE_VS_TX_TEST: case LHCI_OPCODE_VS_RESET_ADV_STATS: case LHCI_OPCODE_VS_RESET_SCAN_STATS: + case LHCI_OPCODE_VS_FGEN: /* no action */ break; + case LHCI_OPCODE_VS_GET_RSSI: + { + #if 0 + if(status != LL_SUCCESS) + { + break; + } + + int8_t rssi = 0; + PalBbGetRssi(&rssi, channel); + + + pBuf[0] = (uint8_t)rssi; + #else + pBuf[0] = INT8_MIN; + #endif + + - case LHCI_OPCODE_VS_RESET_TEST_STATS: { - BbBleResetTestStats(); break; } - case LHCI_OPCODE_VS_GET_RSSI:{ - /* - TODO: Needs feature in PHY - */ - // PalBbEnable(); - pBuf[0] = -10; + + case LHCI_OPCODE_VS_RESET_TEST_STATS: { + BbBleResetTestStats(); break; } diff --git a/Libraries/Cordio/controller/sources/ble/lhci/lhci_int.h b/Libraries/Cordio/controller/sources/ble/lhci/lhci_int.h index ad00651f47..9ca0050561 100644 --- a/Libraries/Cordio/controller/sources/ble/lhci/lhci_int.h +++ b/Libraries/Cordio/controller/sources/ble/lhci/lhci_int.h @@ -377,10 +377,14 @@ extern "C" { 0x306) /*! #ifdef __cplusplus extern "C" { @@ -78,6 +79,15 @@ enum PalBbPhy_op { BB_PHY_OPTIONS_BLE_S8 = 2 /*!< Always use S=8 coding when transmitting on LE Coded PHY. */ }; +typedef enum +{ + PAL_BB_CW, + PAL_BB_PRBS9, + PAL_BB_PRBS15, + PAL_BB_DF1, + PAL_BB_DF2 +}PalBbPatternType_t; + #ifndef BB_CLK_RATE_HZ /*! \brief BB clock rate in hertz. */ #define BB_CLK_RATE_HZ 1000000 @@ -160,6 +170,9 @@ typedef struct { uint8_t patch; char *buildDate; } PalBbPhyVersion_t; + + + /************************************************************************************************** Function Declarations **************************************************************************************************/ @@ -281,6 +294,62 @@ void PalBbSetProtId(uint8_t protId); /*************************************************************************************************/ const PalBbPhyVersion_t *PalBbGetPhyVersion(void); +/*************************************************************************************************/ +/*! + * \brief Enable frequency generator + * + * \param freqKhz Frequency to transmit in KHz, Valid range 2402000 - 2500000 + * + * \param type PRBS TYPE + */ +/*************************************************************************************************/ +bool PalBbEnableFgen(uint32_t freqKhz, PalBbPatternType_t type, int8_t txPower); + +/*************************************************************************************************/ +/*! + * \brief Disable frequency generator + * + */ +/*************************************************************************************************/ +void PalBbDisableFgen(void); + +/*************************************************************************************************/ +/*! + * \brief Check if the fgen functionality is enabled + * \return true if enabled. false otherwise + */ +/*************************************************************************************************/ +bool PalBbFgenIsEnabled(void); + +/*************************************************************************************************/ +/*! + * \brief Sample an RSSI capture + * + * \param rssi Pointer to rssi output. + * \param channel RF channel to sample RSSI on. + * \return FALSE if RSSI capture times out + */ +/*************************************************************************************************/ +bool_t PalBbGetRssi(int8_t *rssi, uint8_t rfChannel); + +static inline bool PalBbIsValidPrbsType(uint8_t maybeType) +{ + switch (maybeType) + { + case PAL_BB_CW: + case PAL_BB_PRBS9: + case PAL_BB_PRBS15: + case PAL_BB_DF1: + case PAL_BB_DF2: + return true; + + default: + return false; + } + + +} + /*! \} */ /* PAL_BB */ #ifdef __cplusplus diff --git a/Libraries/Cordio/platform/include/pal_bb_ble.h b/Libraries/Cordio/platform/include/pal_bb_ble.h index 0f24e9ffa5..8decca8dee 100644 --- a/Libraries/Cordio/platform/include/pal_bb_ble.h +++ b/Libraries/Cordio/platform/include/pal_bb_ble.h @@ -187,6 +187,15 @@ void PalBbBleDisable(void); /*************************************************************************************************/ void PalBbBleSetChannelParam(PalBbBleChan_t *pChan); +/*************************************************************************************************/ +/*! + * \brief Set channelization parameters. + * + * \return pChan + */ +/*************************************************************************************************/ +const PalBbBleChan_t* PalBbBleGetChannelParam(void); + /*! \} */ /* PAL_BB_BLE_CHAN */ /*! \addtogroup PAL_BB_BLE_DATA