Restructure files
This commit is contained in:
parent
8c7b62dc2d
commit
b5f86d5972
|
|
@ -1,4 +1,12 @@
|
|||
# C code: object files etc.
|
||||
# IDE / editor files
|
||||
.idea/
|
||||
.vscode/
|
||||
.*.swp
|
||||
|
||||
# General
|
||||
/tmp
|
||||
|
||||
# C code
|
||||
*.o
|
||||
*.obj
|
||||
*.elf
|
||||
|
|
@ -6,5 +14,10 @@
|
|||
*.gch
|
||||
*.pch
|
||||
|
||||
# vim swap files
|
||||
.*.swp
|
||||
# Python
|
||||
__pycache__
|
||||
*.py[cod]
|
||||
/venv
|
||||
|
||||
# Firmware
|
||||
/firmware/build
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ OBJCOPY = avr-objcopy
|
|||
|
||||
# Compiler and linker flags
|
||||
CFLAGS = -Wall -std=c11 -Os
|
||||
LDFLAGS =
|
||||
LDFLAGS =
|
||||
|
||||
# Target platform and programmer
|
||||
GCC_MCU = atmega16a
|
||||
|
|
@ -16,9 +16,9 @@ AVRDUDE_PARTNO = m16
|
|||
AVRDUDE_PROGRAMMER = usbtiny
|
||||
|
||||
# Make target and object files
|
||||
TARGET = eepprog
|
||||
OBJECTS = main.o uart.o eeprom.o protocol.o
|
||||
HEADERS = config.h BitIO.h uart.h eeprom.h protocol.h
|
||||
TARGET = build/eepprog
|
||||
OBJECTS = build/main.o build/uart.o build/eeprom.o build/protocol.o
|
||||
HEADERS = src/config.h src/BitIO.h src/uart.h src/eeprom.h src/protocol.h
|
||||
|
||||
# Default target (build hex file)
|
||||
all: hex
|
||||
|
|
@ -41,7 +41,8 @@ $(TARGET).elf: $(OBJECTS)
|
|||
$(CC) -mmcu=$(GCC_MCU) $(LDFLAGS) -o $(TARGET).elf $(OBJECTS)
|
||||
|
||||
# Object files
|
||||
%.o: %.c $(HEADERS)
|
||||
build/%.o: src/%.c $(HEADERS)
|
||||
@mkdir -p build/
|
||||
$(CC) -mmcu=$(GCC_MCU) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
|
||||
|
|
@ -41,4 +41,3 @@ static inline void BIT_BOOL_SET(volatile uint8_t *target, uint8_t bit, bool enab
|
|||
};
|
||||
|
||||
#endif /* BITIO_H_ */
|
||||
|
||||
|
|
@ -114,4 +114,3 @@ void eepromWriteByte(address_t address, uint8_t data) {
|
|||
// Write pulse width high (50ns)
|
||||
_NOP();
|
||||
}
|
||||
|
||||
|
|
@ -15,10 +15,9 @@ int main(void) {
|
|||
|
||||
// Write initial message via UART
|
||||
uartPutString("INFO -- EEPROM programmer by binaryDiv\r\n");
|
||||
|
||||
|
||||
while(1) {
|
||||
// Run main loop endlessly
|
||||
protocolMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,4 +139,3 @@ void protocolMainLoop() {
|
|||
parseNextCommand();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,10 +20,10 @@ void uartInit() {
|
|||
// U2X mode not necessary
|
||||
UCSRA &= ~(1 << U2X);
|
||||
#endif
|
||||
|
||||
|
||||
// Enable transmitter and receiver
|
||||
UCSRB |= (1 << TXEN) | (1 << RXEN);
|
||||
|
||||
|
||||
// Set frame format (8 bit)
|
||||
UCSRC = (1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0);
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ void uartPutChar(unsigned char data) {
|
|||
// Block until controller is ready to send
|
||||
while (!(UCSRA & (1 << UDRE))) {
|
||||
}
|
||||
|
||||
|
||||
// Write character to UART data register
|
||||
UDR = data;
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ unsigned char uartGetChar() {
|
|||
// Block until a character has been received
|
||||
while (!(UCSRA & (1 << RXC))) {
|
||||
}
|
||||
|
||||
|
||||
// Get character and return
|
||||
return UDR;
|
||||
}
|
||||
|
|
@ -80,15 +80,14 @@ uint8_t uartGetLine(char* buffer, uint8_t maxLength) {
|
|||
|
||||
// Write character to buffer
|
||||
*buffer++ = nextChar;
|
||||
|
||||
|
||||
// Increment counter
|
||||
readChars++;
|
||||
}
|
||||
|
||||
|
||||
// Write a terminating '\0' byte
|
||||
*buffer++ = '\0';
|
||||
|
||||
// Return number of read bytes (excluding the \0)
|
||||
return readChars;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue