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? |
kYc0o
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
From where this variable comes? I can't find any usage.
There was a problem hiding this comment.
drivers/at86rf2xx/include/at86rf2xx_internal.h
It is used in the interrupts.
There was a problem hiding this comment.
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.
Are not this done anyways in enable_rxtx_led();? Also, I think this touches too at86rf2xx driver which doesn't have such pins.
|
|
||
| /* clear interrupt flags, AT86RF233 Manual p.33*/ | ||
| at86rf2xx_reg_read(dev, AT86RF2XX_REG__IRQ_STATUS); | ||
|
|
|
@Josar you may rebase this PR for a final review. |
|
@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. |
benpicco
left a comment
There was a problem hiding this comment.
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.
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.
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){ |
| /* 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){ |
| }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.
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.
| * 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.
Remove the added debug output.
| #endif | ||
|
|
||
| #ifdef MODULE_AT86RFR2 | ||
| void at86rf2xx_reg_write(const at86rf2xx_t *dev, |
There was a problem hiding this comment.
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.
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.
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.
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