Пример #1
0
void nx__abort(bool data, U32 pc, U32 cpsr) {
  nx_interrupts_disable();
  nx_display_auto_refresh(FALSE);
  //nx_display_clear();
  if (data) {
    nx_display_string("Data");
  } else {
    nx_display_string("Prefetch");
  }
  nx_display_string(" abort\nPC: ");
  nx_display_hex(pc);
  nx_display_string("\nCPSR: ");
  nx_display_hex(cpsr);
  nx__lcd_sync_refresh();
  while(1);
}
Пример #2
0
void main() {
  /* We want to draw a moving ellipse, two arcs and two lines */
  /* Declaring center point of the ellipse / arcs and  points representing the lines */
  point ellipse_c, q, r, s, t, u, v, w;

  /* Initialize ellipse center position */
  ellipse_c.x = 1;
  ellipse_c.y = 1;

  /* Initialize the first line position*/
  q.x = 3;
  q.y = 63;

  s.x = 28;
  s.y = 63;

  /* Initialize the second line position */
  r.x = 102;
  r.y = 63;

  t.x = 76;
  t.y = 63;

  /* initialize the triangle position */
  u.x = 48;
  u.y = 33;

  v.x = 48;
  v.y = 45;

  w.x = 61;
  w.y = 39;

  /* Superior radius of the ellipse */
  U8 sradius = 85;
  /* Difference between the superior and inferior radius of the ellipse */
  U8 delta = 73;
  /* Offset angle for arcs rotation */
  U32 offset_angle = 60;
  /* Disable auto refresh of the screen, we want to control each frame */
  nx_display_auto_refresh(FALSE);

  /* Loop until the cancel button is pushed 
  Each loop iteration represent a frame composed of three steps*/
  while (nx_avr_get_button() != BUTTON_CANCEL) {
    /* Clear the screen */
    nx_display_clear();

    /* First step of the frame : calculate positions and parameters of shapes */

    /* If the ellipse is in the first half of the screen,
      make it follow a pseudo sinusoidal path */
    if(ellipse_c.x < 53) {
      ellipse_c.x ++;
      delta--;
      ellipse_c.y = (30 * sinf( ((float) ellipse_c.x) / 25) + 4);
    }
    /* If the ellipse have past the first third of the screen,
      then start to move lines and rotate arcs */
    if(ellipse_c.x > 34) {

      if(ellipse_c.x < 49) {
        q.x = (q.x) + 2;
        s.x = (s.x) + 2;
        r.x = (r.x) - 2;
        t.x = (t.x) - 2;
        offset_angle += ellipse_c.x;
      }
      else if(offset_angle > 5)
        offset_angle -= 5;
    }

    /* Second step of the frame : draw shapes on the screen buffer*/

    /* If the ellipse have past the first third of the screen, 
    draw moving arcs around and lines at the bottom of the screen */    
    if(ellipse_c.x > (34)) {
      nx_display_arc(ellipse_c, 27, 45, offset_angle);
      nx_display_arc(ellipse_c, 27, 45, (180 + offset_angle));
      nx_display_line(q, s);
      nx_display_line(r, t);
    }
    /* If the ellipse is at the middle of the screen, 
    write "NxOS on the screen */
    if(ellipse_c.x > 52) {
      nx_display_cursor_set_pos(7, 3);
      nx_display_string("NxOS");
    }
    /* Just draw the ellipse, every frame */
    nx_display_ellipse(ellipse_c, (sradius / 4), ((sradius - delta) / 3), (ellipse_c.x * 20) ); 

    nx_display_triangle(u, v, w);
    /* Last step of the frame : refresh the screen */
    nx_display_refresh();

    /* Wait a bit before next frame */
    nx_systick_wait_ms(85);
  }    
  /* Shutdown the brick */
  nx_core_halt();

}