Exemplo n.º 1
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;
}
Exemplo n.º 2
0
int
console_wait_for_key(void)
{
	union key key;
	key.ax = serial_getc(true);
	return key.code.ascii;
}
Exemplo n.º 3
0
void TaskStart (void *data)
{
	unsigned char i;
	char key;
	data = data;                            /* Prevent compiler warning */
	
	JZ_StartTicker(OS_TICKS_PER_SEC);	/* os_cfg.h */
	printf("uC/OS-II, The Real-Time Kernel MIPS Ported version\n");
	printf("EXAMPLE #1 %s %s\n",__DATE__,__TIME__);
	while(0)
	{
		if(serial_tstc())
		{
			key = serial_getc();
			printf("you pressed: %c\n",key);
			if(key == 0x1B) 
			{        /* see if it's the ESCAPE key */
				printf(" Escape display of statistic\n");
				os_TaskDelete(TASK_START_PRIO);
			}
		}
		printf("time: %d\n",os_TimeGet());
		os_TimeDelayHMSM(0, 0, 1, 0);     /* Wait one second */
	}
	NandTest();
}
Exemplo n.º 4
0
int do_ramdump(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{

	exynos_usbd_dn_addr = USBD_DOWN_ADDR;	/* Default Address */

	exynos_receive_done = 0;

	exynos_usbctl_init();
	exynos_usbc_activate();

	printf("Now, Waiting for USB RAMDUMP\n");

	while (1) {
		if (EXYNOS_USBD_DETECT_IRQ()) {
			exynos_udc_int_hndlr();
			EXYNOS_USBD_CLEAR_IRQ();
		}

		if (exynos_receive_done)
			break;

		if (serial_tstc()) {
			serial_getc();
			break;
		}
	}

	/* when operation is done, usbd must be stopped */
	exynos_usb_stop();

	printf("Finished RAMDUMP\n");

	return 0;
}
Exemplo n.º 5
0
Arquivo: serial.c Projeto: yumm007/C
void gets(char *s)
{
	char c;
	while((c = serial_getc()) != '\n')
		*s++ = c;
	*s = 0;
}
Exemplo n.º 6
0
static int
calc_looperms(void)
{
    int	i, count, c;
    int	totalloops = 0;

    serial_init();
    serial_set(TESTBAUD);		/* set 300 baud */
    serial_loopback(1);		/* enable loop back mode */

    for (i=0; i < NBYTES; i++)
    {
        count = 1;
        serial_putc(0xaa);	/* xmit character */

        /*
         * The timing loop is the same as the loops in serial_read.
         * Any changes to the loops in serial_read should be reflected
         * here.
         */
        do
        {
            c = serial_getc();
        } while (c < 0 && count++ > 0);

        totalloops += count;
    }

    serial_loopback(0);

    return(totalloops/TOTAL_MS);
}
Exemplo n.º 7
0
int getDebugChar(void)
{
	if (kgdb_debugport == 0)
		kgdb_debugport = serial_init(KGDB_PORT, NULL);

	return(serial_getc(kgdb_debugport));
}
Exemplo n.º 8
0
int main() {
	
	//initialize all necessary sensors and utilities
	lcd_init();
	timer1_init();
	timer3_init();
	move_servo(90);
 	ADC_init();
	USART_Init(MYUBRR);
	init_push_buttons();
	
	oi_t *sensor_data = oi_alloc();
	oi_init(sensor_data);
	
	audioInit(sensor_data);
	//oi_play_song(1);
	
	while(1) {
		//empty currentObjects before proceeding by setting all stored objects to "invalid" - ignored by later checks
		for (int i = 0; i < 20; i++) {
			currentObjects[i].isValid = 0;
		}
		char received = serial_getc(); //take keyboard input from putty
		takeDirectionInput(received, currentObjects); //translate keyboard input into functionality
	}
	
	return 0;
}
Exemplo n.º 9
0
/**
 * shell_getline
 *
 * Read a line of user input and place it in an input buffer.
 */
static void shell_getline(char *buffer, int minlen, int maxlen)
{
	int ch;
	char *lp;
	int ch_count = 0;

	lp = buffer;

	while (1) {
		ch = serial_getc();

		switch (ch) {
			case '\n':
			case '\r':
			    serial_puts("\n");
			    *lp++ = '\0';
			    return;
			case '\b':
			case '\177':
			    if (lp >= (buffer + minlen - 1)) {
				serial_puts("\b \b");
				lp--;
			    }
			    continue;
			default:
			    if ((ch > '\040' || ch < '\177') && ch_count < maxlen) {
			    	serial_putc(ch);
				*lp++ = ch;
				ch_count++;
			    }
		}
	}

	return;
}
Exemplo n.º 10
0
int main(int argc)
{
	// Allocate memory and setup sensorData struct
	sensorData = oi_alloc();
	initAll(sensorData);


	serial_puts("Press 's' to initiate connection with robot\n\r");
	while(start != 's') // Wait for Start Command
	{
		start = serial_getc();
	}
	serial_puts("Robot communication initiated.\n\r\n\r");
	display_help();
	running_LED();
	while(1)
	{
		read_user_input_string(sensorData);
	}
	//START TRAVERSING CODE

	while("NOT DONE") //While the robot is not in the Final Zone
	{
		//TODO Interface and Movement
	}

	//TODO FLASH LEDS WHEN DONE


}
Exemplo n.º 11
0
/* 'inline' - We have to do it fast */
static inline void mdm_readline(char *buf, int bufsiz)
{
	char c;
	char *p;
	int n;

	n = 0;
	p = buf;
	for(;;) {
		c = serial_getc();

		/*		dbg("(%c)", c); */

		switch(c) {
		case '\r':
			break;
		case '\n':
			*p = '\0';
			return;

		default:
			if(n++ > bufsiz) {
				*p = '\0';
				return; /* sanity check */
			}
			*p = c;
			p++;
			break;
		}
	}
}
Exemplo n.º 12
0
static void serial_isr_func(int n)
{
	uint32_t c;
	
	c = serial_getc();
	mbox_post(&console_mbox, &c);
}
Exemplo n.º 13
0
int do_pause (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
	int pause_time;
	unsigned int delay_time;
	int break_loop = 0;

	/* display value if no argument */
	if (argc < 2) {
		pause_time = 1;
	}

	else if (argc > 2) {
		printf ("Too many arguments\n");
		return -1;
	} else {
		pause_time = simple_strtoul (argv[1], NULL, 0);
	}

	printf ("Pausing with a poll time of %d, press any key to reactivate\n", pause_time);
	delay_time = pause_time * ONE_SECOND;
	while (break_loop == 0) {
		udelay (delay_time);
		if (serial_tstc () != 0) {
			break_loop = 1;
			/* eat user key presses */
			while (serial_tstc () != 0) {
				serial_getc ();
			}
		}
	}

	return 0;
}
Exemplo n.º 14
0
/*
 *  * Initialise the serial port with the given baudrate. The settings
 *   * are always 8 data bits, no parity, 1 stop bit, no start bits.
 *    *
 *     */
int serial_init (void)
{
    SIO_Open(&gUart1Channel, 115200);
    /* clear input buffer */
    if(serial_tstc())
        serial_getc();
    return 0;
}
Exemplo n.º 15
0
void jshIdle() {
  /*static bool foo = false;
  foo = !foo;
  jshPinSetValue(LED1_PININDEX, foo);*/

  while (serial_readable(&mbedSerial[0])>0)
        jshPushIOCharEvent(EV_SERIAL1, serial_getc(&mbedSerial[0]));
}
Exemplo n.º 16
0
int spl_start_uboot(void)
{
	/* break into full u-boot on 'c' */
	if (serial_tstc() && serial_getc() == 'c')
		return 1;

	return 0;
}
Exemplo n.º 17
0
int getc (void)
{
	if (gd->flags & GD_FLG_DEVINIT) {
		
		return fgetc (stdin);
	}

	return serial_getc ();
}
Exemplo n.º 18
0
Arquivo: init.c Projeto: 173210/ds2sdk
void CONSOL_GetChar(unsigned char *ch)
{
	int r;
	r = serial_getc();
	if (r > 0)
		*ch = (unsigned char)r;
	else
		*ch = 0;
}
Exemplo n.º 19
0
void BufferedSerial::rxIrq(void)
{
    // read from the peripheral and make sure something is available
    if(serial_readable(&_serial)) {
        _rxbuf = serial_getc(&_serial); // if so load them into a buffer
    }

    return;
}
Exemplo n.º 20
0
int getc (void)
{
	if (gd->flags & GD_FLG_DEVINIT) {
		/* Get from the standard input */
		return fgetc (stdin);
	}

	/* Send directly to the handler */
	return serial_getc ();
}
Exemplo n.º 21
0
int jz_std_gets(unsigned char *s,unsigned int count)
{
  unsigned int i = 0;
  if(jz_std_sem == NULL) jz_std_sem = os_SemaphoreCreate(1);
  OP_STD_LOCK();	
  while(i++ < count)
   	*s++ = serial_getc();
  OP_STD_UNLOCK();
  return (count);
}
Exemplo n.º 22
0
static int ameba_uart_getc (struct rt_serial_device *serial)
{
    struct device_uart* uart = serial->parent.user_data;

	if(!serial_readable(&uart->serial))
        return -1;

    /* Receive Data Available */
    return serial_getc(&uart->serial);
}
Exemplo n.º 23
0
/**
 * read bytes from uart
 */
int suli_uart_read_bytes(UART_T *uart, uint8_t *buff, int len)
{
    uint8_t *ptr = buff;
    uint8_t *end = ptr + len;
    while (ptr != end)
    {
        int c = serial_getc(uart);
        *ptr++ = c;
    }
    return ptr - buff;
}
Exemplo n.º 24
0
void UARTClass1::IrqHandler(SerialIrq event)
{
    PHAL_RUART_ADAPTER pHalRuartAdapter=(PHAL_RUART_ADAPTER)&(this->sobj.hal_uart_adp);
    u8  uart_idx = pHalRuartAdapter->UartIndex;
	
    uint8_t     data = 0;

	if ( event == RxIrq ) { 
	    data = serial_getc(&(this->sobj));
		_rx_buffer->store_char(data);
	} 
}
Exemplo n.º 25
0
/* Return: 1 - boot to U-Boot. 0 - boot OS (falcon mode) */
int spl_start_uboot(void)
{
	/* break into full u-boot on 'c' */
	if (serial_tstc() && serial_getc() == 'c')
		return 1;

#ifdef CONFIG_SPL_ENV_SUPPORT
	if (env_get_yesno("boot_os") != 1)
		return 1;
#endif
	return 0;
}
Exemplo n.º 26
0
int do_usbd_dnw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{

	if (argv[0][0] == 'u') {
		DNW = 0;
	}
	else {
		DNW = 1;
		exynos_got_header = 0;
	}

	switch (argc) {
	case 1 :
		exynos_usbd_dn_addr = USBD_DOWN_ADDR;	/* Default Address */
		break;
	case 2 :
		exynos_usbd_dn_addr = simple_strtoul(argv[1], NULL, 16);
		break;
	default:
		printf ("Usage:\n%s\n", cmdtp->usage);
		return 1;
	}

	exynos_receive_done = 0;
	exynoy_usb_phy_on();

	printf("Download address 0x%08x\n", exynos_usbd_dn_addr);
	printf("Now, Waiting for DNW to transmit data\n");

	while (1) {
		if (!exynos_usb_wait_cable_insert()) {
			exynos_usbctl_init();
			exynos_usbc_activate();
		}
		if (EXYNOS_USBD_DETECT_IRQ()) {
			exynos_udc_int_hndlr();
			EXYNOS_USBD_CLEAR_IRQ();
		}

		if (exynos_receive_done)
			break;

		if (serial_tstc()) {
			serial_getc();
			break;
		}
	}

	/* when operation is done, usbd must be stopped */
	exynos_usb_stop();

	return 0;
}
/**
 *
 * Function to put the iRobot into manual control in putty
 * will be used to control the iRobot through the course
 */
void courseMode()
{
	// stay in this loop until course is finished
	while(isFinished != 0)
	{
		// move the iRobot with the putty/keyboard, wasd controls
		keyboardInput(serial_getc());
		// separate each command
		serial_puts("------------------------------------------------------");
	}
	
}
Exemplo n.º 28
0
int getc(void)
{
	while (1) {
#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
	|| defined(CONFIG_SERIAL_MPC52xx_CONSOLE)
		if (serial_tstc(com_port))
			return (serial_getc(com_port));
#endif /* serial console */
		if (keyb_present)
			if(CRT_tstc())
				return (CRT_getc());
	}
}
/**
 *
 * Function to let the robot be in idle until we start
 */
void start()
{
	// stay in while loop until ready when 1 is entered
	while(1)
	{
		if(serial_getc() == '1')
			break;
	}
	
	// play introduction song (Lost Woods)
	oi_play_song(3);
	
}
Exemplo n.º 30
0
/**
 * read bytes from uart with timeout ms
 */
int suli_uart_read_bytes_timeout(UART_T *uart, uint8_t *buff, int len, int timeout_ms)
{
    uint8_t *ptr = buff;
    uint8_t *end = ptr + len;
    uint32_t t = suli_millis();

    while (ptr != end)
    {
        if ((suli_millis() - t) > timeout_ms) break;
        int c = serial_getc(uart);
        *ptr++ = c;
    }
    return ptr - buff;
}