Makefile
This commit is contained in:
		
							parent
							
								
									4bc1679242
								
							
						
					
					
						commit
						41c3a9feba
					
				
					 2 changed files with 50 additions and 1 deletions
				
			
		
							
								
								
									
										2
									
								
								config.h
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								config.h
									
										
									
									
									
								
							|  | @ -1,6 +1,6 @@ | ||||||
| #ifndef CONFIG_H | #ifndef CONFIG_H | ||||||
| #define CONFIG_H | #define CONFIG_H | ||||||
| 
 | 
 | ||||||
| #define F_CPU 1600000UL | //#define F_CPU 1600000UL
 | ||||||
| 
 | 
 | ||||||
| #endif // CONFIG_H
 | #endif // CONFIG_H
 | ||||||
|  |  | ||||||
							
								
								
									
										49
									
								
								makefile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								makefile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,49 @@ | ||||||
|  | # AVR-GCC compiler
 | ||||||
|  | CC = avr-gcc | ||||||
|  | 
 | ||||||
|  | # Programmer (change it according to your programmer)
 | ||||||
|  | PROGRAMMER = usbasp | ||||||
|  | 
 | ||||||
|  | # MCU
 | ||||||
|  | MCU = atmega328p | ||||||
|  | QEMU_MACHINE_NAME = uno | ||||||
|  | 
 | ||||||
|  | # Compiler flags
 | ||||||
|  | CFLAGS = -std=c2x -Wall -Wno-array-bounds -mmcu=$(MCU) -DF_CPU=16000000UL -O3 | ||||||
|  | 
 | ||||||
|  | # Source files
 | ||||||
|  | SRCS = $(wildcard *.c) | ||||||
|  | 
 | ||||||
|  | # Object files
 | ||||||
|  | OBJS = $(SRCS:.c=.o) | ||||||
|  | 
 | ||||||
|  | # Target file
 | ||||||
|  | TARGET = main | ||||||
|  | 
 | ||||||
|  | # Default target
 | ||||||
|  | all: $(TARGET).hex | ||||||
|  | 
 | ||||||
|  | # Compile C files
 | ||||||
|  | %.o: %.c | ||||||
|  | 	$(CC) $(CFLAGS) -c $< -o $@ | ||||||
|  | 
 | ||||||
|  | # Link object files
 | ||||||
|  | $(TARGET).elf: $(OBJS) | ||||||
|  | 	$(CC) $(CFLAGS) $(OBJS) -o $(TARGET).elf | ||||||
|  | 
 | ||||||
|  | # Convert ELF to HEX
 | ||||||
|  | $(TARGET).hex: $(TARGET).elf | ||||||
|  | 	avr-objcopy -O ihex -R .eeprom $(TARGET).elf $(TARGET).hex | ||||||
|  | 
 | ||||||
|  | # Flash the program
 | ||||||
|  | flash: $(TARGET).hex | ||||||
|  | 	avrdude -p $(MCU) -c $(PROGRAMMER) -U flash:w:$(TARGET).hex | ||||||
|  | 
 | ||||||
|  | # Run the program in QEMU
 | ||||||
|  | qemu: $(TARGET).elf | ||||||
|  | 	qemu-system-avr -machine $(QEMU_MACHINE_NAME) -bios $(TARGET).elf | ||||||
|  | 
 | ||||||
|  | # Clean
 | ||||||
|  | clean: | ||||||
|  | 	rm -f $(OBJS) $(TARGET).elf $(TARGET).hex | ||||||
|  | 
 | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus