Example #1
0
/*********************************************************************
* Function:         void ConsolePut(BYTE c)
*
* PreCondition:     none
*
* Input:		    c - character to be printed
*
* Output:		    none
*
* Side Effects:	    c is printed to the console
*
* Overview:		    This function will print the inputed character
*
* Note:			    Do not power down the microcontroller until 
*                   the transmission is complete or the last 
*                   transmission of the string can be corrupted.  
********************************************************************/
void ConsolePut(BYTE c)
{
#if defined(ENABLE_CONSOLE)
	usb_putchar(c);
	USBCDCWait();
#endif
}
Example #2
0
void WriteUART2(unsigned int data)
{
	#ifndef USB_INTERRUPT
	USBDeviceTasks(); 	// Interrupt or polling method.  If using polling, must call
	#endif
	USBProcessIO();
    usb_putchar((unsigned char)data);
}
Example #3
0
File: usb.c Project: emente/Freecut
/*
 * write a single character to output queue, and enable Tx interrupts.
 */
int usb_putchar( char c, FILE *stream ) 
{
    if( c == '\n' )
        usb_putchar( '\r', stream );
    while( (uint8_t) (usb_tx_head - usb_tx_tail) == USB_OUTBUF_LEN )
	wdt_reset( );
    usb_tx_buf[usb_tx_head++ % USB_OUTBUF_LEN] = c;
    UCSR1B |= (1 << UDRIE1 );
    return 0;
}
Example #4
0
// USB/USART combined put char (handles printf)
void _user_putc(unsigned char c)
{
#ifdef USE_USART
    putc1USART(c);
    while(Busy1USART()); 
#endif
#if defined(DEBUG_USART2_TX) || defined(UART2_DATA_OUTPUT)
    Write2USART(c);
    while(Busy2USART()); 
#endif
    usb_putchar(c);
}
Example #5
0
result_e usb_cmd(uint8_t * req, uint8_t * ack, size_t ack_size, uint16_t delay)
{
	result_e		res;
	uint8_t			timer_id;
	uint8_t			idx;
	
	if (!usb_on)
		return RESULT_TIMEOUT;
	
	for (idx = 0; req[idx] != '\n'; idx++)
		usb_putchar(req[idx]);
	usb_putchar('\n');
		
	if (NULL == ack)
		return RESULT_OK;
	
	res = RESULT_TIMEOUT;
		
	timer_id = start_timer(delay);
		
	while (timer_value(timer_id))
	{
		usb_getmsg();
		if (usb_msg_ready)
		{
			res = RESULT_OK;
			usb_msg_ready = 0;
			memcpy(ack, usb_inbuf, (ack_size < USB_INBUF_SIZE)?ack_size:USB_INBUF_SIZE);
			stop_timer(timer_id);
			break;
		}
	}
	
	stop_timer(timer_id);
	
	return res;
}
Example #6
0
void
srvtx()
{
	int i;
	uint8 length;
	char txcall_in_ascii[SPIMAX * 2];
	int ascii_idx;

	flag &= ~Ftxcall;
	length = txcall[0];

	for (ntx = 0; ntx < length; ntx++) {
		to_hex8_ascii(&txcall_in_ascii[ntx * 2], txcall[ntx]);
	}

	for (ascii_idx = 0; ascii_idx < length * 2; ascii_idx++) {
		usb_putchar(txcall_in_ascii[ascii_idx]);
	}
	usb_flush( );
	flag |= Ftxcall;
}
Example #7
0
void serial_tx_byte(uint8_t tx_byte) {
  // return usb_putc(tx_byte);
  usb_putchar(  tx_byte);
  usb_flush( );
}
Example #8
0
void usb_puts(const char * buf)
{
	while (*buf)
		usb_putchar(*buf++);
}
Example #9
0
int usb_putchar_printf(char var, FILE *stream) {
	// translate \n to \r for br@y++ terminal
	if (var == '\n') usb_putchar('\r');
	usb_putchar(var);
	return 0;
}
Example #10
0
void usb_write_line(char * string)
{
	while (*string != '\0')
	usb_putchar(*string++);
}
Example #11
0
void
srvrxpeek()
{
	uint8_t length;
	uint8_t in_byte;
	char nibbles[2];
	int bytes_to_read;

	if (rxstate != Urxing){
		return;
	}
	GREEN=1;

	dprint("start of reading ---- ");

	nibbles[0] = usb_getchar();

	if(nibbles[0] == 1){
		dprint("info request\n");
		usb_putchar(1);
		dprint("flush\n");
		usb_flush();
		rxstate = Uready;
		GREEN = 0;
		return;
	}
	GREEN=0;

	dprint("%c ", nibbles[0]);
	nibbles[1] = usb_getchar();
	dprint("%c ", nibbles[1]);
	in_byte = hex8(&nibbles[0]);
	dprint("(%x) ", in_byte);

	if (nrx == 0) {
		if (in_byte == 0) {
			dprint("getting 0 size. error\n");
			while (1) {;}
        		rxstate = Uready;
			flag &= ~Frxcall;
			return;
		}

		if (in_byte == 0xff) {
			dprint("radio reset\n");
        		rxstate = Uready;
			flag &= ~Frxcall;
			return;
		}

		// if the index is still at 0, here is the length
		rxcall[nrx++] = in_byte;
	}

	length = rxcall[0];
	while (nrx < length) {
		nibbles[0] = usb_getchar();
		dprint("%c ", nibbles[0]);
		nibbles[1] = usb_getchar();
		dprint("%c ", nibbles[1]);
		in_byte = hex8(&nibbles[0]);
		dprint("(%x) ", in_byte);

		rxcall[nrx++] = in_byte;
		if(nrx == sizeof rxcall)
			panic("usb: rxcall overrun");
	}

	if (nrx == length) {
		rxstate = Uidle;
		flag |= Frxcall;
		dprint(" ---- read %d\n", length);
	} else {
		// if we didn't read everything, let's let
		// WD take over here
		dprint(" ---- only read %d out of %d\n", nrx, length);
		while (1) {;}
	}
}