Fixed PDI programming mode in the AVRISP programmer project not exiting programming...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 16 Mar 2010 11:47:11 +0000 (11:47 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 16 Mar 2010 11:47:11 +0000 (11:47 +0000)
Add newlines to the MIDI event printf() statements in the MIDI host demos.

Demos/Host/ClassDriver/MIDIHost/MIDIHost.c
Demos/Host/LowLevel/MIDIHost/MIDIHost.c
LUFA/ManPages/ChangeLog.txt
Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c

index 64e6519..f467d16 100644 (file)
@@ -114,9 +114,9 @@ int main(void)
                                        \r
                                        if (NoteOnEvent || NoteOffEvent)\r
                                        {\r
-                                               printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d"), NoteOnEvent ? "On" : "Off",\r
-                                                                                                                                                                                  ((MIDIEvent.Data1 & 0x0F) + 1),\r
-                                                                                                                                                                                  MIDIEvent.Data2, MIDIEvent.Data3);\r
+                                               printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d\r\n"), NoteOnEvent ? "On" : "Off",\r
+                                                                                                                                                                                      ((MIDIEvent.Data1 & 0x0F) + 1),\r
+                                                                                                                                                                                      MIDIEvent.Data2, MIDIEvent.Data3);\r
                                        }\r
                                }\r
                \r
index 1ca7bd9..6964f71 100644 (file)
@@ -186,9 +186,9 @@ void MIDI_Host_Task(void)
                                \r
                                if (NoteOnEvent || NoteOffEvent)\r
                                {\r
-                                       printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d"), NoteOnEvent ? "On" : "Off",\r
-                                                                                                      ((MIDIEvent.Data1 & 0x0F) + 1),\r
-                                                                                                      MIDIEvent.Data2, MIDIEvent.Data3);\r
+                                       printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d\r\n"), NoteOnEvent ? "On" : "Off",\r
+                                                                                                          ((MIDIEvent.Data1 & 0x0F) + 1),\r
+                                                                                                          MIDIEvent.Data2, MIDIEvent.Data3);\r
                                }\r
 \r
                                Pipe_ClearIN();\r
index 1eac9eb..e7f1f43 100644 (file)
@@ -26,6 +26,8 @@
   *  - Fixed ADC routines not correctly returning the last result when multiple channels were read\r
   *  - Fixed ADC routines failing to read the extended channels (Channels 8 to 13, Internal Temperature Sensor) on the\r
   *    U4 series USB AVR parts\r
+  *  - Fixed PDI programming mode in the AVRISP programmer project not exiting programming mode correctly (clear target\r
+  *    Reset key twice, set /RESET pin to pullup)\r
   *\r
   *  \section Sec_ChangeLog100219 Version 100219\r
   *\r
index 805eaa3..08936a2 100644 (file)
@@ -119,7 +119,7 @@ static void XPROGProtocol_EnterXPROGMode(void)
        {\r
                /* Enable PDI programming mode with the attached target */\r
                XPROGTarget_EnableTargetPDI();\r
-               \r
+\r
                /* Store the RESET key into the RESET PDI register to keep the XMEGA in reset */\r
                XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);     \r
                XPROGTarget_SendByte(PDI_RESET_KEY);\r
@@ -170,14 +170,22 @@ static void XPROGProtocol_LeaveXPROGMode(void)
        \r
        if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)\r
        {\r
+               XMEGANVM_WaitWhileNVMBusBusy();\r
+\r
                /* Clear the RESET key in the RESET PDI register to allow the XMEGA to run */\r
                XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);     \r
                XPROGTarget_SendByte(0x00);\r
+               \r
+               /* Clear /RESET key twice (for some reason this needs to be done twice to take effect) */\r
+               XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);     \r
+               XPROGTarget_SendByte(0x00);\r
 \r
                XPROGTarget_DisableTargetPDI();\r
        }\r
        else\r
        {\r
+               TINYNVM_WaitWhileNVMBusBusy();\r
+\r
                /* Clear the NVMEN bit in the TPI CONTROL register to disable TPI mode */\r
                XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG);     \r
                XPROGTarget_SendByte(0x00);\r
index 957084c..4ecf033 100644 (file)
@@ -232,33 +232,24 @@ void XPROGTarget_DisableTargetPDI(void)
        XPROGTarget_SetRxMode();\r
 \r
 #if defined(XPROG_VIA_HARDWARE_USART)\r
-       /* Set /RESET high for a one millisecond to ensure target device is restarted */\r
-       PORTD |= (1 << 5);\r
-       _delay_ms(1);\r
-\r
        /* Turn off receiver and transmitter of the USART, clear settings */\r
-       UCSR1A |= (1 << TXC1) | (1 << RXC1);\r
+       UCSR1A  = ((1 << TXC1) | (1 << RXC1));\r
        UCSR1B  = 0;\r
        UCSR1C  = 0;\r
 \r
-       /* Set all USART lines as input, tristate */\r
+       /* Make Reset input with pullup to take target out of /RESET, tristate all other pins */\r
        DDRD  &= ~((1 << 5) | (1 << 3));\r
-       PORTD &= ~((1 << 5) | (1 << 3) | (1 << 2));\r
+       PORTD &= ~((1 << 3) | (1 << 2));\r
+       PORTD |=   (1 << 5);\r
 #else\r
        /* Turn off software USART management timer */\r
        TCCR1B = 0;\r
 \r
-       /* Set /RESET high for a one millisecond to ensure target device is restarted */\r
-       BITBANG_PDICLOCK_PORT |= BITBANG_PDICLOCK_MASK;\r
-       _delay_ms(1);\r
-\r
-       /* Set DATA and CLOCK lines to inputs */\r
+       /* Make Reset input with pullup to take target out of /RESET, tristate all other pins */\r
        BITBANG_PDIDATA_DDR   &= ~BITBANG_PDIDATA_MASK;\r
        BITBANG_PDICLOCK_DDR  &= ~BITBANG_PDICLOCK_MASK;\r
-       \r
-       /* Tristate DATA and CLOCK lines */\r
-       BITBANG_PDIDATA_PORT  &= ~BITBANG_PDIDATA_MASK;\r
        BITBANG_PDICLOCK_PORT &= ~BITBANG_PDICLOCK_MASK;        \r
+       BITBANG_PDIDATA_PORT  |=  BITBANG_PDIDATA_MASK;\r
 #endif\r
 }\r
 \r