/Modules/AVR/AVRUSB01A/SW/fw_usbasp/!____!.txt |
---|
File deleted |
/Modules/AVR/AVRUSB01A/SW/fw_usbasp/bin/usbasp_atmega88.hex |
---|
File deleted |
/Modules/AVR/AVRUSB01A/SW/fw_usbasp/bin/usbasp_atmega8.hex |
---|
File deleted |
/Modules/AVR/AVRUSB01A/SW/fw_usbasp/Makefile |
---|
2,38 → 2,16 |
# Makefile for usbasp |
# 20061119 Thomas Fischl original |
# 20061120 Hanns-Konrad Unger help: and TARGET=atmega48 added |
# 20140209 Milan Horkel added automatic built for more targets |
# |
ALL_TARGETS=atmega8 atmega88 |
# TARGET=atmega8 HFUSE=0xc9 LFUSE=0xef |
# TARGET=atmega48 HFUSE=0xdd LFUSE=0xff |
# TARGET=at90s2313 |
TARGET=atmega8 |
HFUSE=0xc9 |
LFUSE=0xef |
# Default target |
# -------------- |
ifndef $(TARGET) |
TARGET=atmega88 |
endif |
# Define target dependent constants |
# --------------------------------- |
ifeq ($(TARGET), atmega88) |
HFUSE=0xc9 |
LFUSE=0xef |
endif |
ifeq ($(TARGET), atmega8) |
HFUSE=0xc9 |
LFUSE=0xef |
endif |
ifeq ($(TARGET), atmega8) |
HFUSE=0xdd |
LFUSE=0xff |
endif |
# ISP=bsd PORT=/dev/parport0 |
# ISP=ponyser PORT=/dev/ttyS1 |
# ISP=stk500 PORT=/dev/ttyS1 |
45,12 → 23,11 |
help: |
@echo "Usage: make same as make help" |
@echo " make help same as make" |
@echo " make all build HEX for all target CPUs" |
@echo " make hex create HEX for default target CPU" |
@echo " make main.hex create main.hex" |
@echo " make clean remove redundant data" |
@echo " make disasm create listing" |
@echo " make flash upload HEX into flash (for default target CPU)" |
@echo " make fuses program fuses (for default target CPU)" |
@echo " make disasm disasm main" |
@echo " make flash upload main.hex into flash" |
@echo " make fuses program fuses" |
@echo " make avrdude test avrdude" |
@echo "Current values:" |
@echo " TARGET=${TARGET}" |
78,33 → 55,28 |
.c.s: |
$(COMPILE) -S $< -o $@ |
cleantmp: |
rm -f usbasp.lst usbasp.obj usbasp.cof usbasp.list usbasp.map usbasp.bin *.o main.s usbdrv/*.o |
clean: |
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o main.s usbdrv/*.o |
clean: cleantmp |
rm -f usbasp_$(TARGET).hex usbasp_$(TARGET).eep.hex |
# file targets: |
usbasp.bin: $(OBJECTS) |
$(COMPILE) -o usbasp.bin $(OBJECTS) -Wl,-Map,usbasp.map |
main.bin: $(OBJECTS) |
$(COMPILE) -o main.bin $(OBJECTS) -Wl,-Map,main.map |
usbasp.hex: usbasp_$(TARGET).hex |
usbasp_$(TARGET).hex: usbasp.bin |
rm -f usbasp_$(TARGET).hex usbasp_$(TARGET).eep.hex |
avr-objcopy -j .text -j .data -O ihex usbasp.bin $@ |
# ./checksize usbasp.bin |
main.hex: main.bin |
rm -f main.hex main.eep.hex |
avr-objcopy -j .text -j .data -O ihex main.bin main.hex |
# ./checksize main.bin |
# do the checksize script as our last action to allow successful compilation |
# on Windows with WinAVR where the Unix commands will fail. |
disasm: usbasp.bin |
avr-objdump -d usbasp.bin |
disasm: main.bin |
avr-objdump -d main.bin |
cpp: |
$(COMPILE) -E main.c |
flash: |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -U flash:w:usbasp.hex |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -U flash:w:main.hex |
fuses: |
avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -u -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m |
159,17 → 131,5 |
uisp: all |
$(UISP) --erase |
$(UISP) --upload --verify if=usbasp_$(TARGET).hex |
$(UISP) --upload --verify if=main.hex |
# Execute these steps for each target CPU |
# Do not remove empty line in this definition! |
define EXEC |
rm -f usbasp_$(1).hex |
make TARGET=$(1) cleantmp |
make TARGET=$(1) usbasp_$(1).hex |
endef |
ALL: |
@$(foreach III,$(ALL_TARGETS),$(call EXEC,$(III))) |
@make cleantmp |
/Modules/AVR/AVRUSB01A/SW/fw_usbasp/main.c |
---|
11,9 → 11,6 |
* PC2 SCK speed option. |
* GND -> slow (8khz SCK), |
* open -> software set speed (default is 375kHz SCK) |
* |
* 2014_02_09 miho@mlab.cz - cleaned code and defined IO port better, automatic compile prodcess for more target CPUs |
* |
*/ |
#include <avr/io.h> |
47,7 → 44,7 |
if (data[1] == USBASP_FUNC_CONNECT) { |
/* set SCK speed */ |
if ((PIN(CLKSW_PORT) & (1 << CLKSW_BIT)) == 0) { |
if ((PINC & (1 << PC2)) == 0) { |
ispSetSCKOption(USBASP_ISP_SCK_8); |
} else { |
ispSetSCKOption(prog_sck); |
306,24 → 303,16 |
int main(void) { |
uchar i, j; |
/* unused pins with pullups */ |
PORTB = PORTB_UNUSED_MASK; |
PORTC = PORTC_UNUSED_MASK; |
PORTD = PORTD_UNUSED_MASK; |
/* no pullups on USB and ISP pins */ |
PORTD = 0; |
PORTB = 0; |
/* all outputs except PD2 = INT0 */ |
DDRD = ~(1 << 2); |
/* LED ports as output */ |
ledInit(); |
ledGreenOn(); |
ledRedOff(); |
/* CLKSW input with PullUp (external jumper to GND) */ |
clkswInit(); |
/* output SE0 for USB reset */ |
DDR(USB_CFG_IOPORTNAME) |= (1 << USB_CFG_DPLUS_BIT | 1<<USB_CFG_DMINUS_BIT); |
DDRB = ~0; |
j = 0; |
/* USB Reset by device only required on Watchdog Reset */ |
j = 0; |
while (--j) { |
i = 0; |
/* delay >10ms for USB reset */ |
330,10 → 319,13 |
while (--i) |
; |
} |
/* all USB and ISP pins inputs */ |
DDR(USB_CFG_IOPORTNAME) &= ~(1 << USB_CFG_DPLUS_BIT | 1<<USB_CFG_DMINUS_BIT); |
DDRB = 0; |
/* all inputs except PC0, PC1 */ |
DDRC = 0x03; |
PORTC = 0xfe; |
/* init timer */ |
clockInit(); |
345,3 → 337,4 |
} |
return 0; |
} |
/Modules/AVR/AVRUSB01A/SW/fw_usbasp/usbasp.h |
---|
11,17 → 11,6 |
#ifndef USBASP_H_ |
#define USBASP_H_ |
/* PORTS Definitions */ |
#define LED_RED_PORT C |
#define LED_RED_BIT 0 |
#define LED_GREEN_PORT C |
#define LED_GREEN_BIT 1 |
#define CLKSW_PORT D |
#define CLKSW_BIT 0 |
#define PORTB_UNUSED_MASK (1<<PB1 | 1<<PB0) |
#define PORTC_UNUSED_MASK (1<<PC5 | 1<<PC4 | 1<<PC3 | 1<<PC2) |
#define PORTD_UNUSED_MASK (1<<PD7 | 1<<PD6 | 1<<PD5 | 1<<PD3 | 1<<PD1) |
/* USB function call identifiers */ |
#define USBASP_FUNC_CONNECT 1 |
#define USBASP_FUNC_DISCONNECT 2 |
72,20 → 61,10 |
#define USBASP_ISP_SCK_750 11 /* 750 kHz */ |
#define USBASP_ISP_SCK_1500 12 /* 1.5 MHz */ |
/* Macros for Port (enables to easily define IO signals) */ |
#define GLUE(A,B) A##B |
#define DDR(PORT_LETTER) GLUE(DDR, PORT_LETTER) // Makes DDRC from DDR(C) etc. |
#define PORT(PORT_LETTER) GLUE(PORT,PORT_LETTER) // Makes PORTC from PORT(C) |
#define PIN(PORT_LETTER) GLUE(PIN, PORT_LETTER) // Makes PINC from PIN(C) |
/* macros for gpio functions */ |
#define ledRedOn() PORT(LED_RED_PORT) &= ~(1 << LED_RED_BIT) // Active L |
#define ledRedOff() PORT(LED_RED_PORT) |= (1 << LED_RED_BIT) |
#define ledGreenOn() PORT(LED_GREEN_PORT) &= ~(1 << LED_GREEN_BIT) // Active L |
#define ledGreenOff() PORT(LED_GREEN_PORT) |= (1 << LED_GREEN_BIT) |
#define ledInit() DDR(LED_RED_PORT) |= (1 << LED_RED_BIT),\ |
DDR(LED_GREEN_PORT) |= (1 << LED_GREEN_BIT) // Outputs |
#define clkswInit() DDR(CLKSW_PORT) &= ~(1 << CLKSW_BIT),\ |
PORT(CLKSW_PORT) |= (1 << CLKSW_BIT) // Input with PullUp |
#define ledRedOn() PORTC &= ~(1 << PC1) |
#define ledRedOff() PORTC |= (1 << PC1) |
#define ledGreenOn() PORTC &= ~(1 << PC0) |
#define ledGreenOff() PORTC |= (1 << PC0) |
#endif /* USBASP_H_ */ |
/Modules/AVR/AVRUSB01A/SW/fw_usbasp/usbconfig.h |
---|
22,19 → 22,15 |
/* ---------------------------- Hardware Config ---------------------------- */ |
#define USB_COUNT_SOF 0 |
/* Define this to 1 if interrupt is conected to D- signal |
*/ |
#define USB_CFG_IOPORTNAME D |
#define USB_CFG_IOPORTNAME B |
/* This is the port where the USB bus is connected. When you configure it to |
* "B", the registers PORTB, PINB and DDRB will be used. |
*/ |
#define USB_CFG_DMINUS_BIT 4 |
#define USB_CFG_DMINUS_BIT 0 |
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. |
* This may be any bit in the port. |
*/ |
#define USB_CFG_DPLUS_BIT 2 |
#define USB_CFG_DPLUS_BIT 1 |
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. |
* This may be any bit in the port. Please note that D+ must also be connected |
* to interrupt pin INT0! |