Пример #1
0
void stepReportAxes(void)
{
    uart_send_u16(posX);
    uart_send_buffered(':');
    uart_send_u16(posY);
    uart_send_buffered(':');
    uart_send_u16(posZ);
    uart_crlf();
}
Пример #2
0
void uart_dump(u8 *mem, int len)
{
  int i;
  while(len)
  {
    uart_puthex((u32)mem);
    uart_puts("  ");
    for (i = 0; i < 16; i++)
    {
      uart_puthex8(*mem);
      uart_putc(' ');
      mem++;
      len --;
      if (len == 0)
        break;
    }
    uart_crlf();
  }
}
Пример #3
0
int main(void)
{
    int i;
    int line_count;

    hw_init();
    uart_init();
    
    uart_puts("Exstina-50 - Display Unit Test\r\n");
    uart_crlf();
    
    disp_init();
    
    /* Show line 1 */
    disp_puts(3, "   Exstina 50   ");
    /* Wait a short time */
    for (i = 0; i < 0x10000; i++)
        ;
    /* Show line 4 */
    disp_puts(0, "Display test 0.2");
    
    line_count = 0;

    while(1)
    {
        while (but_value() == 0)
            ;
        if (but_value() & 2)
        {
            disp_puts(line_count & 0x03, "Button 0        ");
            line_count ++;
        }
        if (but_value() & 8)
        {
            disp_puts(line_count & 0x03, "Button 1        ");
            line_count ++;
        }
        while (but_value() != 0)
            ;
    }
}
Пример #4
0
void uart_dump512(u8 *buff)
{
 u8 stored_flags1;
 stored_flags1=flags1;
 flags1&=~(ENABLE_SD_LOG|ENABLE_SCR|ENABLE_DIRECTUART);
 flags1|=ENABLE_UART;
 print_msg(PGMSTR("\r\n;     .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F"));
 u16 i;
 i=0;
 do
 {
  uart_crlf();
  print_hexbyte(i&0xff);
  print_hexbyte(i>>8);
  uart_putchar(0x20);
  uart_putchar(0x20);
  u8 j;
  for (j=0;j<16;j++) print_hexbyte_for_dump(buff[i+j]);
  uart_putchar(0x20);
  for (j=0;j<16;j++) put_char_for_dump(buff[i+j]);
  i+=16;
 }while (i<512);
 flags1=stored_flags1;
}
Пример #5
0
static void upd_flash(tftp *tftp)
{
  char str[17];
  int tftp_block;
  u32 waddr;
  u32 sector, last_sector;
  int len;
  
  tftp_init(tftp);
  tftp->filename = upd_mem;
  
  waddr = 0;
  last_sector= 0xFFFFFFFF;
  
  while(1)
  {
    tftp_run(tftp);
    if ( (tftp->state == 2) ||
         (tftp->state == 3))
    {
        if (tftp->lastblock != tftp_block)
        {
          tftp_block = tftp->lastblock;
          
          strcpy(str, "Load flash      ");
          b2ds(&str[11], tftp_block);
          oled_pos(0, 0);
          oled_puts(str);

          sector = (tftp_block << 9) & 0xFFFF0000;
          if (sector != last_sector)
          {
            flash_erase(sector);
            last_sector = sector;
          }
          uart_puts(str); uart_putc('\r');
          
          len = 0;
          if (tftp->length > 4)
          {
            u8 *dat;
            dat = (u8 *)&tftp->data[4];
            
            len = tftp->length - 4;
            if (len > 256)
            {
              flash_write(waddr, dat, 256);
              len   -= 256; /* Update remaining data length */
              dat   += 256; /* Move the source pointer      */
              waddr += 256; /* Update the dest address      */

              /* Wait for the write transfer ends */
              while(flash_status() & 1)
                ;
            }
            flash_write(waddr, dat, len);
            /* Wait for the write transfer ends */
            while(flash_status() & 1)
              ;
            /* Update write address for next packet */
            waddr += len;
          }
        }
        tftp_ack(tftp);
    }
    if (tftp->state == 3)
    {
      uart_crlf();
      break;
    }
    if (tftp->state == 98)
    {
      uart_puts("TFTP timeout, restart\r\n");
      oled_pos(0, 0);
      oled_puts("TFTP: timeout!");
      tftp->timestamp = 0x3000;
      tftp->state = 0;
    }
    if (tftp->state == 99)
    {
      uart_puts("upd_firmware() TFTP error 99\r\n");
      break;
    }
  }
}