Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Conversation

Josar
Copy link
Contributor

@Josar Josar commented May 23, 2018

This PR adds support for the at86rfr2 transceiver into the at86rf2xx driver.

This is split out from #8742

@Josar
Copy link
Contributor Author

Josar commented May 29, 2018

@kYc0o maybe this could be a review where you could help out as you could test it on the RCB256RFR2-xpro. 😁

@PeterKietzmann
Copy link
Member

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.

@kYc0o
Copy link
Contributor

kYc0o commented May 29, 2018

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.

@Josar
Copy link
Contributor Author

Josar commented Jun 15, 2018

@gebart could you find some time for this?

@jnohlgard jnohlgard added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT Platform: AVR Platform: This PR/issue effects AVR-based platforms CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: boards Area: Board ports Area: drivers Area: Device drivers labels Jul 3, 2018
Copy link
Contributor

@kYc0o kYc0o left a 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
Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

Copy link
Contributor Author

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
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

| 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);
Copy link
Contributor

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);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated.

drivers/at86rf2xx/at86rf2xx_getset.c Outdated Show resolved Hide resolved
drivers/at86rf2xx/at86rf2xx_internal.c Outdated Show resolved Hide resolved
drivers/at86rf2xx/at86rf2xx_internal.c Outdated Show resolved Hide resolved
drivers/at86rf2xx/at86rf2xx_internal.c Outdated Show resolved Hide resolved
@Josar
Copy link
Contributor Author

Josar commented Jul 6, 2018

#9508
#9509
#9510

@gebart @kYc0o could we get this merged before and rebase on them as this will require some rework of this PR.

@kYc0o
Copy link
Contributor

kYc0o commented Oct 29, 2018

@Josar you may rebase this PR for a final review.

Copy link
Contributor Author

@Josar Josar left a 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.

@Josar
Copy link
Contributor Author

Josar commented Oct 29, 2018

@kYc0o squashed and rebased.

@RIOT-OS RIOT-OS deleted a comment Oct 30, 2018
@stale
Copy link

stale bot commented Aug 10, 2019

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.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
Copy link
Contributor

@benpicco benpicco left a 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
Copy link
Contributor

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) {
Copy link
Contributor

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){
Copy link
Contributor

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){
Copy link
Contributor

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;
Copy link
Contributor

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);
Copy link
Contributor

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,
Copy link
Contributor

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
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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.

@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Sep 9, 2019
@benpicco
Copy link
Contributor

benpicco commented Oct 9, 2019

I now have a board with this radio #12411
It's much cheaper than the official dev boards too.

@benpicco
Copy link
Contributor

Superseded by #12537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: drivers Area: Device drivers Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants