Skip to content

drivers/ata8520e: add initial implementation (without netdev but provides Sigfox feature)#7087

Merged
kYc0o merged 2 commits intoRIOT-OS:masterfrom
aabadie:driver_ata8520
Jan 25, 2018
Merged

drivers/ata8520e: add initial implementation (without netdev but provides Sigfox feature)#7087
kYc0o merged 2 commits intoRIOT-OS:masterfrom
aabadie:driver_ata8520

Conversation

@aabadie
Copy link
Copy Markdown
Contributor

@aabadie aabadie commented May 22, 2017

The ATA8520E is a Sigfox communication module from Microchip. It can be controlled from SPI and is available on the arduino-mkrfox1200 (see #7092).

This PR add supports for the following features:

  • read Atmel and Sigfox versions
  • read device ID and PAC keys required to register the device in the Sigfox cloud backend
  • hardware reset
  • send frame, bit and send/receive frame

I think it can also be possible to add a netdev adaption.

@aabadie aabadie added Area: drivers Area: Device drivers Type: new feature The issue requests / The PR implemements a new feature for RIOT labels May 22, 2017
@aabadie aabadie added this to the Release 2017.07 milestone May 22, 2017
@aabadie aabadie changed the title Driver ata8520 drivers/ata8520: add initial implementation May 22, 2017
@aabadie aabadie added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Aug 29, 2017
@aabadie aabadie force-pushed the driver_ata8520 branch 6 times, most recently from 2b1f0d5 to 361c37a Compare January 12, 2018 14:46
@aabadie aabadie added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 19, 2018
@aabadie aabadie changed the title drivers/ata8520: add initial implementation drivers/ata8520e: add initial implementation Jan 21, 2018
@aabadie aabadie added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 21, 2018
@aabadie aabadie changed the title drivers/ata8520e: add initial implementation drivers/ata8520e: add initial implementation (provides SigFox feature) Jan 21, 2018
@aabadie aabadie changed the title drivers/ata8520e: add initial implementation (provides SigFox feature) drivers/ata8520e: add initial implementation (provides Sigfox feature) Jan 21, 2018
@aabadie aabadie force-pushed the driver_ata8520 branch 4 times, most recently from a3c9df9 to b39c258 Compare January 22, 2018 07:57
@aabadie
Copy link
Copy Markdown
Contributor Author

aabadie commented Jan 22, 2018

This PR is ready for review, I tested it (with #7093) and it works now.

Copy link
Copy Markdown
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.

I've found some minor things. Please also state in the title "without netdev". It might be used in the future, though I really doubt we can use any protocol on top of sigfox (VERY limited bandwidth).

#define CSPIN (dev->params.cs_pin)
#define INTPIN (dev->params.int_pin)
#define RESETPIN (dev->params.reset_pin)
#define POWERPIN (dev->params.power_pin)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmmm... all the above defines look a bit weird to me, since I have no knowledge of what is dev. Did you find this style in other drivers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, these are helper defines, see here for example

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK.

#define SPI_CS_DELAY (US_PER_MS)
#define DELAY_10_MS (10 * US_PER_MS) /* 10 ms */
#define TX_TIMEOUT (8U) /* 8 s */
#define TX_RX_TIMEOUT (50U) /* 50 s */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please align the comments.

@aabadie
Copy link
Copy Markdown
Contributor Author

aabadie commented Jan 25, 2018

Comments addressed @kYc0o

@aabadie aabadie changed the title drivers/ata8520e: add initial implementation (provides Sigfox feature) drivers/ata8520e: add initial implementation (without netdev but provides Sigfox feature) Jan 25, 2018
@aabadie
Copy link
Copy Markdown
Contributor Author

aabadie commented Jan 25, 2018

And PR title updated

@kYc0o
Copy link
Copy Markdown
Contributor

kYc0o commented Jan 25, 2018

Tested (with #7093) ACK.

@kYc0o kYc0o merged commit 972b0ab into RIOT-OS:master Jan 25, 2018
@haukepetersen
Copy link
Copy Markdown
Contributor

Sorry for mentioning this only now (are scanning through my backlog this morning...): I think there are still some issues to fix in this driver, most of them w.r.t. to debug code. For example in the init function: if debug is enabled, ata8520e_read_sigfox_version() is called, followed by a call to ata8520e_status() which ends with power_off. Now the read version functions ends with _poweroff(), but the status() function does not turn on power again, so this seems broken, right?

Also, the _poweroff() function seems incorrect, shouldn't the command be send before releaseing the power pin?

These are all things that a reviewer should notice when doing a CODE review! So please make sure you watch for these things!

@aabadie
Copy link
Copy Markdown
Contributor Author

aabadie commented Jan 26, 2018

These are all things that a reviewer should notice when doing a CODE review!

Another thing is to look at the datasheet before starting reviewing.

the _poweroff() function seems incorrect

This is what is in the datasheet, see section 2.1.2.5 page 11

but the status() function does not turn on power again, so this seems broken, right?

No because this function is called by other functions that switch the device on before.

@aabadie
Copy link
Copy Markdown
Contributor Author

aabadie commented Jan 26, 2018

BTW, if you see some things that could be changed (e.g remove ata8520e_status from public API, etc). Let me know here and I'll open a PR with the changes.

@haukepetersen
Copy link
Copy Markdown
Contributor

Never mind about the issue in the poweroff() function, you are right and I should have looked into the datasheet. Maybe we can try to comment such kind of 'uncommon' calls so that it is clear this was intended and required by the device? And please remind me in my own PRs :-)

but the status() function does not turn on power again, so this seems broken, right?

No because this function is called by other functions that switch the device on before.

In general yes, but with debug enabled this seems not to be true for line 291. Power is disabled in line 281, and then not enabled agian inside the ata8520e_status() function in line 291. It seems I am missing something here?!

And I forgot to say: nice work with this driver! I am really not just trying to be nitpicky here. I just recently started to stumbled upon many cases where we (me included) merged stuff with more or less obvious flaws, so I am trying to raise the awareness for thorough reviewing a bit...

@kYc0o
Copy link
Copy Markdown
Contributor

kYc0o commented Jan 26, 2018

These are all things that a reviewer should notice when doing a CODE review! So please make sure you watch for these things!

I accept that there are some things I don't check exhaustively, but here the real mistake is that this review was done with the author sit next to me, so I asked why some things seemed weird and he explained them. Problem: if someone comes afterwards and such questions are not logged here we trigger the situation just happened. I'll make myself sure I log every question when I review something along with the author.

Second, this is a new driver and the users are very limited. I wasn't expecting a perfect implementation when a first version is PRed. If someone uses it and discovers a problem that can be fixed with another PR, and so on. IMHO there's nothing critical here.

And third: this PR adds a new feature which is super useful in RIOT, I was suprised about the simplicity of the driver and how we could send packets (small, yes) and receive them through the Internet with 0 infrastructure on our side! Thus, having this on master seemed awesome to me, with no harm, nothing was broken in RIOT afterwards.

@haukepetersen
Copy link
Copy Markdown
Contributor

@aabadie see #8449 -> better to fix than to complaim, right :-)

@kYc0o I think we have very differing opinions about reviewing...

I accept that there are some things I don't check exhaustively

This is IMHO a problem.

Second, this is a new driver and the users are very limited. I wasn't expecting a perfect implementation when a first version is PRed. If someone uses it and discovers a problem that can be fixed with another PR, and so on. IMHO there's nothing critical here.

Ok, here we seem to have a very different understanding and/or expectation in the group of maintainers. But here is the wrong place for discussion, I will put this on the agenda of the next maintainer meeting.

And third: this PR adds a new feature which is super useful in RIOT, I was suprised about the simplicity of the driver and how we could send packets (small, yes) and receive them through the Internet with 0 infrastructure on our side! Thus, having this on master seemed awesome to me, with no harm, nothing was broken in RIOT afterwards.

I totally agree, this driver is awesome!

@kYc0o
Copy link
Copy Markdown
Contributor

kYc0o commented Jan 26, 2018

I accept that there are some things I don't check exhaustively

This is IMHO a problem.

I was talking about this PR.

Ok, here we seem to have a very different understanding and/or expectation in the group of maintainers. But here is the wrong place for discussion, I will put this on the agenda of the next maintainer meeting.

Yes, let's discuss it in the right channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR 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.

4 participants