示例#1
0
void USART_SPI::begin() {
	UBRR(UCSRA)	= 0;							//Disable USART

	volatile uint8_t* DDR = (volatile uint8_t*) pgm_read_word(UART_SCK_DDR + UART_module);
	*DDR	|= pgm_read_byte(UART_SCK_MASK + UART_module); //set XCK PIN mode to OUTPUT

	UCSRC(UCSRA)		= _BV(UMSEL01) | _BV(UMSEL00);	//UCPHAn=0 UCPOLn=0 for mode0
	UCSRB(UCSRA)		= _BV(TXEN0) | _BV(RXEN0);		//Enable USART
}
示例#2
0
    #define AVR_SD2_RX_VECT USART1_RX_vect
    #define AVR_SD2_TX_VECT USART1_UDRE_vect
  #else
    #error "Cannot find USART to use for SD2"
  #endif
#endif /* AVR_SERIAL_USE_USART1 */

/*===========================================================================*/
/* Driver local variables and types.                                         */
/*===========================================================================*/

/**
 * @brief   Driver default configuration.
 */
static const SerialConfig default_config = {
  UBRR(SERIAL_DEFAULT_BITRATE),
  USART_CHAR_SIZE_8
};

/*===========================================================================*/
/* Driver local functions.                                                   */
/*===========================================================================*/

static void set_error(uint8_t sra, SerialDriver *sdp) {
  eventflags_t sts = 0;
  uint8_t dor = 0;
  uint8_t upe = 0;
  uint8_t fe = 0;

#if AVR_SERIAL_USE_USART0
  if (&SD1 == sdp) {