projects
/
pub
/
USBasp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
244bba2
)
Add VTARGET level detection to the AVRISP project on supported AVR models.
author
Dean Camera
<dean@fourwalledcubicle.com>
Tue, 25 Aug 2009 14:02:47 +0000
(14:02 +0000)
committer
Dean Camera
<dean@fourwalledcubicle.com>
Tue, 25 Aug 2009 14:02:47 +0000
(14:02 +0000)
Projects/AVRISP/AVRISP.c
patch
|
blob
|
blame
|
history
Projects/AVRISP/AVRISP.h
patch
|
blob
|
blame
|
history
Projects/AVRISP/AVRISP.txt
patch
|
blob
|
blame
|
history
Projects/AVRISP/makefile
patch
|
blob
|
blame
|
history
diff --git
a/Projects/AVRISP/AVRISP.c
b/Projects/AVRISP/AVRISP.c
index
f14b654
..
d4ae910
100644
(file)
--- a/
Projects/AVRISP/AVRISP.c
+++ b/
Projects/AVRISP/AVRISP.c
@@
-35,7
+35,6
@@
*/
\r
\r
// TODO: Add in software SPI for lower programming speeds below 125KHz
\r
*/
\r
\r
// TODO: Add in software SPI for lower programming speeds below 125KHz
\r
-// TODO: Add in VTARGET detection
\r
// TODO: Add reversed target connector checks
\r
\r
#include "AVRISP.h"
\r
// TODO: Add reversed target connector checks
\r
\r
#include "AVRISP.h"
\r
@@
-53,7
+52,12
@@
int main(void)
\r
for (;;)
\r
{
\r
for (;;)
\r
{
- Process_AVRISP_Commands();
+ Process_AVRISP_Commands();
\r
+
\r
+ #if defined(ADC)
\r
+ /* Update VTARGET parameter with the latest ADC conversion of VTARGET on supported AVR models */
\r
+ V2Params_SetParameterValue(PARAM_VTARGET, ((5 * 10 * ADC_GetResult()) / 1024));
\r
+ #endif
\r
USB_USBTask();
\r
}
\r
\r
USB_USBTask();
\r
}
\r
@@
-73,6
+77,13
@@
void SetupHardware(void)
LEDs_Init();
\r
USB_Init();
\r
\r
LEDs_Init();
\r
USB_Init();
\r
\r
+ #if defined(ADC)
\r
+ /* Initialize the ADC converter for VTARGET level detection on supported AVR models */
\r
+ ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
\r
+ ADC_SetupChannel(VTARGET_ADC_CHANNEL);
\r
+ ADC_StartReading(VTARGET_ADC_CHANNEL | ADC_RIGHT_ADJUSTED | ADC_REFERENCE_AVCC);
\r
+ #endif
\r
+
\r
/* Millisecond timer initialization for timeout checking */
\r
OCR0A = ((F_CPU / 64) / 1000);
\r
TCCR0A = (1 << WGM01);
\r
/* Millisecond timer initialization for timeout checking */
\r
OCR0A = ((F_CPU / 64) / 1000);
\r
TCCR0A = (1 << WGM01);
\r
diff --git
a/Projects/AVRISP/AVRISP.h
b/Projects/AVRISP/AVRISP.h
index
d37bf53
..
e17fe30
100644
(file)
--- a/
Projects/AVRISP/AVRISP.h
+++ b/
Projects/AVRISP/AVRISP.h
@@
-46,8
+46,12
@@
\r
#include <LUFA/Version.h>
\r
#include <LUFA/Drivers/Board/LEDs.h>
\r
\r
#include <LUFA/Version.h>
\r
#include <LUFA/Drivers/Board/LEDs.h>
\r
- #include <LUFA/Drivers/USB/USB.h>
-
+ #include <LUFA/Drivers/USB/USB.h>
\r
+
\r
+ #if defined(ADC)
+ #include <LUFA/Drivers/Peripheral/ADC.h>
\r
+ #endif
\r
+
#include "Lib/V2Protocol.h"
\r
\r
/* Macros: */
#include "Lib/V2Protocol.h"
\r
\r
/* Macros: */
@@
-61,7
+65,7
@@
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
\r
\r
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
\r
\r
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
\r
- #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
\r
+ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
\r
\r
/* Function Prototypes: */
\r
void SetupHardware(void);
\r
\r
/* Function Prototypes: */
\r
void SetupHardware(void);
\r
diff --git
a/Projects/AVRISP/AVRISP.txt
b/Projects/AVRISP/AVRISP.txt
index
e26cfb1
..
8d299e2
100644
(file)
--- a/
Projects/AVRISP/AVRISP.txt
+++ b/
Projects/AVRISP/AVRISP.txt
@@
-60,9
+60,12
@@
*
\r
* Note that this design currently has several limitations:
\r
* - Minimum target clock speed of 500KHz due to hardware SPI used
\r
*
\r
* Note that this design currently has several limitations:
\r
* - Minimum target clock speed of 500KHz due to hardware SPI used
\r
- * - No VTARGET detection and notification
\r
* - No reversed/shorted target connector detection and notification
\r
*
\r
* - No reversed/shorted target connector detection and notification
\r
*
\r
+ * On AVR models with an ADC converter, ACC should be tied to 5V (e.g. VBUS) and the VTARGET_ADC_CHANNEL token should be
\r
+ * set to an appropriate ADC channel number in the project makefile for VTARGET detection to operate correctly. On models
\r
+ * without an ADC converter, VTARGET will report at a fixed 5V level.
\r
+ *
\r
* \section SSec_Options Project Options
\r
*
\r
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
\r
* \section SSec_Options Project Options
\r
*
\r
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
\r
@@
-88,5
+91,10
@@
* <td>Makefile CDEFS</td>
\r
* <td>Mask for the programmer's target RESET line on the chosen port.</td>
\r
* </tr>
\r
* <td>Makefile CDEFS</td>
\r
* <td>Mask for the programmer's target RESET line on the chosen port.</td>
\r
* </tr>
\r
+ * <tr>
\r
+ * <td>VTARGET_ADC_CHANNEL</td>
\r
+ * <td>Makefile CDEFS</td>
\r
+ * <td>ADC channel number (on supported AVRs) to use for VTARGET level detection.</td>
\r
+ * </tr>
\r
* </table>
\r
*/
\r
* </table>
\r
*/
\r
diff --git
a/Projects/AVRISP/makefile
b/Projects/AVRISP/makefile
index
84ca93a
..
5ea1176
100644
(file)
--- a/
Projects/AVRISP/makefile
+++ b/
Projects/AVRISP/makefile
@@
-60,7
+60,7
@@
\r
\r
# MCU name
\r
\r
\r
# MCU name
\r
-MCU = at90usb
64
7
\r
+MCU = at90usb
128
7
\r
\r
\r
# Target board (see library "Board Types" documentation, USER or blank for projects not requiring
\r
\r
\r
# Target board (see library "Board Types" documentation, USER or blank for projects not requiring
\r
@@
-197,6
+197,7
@@
CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA
CDEFS += -DRESET_LINE_PORT=PORTB
\r
CDEFS += -DRESET_LINE_DDR=DDRB
\r
CDEFS += -DRESET_LINE_MASK="(1 << 4)"
\r
CDEFS += -DRESET_LINE_PORT=PORTB
\r
CDEFS += -DRESET_LINE_DDR=DDRB
\r
CDEFS += -DRESET_LINE_MASK="(1 << 4)"
\r
+CDEFS += -DVTARGET_ADC_CHANNEL=2
\r
\r
\r
# Place -D or -U options here for ASM sources
\r
\r
\r
# Place -D or -U options here for ASM sources
\r