Exemplo n.º 1
0
void serial_putchar(sio_fd_t fd, uint32_t c)
{
  uint32_t *uart_tx = fd + UART_TX;
  while(!serial_ready(fd))
    ; /* Wait for empty transmit */
  mmio_write32(uart_tx, c);
}
Exemplo n.º 2
0
void
serial_reset ()
{
  usleep (10000);
  Reset (1);
  usleep (10000);
  Reset (0);
  usleep (10000);
  while (serial_ready ())
    serial_read ();
}
Exemplo n.º 3
0
Arquivo: serial.c Projeto: KGG814/AOS
static int serial_putchar(ps_chardevice_t* device, int c)
{
    uint32_t io_port = (uint32_t) device->vaddr;

    /* Check if serial is ready. */
    if (!serial_ready(device)) {
        return -1;
    }

    /* Write out the next character. */
    ps_io_port_out(&device->ioops.io_port_ops, CONSOLE(io_port, THR), 1, c);

    if (c == '\n') {
        /* If we output immediately then odds are the transmit buffer
         * will be full, so we have to wait */
        while (!serial_ready(device));
        serial_putchar(device, '\r');
    }

    return c;
}
Exemplo n.º 4
0
int touch_isDown() {
	return (serial_ready(TOUCHSCREEN) & 0x1) == 0x1;
}
Exemplo n.º 5
0
int
main (int argc, char **argv)
{
  net_addr remote;
  int serial;
  int net;

  graphics_initialise ();
  graphics_mode (0);

  serial = serial_open ();
  net = net_open ();

  if (argc != 1)
  {
    if (argc != 2)
    {
      fprintf (stderr, "only 1 or 0 args\n");
      return 1;
    }

    if (strcmp (argv[1], "--final"))
    {
      fprintf (stderr, "unrecognised option\n");
      return 1;
    }
  }
  else
    randomised = true;

  printf ("randomised: %d\n", randomised);

  while (serial_ready (serial))
    serial_discard (serial);
  net_addr_set (&remote, "10.0.0.2");

  while (true)
  {
    bool ended;

    /* wait for user */
    reset_the_physics (true);
    publish_the_physics (serial, net, &remote);
    graphics_render (0, 0);

    while (!serial_ready (serial))
      check_sdl ();

    reset_the_physics (false);
    ended = false;
    while (!ended)
    {
      serial_read (serial);
      poll (NULL, 0, 10);
      ended = physics_update ();
      publish_the_physics (serial, net, &remote);
      check_sdl ();
      graphics_render (0, 0);
    }

    while (check_sdl () != ' ')
      poll (NULL, 0, 10);

    while (serial_ready (serial))
      serial_read (serial);
  }
}