Commit 4f74075f authored by Dean Camera's avatar Dean Camera
Browse files

Speed up bit-banged USART code in the AVRISP project.

Fix project text files to refer to "project" instead of "demo".
parent 2f6c0960
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
/** \mainpage AVRISP MKII Programmer Project /** \mainpage AVRISP MKII Programmer Project
* *
* \section SSec_Compat Demo Compatibility: * \section SSec_Compat Project Compatibility:
* *
* The following list indicates what microcontrollers are compatible with this demo. * The following list indicates what microcontrollers are compatible with this project.
* *
* - Series 7 USB AVRs * - Series 7 USB AVRs
* - Series 6 USB AVRs * - Series 6 USB AVRs
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* \section SSec_Info USB Information: * \section SSec_Info USB Information:
* *
* The following table gives a rundown of the USB utilization of this demo. * The following table gives a rundown of the USB utilization of this project.
* *
* <table> * <table>
* <tr> * <tr>
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
* While this application can be compiled for USB AVRs with as little as 8KB of FLASH, for full functionality 16KB or more * While this application can be compiled for USB AVRs with as little as 8KB of FLASH, for full functionality 16KB or more
* of FLASH is required. On 8KB devices, either ISP or PDI programming support can be disabled to reduce program size. * of FLASH is required. On 8KB devices, either ISP or PDI programming support can be disabled to reduce program size.
* *
* * \section Sec_ISP ISP Connections
* Connections to the device for SPI programming (when enabled): * Connections to the device for SPI programming (when enabled):
* *
* <table> * <table>
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
* <b><sup>1</sup></b> <i>Optional, see \ref SSec_Options section - for USB AVRs with ADC modules only</i> \n * <b><sup>1</sup></b> <i>Optional, see \ref SSec_Options section - for USB AVRs with ADC modules only</i> \n
* <b><sup>2</sup></b> <i>See \ref SSec_Options section</i> * <b><sup>2</sup></b> <i>See \ref SSec_Options section</i>
* *
* * \section Sec_PDI PDI Connections
* Connections to the device for PDI programming<b><sup>1</sup></b> (when enabled): * Connections to the device for PDI programming<b><sup>1</sup></b> (when enabled):
* *
* <table> * <table>
...@@ -152,12 +152,12 @@ ...@@ -152,12 +152,12 @@
* </tr> * </tr>
* </table> * </table>
* *
* <b><sup>1</sup></b> When PDI_VIA_HARDWARE_USART is set, the AVR's Tx and Rx become the DATA line when connected together * <b><sup>1</sup></b> <i>When PDI_VIA_HARDWARE_USART is set, the AVR's Tx and Rx become the DATA line when connected together
* via a pair of 300 ohm resistors, and the AVR's XCK pin becomes CLOCK. * via a pair of 300 ohm resistors, and the AVR's XCK pin becomes CLOCK.</i>
* *
* \section SSec_Options Project Options * \section SSec_Options Project Options
* *
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. * The following defines can be found in this project, which can control the project behaviour when defined, or changed in value.
* *
* <table> * <table>
* <tr> * <tr>
......
...@@ -182,7 +182,6 @@ bool NVMTarget_ReadMemory(uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t Re ...@@ -182,7 +182,6 @@ bool NVMTarget_ReadMemory(uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t Re
* \param[in] WriteCommand Command to send to the device to write each memory byte * \param[in] WriteCommand Command to send to the device to write each memory byte
* \param[in] WriteAddress Start address to write to within the target's address space * \param[in] WriteAddress Start address to write to within the target's address space
* \param[in] WriteBuffer Buffer to source data from * \param[in] WriteBuffer Buffer to source data from
* \param[in] WriteSize Number of bytes to write
* *
* \return Boolean true if the command sequence complete successfully * \return Boolean true if the command sequence complete successfully
*/ */
......
...@@ -45,9 +45,8 @@ volatile bool IsSending; ...@@ -45,9 +45,8 @@ volatile bool IsSending;
/** Software USART raw frame bits for transmission/reception. */ /** Software USART raw frame bits for transmission/reception. */
volatile uint16_t SoftUSART_Data; volatile uint16_t SoftUSART_Data;
/** Bits remaining to be sent or received via the software USART. */ /** Bits remaining to be sent or received via the software USART - set as a GPIOR for speed. */
volatile uint8_t SoftUSART_BitCount; #define SoftUSART_BitCount GPIOR2
/** ISR to manage the software USART when bit-banged USART mode is selected. */ /** ISR to manage the software USART when bit-banged USART mode is selected. */
ISR(TIMER1_COMPA_vect, ISR_BLOCK) ISR(TIMER1_COMPA_vect, ISR_BLOCK)
...@@ -59,21 +58,13 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK) ...@@ -59,21 +58,13 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
if (!(SoftUSART_BitCount)) if (!(SoftUSART_BitCount))
return; return;
/* Check to see if the current clock state is on the rising or falling edge */ /* Check to see if we are at a rising or falling edge of the clock */
bool IsRisingEdge = (BITBANG_PDICLOCK_PORT & BITBANG_PDICLOCK_MASK); if (BITBANG_PDICLOCK_PORT & BITBANG_PDICLOCK_MASK)
if (IsSending && !IsRisingEdge)
{
if (SoftUSART_Data & 0x01)
BITBANG_PDIDATA_PORT |= BITBANG_PDIDATA_MASK;
else
BITBANG_PDIDATA_PORT &= ~BITBANG_PDIDATA_MASK;
SoftUSART_Data >>= 1;
SoftUSART_BitCount--;
}
else if (!IsSending && IsRisingEdge)
{ {
/* If at rising clock edge and we are in send mode, abort */
if (IsSending)
return;
/* Wait for the start bit when receiving */ /* Wait for the start bit when receiving */
if ((SoftUSART_BitCount == BITS_IN_FRAME) && (BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK)) if ((SoftUSART_BitCount == BITS_IN_FRAME) && (BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK))
return; return;
...@@ -84,6 +75,20 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK) ...@@ -84,6 +75,20 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
SoftUSART_Data >>= 1; SoftUSART_Data >>= 1;
SoftUSART_BitCount--; SoftUSART_BitCount--;
} }
else
{
/* If at falling clock edge and we are in receive mode, abort */
if (!IsSending)
return;
if (SoftUSART_Data & 0x01)
BITBANG_PDIDATA_PORT |= BITBANG_PDIDATA_MASK;
else
BITBANG_PDIDATA_PORT &= ~BITBANG_PDIDATA_MASK;
SoftUSART_Data >>= 1;
SoftUSART_BitCount--;
}
} }
#endif #endif
...@@ -120,7 +125,7 @@ void PDITarget_EnableTargetPDI(void) ...@@ -120,7 +125,7 @@ void PDITarget_EnableTargetPDI(void)
asm volatile ("NOP"::); asm volatile ("NOP"::);
/* Fire timer compare ISR every 100 cycles to manage the software USART */ /* Fire timer compare ISR every 100 cycles to manage the software USART */
OCR1A = 100; OCR1A = 80;
TCCR1B = (1 << WGM12) | (1 << CS10); TCCR1B = (1 << WGM12) | (1 << CS10);
TIMSK1 = (1 << OCIE1A); TIMSK1 = (1 << OCIE1A);
......
...@@ -66,7 +66,7 @@ MCU = at90usb1287 ...@@ -66,7 +66,7 @@ MCU = at90usb1287
# Target board (see library "Board Types" documentation, USER or blank for projects not requiring # Target board (see library "Board Types" documentation, USER or blank for projects not requiring
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # LUFA board drivers). If USER is selected, put custom board drivers in a directory called
# "Board" inside the application directory. # "Board" inside the application directory.
BOARD = XPLAIN BOARD = USBKEY
# Processor frequency. # Processor frequency.
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
/** \mainpage Benito Arduino Programmer Project /** \mainpage Benito Arduino Programmer Project
* *
* \section SSec_Compat Demo Compatibility: * \section SSec_Compat Project Compatibility:
* *
* The following list indicates what microcontrollers are compatible with this demo. * The following list indicates what microcontrollers are compatible with this project.
* *
* - Series 7 USB AVRs * - Series 7 USB AVRs
* - Series 6 USB AVRs * - Series 6 USB AVRs
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* \section SSec_Info USB Information: * \section SSec_Info USB Information:
* *
* The following table gives a rundown of the USB utilization of this demo. * The following table gives a rundown of the USB utilization of this project.
* *
* <table> * <table>
* <tr> * <tr>
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
* *
* \section SSec_Options Project Options * \section SSec_Options Project Options
* *
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. * The following defines can be found in this project, which can control the project behaviour when defined, or changed in value.
* *
* <table> * <table>
* <tr> * <tr>
......
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
/** \mainpage Denver Gingerich's USBSnoop Magnetic Card Reader Project /** \mainpage Denver Gingerich's USBSnoop Magnetic Card Reader Project
* *
* \section SSec_Compat Demo Compatibility: * \section SSec_Compat Project Compatibility:
* *
* The following list indicates what microcontrollers are compatible with this demo. * The following list indicates what microcontrollers are compatible with this project.
* *
* - AT90USB1287 * - AT90USB1287
* - AT90USB1286 * - AT90USB1286
* *
* \section SSec_Info USB Information: * \section SSec_Info USB Information:
* *
* The following table gives a rundown of the USB utilization of this demo. * The following table gives a rundown of the USB utilization of this project.
* *
* <table> * <table>
* <tr> * <tr>
...@@ -87,17 +87,17 @@ ...@@ -87,17 +87,17 @@
* </tr> * </tr>
* </table> * </table>
* *
* This project is based on the LUFA Keyboard demonstration application, * This project is based on the LUFA Keyboard projectnstration application,
* written by Denver Gingerich. * written by Denver Gingerich.
* *
* This application uses a keyboard HID driver to communicate the data collected * This application uses a keyboard HID driver to communicate the data collected
* a TTL magnetic stripe reader to the connected computer. The raw bitstream * a TTL magnetic stripe reader to the connected computer. The raw bitstream
* obtained from the magnetic stripe reader is "typed" through the keyboard * obtained from the magnetic stripe reader is "typed" through the keyboard
* driver as 0's and 1's. After every card swipe, the demo will send a return key. * driver as 0's and 1's. After every card swipe, the project will send a return key.
* *
* \section SSec_Options Project Options * \section SSec_Options Project Options
* *
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. * The following defines can be found in this project, which can control the project behaviour when defined, or changed in value.
* *
* <table> * <table>
* <tr> * <tr>
......
...@@ -4,17 +4,17 @@ ...@@ -4,17 +4,17 @@
* documentation pages. It is not a project source file. * documentation pages. It is not a project source file.
*/ */
/** \mainpage Missile Launcher /** \mainpage David Fletcher's Missile Launcher
* *
* \section SSec_Compat Demo Compatibility: * \section SSec_Compat Project Compatibility:
* *
* The following list indicates what microcontrollers are compatible with this demo. * The following list indicates what microcontrollers are compatible with this project.
* *
* - Series 7 USB AVRs * - Series 7 USB AVRs
* *
* \section SSec_Info USB Information: * \section SSec_Info USB Information:
* *
* The following table gives a rundown of the USB utilization of this demo. * The following table gives a rundown of the USB utilization of this project.
* *
* <table> * <table>
* <tr> * <tr>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
* *
* \section SSec_Options Project Options * \section SSec_Options Project Options
* *
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. * The following defines can be found in this project, which can control the project behaviour when defined, or changed in value.
* *
* <table> * <table>
* <tr> * <tr>
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
* documentation pages. It is not a project source file. * documentation pages. It is not a project source file.
*/ */
/** \mainpage USB to Serial Converter Project (via CDC-ACM class) /** \mainpage USB to Serial Converter Project
* *
* \section SSec_Compat Demo Compatibility: * \section SSec_Compat Project Compatibility:
* *
* The following list indicates what microcontrollers are compatible with this demo. * The following list indicates what microcontrollers are compatible with this project.
* *
* - Series 7 USB AVRs * - Series 7 USB AVRs
* - Series 6 USB AVRs * - Series 6 USB AVRs
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* \section SSec_Info USB Information: * \section SSec_Info USB Information:
* *
* The following table gives a rundown of the USB utilization of this demo. * The following table gives a rundown of the USB utilization of this project.
* *
* <table> * <table>
* <tr> * <tr>
...@@ -55,8 +55,8 @@ ...@@ -55,8 +55,8 @@
* error rates at the AVR's clock speed, data lengths other than 6, 7 or 8 bits, * error rates at the AVR's clock speed, data lengths other than 6, 7 or 8 bits,
* 1.5 stop bits, parity other than none, even or odd). * 1.5 stop bits, parity other than none, even or odd).
* *
* After running this demo for the first time on a new computer, * After running this project for the first time on a new computer,
* you will need to supply the .INF file located in this demo * you will need to supply the .INF file located in this project
* project's directory as the device's driver when running under * project's directory as the device's driver when running under
* Windows. This will enable Windows to use its inbuilt CDC drivers, * Windows. This will enable Windows to use its inbuilt CDC drivers,
* negating the need for custom drivers for the device. Other * negating the need for custom drivers for the device. Other
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
* *
* \section SSec_Options Project Options * \section SSec_Options Project Options
* *
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. * The following defines can be found in this project, which can control the project behaviour when defined, or changed in value.
* *
* <table> * <table>
* <tr> * <tr>
......
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
/** \mainpage XPLAIN UART Bridge Project /** \mainpage XPLAIN UART Bridge Project
* *
* \section SSec_Compat Demo Compatibility: * \section SSec_Compat Project Compatibility:
* *
* The following list indicates what microcontrollers are compatible with this demo. * The following list indicates what microcontrollers are compatible with this project.
* *
* - AT90USB1287 * - AT90USB1287
* *
* \section SSec_Info USB Information: * \section SSec_Info USB Information:
* *
* The following table gives a rundown of the USB utilization of this demo. * The following table gives a rundown of the USB utilization of this project.
* *
* <table> * <table>
* <tr> * <tr>
...@@ -46,14 +46,14 @@ ...@@ -46,14 +46,14 @@
* host. When inserted, the device will enumerate as a regular COM port on the host, which can then be opened and data exchanged * host. When inserted, the device will enumerate as a regular COM port on the host, which can then be opened and data exchanged
* between the XMEGA and Host as if the XMEGA was connected directly to the host's serial port. * between the XMEGA and Host as if the XMEGA was connected directly to the host's serial port.
* *
* After running this demo for the first time on a new computer, you will need to supply the .INF file located in this demo * After running this project for the first time on a new computer, you will need to supply the .INF file located in this project
* project's directory as the device's driver when running under Windows. This will enable Windows to use its inbuilt CDC drivers, * project's directory as the device's driver when running under Windows. This will enable Windows to use its inbuilt CDC drivers,
* negating the need for custom drivers for the device. Other Operating Systems should automatically use their own inbuilt CDC-ACM * negating the need for custom drivers for the device. Other Operating Systems should automatically use their own inbuilt CDC-ACM
* drivers. * drivers.
* *
* \section SSec_Options Project Options * \section SSec_Options Project Options
* *
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. * The following defines can be found in this project, which can control the project behaviour when defined, or changed in value.
* *
* <table> * <table>
* <tr> * <tr>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment