-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Jiminy Support for at86rfr2 transceiver #9172
Conversation
@kYc0o maybe this could be a review where you could help out as you could test it on the RCB256RFR2-xpro. 😁 |
I don't want / can't hop into the review process so late. Just wanted to inform that I can test on the Jiminy hardware once we are at that point. |
Yes, but first I'd like to get #9130 in. Afterwards I want to add support for that board, then I can test this. If the guys at HAW who have the jiminy board can test it before it's also OK. |
@gebart could you find some time for this? |
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.
First round of review.
I'd like to have a more consistent use of the register reading and writing, maybe using at86rf2xx_reg_write/read a bit more extensively.
I'll try to test but I think I need first to see if the at86rf2xx driver is not broken with this PR.
* 76923 | ||
* 38400 | ||
* 76800 | ||
* 38400 fetching data from interrupt to slow for long data |
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.
What this comment is about? It's confusing.
#include "board.h" | ||
#define ENABLE_HEX_DUMP_TX (0) | ||
#if ENABLE_HEX_DUMP_TX | ||
#include "od.h" |
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.
Why is this necessary?
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.
To enable a hexdump at the lowest possible layer.
USEMODULE += boards_common_atmega | ||
|
||
ifneq (, $(filter gnrc_netdev_default netdev_default, $(USEMODULE))) | ||
USEMODULE += at86rfr2 |
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.
Please add 2 spaces indentation.
|
||
#ifdef MODULE_AT86RFR2 | ||
/* Store device pointer for interrupts */ | ||
at86rfr2_dev = (netdev_t *)dev; |
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.
From where this variable comes? I can't find any usage.
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.
drivers/at86rf2xx/include/at86rf2xx_internal.h
It is used in the interrupts.
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.
Would be nicer if it were made static
and you had a at86rfr2_init_isr(dev);
here.
drivers/at86rf2xx/at86rf2xx.c
Outdated
| DEBUG_ATRFR2_PIN_TX_END|DEBUG_ATRFR2_PIN_RX_END); | ||
/* Pin Low */ | ||
DEBUG_ATRFR2_PORT &= ~( DEBUG_ATRFR2_PIN_TX_START | ||
|DEBUG_ATRFR2_PIN_TX_END|DEBUG_ATRFR2_PIN_RX_END); |
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.
Are not this done anyways in enable_rxtx_led();
? Also, I think this touches too at86rf2xx driver which doesn't have such pins.
@@ -113,11 +182,13 @@ void at86rf2xx_reset(at86rf2xx_t *dev) | |||
tmp |= (AT86RF2XX_TRX_CTRL_0_CLKM_CTRL__OFF); | |||
at86rf2xx_reg_write(dev, AT86RF2XX_REG__TRX_CTRL_0, tmp); | |||
|
|||
/* clear interrupt flags, AT86RF233 Manual p.33*/ | |||
at86rf2xx_reg_read(dev, AT86RF2XX_REG__IRQ_STATUS); | |||
|
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.
Unrelated.
@Josar you may rebase this PR for a final review. |
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.
This rx_sens_to_dbm
seems to be new. Please see my implementation. One question which i had was if this arrays with values are needed.
@kYc0o squashed and rebased. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
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.
If you are still interested in that driver, I think we can get it merged.
But remove the additional debug code and check if some more code can be shared between at86rfr2 and at86rfr2xx. Especially the two separate code paths in _recv()
will be hard to maintain.
The get/set rxsensitivity, txpower fuctions should also basically follow the same logic as the existing driver. Maybe the formulas for calculating the register values have changed, but the general logic / parameter checks should still be the same.
Also, a rebase is in order.
memcpy( data, (void *)(AT86RF2XX_REG__TRXFBST), len); | ||
puts("SENDING:"); | ||
od_hex_dump(data, len, OD_WIDTH_DEFAULT); | ||
#endif |
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'd say remove that debug code, it's useful during development but just clutters the code afterwards.
* take the next value, it is the next smaller than the requested. | ||
*/ | ||
unsigned int i = 0; | ||
while (tx_pow_to_dbm[i] > txpower) { |
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.
Is this really just necessary for AT86RFR2?
The dimensions of the array are the same for AT86RF233, AT86RF212B
rxsens = (rxsens - RSSI_BASE_VAL)/3; | ||
if (rxsens >14){ | ||
rxsens =14; | ||
}else if(rxsens <0){ |
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.
< MIN_RX_SENSITIVITY
?
/* Always set the treshhold which at least limits the requested value. | ||
* requesting -50dBm will result in -48dBm */ | ||
rxsens = (rxsens - RSSI_BASE_VAL)/3; | ||
if (rxsens >14){ |
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.
> MAX_RX_SENSITIVITY
?
}else{ | ||
rxsens +=1; | ||
} | ||
*AT86RF2XX_REG__RX_SYN = (*AT86RF2XX_REG__RX_SYN & ~(AT86RF2XX_RX_SYN__RX_PDT_LEVEL)) | rxsens; |
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 have the feeling that everything but the calculation of rxsens
could be shared with the !MODULE_AT86RFR2
code (and you could also use the at86rf2xx_reg_write()
path here).
That would make the #ifdef
block much smaller.
@@ -499,6 +562,7 @@ uint8_t at86rf2xx_set_state(at86rf2xx_t *dev, uint8_t state) | |||
* in progress */ | |||
do { | |||
old_state = at86rf2xx_get_status(dev); | |||
DEBUG("at86rf2xx_set_state: 0x%02x old_state is: 0x%02x\n", state, old_state); |
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.
Remove the added debug output.
#endif | ||
|
||
#ifdef MODULE_AT86RFR2 | ||
void at86rf2xx_reg_write(const at86rf2xx_t *dev, |
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.
Maybe we can make those static inline
directly in at86rf2xx_internal.h
so the compiler can optimize them away entirely.
#if ENABLE_HEX_DUMP_RX | ||
puts("RECEIVED:"); | ||
od_hex_dump(data, len, OD_WIDTH_DEFAULT); | ||
#endif |
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.
Remove the added debug code.
/* get the size of the received packet */ | ||
/* Transceiver Received Frame Length Register (refer p.35, 85, 154) */ | ||
/* subtract length of FCS */ | ||
pkt_len = (TST_RX_LENGTH & 0x7f) - 2; |
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.
Where is TST_RX_LENGTH
defined?
Also, is the receive procedure so different that you need an entirely different code path for AT86RFR2
?
#endif | ||
/* This is a short light pulse*/ | ||
#if RXTX_LED_ENABLE | ||
RXTX_LED_ON; |
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.
You can save the #ifdef and just write
RXTX_LED_ON;
as you can just
#if RXTX_LED_ENABLE
#define RXTX_LED_ON LED0_ON
#else
#define RXTX_LED_ON
#endif
But this seems more like a debug feature that should be removed / put into a separate commit.
I now have a board with this radio #12411 |
Superseded by #12537 |
This PR adds support for the at86rfr2 transceiver into the at86rf2xx driver.
This is split out from #8742