Skip to content

Commit

Permalink
feat(BLE): Placeholder for VS Commands for RSSI and Signal Generation (
Browse files Browse the repository at this point in the history
  • Loading branch information
EricB-ADI authored Sep 30, 2024
1 parent e4f7ed4 commit 293a232
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ mxc_version.h
mxc_version.mk
Packetcraft-ADI
packetcraft-adi

92 changes: 83 additions & 9 deletions Libraries/Cordio/controller/sources/ble/lhci/lhci_cmd_vs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions Libraries/Cordio/controller/sources/ble/lhci/lhci_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,14 @@ extern "C" {
0x306) /*!<Vendor specific Get RSSI*/
#define LHCI_OPCODE_VS_RESET_ADV_STATS \
HCI_OPCODE(HCI_OGF_VENDOR_SPEC, \
0x307) /*!<Vendor specific Get RSSI*/
0x307) /*!<Vendor specific reset adv stats*/
#define LHCI_OPCODE_VS_RESET_SCAN_STATS \
HCI_OPCODE(HCI_OGF_VENDOR_SPEC, \
0x308) /*!<Vendor specific Get RSSI*/
0x308) /*!<Vendor specific reset scan stats*/
#define LHCI_OPCODE_VS_FGEN \
HCI_OPCODE(HCI_OGF_VENDOR_SPEC, \
0x309) /*!<Vendor specific frequency generator*/

/* Vendor specific event masks. */
#define LHCI_VS_EVT_MASK_SCAN_REPORT_EVT 0x01 /*!< (Byte 0) VS event bit, scan report. */
#define LHCI_VS_EVT_MASK_DIAG_TRACE_EVT 0x02 /*!< (Byte 0) VS event bit, diagnostic tracing. */
Expand Down
69 changes: 69 additions & 0 deletions Libraries/Cordio/platform/include/pal_bb.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define PAL_BB_H

#include "pal_types.h"
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -160,6 +170,9 @@ typedef struct {
uint8_t patch;
char *buildDate;
} PalBbPhyVersion_t;



/**************************************************************************************************
Function Declarations
**************************************************************************************************/
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions Libraries/Cordio/platform/include/pal_bb_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 293a232

Please sign in to comment.