Example #1
0
PUBLIC	void	in_process(TTY * p_tty,u32 key)
{
	//u8 out_buf[2] = {'\0','\0'};
	u32 raw_code;
	
	if(!(key & FLAG_EXT))
	{
		//out_buf[0] = key_code & 0xFF;
		put_char(p_tty,key);
	}
	else
	{
		raw_code = key & KEY_CODE_MASK;
		switch(raw_code)
		{
			case	F1:
			case	F2:
			case	F3:
				//disp_int(key);
				if((key & FLAG_LALT) || (key & FLAG_RALT))
				{
					switch_console((raw_code - F1) >> 16);
				}
				break;
			default:
				put_char(p_tty,raw_code);
		}
	}
Example #2
0
static void retry_transmit(struct r3964_info *pInfo)
{
   if(pInfo->nRetry<R3964_MAX_RETRIES)
   {
      TRACE_PE("transmission failed. Retry #%d", 
             pInfo->nRetry);
      pInfo->bcc = 0;
      put_char(pInfo, STX);
      flush(pInfo);
      pInfo->state = R3964_TX_REQUEST;
      pInfo->count_down = R3964_TO_QVZ;
      pInfo->nRetry++;
   }
   else
   {
      TRACE_PE("transmission failed after %d retries", 
             R3964_MAX_RETRIES);

      remove_from_tx_queue(pInfo, R3964_TX_FAIL);
      
      put_char(pInfo, NAK);
      flush(pInfo);
      pInfo->state = R3964_IDLE;

      trigger_transmit(pInfo);
   }
}
Example #3
0
// system interrupt handler
extern void sys_handler(void) {
    unsigned st_status = AT91C_BASE_ST->ST_SR & AT91C_BASE_ST->ST_IMR;
    unsigned rtc_status = AT91C_BASE_RTC->RTC_SR & AT91C_BASE_RTC->RTC_IMR;
    unsigned dbgu_status = AT91C_BASE_DBGU->DBGU_CSR & AT91C_BASE_DBGU->DBGU_IMR;
    static unsigned char counter = '0';

    if (dbgu_status & AT91C_US_RXRDY) {
        // disable RXRDY interrupt in DBGU
        AT91C_BASE_DBGU->DBGU_IDR |= AT91C_US_RXRDY;
        // disable rtt interrupt flag
        AT91C_BASE_ST->ST_IDR = AT91C_ST_RTTINC;
        if (wait_status == 1) {
            wait_status = 0;
        }
        else {
            transfer_size = dbgu_xmod_recv((void *)LINUX_BASE_ADDRESS);
            run_kernel();
        }
    }

    // handler of rtt - rttinc
    if (st_status & AT91C_ST_RTTINC) {
        AT91C_BASE_PIOB->PIO_ODSR ^= AT91C_PIO_PB27;
        if (wait_status == 1) {
            put_char(counter);
            counter++;
            if (counter == '6')
                run_kernel();
            put_char(' ');
        }
        else
            put_char('C');
    }
}
/**
 * Construct the "pretty-printed" representation of the name in a short directory entry.
 *
 * @param[in]    fixed  Pointer to name[0] of a DIR_ENT
 *
 * @return  Pointer to static string containing pretty "8.3" equivalent of the
 *          name in the directory entry.
 */
char *file_name(unsigned char *fixed)
{
    static char path[MSDOS_NAME * 4 + 2];
    char *p;
    int i, j;

    p = path;
    for (i = j = 0; i < 8; i++)
	if (fixed[i] != ' ') {
	    while (j++ < i)
		*p++ = ' ';
	    put_char(&p, fixed[i]);
	}
    if (strncmp((const char *)(fixed + 8), "   ", 3)) {
	*p++ = '.';
	for (i = j = 0; i < 3; i++)
	    if (fixed[i + 8] != ' ') {
		while (j++ < i)
		    *p++ = ' ';
		put_char(&p, fixed[i + 8]);
	    }
    }
    *p = 0;
    return path;
}
Example #5
0
int main(void)
{
	char c;
	int term[2], result;
	unsigned int current_term;

	lcd_init();
	keymatrix_init();

	while (1) {
		put_char('>');
		term[0] = 0;
		term[1] = 0;
		current_term = 0;
		while (1) {
			c = get_char();
			put_char(c);
			if ('0' <= c && c <= '9') {
				term[current_term] = (term[current_term] * 10) + (c - '0');
			} else if (c == '*') {
				current_term++;
			} else if (c == '\n') {
				result = term[0] * term[1];
				put_dec(result);
				get_char();	/* 演算結果表示後、何らかのキー入力を待つ */
				break;
			}
		}
		put_char('\n');
	}

	return 0;
}
Example #6
0
void print_simple_condition (STREAM stream, D instance, BOOL escape_p, int print_depth) {
  D format_string = dylan_simple_condition_format_string(instance);
  D format_args = dylan_simple_condition_format_args(instance);
  ignore(print_depth);
  if (escape_p) put_char('"', stream);
  dylan_format(stream, format_string, format_args);
  if (escape_p) put_char('"', stream);
}
static void
_arch_debug_serial_putchar(const char c)
{
    if (c == '\n') {
        put_char('\r');
        put_char('\n');
    } else if (c != '\r')
        put_char(c);
}
Example #8
0
 void do_filter()
 {
     int c;
     while ((c = std::cin.get()) != EOF) {
         if (c != '\n' && col_no_ >= line_length_)
             put_char('\n');
         put_char(c);
     }
 }
Example #9
0
static void echo_char(unsigned char c, struct tty_struct *tty)
{
	if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') {
		put_char('^', tty);
		put_char(c ^ 0100, tty);
		tty->column += 2;
	} else
		opost(c, tty);
}
Example #10
0
void process_command() {
  int command_ptr  = 0;

  initialize_array(command, 80, 0);
  copy_string(command, buffer + C(current_line, 2));
  initialize_array(argument, ARGUMENT_HEAP_SIZE, 0);

  send_rs(command, 10);
  next_line();

  if (str_equal(c_exit, command, 4)) {
    put_char('b');
    put_char('y');
    put_char('e');
    send_display(buffer);
    halt();

  } else if (str_equal(c_cd, command, 3)) {
    int length = copy_string(argument, command + 3);
    change_directory(argument, length);

  } else if (command[0] == 0) {
    return;

  } else {
    int ptr = 0;
    while (command[command_ptr] != ' '
           && command[command_ptr] != 0
           && command_ptr < COLS) {
      int byte = command[command_ptr];
      if (byte >= 'a' && byte <= 'z') {
        byte -= 0x20;
      }
      program_name[ptr] = byte;
      command_ptr += 1;
      ptr += 1;
    }
    program_name[ptr] = 0;

    while (command[command_ptr] == ' ' && command_ptr < COLS) {
      command_ptr += 1;
    }

    ptr = 0;
    while (command[command_ptr] != ' '
           && command[command_ptr] != 0
           && command_ptr < COLS) {
      argument[ptr] = command[command_ptr];
      command_ptr += 1;
      ptr += 1;
    }
    argument[ptr] = 0;
    argument[ARGUMENT_HEAP_SIZE-1] = current_directory_id;
    execute_bin(program_name, argument);
  }
}
Example #11
0
void put_uint64(uint64_t i)
{
  char str[32];
  int n = 0;
  while (i > 0) { str[n] = '0' + (i % 10); i /= 10; n++; }
  if (n == 0)
    put_char('0');
  else
    while (n > 0) { n--; put_char(str[n]); }
}
Example #12
0
acoral_32 console_write(void *data,acoral_u32 size,acoral_time tm_out){
	acoral_u32 i;
  	char p;
	for(i=0;i<size;i++){
		p=*((acoral_char *)data+i);
		if(p=='\n')
			put_char('\r');
		put_char(p);
	}
}
Example #13
0
Boolean
CDR::put_bytes (const Short len, const Ptr data)
{
    Char *tmp = (Char *)data;
    int i;
    put_short (len + 1);
    for (i = 0; i < len; i++)
      put_char (*tmp++);
    put_char ((Char) 0);
    return CDR_TRUE;
}
Example #14
0
File: main.c Project: westrup/stm32
void main(void) {
  uart_init();
  led_init();
  put_string("boot\r\n");
  while (1) {
    led_toggle();
    char c = get_char();
    put_char(c);
    if (c == '\r')
      put_char('\n');
  }
}
Example #15
0
 void do_filter()
 {
     int c;
     while ((c = std::cin.get()) != EOF) {
         if (c == '\t') {
             int spaces = tab_size_ - (col_no_ % tab_size_);
             for (; spaces > 0; --spaces)
                 put_char(' ');
         } else {
             put_char(c);
         }
     }
 }
Example #16
0
    bool put(Sink& dest, int c)
    {
        for (; spaces_ > 0; --spaces_)
            if (!put_char(dest, ' '))
                return false;

        if (c == '\t') {
            spaces_ = tab_size_ - (col_no_ % tab_size_) - 1;
            return this->put(dest, ' ');
        }

        return put_char(dest, c);
    }
Example #17
0
void tensor2str_recur(char* str, Shape& shape, T* buffer, int& cnt, int& val_cnt, int lv, int formal_indent, char format[])
{
  for (int i = 0; i < formal_indent; ++i) put_char(' ');

  if (shape.size() == 0) {
    char str_buf[16];
    sprintf(str_buf, format, *(buffer + (val_cnt++)));
    auto len = strlen(str_buf);
    memcpy(str + cnt, str_buf, len * sizeof(char));
    cnt += len;
  }
  else if (shape.size() - 1 == lv) {
    put_char('[');
    for (int i = 0; i < shape[lv]; ++i) {
      char str_buf[16];
      sprintf(str_buf, format, *(buffer + (val_cnt++)));
      auto len = strlen(str_buf);
      memcpy(str + cnt, str_buf, len * sizeof(char));
      cnt += len;
      if (i < shape[lv] - 1) {
        put_char(',');
        put_char(' ');
      }
    }
    put_char(']');
  }
  else {
    put_char('[');
    for (int i = 0; i < shape[lv]; i++) {
      tensor2str_recur<T>(str, shape, buffer, cnt, val_cnt, lv + 1, (i == 0 ? 0 : lv) + (int)(i != 0), format);
      if (i < shape[lv] - 1) put_char('\n');
    }
    put_char(']');
  }
}
Example #18
0
/*
 * Send a token to the output at a given line (this is for text output
 * and unreplaced macros due to lack of arguments).
 */
static void print_token_nailed(struct lexer_state *ls, struct token *t,
	long nail_line)
{
	char *x = t->name;

	if (ls->flags & LEXER) {
		print_token(ls, t, 0);
		return;
	}
	if (ls->flags & KEEP_OUTPUT) {
		for (; ls->oline < nail_line;) put_char(ls, '\n');
	}
	if (!S_TOKEN(t->type)) x = operators_name[t->type];
	for (; *x; x ++) put_char(ls, *x);
}
Example #19
0
int printf(const char *format, ...) {
	va_list ap;
	char *fmt = (char *)format;
	int d;
	char c;
	char *s;

	va_start(ap, format);

	while(*fmt) {
		c = *fmt++;
		if(c != '%') {
			put_char(c);
			continue;
		}
		switch(*fmt++) {
			case 'd':
				d = va_arg(ap, int);
				print_num(d, 10);
				break;
			case 'x':
				d = va_arg(ap, int);
				print_num(d, 16);
				break;
			case 'c':
				d = va_arg(ap, int);
				put_char(d);
				break;
			case 's':
				s = va_arg(ap, char *);
				while(*s != '\0') {
					put_char(*s++);
				}
				break;
			case 'b':
				d = va_arg(ap, int);
				print_num(d, 2);
				break;
			case 'o':
				d = va_arg(ap, int);
				print_num(d, 8);
				break;
		}
	}

	va_end(ap);
	return 0;
}
/*
 * UART0 Interrupt Handler
 * Echos received character
 */
void UART0_IRQHandler(void)
{
	PRINTF("Echo:");
    if(UART0_S1 & RDRF_MASK)
    	//PUTCHAR(UART0_D);
    	put_char(UART0_D);
}
Example #21
0
int				ft_printf(char *format, ...)
{
	char		*tmp;
	t_precis	nb;
	t_flag		flag;
	va_list		ap;
	int			len;

	va_start(ap, format);
	tmp = format;
	len = 0;
	nb.j = -1;
	while (nb.j++ < (int)ft_strlen(format) - 1)
	{
		if (tmp[nb.j] == '%' && check_double_modulo(format, &nb) == 1)
			modul(&nb, &flag, format, &len);
		else if (tmp[nb.j] == '%' && tmp[nb.j + 1] != '\0')
		{
			modul_alo(&nb, &flag, format);
			len += check_convers(&flag, ap, format, &nb);
		}
		else if ((tmp[nb.j] != '%' && ft_strlen(format) != 1) ||
				(tmp[nb.j] != '%' && ft_strlen(format) == 1))
			put_char(tmp[nb.j], &len);
	}
	va_end(ap);
	return (len);
}
void LCD::put_string(const char *str, char line){
	
	set_command_mode();
	
	if(line == LINE_1){
		PORTD = 0b10000000;
		send_command();
		PORTD = 0b00000000;
		send_command();
	} else {
		PORTD = 0b11000000;
		send_command();
		PORTD = 0b00000000;
		send_command();
	}
	
	set_text_mode();
	
	while(*str){
		if(*str != '\r' && *str != '\n'){
			put_char(*str++); //don't print \r\n to the LCD display
		}
	};
	
	set_command_mode();
}
Example #23
0
void print_str(const char *str, int row, int col) {
	int backup = cursor;
	cursor = row * WIDTH + col;
	while (*str != '\0')
		put_char(*str++);
	cursor = backup;
}
static void trigger_transmit(struct r3964_info *pInfo)
{
   unsigned long flags;
   

   spin_lock_irqsave(&pInfo->lock, flags);

   if((pInfo->state == R3964_IDLE) && (pInfo->tx_first!=NULL))
   {
      pInfo->state = R3964_TX_REQUEST;
      pInfo->nRetry=0;
      pInfo->flags &= ~R3964_ERROR;
      mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);

      spin_unlock_irqrestore(&pInfo->lock, flags);

      TRACE_PS("trigger_transmit - sent STX");

      put_char(pInfo, STX);
      flush(pInfo);

      pInfo->bcc = 0;
   }
   else
   {
      spin_unlock_irqrestore(&pInfo->lock, flags);
   }
}
Example #25
0
static int
get_int(FILE *fp_in)

{

    int	    n;				/* value */
    int	    ch;				/* next digit */

/*
 * 
 * Reads digits from file *fp_in, copies them to *fp_out, and returns the value of
 * the integer.
 * 
 */

    n = 0;

    while ( isdigit(ch = getc(fp_in)) )  {
	put_char(ch, fp_out);
	n = n * 10 + (ch - '0');
    }	/* End while */

    ungetc(ch, fp_in);
    return(n);

}   /* End of get_int */
Example #26
0
void HwWriteCMD(int HwPort, unsigned char CmdNo, unsigned char* buf)
{
	int i;
	
	while (get_rev_count(HwPort))
	{
		get_char(HwPort);
	}
   	
   	HW_Delay(10);
   	
   	memset (sendBuf, 0, sizeof(sendBuf));
   	*(sendBuf+0) = 'P';
   	*(sendBuf+1) = CmdNo;
   	*(sendBuf+2) = 4;
   	memcpy(sendBuf+3, buf, 4);
   	*(sendBuf+7) = GenerateCRC(sendBuf, sizeof(sendBuf));
   	
	for(i=0; i<8; i++)
	{
		put_char(HwPort, sendBuf[i]);
	}
	HW_Delay(30);
	
	return ;

}
Example #27
0
void put_chars(SCREEN_Screen* scr, const char* str)
{
    while (*str) {
        put_char(scr, *str);
        str++;
    }
}
Example #28
0
static void trigger_transmit(struct r3964_info *pInfo)
{
   unsigned long flags;
   

   save_flags(flags);
   cli();

   if((pInfo->state == R3964_IDLE) && (pInfo->tx_first!=NULL))
   {
      pInfo->state = R3964_TX_REQUEST;
      pInfo->count_down = R3964_TO_QVZ;
      pInfo->nRetry=0;
      pInfo->flags &= ~R3964_ERROR;
      
      restore_flags(flags);

      TRACE_PS("trigger_transmit - sent STX");

      put_char(pInfo, STX);
      flush(pInfo);

      pInfo->bcc = 0;
   }
   else
   {
      restore_flags(flags);
   }
}
Example #29
0
/* send a word on the serial port, little-endian */
void put_word(unsigned w)
{
	put_char(w);
	put_char(w >> 8);
	put_char(w >> 16);
	put_char(w >> 24);
}
Example #30
0
/* tell the target to write a block of memory */
void target_write_block(unsigned addr, const char *buf,
			unsigned size, unsigned progress)
{
	assert(portfd >= 0);
	while (size > 0) {
		char checksum = 0;
		int step = min(size, SERIAL_BLOCKSIZE);
		
		put_char('W');
		put_word(addr);
		put_word(step);
		xawrite(portfd, buf, step);
		addr += step;
		size -= step;
		progress += step;
		while (step-- > 0) {
			checksum += *buf++;
		}
		if (checksum != (char)get_char()) {
			printf("\nSerial checksum error\n");
			exit(1);
		}
		printf("0x%08x\r", progress);
		fflush(NULL);
	}
}