Esempio n. 1
0
int
_serial_putchar(int c)
{
    static unsigned int txmask;
    static unsigned int bitcycles;
    static unsigned int cached_baud;

    if (cached_baud != _baud) {
        cached_baud = _baud;
        bitcycles = _clkfreq / cached_baud;
        txmask = (1UL << _txpin);
    }
    if (c == '\n') {
        _serial_tx('\r', txmask, bitcycles);
    }
    return _serial_tx(c, txmask, bitcycles);
}
Esempio n. 2
0
static void _serial_tx_char(char c)
{
	uint8_t buffer[10];
	uint8_t i = 0;
	
	buffer[i++] = 0;	// START
	for (int idx = 0; idx < 8; ++idx)
	buffer[i++] = (((uint8_t)(c) & ((uint8_t)1<<((idx)))) ? 0x01 : 0x00);	// Endianness: 7-
	buffer[i++] = 1;	// STOP
	
	_serial_tx(buffer);
}