Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Erik Strand
lufa
Commits
17d06b84
Commit
17d06b84
authored
Aug 25, 2009
by
Dean Camera
Browse files
Add VTARGET level detection to the AVRISP project on supported AVR models.
parent
244bba20
Changes
4
Show whitespace changes
Inline
Side-by-side
Projects/AVRISP/AVRISP.c
View file @
17d06b84
...
...
@@ -35,7 +35,6 @@
*/
// TODO: Add in software SPI for lower programming speeds below 125KHz
// TODO: Add in VTARGET detection
// TODO: Add reversed target connector checks
#include
"AVRISP.h"
...
...
@@ -55,6 +54,11 @@ int main(void)
{
Process_AVRISP_Commands
();
#if defined(ADC)
/* Update VTARGET parameter with the latest ADC conversion of VTARGET on supported AVR models */
V2Params_SetParameterValue
(
PARAM_VTARGET
,
((
5
*
10
*
ADC_GetResult
())
/
1024
));
#endif
USB_USBTask
();
}
}
...
...
@@ -73,6 +77,13 @@ void SetupHardware(void)
LEDs_Init
();
USB_Init
();
#if defined(ADC)
/* Initialize the ADC converter for VTARGET level detection on supported AVR models */
ADC_Init
(
ADC_FREE_RUNNING
|
ADC_PRESCALE_128
);
ADC_SetupChannel
(
VTARGET_ADC_CHANNEL
);
ADC_StartReading
(
VTARGET_ADC_CHANNEL
|
ADC_RIGHT_ADJUSTED
|
ADC_REFERENCE_AVCC
);
#endif
/* Millisecond timer initialization for timeout checking */
OCR0A
=
((
F_CPU
/
64
)
/
1000
);
TCCR0A
=
(
1
<<
WGM01
);
...
...
Projects/AVRISP/AVRISP.h
View file @
17d06b84
...
...
@@ -48,6 +48,10 @@
#include
<LUFA/Drivers/Board/LEDs.h>
#include
<LUFA/Drivers/USB/USB.h>
#if defined(ADC)
#include
<LUFA/Drivers/Peripheral/ADC.h>
#endif
#include
"Lib/V2Protocol.h"
/* Macros: */
...
...
Projects/AVRISP/AVRISP.txt
View file @
17d06b84
...
...
@@ -60,9 +60,12 @@
*
* Note that this design currently has several limitations:
* - Minimum target clock speed of 500KHz due to hardware SPI used
* - No VTARGET detection and notification
* - No reversed/shorted target connector detection and notification
*
* On AVR models with an ADC converter, ACC should be tied to 5V (e.g. VBUS) and the VTARGET_ADC_CHANNEL token should be
* set to an appropriate ADC channel number in the project makefile for VTARGET detection to operate correctly. On models
* without an ADC converter, VTARGET will report at a fixed 5V level.
*
* \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.
...
...
@@ -88,5 +91,10 @@
* <td>Makefile CDEFS</td>
* <td>Mask for the programmer's target RESET line on the chosen port.</td>
* </tr>
* <tr>
* <td>VTARGET_ADC_CHANNEL</td>
* <td>Makefile CDEFS</td>
* <td>ADC channel number (on supported AVRs) to use for VTARGET level detection.</td>
* </tr>
* </table>
*/
Projects/AVRISP/makefile
View file @
17d06b84
...
...
@@ -60,7 +60,7 @@
# MCU name
MCU
=
at90usb
64
7
MCU
=
at90usb
128
7
# Target board (see library "Board Types" documentation, USER or blank for projects not requiring
...
...
@@ -197,6 +197,7 @@ CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA
CDEFS
+=
-DRESET_LINE_PORT
=
PORTB
CDEFS
+=
-DRESET_LINE_DDR
=
DDRB
CDEFS
+=
-DRESET_LINE_MASK
=
"(1 << 4)"
CDEFS
+=
-DVTARGET_ADC_CHANNEL
=
2
# Place -D or -U options here for ASM sources
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment