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