Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 23 Feb 2010 01:03:27 +0000 (01:03 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 23 Feb 2010 01:03:27 +0000 (01:03 +0000)
Fix broken AVR8 Serial peripheral driver.

LUFA/Common/Common.h
LUFA/Drivers/Peripheral/AVR32/SPI.h
LUFA/Drivers/Peripheral/AVR8/SPI.h
LUFA/Drivers/Peripheral/AVR8/Serial.h
LUFA/Drivers/Peripheral/AVR8/TWI.h
LUFA/ManPages/ChangeLog.txt
Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c

index 04480d5..67bbb92 100644 (file)
@@ -62,7 +62,7 @@
 \r
                        #include "Atomic.h"\r
 \r
 \r
                        #include "Atomic.h"\r
 \r
-                       #define PROGMEM\r
+                       #define PROGMEM const\r
                #else\r
                        #include <avr/io.h>\r
                #endif\r
                #else\r
                        #include <avr/io.h>\r
                #endif\r
index e07eb6c..b748479 100644 (file)
@@ -51,6 +51,7 @@
 #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
index 3440cc9..f466162 100644 (file)
@@ -51,6 +51,7 @@
 #define __SPI_AVR8_H__\r
 \r
        /* Includes: */\r
 #define __SPI_AVR8_H__\r
 \r
        /* Includes: */\r
+               #include <avr/io.h>\r
                #include <stdbool.h>\r
 \r
        /* Preprocessor Checks: */\r
                #include <stdbool.h>\r
 \r
        /* Preprocessor Checks: */\r
index 282528b..0421dea 100644 (file)
@@ -80,7 +80,7 @@
                                 */\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
-                               // TODO\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
-                               // TODO\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
-                               // TODO\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
-                               // TODO\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
index 673f1b0..d169b82 100644 (file)
@@ -37,7 +37,7 @@
  */\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
index f05ace3..ad43258 100644 (file)
@@ -9,7 +9,7 @@
   *  \section Sec_ChangeLogXXXXXX Version XXXXXX\r
   *\r
   *  <b>New:</b>\r
   *  \section Sec_ChangeLogXXXXXX Version XXXXXX\r
   *\r
   *  <b>New:</b>\r
-  *  - (None)\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
@@ -17,7 +17,7 @@
   *  - 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
-  *  - (None)\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
index f1bb45a..957084c 100644 (file)
@@ -53,7 +53,7 @@ volatile uint16_t           SoftUSART_Data;
 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
@@ -103,7 +103,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
 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