-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a function to activate CW mode #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Overall, this PR looks good. Some remarks/questions:
- You've also included a commit for RAK support, that probably warrants its own PR. Could you remove it (just force push to your branch with the commit removed).
- Are you sure the power is directly specified in dB? The regular TX power is specified by index, with a non-trivial conversion from dB:
STM32LoRaWAN/src/STM32LoRaWAN.cpp
Lines 218 to 223 in 46d7e91
bool STM32LoRaWAN::powerdB(int8_t db){ // This uses knowledge about the radio implementation to calculate the // index to use. See RegionCommonComputeTxPower() int8_t index = -(db - 1) / 2; return mibSetInt8("power", MIB_CHANNELS_TX_POWER, index); } - Is there a special "no timeout" value? If so, the comments should specify it.
Argh, you are right, I have based my changes on previous branch. Will fix that. You are right about power units also. |
Fixed that |
Seems you dropped the RAK commit, but haven't addressed the other questions about power and timeout yet? |
Yes, I have removed dBm mention from the documentation and no, there is no special "no timeout" value it seems: UTIL_TIMER_Status_t UTIL_TIMER_SetPeriod(UTIL_TIMER_Object_t *TimerObject, uint32_t NewPeriodValue)
{
UTIL_TIMER_Status_t ret = UTIL_TIMER_OK;
if(NULL == TimerObject)
{
ret = UTIL_TIMER_INVALID_PARAM;
}
else
{
TimerObject->ReloadValue = UTIL_TimerDriver.ms2Tick(NewPeriodValue);
if(TimerExists(TimerObject))
{
(void)UTIL_TIMER_Stop(TimerObject);
ret = UTIL_TIMER_Start(TimerObject);
}
}
return ret;
} Time is converted from seconds to ms in uint32_t timeout = ( uint32_t )time * 1000;
uint8_t antswitchpow;
SUBGRF_SetRfFrequency( freq );
antswitchpow = SUBGRF_SetRfTxPower( power );
/* WORKAROUND - Trimming the output voltage power_ldo to 3.3V */
SUBGRF_WriteRegister(REG_DRV_CTRL, 0x7 << 1);
/* Set RF switch */
SUBGRF_SetSwitch( antswitchpow, RFSWITCH_TX );
SUBGRF_SetTxContinuousWave( );
TimerSetValue( &TxTimeoutTimer, timeout );
TimerStart( &TxTimeoutTimer ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typos else LGTM.
Thanks for your contribution.
I wonder if the API should accept a power in dBm, just like the regular power setting function. Of course it is a testing function, so having a somewhat less friendly API that has a potentially hardware-dependent power argument might be acceptable (@fpistm, what do you think?), but in that case at least the documentation should say something about what the power values mean (even if it is just a reference to the relevant register in the STM32WL55 datasheet). |
Agreed. |
Fix a typo Co-authored-by: Frederic Pillon <frederic.pillon@st.com> Signed-off-by: Albertas Mickėnas <albertas@technarium.lt>
Fix a typo Co-authored-by: Frederic Pillon <frederic.pillon@st.com> Signed-off-by: Albertas Mickėnas <albertas@technarium.lt>
Cool, I will re-calculate to index from dB in the same manner you have posted above |
I found something fishy in Semtech code. uint8_t SUBGRF_SetRfTxPower(int8_t power)
Set the Tx End Device conducted power
Parameters:
[in] – power Tx power level [0..15]
Return values:
paSelect [RFO_LP, RFO_HP] Then it does checks for PA selection: switch (TxConfig)
{
case RBI_CONF_RFO_LP_HP:
{
if (power > 15)
{
paSelect = RFO_HP;
}
else
{
paSelect = RFO_LP;
}
break;
} And then calls void SUBGRF_SetTxParams(uint8_t paSelect, int8_t power, RadioRampTimes_t rampTime)
Sets the transmission parameters
Parameters:
[in] – paSelect RegPaConfig PaSelect value (RFO_LP, RFO_HP, etc)
[in] – power RF output power [-18..13] dBm
[in] – rampTime Transmission ramp up time Thus the check for 15 in
So yeah, I think Can anyone guide me on |
…_SetRfTxPower behaviour
Looking at the code, when
then SetTxContinuousWave :
with SetTxContinuousWave :STM32LoRaWAN/src/STM32CubeWL/SubGHz_Phy/radio.h Lines 297 to 304 in d3aa385
So I think we could only deal with dBm while it is explicitly describe, as this feature is for test purpose, I think it is acceptable. |
Yes, and then So it's clearly dBm, but I think there's a bug in |
Right, I guess an issue should be filled in https://github.com/STMicroelectronics/STM32CubeWL/issues |
Ok, will do. So this PR then can be merged - I have altered the documentation strings to represent dBm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the update.
Waiting @matthijskooijman feedback 😉
Thanks @Miceuz to the issue submitted here: STMicroelectronics/STM32CubeWL#64 @matthijskooijman are you agreed with this PR now? I guess it could be merged safely as it does not impact other API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a bit confused by all the different code snippets, but finally found the time to look a bit closer. Looks good to me now, yes.
As for SUBGRF_SetRfTxPower()
, AFAICS the problem is not actually the code, just the documentation problem, right? Reading your comments and the code right, the function is called with dBm, passes dBm on to SUBGRF_SetTxParams()
and the >15
check makes sense, since LP goes up to 15dBm and HP up to 22dBm, so it should work as expected, right?
For reference, here is the upstream issue @Miceuz reported: STMicroelectronics/STM32CubeWL#64
Agreed, documentations are not coherent. Let's see how it will be handled on STM32CubeWL repo. |
It's just a wrapper function for underlying Semtech infrastructure for activating CW mode.