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

drivers/at30tse75x: add device driver for AT30TSE75x temperature sensor #3755

Merged
merged 1 commit into from
Oct 2, 2015

Conversation

daniel-k
Copy link
Member

@daniel-k daniel-k commented Sep 1, 2015

This PR add a device driver for the AT30TSE75x series temperature sensors included in the ATIO1-XPRO dev board. There's also a EEPROM on the same chips, for which I will add driver support later.

This PR weakly depends on #3751, but should work without error feedback nevertheless.

@daniel-k daniel-k added Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: drivers Area: Device drivers labels Sep 1, 2015
@daniel-k daniel-k force-pushed the pr/at30tse75x branch 2 times, most recently from d0e9619 to 51ab79f Compare September 1, 2015 15:23
@PeterKietzmann
Copy link
Member

@daniel-k thanks for the nice driver! Is the review urgent? Generally I would review this PR, but currently this may take some time. Does someone own this piece of hardware? Maybe @kaspar030?

@PeterKietzmann
Copy link
Member

Ah, and I will assign myself for now. If someone else has capacities for a review, feel free to assign yourself :-) !

@PeterKietzmann PeterKietzmann self-assigned this Sep 1, 2015
@daniel-k
Copy link
Member Author

daniel-k commented Sep 1, 2015

No, it's not urgent. Nothing depends on it, so take your time. Maybe the EEPROM driver will be finished before this get's merged (depending on my motivation) but I'd open a separate PR anyway.

@daniel-k
Copy link
Member Author

daniel-k commented Sep 2, 2015

@PeterKietzmann

I'm not sure if it's a good idea to call i2c_init_master() inside the driver. Shouldn't this be called by the user code, because every i2c driver would then initialize the master device again? I'm asking because other driver are doing the same.

@OlegHahm OlegHahm modified the milestone: Release NEXT MAJOR Sep 2, 2015
@PeterKietzmann
Copy link
Member

I know I know.. Please check #2528?



#include "periph/i2c.h"
#include "hwtimer.h"
Copy link
Member

Choose a reason for hiding this comment

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

@daniel-k, sorry for the delay. Could you adapt the implementation to use xtimer please

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, see 0d171a8 3b9b21c.

}

switch(mode) {
case AT30TSE75X_MODE_ONE_SHOT:
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure out of my head if it's written in our coding conventions, but I think that case is indented against switch mostly

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm just aware of these coding conventions and they don't mention this. But I don't really have an opinion on this, so I can adapt it if you wish.

EDIT: Linux kernel coding conventions even say to not indent case :P

Copy link
Member

Choose a reason for hiding this comment

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

Honestly I don't even care either. Just wanted to make it look similar to other code. Are there other opinions?

@daniel-k daniel-k added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Sep 29, 2015
AT30TSE75X_CONFIG__RESOLUTION_SHIFT;

/* Wait until conversion is finished */
xtimer_usleep((uint32_t)(25000 << resolution));
Copy link
Member

Choose a reason for hiding this comment

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

I understand that the conversion time is dependent from the resolution. But why shifting 25000?

Copy link
Member Author

Choose a reason for hiding this comment

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

The conversion time is a multiple of 25ms. See datasheet p.47.

EDIT: Shifting because it's multiplication by 2^resolution.

@PeterKietzmann
Copy link
Member

@daniel-k thanks again for that PR. Code looks nice overall. Please adapt the discussed changes. After that we should see what the build tests report. Again: Does anyone own that hardware (e.g. ATIO1-XPRO dev board) ? Would be nice if the PR is tested by a second party before merging it.

@daniel-k
Copy link
Member Author

@PeterKietzmann
When testing the board again it suddenly not worked anymore. After some (too much) debugging I found out that the mcu is too fast calling driver functions that access I2C successively so that the bus free time of at least 600ns (p.48) is violated and communication fails. I fixed this by prefixing every bus access by the driver with a 1us spin. Considering the already slow operation of I2C (100kHz) this shouldn't hurt too much.

Additionally I rebased on master and squashed everything that has been reviewed already into the first commit, as well as some cleanups and a sanity check of the supplied device address.

return -1;
}

#if ENABLE_DEBUG
Copy link
Member

Choose a reason for hiding this comment

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

I think you can remove these preprocessor instructions now

@PeterKietzmann
Copy link
Member

@daniel-k thanks for addressing my comments. I'm fine with the small delay before the bus access. IIRC we had a similar situation for an other sensor (but with the CS line of SPI). Please address my latest minor comments. After that we can run Travis.

@daniel-k daniel-k added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable labels Oct 1, 2015
@daniel-k
Copy link
Member Author

daniel-k commented Oct 1, 2015

Travis running, but still needs squashing.

@PeterKietzmann
Copy link
Member

@daniel-k Travis failed for several boards because of a redefinition of MODULE_AT30TSE75X in sc_at30tse75x.c. Please remove that define out of the script. AFAIK this is generated by the makefile.

#include <stdlib.h>
#include <stdbool.h>
#include "at30tse75x.h"
#define MODULE_AT30TSE75X
Copy link
Member

Choose a reason for hiding this comment

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

Why did you introduce this in late before last commit? Travis complains about that define. (He complains about redefinition and I think it is initially defined by the makefile system)

Copy link
Member Author

Choose a reason for hiding this comment

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

This slipped through by accident. Eclipse doesn't know those defines, so auto-completion doesn't work inside unknown #ifdefs.

Copy link
Member

Choose a reason for hiding this comment

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

Run make eclipsesym to create an eclipse symbol xml file that you can
import into your eclipse project. There's a page in the wiki about it.
On Oct 2, 2015 12:17 PM, "Daniel Krebs" [email protected] wrote:

In sys/shell/commands/sc_at30tse75x.c
#3755 (comment):

  • * @{
  • * @file
  • * @brief Provides shell commands to test AT30TSE75x temperature sensor
  • * @author Daniel Krebs [email protected]
  • * @}
  • */
    +
    +#include <stdio.h>
    +#include <string.h>
    +#include <stdlib.h>
    +#include <stdbool.h>
    +#include "at30tse75x.h"
    +#define MODULE_AT30TSE75X

This slipped through by accident. Eclipse doesn't know those defines, so
auto-completion doesn't work inside unknown #ifdefs.


Reply to this email directly or view it on GitHub
https://github.com/RIOT-OS/RIOT/pull/3755/files#r41007887.

@PeterKietzmann
Copy link
Member

Oh no, there are 14 commits :-) ! @daniel-k please squash again. @OlegHahm the code looks fine to me and Travis succeeded. But no one else has the hardware to test. I tend to merge anyway. Ok with you?

@daniel-k
Copy link
Member Author

daniel-k commented Oct 2, 2015

Finally, travis is happy :-D

@PeterKietzmann
Copy link
Member

As far as I see it, nobody objects merging this PR. Again: I did not test this PR with hardware but the code looks fine now and makes Travis green. Because I'm away for two weeks from now on, I will just merge the PR, so @daniel-k can use the driver in his project in a more comfortable way. Also I do trust him that he'll take care of it, just if it causes some problems (but I assume that won't be the case ;-) )

@PeterKietzmann
Copy link
Member

So ACK and go

PeterKietzmann added a commit that referenced this pull request Oct 2, 2015
drivers/at30tse75x: add device driver for AT30TSE75x temperature sensor
@PeterKietzmann PeterKietzmann merged commit 10bddd5 into RIOT-OS:master Oct 2, 2015
@daniel-k
Copy link
Member Author

daniel-k commented Oct 2, 2015

Also I do trust him that he'll take care of it, just if it causes some problems

Sure! Thanks for merging!

@daniel-k daniel-k deleted the pr/at30tse75x branch October 9, 2015 16:38
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