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

Add inter-bit delay #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dmitrodem
Copy link

Please add delay between bits in message for slow 1-wire devices. For example, inter-bit delay is needed to program RW1990 touch memory. For example, writing new ID on such key could be as simple as

#include <OneWire.h>

OneWire ds(10); 

static const byte rw1990_key[] = {0x01, 0x27, 0x4f, 0x27, 0x01, 0x00, 0x00, 0xd5};

void cmd_rw1990_write(void) {
  if (!ds.reset()) {
    return;
  }
  ds.write(0xd1);
  ds.write_bit(0);
  _delay_ms(10);

  if (!ds.reset()) {
    return;
  }
  ds.write(0xd5);
  ds.set_bit_delay(2000);
  for (uint8_t i = 0; i < 8; i++) {
    ds.write(~rw1990_key[i]);
  }
  ds.set_bit_delay(0);
  
  if (!ds.reset()) {
    return;
  }
  ds.write(0xd1);
  ds.write_bit(1);
  _delay_ms(10);
}

(much simpler than original code at https://habr.com/ru/post/260891/ )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant