Fixed PDI programming mode in the AVRISP programmer project not exiting programming mode correctly (clear target Reset key twice, set /RESET pin to pullup).

Add newlines to the MIDI event printf() statements in the MIDI host demos.
pull/1469/head
Dean Camera 15 years ago
parent b2bdfe4377
commit 39d56aeffe

@ -114,9 +114,9 @@ int main(void)
if (NoteOnEvent || NoteOffEvent) if (NoteOnEvent || NoteOffEvent)
{ {
printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d"), NoteOnEvent ? "On" : "Off", printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d\r\n"), NoteOnEvent ? "On" : "Off",
((MIDIEvent.Data1 & 0x0F) + 1), ((MIDIEvent.Data1 & 0x0F) + 1),
MIDIEvent.Data2, MIDIEvent.Data3); MIDIEvent.Data2, MIDIEvent.Data3);
} }
} }

@ -186,9 +186,9 @@ void MIDI_Host_Task(void)
if (NoteOnEvent || NoteOffEvent) if (NoteOnEvent || NoteOffEvent)
{ {
printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d"), NoteOnEvent ? "On" : "Off", printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d\r\n"), NoteOnEvent ? "On" : "Off",
((MIDIEvent.Data1 & 0x0F) + 1), ((MIDIEvent.Data1 & 0x0F) + 1),
MIDIEvent.Data2, MIDIEvent.Data3); MIDIEvent.Data2, MIDIEvent.Data3);
} }
Pipe_ClearIN(); Pipe_ClearIN();

@ -26,6 +26,8 @@
* - Fixed ADC routines not correctly returning the last result when multiple channels were read * - Fixed ADC routines not correctly returning the last result when multiple channels were read
* - Fixed ADC routines failing to read the extended channels (Channels 8 to 13, Internal Temperature Sensor) on the * - Fixed ADC routines failing to read the extended channels (Channels 8 to 13, Internal Temperature Sensor) on the
* U4 series USB AVR parts * U4 series USB AVR parts
* - Fixed PDI programming mode in the AVRISP programmer project not exiting programming mode correctly (clear target
* Reset key twice, set /RESET pin to pullup)
* *
* \section Sec_ChangeLog100219 Version 100219 * \section Sec_ChangeLog100219 Version 100219
* *

@ -170,14 +170,22 @@ static void XPROGProtocol_LeaveXPROGMode(void)
if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI) if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
{ {
XMEGANVM_WaitWhileNVMBusBusy();
/* Clear the RESET key in the RESET PDI register to allow the XMEGA to run */ /* Clear the RESET key in the RESET PDI register to allow the XMEGA to run */
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG); XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
XPROGTarget_SendByte(0x00); XPROGTarget_SendByte(0x00);
/* Clear /RESET key twice (for some reason this needs to be done twice to take effect) */
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
XPROGTarget_SendByte(0x00);
XPROGTarget_DisableTargetPDI(); XPROGTarget_DisableTargetPDI();
} }
else else
{ {
TINYNVM_WaitWhileNVMBusBusy();
/* Clear the NVMEN bit in the TPI CONTROL register to disable TPI mode */ /* Clear the NVMEN bit in the TPI CONTROL register to disable TPI mode */
XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG); XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG);
XPROGTarget_SendByte(0x00); XPROGTarget_SendByte(0x00);

@ -232,33 +232,24 @@ void XPROGTarget_DisableTargetPDI(void)
XPROGTarget_SetRxMode(); XPROGTarget_SetRxMode();
#if defined(XPROG_VIA_HARDWARE_USART) #if defined(XPROG_VIA_HARDWARE_USART)
/* Set /RESET high for a one millisecond to ensure target device is restarted */
PORTD |= (1 << 5);
_delay_ms(1);
/* Turn off receiver and transmitter of the USART, clear settings */ /* Turn off receiver and transmitter of the USART, clear settings */
UCSR1A |= (1 << TXC1) | (1 << RXC1); UCSR1A = ((1 << TXC1) | (1 << RXC1));
UCSR1B = 0; UCSR1B = 0;
UCSR1C = 0; UCSR1C = 0;
/* Set all USART lines as input, tristate */ /* Make Reset input with pullup to take target out of /RESET, tristate all other pins */
DDRD &= ~((1 << 5) | (1 << 3)); DDRD &= ~((1 << 5) | (1 << 3));
PORTD &= ~((1 << 5) | (1 << 3) | (1 << 2)); PORTD &= ~((1 << 3) | (1 << 2));
PORTD |= (1 << 5);
#else #else
/* Turn off software USART management timer */ /* Turn off software USART management timer */
TCCR1B = 0; TCCR1B = 0;
/* Set /RESET high for a one millisecond to ensure target device is restarted */ /* Make Reset input with pullup to take target out of /RESET, tristate all other pins */
BITBANG_PDICLOCK_PORT |= BITBANG_PDICLOCK_MASK;
_delay_ms(1);
/* Set DATA and CLOCK lines to inputs */
BITBANG_PDIDATA_DDR &= ~BITBANG_PDIDATA_MASK; BITBANG_PDIDATA_DDR &= ~BITBANG_PDIDATA_MASK;
BITBANG_PDICLOCK_DDR &= ~BITBANG_PDICLOCK_MASK; BITBANG_PDICLOCK_DDR &= ~BITBANG_PDICLOCK_MASK;
/* Tristate DATA and CLOCK lines */
BITBANG_PDIDATA_PORT &= ~BITBANG_PDIDATA_MASK;
BITBANG_PDICLOCK_PORT &= ~BITBANG_PDICLOCK_MASK; BITBANG_PDICLOCK_PORT &= ~BITBANG_PDICLOCK_MASK;
BITBANG_PDIDATA_PORT |= BITBANG_PDIDATA_MASK;
#endif #endif
} }

Loading…
Cancel
Save