OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [cmds/] [camera.c] - Diff between revs 246 and 406

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 246 Rev 406
Line 27... Line 27...
#define get_mem32(addr)  (*((unsigned long *) (addr)))
#define get_mem32(addr)  (*((unsigned long *) (addr)))
#define set_palette(idx,r,g,b) set_mem32 (CRT_BASE + 0x400 + (idx) * 4, (((r) >> 3) << 11) | (((g) >> 2) << 5) | (((b) >> 3) << 0))
#define set_palette(idx,r,g,b) set_mem32 (CRT_BASE + 0x400 + (idx) * 4, (((r) >> 3) << 11) | (((g) >> 2) << 5) | (((b) >> 3) << 0))
#define put_pixel(xx,yy,idx)   (*(unsigned char *)(FRAME_BUF + (xx) + (yy) * SCREEN_X) = (idx))
#define put_pixel(xx,yy,idx)   (*(unsigned char *)(FRAME_BUF + (xx) + (yy) * SCREEN_X) = (idx))
 
 
int camera_pos_x;
int camera_pos_x;
 
 
int camera_move_speed = 1;
int camera_move_speed = 1;
 
 
int current_buf;
int current_buf;
 
 
 
 
void camera_int (void)
void camera_int (void)
{
{
 
 
  /* Change base addresse of camera */
  /* Change base addresse of camera */
  set_mem32 (CAMERA_BASE, CAMERA_BUF(current_buf)); /* Set address to store to */
  set_mem32 (CAMERA_BASE, CAMERA_BUF(current_buf)); /* Set address to store to */
 
 
 
 
  /* Change base addresse of crt */
  /* Change base addresse of crt */
  set_mem32 (CRT_BASE + 8, CAMERA_BUF(1 - current_buf)); /* Tell CRT when camera buffer is */
  set_mem32 (CRT_BASE + 8, CAMERA_BUF(1 - current_buf)); /* Tell CRT when camera buffer is */
 
 
  printf ("\n %08x\n ", CAMERA_BUF(current_buf));
  printf ("\n %08x\n ", CAMERA_BUF(current_buf));
 
 
 
 
  current_buf = 1 - current_buf;
  current_buf = 1 - current_buf;
 
 
 
 
  /* move the camera screen around */
  /* move the camera screen around */
  camera_pos_x += camera_move_speed;
  camera_pos_x += camera_move_speed;
 
 
  if (camera_pos_x >= SCREEN_X - CAMERA_X || camera_pos_x <= 0)
  if (camera_pos_x >= SCREEN_X - CAMERA_X || camera_pos_x <= 0)
 
 
    camera_move_speed = -camera_move_speed;
    camera_move_speed = -camera_move_speed;
 
 
  mtspr(SPR_PICSR, 0);
  mtspr(SPR_PICSR, 0);
 
 
}
}
 
 
 
 
 
 
int crt_enable_cmd (int argc, char *argv[])
int crt_enable_cmd (int argc, char *argv[])
{
{
 
 
  int i, x, y;
  int i, x, y;
 
 
  if (argc) return -1;
 
 
if (argc)
 
                return -1;
 
 
  /* Init CRT */
  /* Init CRT */
  set_mem32 (CRT_BASE + 4, FRAME_BUF); /* Frame buffer start */
  set_mem32 (CRT_BASE + 4, FRAME_BUF); /* Frame buffer start */
 
 
  set_mem32 (CRT_BASE, get_mem32 (CRT_BASE) | 1);          /* Enable CRT only */
  set_mem32 (CRT_BASE, get_mem32 (CRT_BASE) | 1);          /* Enable CRT only */
 
 
 
 
  /* Init palette */
  /* Init palette */
  for (i = 0; i < 32; i++) {
  for (i = 0; i < 32; i++) {
 
 
    set_palette (8 * i + 0, 0x00, 0x00, 0x00); /* black */
    set_palette (8 * i + 0, 0x00, 0x00, 0x00); /* black */
 
 
    set_palette (8 * i + 1, 0xff, 0xff, 0xff); /* white */
    set_palette (8 * i + 1, 0xff, 0xff, 0xff); /* white */
 
 
    set_palette (8 * i + 2, 0x7f, 0x7f, 0x7f); /* gray */
    set_palette (8 * i + 2, 0x7f, 0x7f, 0x7f); /* gray */
 
 
    set_palette (8 * i + 3, 0xff, 0x00, 0x00); /* red */
    set_palette (8 * i + 3, 0xff, 0x00, 0x00); /* red */
 
 
    set_palette (8 * i + 4, 0x00, 0xff, 0x00); /* green */
    set_palette (8 * i + 4, 0x00, 0xff, 0x00); /* green */
 
 
    set_palette (8 * i + 5, 0x00, 0x00, 0xff); /* blue */
    set_palette (8 * i + 5, 0x00, 0x00, 0xff); /* blue */
 
 
    set_palette (8 * i + 6, 0x00, 0xff, 0xff); /* cyan */
    set_palette (8 * i + 6, 0x00, 0xff, 0xff); /* cyan */
 
 
    set_palette (8 * i + 7, 0xff, 0x00, 0xff); /* purple */
    set_palette (8 * i + 7, 0xff, 0x00, 0xff); /* purple */
 
 
  }
  }
 
 
  for (x = 0; x < SCREEN_X; x++)
  for (x = 0; x < SCREEN_X; x++)
 
 
    for (y = 0; y < SCREEN_Y; y++)
    for (y = 0; y < SCREEN_Y; y++)
 
 
      put_pixel(x, y, 3);
      put_pixel(x, y, 3);
 
 
  return 0;
  return 0;
 
 
}
}
 
 
 
 
 
 
int crt_test_cmd (int argc, char *argv[])
int crt_test_cmd (int argc, char *argv[])
{
{
 
 
  int i, x, y;
  int i, x, y;
  if (argc) return -1;
 
 
if (argc)
 
                return -1;
 
 
  for (x = 0; x < SCREEN_X; x++)
  for (x = 0; x < SCREEN_X; x++)
 
 
    for (y = 0; y < SCREEN_Y; y++)
    for (y = 0; y < SCREEN_Y; y++)
 
 
      put_pixel(x, y, 0);
      put_pixel(x, y, 0);
 
 
 /* Draw gray X */
 /* Draw gray X */
  for (i = 0; i < SCREEN_Y; i++) {
  for (i = 0; i < SCREEN_Y; i++) {
 
 
    put_pixel (i, i, 2);
    put_pixel (i, i, 2);
 
 
    put_pixel (SCREEN_X - i - 1, i, 1);
    put_pixel (SCREEN_X - i - 1, i, 1);
 
 
  }
  }
 
 
 
 
  /* Draw color boxes */
  /* Draw color boxes */
  for (y = 0; y < 50; y++)
  for (y = 0; y < 50; y++)
 
 
    for (x = 0; x < 50; x++)
    for (x = 0; x < 50; x++)
 
 
      for (i = 0; i < 8; i++)
      for (i = 0; i < 8; i++)
 
 
        put_pixel (i * 50 + x, y, i);
        put_pixel (i * 50 + x, y, i);
 
 
  return 0;
  return 0;
 
 
}
}
 
 
 
 
 
 
int crt_disable_cmd (int argc, char *argv[])
int crt_disable_cmd (int argc, char *argv[])
{
{
  if (argc) return -1;
 
 
if (argc)
 
                return -1;
 
 
  set_mem32 (CRT_BASE, get_mem32 (CRT_BASE) & ~1);             /* Disable CRT */
  set_mem32 (CRT_BASE, get_mem32 (CRT_BASE) & ~1);             /* Disable CRT */
 
 
  return 0;
  return 0;
 
 
}
}
 
 
 
 
 
 
int camera_enable_cmd (int argc, char *argv[])
int camera_enable_cmd (int argc, char *argv[])
{
{
  if (argc) return -1;
 
 
if (argc)
 
                return -1;
 
 
  /* Init Camera */
  /* Init Camera */
  set_mem32 (CAMERA_BASE, CAMERA_BUF(current_buf = 0)); /* Set address to store to */
  set_mem32 (CAMERA_BASE, CAMERA_BUF(current_buf = 0)); /* Set address to store to */
 
 
  set_mem32 (CAMERA_BASE + 4, 1);         /* Enable it */
  set_mem32 (CAMERA_BASE + 4, 1);         /* Enable it */
 
 
 
 
  /* Init CRT to display camera */
  /* Init CRT to display camera */
  set_mem32 (CRT_BASE + 8, CAMERA_BUF(1 - current_buf)); /* Tell CRT when camera buffer is */
  set_mem32 (CRT_BASE + 8, CAMERA_BUF(1 - current_buf)); /* Tell CRT when camera buffer is */
 
 
  camera_pos_x = 0;
  camera_pos_x = 0;
 
 
  set_mem32 (CRT_BASE + 0xc, CAMERA_POS);
  set_mem32 (CRT_BASE + 0xc, CAMERA_POS);
 
 
  set_mem32 (CRT_BASE, get_mem32 (CRT_BASE) | 2);         /* Enable camera overlay */
  set_mem32 (CRT_BASE, get_mem32 (CRT_BASE) | 2);         /* Enable camera overlay */
 
 
 
 
  /* Enable interrupts */
  /* Enable interrupts */
  mtspr (SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
  mtspr (SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
 
 
  mtspr (SPR_PICMR, mfspr(SPR_PICSR) | (1 << 13));
  mtspr (SPR_PICMR, mfspr(SPR_PICSR) | (1 << 13));
 
 
  return 0;
  return 0;
 
 
}
}
 
 
 
 
 
 
int camera_disable_cmd (int argc, char *argv[])
int camera_disable_cmd (int argc, char *argv[])
{
{
  if (argc) return -1;
 
 
if (argc)
 
                return -1;
 
 
  /* Disable interrupts */
  /* Disable interrupts */
  mtspr (SPR_SR, mfspr(SPR_SR) & ~SPR_SR_IEE);
  mtspr (SPR_SR, mfspr(SPR_SR) & ~SPR_SR_IEE);
 
 
  mtspr (SPR_PICMR, mfspr(SPR_PICSR) & ~(1 << 13));
  mtspr (SPR_PICMR, mfspr(SPR_PICSR) & ~(1 << 13));
 
 
 
 
  /* Disable Camera */
  /* Disable Camera */
  set_mem32 (CAMERA_BASE + 4, 1);         /* Enable it */
  set_mem32 (CAMERA_BASE + 4, 1);         /* Enable it */
 
 
  set_mem32 (CRT_BASE, get_mem32 (CRT_BASE) & ~2);                           /* Disable camera overlay */
  set_mem32 (CRT_BASE, get_mem32 (CRT_BASE) & ~2);                           /* Disable camera overlay */
 
 
  return 0;
  return 0;
 
 
}
}
 
 
 
 
 
 
void module_camera_init (void)
void module_camera_init (void)
{
{
 
 
  register_command ("crt_enable", "", "enables CRT", crt_enable_cmd);
  register_command ("crt_enable", "", "enables CRT", crt_enable_cmd);
 
 
  register_command ("crt_disable", "", "disables CRT", crt_disable_cmd);
  register_command ("crt_disable", "", "disables CRT", crt_disable_cmd);
  register_command ("crt_test", "", "enables CRT and displays some test patterns", crt_test_cmd);
 
  register_command ("camera_enable", "", "enables camera", camera_enable_cmd);
register_command("crt_test", "",
  register_command ("camera_disable", "", "disables camera", camera_disable_cmd);
                          "enables CRT and displays some test patterns",
 
                          crt_test_cmd);
 
 
 
register_command("camera_enable", "", "enables camera",
 
                          camera_enable_cmd);
 
 
 
register_command("camera_disable", "", "disables camera",
 
                          camera_disable_cmd);
 
 
}
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.