Fix broken AVR8 Serial peripheral driver.
\r
#include "Atomic.h"\r
\r
\r
#include "Atomic.h"\r
\r
+ #define PROGMEM const\r
#else\r
#include <avr/io.h>\r
#endif\r
#else\r
#include <avr/io.h>\r
#endif\r
#define __SPI_AVR32_H__\r
\r
/* Includes: */\r
#define __SPI_AVR32_H__\r
\r
/* Includes: */\r
+ #include <avr32/io.h>\r
#include <stdbool.h>\r
\r
/* Preprocessor Checks: */\r
#include <stdbool.h>\r
\r
/* Preprocessor Checks: */\r
#define __SPI_AVR8_H__\r
\r
/* Includes: */\r
#define __SPI_AVR8_H__\r
\r
/* Includes: */\r
#include <stdbool.h>\r
\r
/* Preprocessor Checks: */\r
#include <stdbool.h>\r
\r
/* Preprocessor Checks: */\r
*/\r
static inline bool Serial_IsCharReceived(void);\r
#else\r
*/\r
static inline bool Serial_IsCharReceived(void);\r
#else\r
- #define Serial_IsCharReceived() /* TODO */\r
+ #define Serial_IsCharReceived() ((UCSR1A & (1 << RXC1)) ? true : false)\r
#endif\r
\r
/* Inline Functions: */\r
#endif\r
\r
/* Inline Functions: */\r
*/\r
static inline void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed)\r
{\r
*/\r
static inline void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed)\r
{\r
+ UCSR1A = (DoubleSpeed ? (1 << U2X1) : 0);\r
+ UCSR1B = ((1 << TXEN1) | (1 << RXEN1));\r
+ UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10));\r
+ \r
+ DDRD |= (1 << 3); \r
+ PORTD |= (1 << 2);\r
+ \r
+ UBRR1 = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate));\r
}\r
\r
/** Turns off the USART driver, disabling and returning used hardware to their default configuration. */\r
static inline void Serial_ShutDown(void)\r
{\r
}\r
\r
/** Turns off the USART driver, disabling and returning used hardware to their default configuration. */\r
static inline void Serial_ShutDown(void)\r
{\r
+ UCSR1A = 0;\r
+ UCSR1B = 0;\r
+ UCSR1C = 0;\r
+ \r
+ DDRD &= ~(1 << 3); \r
+ PORTD &= ~(1 << 2);\r
+ \r
+ UBRR1 = 0;\r
}\r
\r
/** Transmits a given byte through the USART.\r
}\r
\r
/** Transmits a given byte through the USART.\r
*/\r
static inline void Serial_TxByte(const char DataByte)\r
{\r
*/\r
static inline void Serial_TxByte(const char DataByte)\r
{\r
+ while (!(UCSR1A & (1 << UDRE1)));\r
+ UDR1 = DataByte;\r
}\r
\r
/** Receives a byte from the USART.\r
}\r
\r
/** Receives a byte from the USART.\r
*/\r
static inline uint8_t Serial_RxByte(void)\r
{\r
*/\r
static inline uint8_t Serial_RxByte(void)\r
{\r
+ while (!(UCSR1A & (1 << RXC1)));\r
+ return UDR1; \r
}\r
\r
/* Disable C linkage for C++ Compilers: */\r
}\r
\r
/* Disable C linkage for C++ Compilers: */\r
*/\r
\r
/** \ingroup Group_TWI\r
*/\r
\r
/** \ingroup Group_TWI\r
- * @defgroup Group_TWI_AVR8 Series U4, U6 and U7 Model TWI Driver\r
+ * @defgroup Group_TWI_AVR8 8-Bit AVR TWI Driver\r
*\r
* Master mode TWI driver for the 8-Bit AVRs containing a hardware TWI module.\r
*\r
*\r
* Master mode TWI driver for the 8-Bit AVRs containing a hardware TWI module.\r
*\r
* \section Sec_ChangeLogXXXXXX Version XXXXXX\r
*\r
* <b>New:</b>\r
* \section Sec_ChangeLogXXXXXX Version XXXXXX\r
*\r
* <b>New:</b>\r
+ * - Added support for the UC3B0256 AVR32 microcontroller\r
*\r
* <b>Changed:</b>\r
* - AVRISP programmer project now has a more robust timeout system, allowing for a doubling of the software USART speed\r
*\r
* <b>Changed:</b>\r
* - AVRISP programmer project now has a more robust timeout system, allowing for a doubling of the software USART speed\r
* - Increased the speed of both software and hardware TPI/PDI programming modes of the AVRISP project\r
*\r
* <b>Fixed:</b>\r
* - Increased the speed of both software and hardware TPI/PDI programming modes of the AVRISP project\r
*\r
* <b>Fixed:</b>\r
+ * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin\r
*\r
* \section Sec_ChangeLog100219 Version 100219\r
*\r
*\r
* \section Sec_ChangeLog100219 Version 100219\r
*\r
ISR(TIMER1_COMPA_vect, ISR_BLOCK)\r
{\r
/* Toggle CLOCK pin in a single cycle (see AVR datasheet) */\r
ISR(TIMER1_COMPA_vect, ISR_BLOCK)\r
{\r
/* Toggle CLOCK pin in a single cycle (see AVR datasheet) */\r
- BITBANG_PDICLOCK_PIN |= BITBANG_PDICLOCK_MASK;\r
+ BITBANG_PDICLOCK_PIN = BITBANG_PDICLOCK_MASK;\r
\r
/* If not sending or receiving, just exit */\r
if (!(SoftUSART_BitCount))\r
\r
/* If not sending or receiving, just exit */\r
if (!(SoftUSART_BitCount))\r
ISR(TIMER1_CAPT_vect, ISR_BLOCK)\r
{\r
/* Toggle CLOCK pin in a single cycle (see AVR datasheet) */\r
ISR(TIMER1_CAPT_vect, ISR_BLOCK)\r
{\r
/* Toggle CLOCK pin in a single cycle (see AVR datasheet) */\r
- BITBANG_TPICLOCK_PIN |= BITBANG_TPICLOCK_MASK;\r
+ BITBANG_TPICLOCK_PIN = BITBANG_TPICLOCK_MASK;\r
\r
/* If not sending or receiving, just exit */\r
if (!(SoftUSART_BitCount))\r
\r
/* If not sending or receiving, just exit */\r
if (!(SoftUSART_BitCount))\r