void output_byte(uint8_t rs, uint8_t data, uint8_t en)
{
    output_nibble(rs, HIGH_NIBBLE(data), en);
    output_nibble(rs, LOW_NIBBLE(data), en);

#ifdef HD44780_READBACK
    /* wait until command is executed by checking busy flag, with timeout */

    /* max execution time is for return home command,
     * which takes at most 1.52ms = 1520us */
    uint8_t busy, timeout = 200;
    do {
        busy = input_byte(0,en) & _BV(BUSY_FLAG);
        _delay_us(10);
        timeout--;
    } while (busy && timeout > 0);
    #ifdef DEBUG
    if (timeout == 0)
        debug_printf("lcd timeout!\n");
    #endif
#else
    /* just wait the maximal time a command can take... */
    _delay_ms(2);
#endif
}
Exemple #2
0
int main(int argc, char **argv)
{
  FILE *f;
  struct stat st;
  int n_read;
  byte *b;

  stat("/etc/passwd", &st);
  f = fopen("/etc/passwd", "r");

  b = (byte *)malloc(st.st_size + 1);
  memset(b, 0, st.st_size + 1);

  n_read = fread(b, sizeof(byte), st.st_size, f);

  fclose(f);

  if (!input_initialize((char *)b))
    return -1;

  while (!input_eof())
    fputc((int)input_byte(), stdout);

  input_cleanup();

  free(b);

  return 0;
}
Exemple #3
0
int main(int argc, char **argv)
{
  if (!input_initialize(NULL))
    return -1;

  while (!input_eof())
    fputc((int)input_byte(), stdout);

  input_cleanup();

  return 0;
}