Пример #1
0
static void serial_putc_dev(struct udevice *dev, char ch)
{
	struct dm_serial_ops *ops = serial_get_ops(cur_dev);
	int err;

	do {
		err = ops->putc(cur_dev, ch);
	} while (err == -EAGAIN);
	if (ch == '\n')
		serial_putc('\r');
}
Пример #2
0
void serial_putc(const char c)
{
	if (c == '\n')
		serial_putc('\r');

	/* Wait for fifo to shift out some bytes */
	while (!((readb(&uart->lsr) & (UART_LSR_TDRQ | UART_LSR_TEMT)) == 0x60))
		;

	writeb((u8)c, &uart->rbr_thr_dllr);
}
Пример #3
0
void serial_puts (const char *s)
#endif
{
	while (*s) {
#if defined(CONFIG_SERIAL_MULTI)
		serial_putc_dev (dev_base, *s++);
#else
		serial_putc (*s++);
#endif
	}
}
Пример #4
0
void uart_irq_callback(uint32_t id, SerialIrq event)
{
	serial_t *sobj = (void*)id;

	if(event == RxIrq) {
		acquire_wakelock(WAKELOCK_EXAMPLE);

		rc = serial_getc(sobj);

		if (rc == '\r' || rc == '\n') {
			serial_putc(sobj, '\r');
			serial_putc(sobj, '\n');
			serial_putc(sobj, '#');
			serial_putc(sobj, ' ');

			if (cmdbuf_index != 0) {

                /* NOTICE: If you don't want loss any data from treating UART signal as GPIO interrupt,
                 *         you can set FREERTOS_PMU_TICKLESS_PLL_RESERVED to 1 in "platform_opt.h".
                 *         It will reserved PLL clock in tickless and UART can receive the whole data.
                 *         But it also cost more power consumption.
                 **/

				// process command
				printf("cmd(%d): %s\r\n", cmdbuf_index, cmdbuf);

				// release wakelock and reset buf
				cmdbuf_index = 0;
				release_wakelock(WAKELOCK_EXAMPLE);
			}
		}

		if (!(rc == '\r' || rc == '\n' )) {
			// receive command
			serial_putc(sobj, rc);
			cmdbuf[cmdbuf_index] = rc;
			cmdbuf_index++;
			cmdbuf[cmdbuf_index] = '\0';
		}
	}
}
Пример #5
0
void handleSetSensorRange(uint8_t sensorId, uint8_t measurementId, uint8_t range)
{
	if (sensorId < no_of_sensors_ && measurementId < sensors_[sensorId]->no_of_measurements)
	{
		sensors_[sensorId]->set_range(measurementId, range);

		serial_putc(OBJECT_START);
		serial_putc(CMD_SET_SENSOR_RANGE);
		serial_putc(DELIMITER);
		serial_putc('0' + sensorId);
		serial_putc(DELIMITER);
		serial_putc('0' + measurementId);
		serial_putc(DELIMITER);
		serial_putc('0' + sensors_[sensorId]->range[measurementId]);
		serial_putc(OBJECT_END);
	}
}
Пример #6
0
/* write write out a single char */
extern void serial_putc (char ch)
{
	/* Stream-LF to CR+LF conversion */
	if (ch == 10)
		serial_putc ('\r');

	/* wait till safe to write next char */
	TxCharReady ();

	/* finally, write next char */
	p2_outl (UART_TXBUFFER_REG, ch);
}
Пример #7
0
void serial_printf(const char* fmt, ...)
{
	char* line = malloc(82);
	va_list args;
	int linelen;

	va_start(args, fmt);
	if ((linelen = vsnprintf(line, 82, fmt, args)) >= 82)
	{
		va_end(args);
		va_start(args, fmt);
		free(line);
		line = malloc(linelen + 1);
		vsnprintf(line, linelen + 1, fmt, args);
	}
	serial_puts(line);
	va_end(args);
	free(line);
	serial_putc('\r');
	serial_putc('\n');
}
Пример #8
0
/*==============================================================================
 * - serial_puts()
 *
 * - send a string
 */
int serial_puts(const char *s)
{
    int i = 0;

    SERIAL_FIFO_LOCK();
    while (*s) {
        serial_putc(*s++);
        i++;
    }
    SERIAL_FIFO_UNLOCK();
    return i;
}
Пример #9
0
void serial_putc (const char c)
{
	__REG(UART_PHYS + UTXD) = c;

	/* wait for transmitter to be ready */
	while (!(__REG(UART_PHYS + UTS) & UTS_TXEMPTY))
		WATCHDOG_RESET();

	/* If \n, also do \r */
	if (c == '\n')
		serial_putc ('\r');
}
Пример #10
0
SPL_STATIC_FUNC
void serial_put_hex(unsigned int data,unsigned bitlen)
{
	int i;
    for (i=bitlen-4;i>=0;i-=4){
        if((data>>i)==0)
        {
            serial_putc(0x30);
            continue;
        }

        unsigned char s = (data>>i)&0xf;
        if (s<10)
            serial_putc(0x30+s);
        else
            serial_putc(0x61+s-10);
    }

	serial_wait_tx_empty();

}
Пример #11
0
void serial_putc (const char c)
{
    volatile u8 *uart_lsr = (volatile u8 *)(UART_BASE + OFF_LSR);
    volatile u8 *uart_tdr = (volatile u8 *)(UART_BASE + OFF_TDR);

    if (c == '\n') serial_putc ('\r');

    /* Wait for fifo to shift out some bytes */
    while ( !((*uart_lsr & (UART_LSR_TDRQ | UART_LSR_TEMT)) == 0x60) );

    *uart_tdr = (u8)c;
}
Пример #12
0
/* Send a character */
void serial_putc(const char c)
{
	/* Wait for room in TX FIFO */
	while (REG_RD(DBGUART_BASE + UARTDBGFR) & TXFF)
		;

	/* Write the data byte */
	REG_WR(DBGUART_BASE + UARTDBGDR, c);

	if (c == '\n')
		serial_putc('\r');
}
Пример #13
0
void serial_putc (const char c)
{
	volatile u32 *uart_lsr = (volatile u32*)(UART0_ADDR+UART_LSR);
	volatile u32 *uart_tx = (volatile u32*)(UART0_ADDR+UART_TX);

	if (c == '\n') serial_putc ('\r');

	/* Wait for fifo to shift out some bytes */
	while((*uart_lsr&UART_LSR_THRE)==0);

	*uart_tx = (u32)c;
}
Пример #14
0
void serial_putb (unsigned int d) {
    unsigned int m;
    for (m = 0x80000000; m != 0x00800000; m >>= 1) serial_putc(m & d ? '1' : '0');
    serial_putc(' ');
    for (m = 0x00800000; m != 0x00008000; m >>= 1) serial_putc(m & d ? '1' : '0');
    serial_putc(' ');
    for (m = 0x00008000; m != 0x00000080; m >>= 1) serial_putc(m & d ? '1' : '0');
    serial_putc(' ');
    for (m = 0x00000080; m != 0x00000000; m >>= 1) serial_putc(m & d ? '1' : '0');
}
Пример #15
0
static int ameba_uart_putc (struct rt_serial_device *serial, char c)
{
    struct device_uart* uart;

    uart = serial->parent.user_data;

    /* FIFO status, contain valid data */
    /* write data */
    serial_putc(&uart->serial, c);

    return (1);
}
Пример #16
0
/*
 * Output a single byte to the serial port.
 */
void serial_putc (const char c)
{
	volatile unsigned char *fifo;

	/* If \n, also do \r */
	if (c == '\n')
		serial_putc ('\r');

	fifo = (volatile unsigned char *) &(serial_reg_ch1->fifo);
	TXWAITRDY (serial_reg_ch1);
	*fifo = c;
}
Пример #17
0
STATIC_PREFIX void debug_read_reg(int argc, char * argv[])
{
    unsigned  reg;
    if(argc<2)
    {
        serial_puts("FAIL:Wrong read reg command\n");
        return;
    }
    if(get_dword(argv[1],&reg))
    {
        serial_puts("FAIL:Wrong reg addr=");
        serial_puts(argv[1]);
        serial_putc('\n');
        return;
    }
    serial_puts("OK:Read ");
    serial_put_hex(reg,32);
    serial_putc('=');
    serial_put_hex(readl(reg),32);
    serial_putc('\n');
}
Пример #18
0
int checkboard (void)
{
    vpd_packet_t *packet;
    int i;

    packet = vpd_find_packet(VPD_PID_PID);
    for (i=0; i<packet->size; i++) {
        serial_putc (packet->data[i]);
    }
    packet = vpd_find_packet(VPD_PID_MT);
    for (i=0; i<packet->size; i++) {
        serial_putc (packet->data[i]);
    }
    serial_putc ('(');
    packet = vpd_find_packet(VPD_PID_FAN);
    for (i=0; i<packet->size; i++) {
        serial_putc (packet->data[i]);
    }
    serial_putc (')');

    if (!(MBX_CSR2 & SR2_BATGD))
        printf("\n         *** Warning: Low Battery Status - On-Board Battery ***");
    if (!(MBX_CSR2 & SR2_NVBATGD))
        printf("\n         *** Warning: Low Battery Status - NVRAM Battery ***");

    serial_putc ('\n');

    return (1);
}
Пример #19
0
void draw_print_buffer() {
#ifdef DRAW_DEBUG
uns8	inv_y, x , y,
		 byte_loc, bit_loc;
uns16	 buffer_loc;

	for(y = 0 ; y < DRAW_PIXELS_HIGH ; y++) {
		inv_y = DRAW_PIXELS_HIGH - 1 - y; // need to print out from the top
		if (inv_y < 10) {
			serial_putc('0');
		}
		serial_print_int(inv_y);
		serial_putc(' ');
		serial_print_int_hex(inv_y * DRAW_PIXELS_WIDE / DRAW_PIXELS_PER_BYTE);
		serial_putc('|');
		for(x = 0 ; x < DRAW_PIXELS_WIDE  ; x++) {
			buffer_loc = inv_y * DRAW_PIXELS_WIDE + x;
			byte_loc = buffer_loc / DRAW_PIXELS_PER_BYTE;
			bit_loc = buffer_loc & (DRAW_PIXELS_PER_BYTE -1);

			//if (bit_loc == 0) {
			//	serial_putc(' ');
			//	serial_print_int_hex(byte_loc);
			//	serial_putc(' ');
			//}	
			
			if (test_bit(draw_buffer0[byte_loc], bit_loc)) {
				
					serial_putc('1');
					
			} else {
				serial_putc('0');
			}
		}
		
		serial_print_str("|\n");
		
	}
#endif	
}			
Пример #20
0
int checkboard (void)
{
	vpd_packet_t *packet;
	int i;
	const char *const fmt =
		"\n	 *** Warning: Low Battery Status - %s Battery ***";

	puts ("Board: ");

	packet = vpd_find_packet (VPD_PID_PID);
	for (i = 0; i < packet->size; i++) {
		serial_putc (packet->data[i]);
	}
	packet = vpd_find_packet (VPD_PID_MT);
	for (i = 0; i < packet->size; i++) {
		serial_putc (packet->data[i]);
	}
	serial_putc ('(');
	packet = vpd_find_packet (VPD_PID_FAN);
	for (i = 0; i < packet->size; i++) {
		serial_putc (packet->data[i]);
	}
	serial_putc (')');

	if (!(MBX_CSR2 & SR2_BATGD))
		printf (fmt, "On-Board");
	if (!(MBX_CSR2 & SR2_NVBATGD))
		printf (fmt, "NVRAM");

	serial_putc ('\n');

	return (0);
}
Пример #21
0
void handleGetSensor(uint8_t sensorId)
{
	if (sensorId < no_of_sensors_)
	{
		serial_putc(OBJECT_START);
		serial_putc(CMD_GET_SENSOR);
		serial_putc(DELIMITER);
		serial_putc('0' + sensorId);
		serial_putc(DELIMITER);

		serial_putc('0' + (uint8_t) sensors_[sensorId]->type);
		serial_putc(DELIMITER);
		serial_puts(sensors_[sensorId]->name);
		serial_putc(DELIMITER);
		serial_puts(sensors_[sensorId]->part);
		serial_putc(OBJECT_END);
	}
}
Пример #22
0
void
serial_putc(const char c)
{
    cma_mbio_serial *mbsp = (cma_mbio_serial *)CMA_MB_SERIAL_BASE;

    if (c == '\n')
	serial_putc('\r');

    while ((cma_mbio_reg_read(&mbsp->ser_lsr) & LSR_THRE) == 0)
	;

    cma_mbio_reg_write(&mbsp->ser_thr, c);
}
Пример #23
0
/*
 * Output a single byte to the serial port.
 */
void serial_putc(const char c)
{
	S3C24X0_UART *const uart = S3C24X0_GetBase_UART(S3C24X0_UART0);

	/* wait for room in the tx FIFO */
	while (!(uart->UTRSTAT & 0x2));

	uart->UTXH = c;

	/* If \n, also do \r */
	if (c == '\n')
		serial_putc('\r');
}
Пример #24
0
/*==============================================================================
 * - serial_write()
 *
 * - send a buffer
 */
int serial_write (char *buf, int e_size, int e_num)
{
    int i;
    int max = e_size * e_num;

    SERIAL_FIFO_LOCK();
    for (i = 0; i < max; i++) {
        serial_putc(buf[i]);
    }
    SERIAL_FIFO_UNLOCK();

    return i;
}
void serial_putc( const char c )
{
	if (c == '\n')
		serial_putc( '\r' );

	while (!(*get_ser_reg_addr_channel( NS9750_SER_STAT_A, CONSOLE) &
		 NS9750_SER_STAT_A_TRDY ) ) {
		/* do nothing, wait for characters in FIFO sent */
	}

	*(volatile char*) get_ser_reg_addr_channel( NS9750_SER_FIFO,
						    CONSOLE) = c;
}
Пример #26
0
/*
 * Output a single byte to the serial port.
 */
void serial_putc (const char c)
{
	volatile struct imx_serial* base = (struct imx_serial *)UART_BASE;

	/* Wait for Tx FIFO not full */
	while (base->uts & UTS_TXFULL);

	base->utxd[0] = c;

	/* If \n, also do \r */
	if (c == '\n')
		serial_putc ('\r');
}
Пример #27
0
Файл: serial.c Проект: yumm007/C
unsigned char serial_getc(void)
{
	while(!(UTRSTAT & 0x1));

	unsigned char c = URXH;

	if(c == '\r')
		c = '\n';

	serial_putc(c);

	return c;
}
void serial_putstr(uint8 *str)
{
    uint8 i;

    i = 0;

    //send characters until the end of the string has been reached
    while (str[i] != '\0')
    {
        serial_putc(str[i]);
        i++;
    }
}
Пример #29
0
//__attribute__((naked)) //To avoid gcc from putting garbage before and after main function, especially with stuffs using stack...
int main(int argc, char **argv)
{
  serial_init();
  serial_puts("\r\n\r\nHello world!\n\r\n\rBrought to you by Florent Guignabert & Axel Schumacher\r\n\r\n");
  char c = serial_getc();
  while (c != 27 /*echap*/)
  {
    serial_putc(c);
    c = serial_getc();
  }
  serial_puts("\n\r");
  return EXIT_SUCCESS;
}
void serial_puts (const char *s)
{
	while (*s) {
		serial_putc (*s++);
	}

	/* busy wait for tx complete */
	while ( !uart->m_stat.bf.txComplete);

	/* clear break */
	uart->m_ctrl.bf.sendBreak = 0;

}