aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/Peripheral/AVR8
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-02-23 01:03:27 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-02-23 01:03:27 +0000
commitc24027f3b5f1ca7bceababc82ea5b897b18dbac1 (patch)
tree092c11a135f245a63fe3f3ae4391f1b0eeb9dab8 /LUFA/Drivers/Peripheral/AVR8
parent2590452104c569f64aeefba3b06734035fb77d66 (diff)
downloadlufa-c24027f3b5f1ca7bceababc82ea5b897b18dbac1.tar.gz
lufa-c24027f3b5f1ca7bceababc82ea5b897b18dbac1.tar.bz2
lufa-c24027f3b5f1ca7bceababc82ea5b897b18dbac1.zip
Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin.
Fix broken AVR8 Serial peripheral driver.
Diffstat (limited to 'LUFA/Drivers/Peripheral/AVR8')
-rw-r--r--LUFA/Drivers/Peripheral/AVR8/SPI.h1
-rw-r--r--LUFA/Drivers/Peripheral/AVR8/Serial.h26
-rw-r--r--LUFA/Drivers/Peripheral/AVR8/TWI.h2
3 files changed, 23 insertions, 6 deletions
diff --git a/LUFA/Drivers/Peripheral/AVR8/SPI.h b/LUFA/Drivers/Peripheral/AVR8/SPI.h
index 3440cc9f1..f466162be 100644
--- a/LUFA/Drivers/Peripheral/AVR8/SPI.h
+++ b/LUFA/Drivers/Peripheral/AVR8/SPI.h
@@ -51,6 +51,7 @@
#define __SPI_AVR8_H__
/* Includes: */
+ #include <avr/io.h>
#include <stdbool.h>
/* Preprocessor Checks: */
diff --git a/LUFA/Drivers/Peripheral/AVR8/Serial.h b/LUFA/Drivers/Peripheral/AVR8/Serial.h
index 282528bb0..0421dea73 100644
--- a/LUFA/Drivers/Peripheral/AVR8/Serial.h
+++ b/LUFA/Drivers/Peripheral/AVR8/Serial.h
@@ -80,7 +80,7 @@
*/
static inline bool Serial_IsCharReceived(void);
#else
- #define Serial_IsCharReceived() /* TODO */
+ #define Serial_IsCharReceived() ((UCSR1A & (1 << RXC1)) ? true : false)
#endif
/* Inline Functions: */
@@ -92,13 +92,27 @@
*/
static inline void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed)
{
- // TODO
+ UCSR1A = (DoubleSpeed ? (1 << U2X1) : 0);
+ UCSR1B = ((1 << TXEN1) | (1 << RXEN1));
+ UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10));
+
+ DDRD |= (1 << 3);
+ PORTD |= (1 << 2);
+
+ UBRR1 = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate));
}
/** Turns off the USART driver, disabling and returning used hardware to their default configuration. */
static inline void Serial_ShutDown(void)
{
- // TODO
+ UCSR1A = 0;
+ UCSR1B = 0;
+ UCSR1C = 0;
+
+ DDRD &= ~(1 << 3);
+ PORTD &= ~(1 << 2);
+
+ UBRR1 = 0;
}
/** Transmits a given byte through the USART.
@@ -107,7 +121,8 @@
*/
static inline void Serial_TxByte(const char DataByte)
{
- // TODO
+ while (!(UCSR1A & (1 << UDRE1)));
+ UDR1 = DataByte;
}
/** Receives a byte from the USART.
@@ -116,7 +131,8 @@
*/
static inline uint8_t Serial_RxByte(void)
{
- // TODO
+ while (!(UCSR1A & (1 << RXC1)));
+ return UDR1;
}
/* Disable C linkage for C++ Compilers: */
diff --git a/LUFA/Drivers/Peripheral/AVR8/TWI.h b/LUFA/Drivers/Peripheral/AVR8/TWI.h
index 673f1b071..d169b8230 100644
--- a/LUFA/Drivers/Peripheral/AVR8/TWI.h
+++ b/LUFA/Drivers/Peripheral/AVR8/TWI.h
@@ -37,7 +37,7 @@
*/
/** \ingroup Group_TWI
- * @defgroup Group_TWI_AVR8 Series U4, U6 and U7 Model TWI Driver
+ * @defgroup Group_TWI_AVR8 8-Bit AVR TWI Driver
*
* Master mode TWI driver for the 8-Bit AVRs containing a hardware TWI module.
*