/** Sends a byte via the USART. * * \param[in] Byte Byte to send through the USART */ void XPROGTarget_SendByte(const uint8_t data) { /* Switch to Tx mode if currently in Rx mode */ if (!(IsSending)) XPROGTarget_SetTxMode(); /* Wait until there is space in the hardware Tx buffer before writing */ usart_putchar(USART_PDI, data); }
/** Sends a byte via the USART. * * \param[in] Byte Byte to send through the USART */ void XPROGTarget_SendByte(const uint8_t Byte) { /* Switch to Tx mode if currently in Rx mode */ if (!(IsSending)) XPROGTarget_SetTxMode(); /* Wait until there is space in the hardware Tx buffer before writing */ while (!(UCSR1A & (1 << UDRE1))); UCSR1A |= (1 << TXC1); UDR1 = Byte; }
/** Sends a BREAK via the USART to the attached target, consisting of a full frame of idle bits. */ void XPROGTarget_SendBreak(void) { /* Switch to Tx mode if currently in Rx mode */ if (!(IsSending)) XPROGTarget_SetTxMode(); /* Need to do nothing for a full frame to send a BREAK */ for (uint8_t i = 0; i < BITS_IN_USART_FRAME; i++) { /* Wait for a full cycle of the clock */ while (PIND & (1 << 5)); while (!(PIND & (1 << 5))); } }
/** Sends an IDLE via the USART to the attached target, consisting of a full frame of idle bits. */ void XPROGTarget_SendIdle(void) { /* Switch to Tx mode if currently in Rx mode */ if (!(IsSending)) XPROGTarget_SetTxMode(); /* Need to do nothing for a full frame to send an IDLE */ for (uint8_t i = 0; i < BITS_IN_USART_FRAME; i++) { /* Wait for a full cycle of the clock */ while(gpio_pin_is_high(PIN_PDIC_GPIO) && TimeoutTicksRemaining); while(gpio_pin_is_low(PIN_PDIC_GPIO) && TimeoutTicksRemaining); while(gpio_pin_is_high(PIN_PDIC_GPIO) && TimeoutTicksRemaining); } }