You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/01/19 19:36:51 UTC

[GitHub] [incubator-nuttx] fjpanag commented on pull request #2717: I2C bitbang driver (and nRF52 implementation)

fjpanag commented on pull request #2717:
URL: https://github.com/apache/incubator-nuttx/pull/2717#issuecomment-763080354


   > BTW, this is yet untested since I'm unsure about proper GPIO handling on nRF52. I understand that the pin should be set to open-drain, but I think nRF52 does not really support this.
   
   > https://devzone.nordicsemi.com/f/nordic-q-a/28373/nrf52810-open-drain-gpio
   
   I have never used these MCUs, but from your link above I understand that it does actually support open-drain configuration.  
   Instead of setting the GPIO as open-drain, as with other MCUs (like STM32 or LPC), you just disable the HIGH side driver. Thus the pin can sink current, but it is in high-Z when set to HIGH.  
   So I believe that this is OK.
   
   > So my reasoning is to using push-pull and switch between OUTPUT/INPUT when required. Although not sure if that is entirely safe (ie, if I send a 1 and the slave sends a 0). I think the drive setting should take care of that, but I've read something about this still being a bit dangerous.
   
   This is very possible in I2C, but you must guarantee that there will be no "conflict", having two devices driving the bus simultaneously. If they do, it is a short-circuit, and even if your prototype works, it is unknown how other devices will behave, or what will be its life-span.
   
   If you absolutely have to do this, then serial resistors are needed.
   
   Two drivers may operate simultaneously in one of the following cases:
   - Multi-master bus. Just forget about it in bit-banging implementations.
   - Clock-stretching. This is documented in the peripheral's datasheet. If the device supports it, then you must assume that it can always stretch the clock. Thus a simple GPIO solution won't do. Best-case scenario, the protocol breaks, worst scenario a part gets damaged.
   
   If the NuttX nRF52 GPIO implementation does not support open-drain mode but the chip does, I would suggest that this needs to be addressed first.
   
   
   > I will place 1.5k resistors on the line without a device, for now...
   These are on the "strong" side, and possibly unneeded for such a small PCB.
   I am afraid that they may get you very close to the maximum of the chip, based on [this](https://devzone.nordicsemi.com/f/nordic-q-a/12614/max-gpio-current-for-nrf52).
   Maybe start with weaker pull-ups?
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org