diff --git a/final_project/312_final.code-workspace b/final_project/312_final.code-workspace new file mode 100644 index 0000000..72f846f --- /dev/null +++ b/final_project/312_final.code-workspace @@ -0,0 +1,15 @@ +{ + "folders": [ + { + "path": "sd_reader" + }, + { + "path": "lcd_disp" + } + ], + "settings": { + "files.associations": { + "io.h": "c" + } + } +} \ No newline at end of file diff --git a/final_project/comms/comms.c b/final_project/comms/comms.c new file mode 100644 index 0000000..2a66e56 --- /dev/null +++ b/final_project/comms/comms.c @@ -0,0 +1,35 @@ +#include "comms.h" + +inline void comms_send_command(comms_cmd_t cmd) { + while (! (UCSRA & (1 << UDRE))); + UDR = cmd; +} + +inline void comms_add_file(uint8_t id, char* filename) { + uint8_t len = strlen(filename); + + comms_send_command(COMMS_CMD_ADD_FILE); + comms_send_command((comms_cmd_t) id); + + uint8_t i = 0; + while (i < len) { + comms_send_command((comms_cmd_t) filename[i]); + } +} + +inline void comms_select_file(uint8_t id) { + comms_send_command(COMMS_CMD_SELECT_FILE); + comms_send_command((comms_cmd_t) id); +} + +inline void comms_clear() { + comms_send_command(COMMS_CMD_CLR); +} + +inline void comms_play() { + comms_send_command(COMMS_CMD_PLAY); +} + +inline void comms_pause() { + comms_send_command(COMMS_CMD_PLAY); +} \ No newline at end of file diff --git a/final_project/comms/comms.h b/final_project/comms/comms.h new file mode 100644 index 0000000..ad660f5 --- /dev/null +++ b/final_project/comms/comms.h @@ -0,0 +1,46 @@ +#ifndef COMMS_H_ +#define COMMS_H_ + +#include +#include + +/** + * Our format goes like this: + * + * 1 byte command, with data after + */ + + +typedef enum { + COMMS_CMD_CLR = 0U, //! Clears LCD and all file names + COMMS_CMD_ADD_FILE, //! Adds a file to the list of files to display, data is 1 byte for ID, 1 byte for strlen, n bytes for string + COMMS_CMD_SELECT_FILE, //! selects a file from the given list to play, data is 1 byte for id + COMMS_CMD_PLAY, //! Starts playing file + COMMS_CMD_PAUSE //! pauses playing file +} comms_cmd_t; + +/** @brief Inline function to send commands and values. + */ +inline void comms_send_command(comms_cmd_t cmd); + +/** @brief Adds a file to the list on the LCD side. + */ +inline void comms_add_file(uint8_t id, char* filename); + +/** @brief Selects a file from the list on the DAC side. + */ +inline void comms_select_file(uint8_t id); + +/** @brief Clears the LCD list of files. + */ +inline void comms_clear(); + +/** @brief Starts playing song. + */ +inline void comms_play(); + +/** @brief Pauses playing song. + */ +inline void comms_pause(); + +#endif \ No newline at end of file diff --git a/final_project/lcd_disp/.vscode/c_cpp_properties.json b/final_project/lcd_disp/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..6fafcf7 --- /dev/null +++ b/final_project/lcd_disp/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "Linux", + "intelliSenseMode": "gcc-x64", + "compilerPath": "/usr/lib/ccache/avr-gcc", + "cStandard": "c99", + "cppStandard": "c++17", + "compilerArgs": [ + "-Wall", "-pedantic", "-mmcu=attiy2313a" + ], + "defines": [ + "F_CPU=16000000" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/final_project/lcd_disp/.vscode/tasks.json b/final_project/lcd_disp/.vscode/tasks.json new file mode 100644 index 0000000..794c3b1 --- /dev/null +++ b/final_project/lcd_disp/.vscode/tasks.json @@ -0,0 +1,19 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "make", + "type": "shell", + "command": "make", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$gcc" + ] + } + ] +} \ No newline at end of file diff --git a/final_project/lcd_disp/Makefile b/final_project/lcd_disp/Makefile new file mode 100644 index 0000000..ace6c7b --- /dev/null +++ b/final_project/lcd_disp/Makefile @@ -0,0 +1,52 @@ + +NAME := sd-reader +HEX := $(NAME).hex +OUT := $(NAME).out +MAP := $(NAME).map +SOURCES := $(wildcard *.c) +HEADERS := $(wildcard *.h) +OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) + +MCU := attiny2313a +MCU_AVRDUDE := t2313 +MCU_FREQ := 8000000UL + +CC := avr-gcc +OBJCOPY := avr-objcopy +SIZE := avr-size -A +DOXYGEN := doxygen + +CFLAGS := -Wall -pedantic -mmcu=$(MCU) -std=c99 -g -Os -DF_CPU=$(MCU_FREQ) + +all: $(HEX) + +clean: + rm -f $(HEX) $(OUT) $(MAP) $(OBJECTS) + rm -rf doc/html + +flash: $(HEX) + avrdude -y -c avr910 -p $(MCU_AVRDUDE) -U flash:w:$(HEX) + +$(HEX): $(OUT) + $(OBJCOPY) -R .eeprom -O ihex $< $@ + +$(OUT): $(OBJECTS) + $(CC) $(CFLAGS) -o $@ -Wl,-Map,$(MAP) $^ + @echo + @$(SIZE) $@ + @echo + +%.o: %.c $(HEADERS) + $(CC) $(CFLAGS) -c -o $@ $< + +%.pp: %.c + $(CC) $(CFLAGS) -E -o $@ $< + +%.ppo: %.c + $(CC) $(CFLAGS) -E $< + +doc: $(HEADERS) $(SOURCES) Doxyfile + $(DOXYGEN) Doxyfile + +.PHONY: all clean flash doc + diff --git a/final_project/lcd_disp/comms.c b/final_project/lcd_disp/comms.c new file mode 120000 index 0000000..14d83ba --- /dev/null +++ b/final_project/lcd_disp/comms.c @@ -0,0 +1 @@ +../comms/comms.c \ No newline at end of file diff --git a/final_project/lcd_disp/comms.h b/final_project/lcd_disp/comms.h new file mode 120000 index 0000000..ad5c9e6 --- /dev/null +++ b/final_project/lcd_disp/comms.h @@ -0,0 +1 @@ +../comms/comms.h \ No newline at end of file diff --git a/final_project/sd_reader/lcd.c b/final_project/lcd_disp/lcd.c similarity index 100% rename from final_project/sd_reader/lcd.c rename to final_project/lcd_disp/lcd.c diff --git a/final_project/sd_reader/lcd.h b/final_project/lcd_disp/lcd.h similarity index 97% rename from final_project/sd_reader/lcd.h rename to final_project/lcd_disp/lcd.h index 8568357..0dbc197 100644 --- a/final_project/sd_reader/lcd.h +++ b/final_project/lcd_disp/lcd.h @@ -128,7 +128,7 @@ #if LCD_IO_MODE #ifndef LCD_PORT -#define LCD_PORT PORTC /**< port for the LCD lines */ +#define LCD_PORT PORTB /**< port for the LCD lines */ #endif #ifndef LCD_DATA0_PORT #define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */ diff --git a/final_project/lcd_disp/main.c b/final_project/lcd_disp/main.c new file mode 100644 index 0000000..c478520 --- /dev/null +++ b/final_project/lcd_disp/main.c @@ -0,0 +1,31 @@ +#include +#include "lcd.h" + +#define USART_BAUDRATE 9600 //! USART baudrate, change this to set it. +#define UBRR_VALUE (((F_CPU/(USART_BAUDRATE*16UL)))-1) + +/** @brief Sets up USART for TX and RX with a baud rate of USART_BAUDRATE + */ +void usart_init() { + // initialize USART + UBRRL = UBRR_VALUE & 255; + UBRRH = UBRR_VALUE >> 8; + UCSRB = (1 << TXEN) | (1 << RXEN); // fire-up USART + UCSRC = (1 << UCSZ1) | (1 << UCSZ0); // fire-up USART + + + UCSRB |= (1 << RXCIE); +} + +int main() { + usart_init(); + + lcd_clrscr(); + lcd_gotoxy(0,0); + + // Main loop + while (1) { + + } + +} \ No newline at end of file diff --git a/final_project/lcd_disp/sd-reader.map b/final_project/lcd_disp/sd-reader.map new file mode 100644 index 0000000..8fab970 --- /dev/null +++ b/final_project/lcd_disp/sd-reader.map @@ -0,0 +1,421 @@ +Archive member included to satisfy reference by file (symbol) + +/usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o (exit) + +Memory Configuration + +Name Origin Length Attributes +text 0x0000000000000000 0x0000000000002000 xr +data 0x0000000000800060 0x000000000000ffa0 rw !x +eeprom 0x0000000000810000 0x0000000000010000 rw !x +fuse 0x0000000000820000 0x0000000000000003 rw !x +lock 0x0000000000830000 0x0000000000000400 rw !x +signature 0x0000000000840000 0x0000000000000400 rw !x +user_signatures 0x0000000000850000 0x0000000000000400 rw !x +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +LOAD /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o +LOAD lcd.o +LOAD comms.o +LOAD main.o +START GROUP +LOAD /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a +LOAD /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/libm.a +LOAD /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/libc.a +LOAD /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/libattiny2313a.a +END GROUP + 0x0000000000002000 __TEXT_REGION_LENGTH__ = DEFINED (__TEXT_REGION_LENGTH__)?__TEXT_REGION_LENGTH__:0x2000 + 0x000000000000ffa0 __DATA_REGION_LENGTH__ = DEFINED (__DATA_REGION_LENGTH__)?__DATA_REGION_LENGTH__:0xffa0 + 0x0000000000010000 __EEPROM_REGION_LENGTH__ = DEFINED (__EEPROM_REGION_LENGTH__)?__EEPROM_REGION_LENGTH__:0x10000 + [0x0000000000000003] __FUSE_REGION_LENGTH__ = DEFINED (__FUSE_REGION_LENGTH__)?__FUSE_REGION_LENGTH__:0x400 + 0x0000000000000400 __LOCK_REGION_LENGTH__ = DEFINED (__LOCK_REGION_LENGTH__)?__LOCK_REGION_LENGTH__:0x400 + 0x0000000000000400 __SIGNATURE_REGION_LENGTH__ = DEFINED (__SIGNATURE_REGION_LENGTH__)?__SIGNATURE_REGION_LENGTH__:0x400 + 0x0000000000000400 __USER_SIGNATURE_REGION_LENGTH__ = DEFINED (__USER_SIGNATURE_REGION_LENGTH__)?__USER_SIGNATURE_REGION_LENGTH__:0x400 + +.hash + *(.hash) + +.dynsym + *(.dynsym) + +.dynstr + *(.dynstr) + +.gnu.version + *(.gnu.version) + +.gnu.version_d + *(.gnu.version_d) + +.gnu.version_r + *(.gnu.version_r) + +.rel.init + *(.rel.init) + +.rela.init + *(.rela.init) + +.rel.text + *(.rel.text) + *(.rel.text.*) + *(.rel.gnu.linkonce.t*) + +.rela.text + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t*) + +.rel.fini + *(.rel.fini) + +.rela.fini + *(.rela.fini) + +.rel.rodata + *(.rel.rodata) + *(.rel.rodata.*) + *(.rel.gnu.linkonce.r*) + +.rela.rodata + *(.rela.rodata) + *(.rela.rodata.*) + *(.rela.gnu.linkonce.r*) + +.rel.data + *(.rel.data) + *(.rel.data.*) + *(.rel.gnu.linkonce.d*) + +.rela.data + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d*) + +.rel.ctors + *(.rel.ctors) + +.rela.ctors + *(.rela.ctors) + +.rel.dtors + *(.rel.dtors) + +.rela.dtors + *(.rela.dtors) + +.rel.got + *(.rel.got) + +.rela.got + *(.rela.got) + +.rel.bss + *(.rel.bss) + +.rela.bss + *(.rela.bss) + +.rel.plt + *(.rel.plt) + +.rela.plt + *(.rela.plt) + +.text 0x0000000000000000 0x1fa + *(.vectors) + .vectors 0x0000000000000000 0x2a /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + 0x0000000000000000 __vectors + 0x0000000000000000 __vector_default + *(.vectors) + *(.progmem.gcc*) + 0x000000000000002a . = ALIGN (0x2) + 0x000000000000002a __trampolines_start = . + *(.trampolines) + .trampolines 0x000000000000002a 0x0 linker stubs + *(.trampolines*) + 0x000000000000002a __trampolines_end = . + *libprintf_flt.a:*(.progmem.data) + *libc.a:*(.progmem.data) + *(.progmem*) + 0x000000000000002a . = ALIGN (0x2) + *(.jumptables) + *(.jumptables*) + *(.lowtext) + *(.lowtext*) + 0x000000000000002a __ctors_start = . + *(.ctors) + 0x000000000000002a __ctors_end = . + 0x000000000000002a __dtors_start = . + *(.dtors) + 0x000000000000002a __dtors_end = . + SORT(*)(.ctors) + SORT(*)(.dtors) + *(.init0) + .init0 0x000000000000002a 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + 0x000000000000002a __init + *(.init0) + *(.init1) + *(.init1) + *(.init2) + .init2 0x000000000000002a 0x8 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + *(.init2) + *(.init3) + *(.init3) + *(.init4) + *(.init4) + *(.init5) + *(.init5) + *(.init6) + *(.init6) + *(.init7) + *(.init7) + *(.init8) + *(.init8) + *(.init9) + .init9 0x0000000000000032 0x4 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + *(.init9) + *(.text) + .text 0x0000000000000036 0x2 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + 0x0000000000000036 __vector_1 + 0x0000000000000036 __vector_12 + 0x0000000000000036 __bad_interrupt + 0x0000000000000036 __vector_6 + 0x0000000000000036 __vector_3 + 0x0000000000000036 __vector_11 + 0x0000000000000036 __vector_13 + 0x0000000000000036 __vector_17 + 0x0000000000000036 __vector_19 + 0x0000000000000036 __vector_7 + 0x0000000000000036 __vector_5 + 0x0000000000000036 __vector_4 + 0x0000000000000036 __vector_9 + 0x0000000000000036 __vector_2 + 0x0000000000000036 __vector_15 + 0x0000000000000036 __vector_8 + 0x0000000000000036 __vector_14 + 0x0000000000000036 __vector_10 + 0x0000000000000036 __vector_16 + 0x0000000000000036 __vector_18 + 0x0000000000000036 __vector_20 + .text 0x0000000000000038 0x1b8 lcd.o + 0x0000000000000102 lcd_command + 0x0000000000000110 lcd_data + 0x000000000000011e lcd_gotoxy + 0x000000000000012a lcd_getxy + 0x0000000000000130 lcd_clrscr + 0x0000000000000134 lcd_home + 0x0000000000000138 lcd_putc + 0x000000000000015a lcd_puts + 0x0000000000000170 lcd_puts_p + 0x000000000000018c lcd_init + .text 0x00000000000001f0 0x0 comms.o + .text 0x00000000000001f0 0x0 main.o + .text 0x00000000000001f0 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + 0x00000000000001f0 . = ALIGN (0x2) + *(.text.*) + .text.startup 0x00000000000001f0 0x6 main.o + 0x00000000000001f0 main + .text.libgcc.mul + 0x00000000000001f6 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + .text.libgcc.div + 0x00000000000001f6 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + .text.libgcc 0x00000000000001f6 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + .text.libgcc.prologue + 0x00000000000001f6 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + .text.libgcc.builtins + 0x00000000000001f6 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + .text.libgcc.fmul + 0x00000000000001f6 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + .text.libgcc.fixed + 0x00000000000001f6 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + 0x00000000000001f6 . = ALIGN (0x2) + *(.fini9) + .fini9 0x00000000000001f6 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + 0x00000000000001f6 exit + 0x00000000000001f6 _exit + *(.fini9) + *(.fini8) + *(.fini8) + *(.fini7) + *(.fini7) + *(.fini6) + *(.fini6) + *(.fini5) + *(.fini5) + *(.fini4) + *(.fini4) + *(.fini3) + *(.fini3) + *(.fini2) + *(.fini2) + *(.fini1) + *(.fini1) + *(.fini0) + .fini0 0x00000000000001f6 0x4 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + *(.fini0) + 0x00000000000001fa _etext = . + +.data 0x0000000000800060 0x0 load address 0x00000000000001fa + [!provide] PROVIDE (__data_start, .) + *(.data) + .data 0x0000000000800060 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + .data 0x0000000000800060 0x0 lcd.o + .data 0x0000000000800060 0x0 comms.o + .data 0x0000000000800060 0x0 main.o + .data 0x0000000000800060 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + *(.data*) + *(.rodata) + *(.rodata*) + *(.gnu.linkonce.d*) + 0x0000000000800060 . = ALIGN (0x2) + 0x0000000000800060 _edata = . + [!provide] PROVIDE (__data_end, .) + +.bss 0x0000000000800060 0x0 + [!provide] PROVIDE (__bss_start, .) + *(.bss) + .bss 0x0000000000800060 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + .bss 0x0000000000800060 0x0 lcd.o + .bss 0x0000000000800060 0x0 comms.o + .bss 0x0000000000800060 0x0 main.o + .bss 0x0000000000800060 0x0 /usr/lib/gcc/avr/5.4.0/avr25/tiny-stack/libgcc.a(_exit.o) + *(.bss*) + *(COMMON) + [!provide] PROVIDE (__bss_end, .) + 0x00000000000001fa __data_load_start = LOADADDR (.data) + 0x00000000000001fa __data_load_end = (__data_load_start + SIZEOF (.data)) + +.noinit 0x0000000000800060 0x0 + [!provide] PROVIDE (__noinit_start, .) + *(.noinit*) + [!provide] PROVIDE (__noinit_end, .) + 0x0000000000800060 _end = . + [!provide] PROVIDE (__heap_start, .) + +.eeprom 0x0000000000810000 0x0 + *(.eeprom*) + 0x0000000000810000 __eeprom_end = . + +.fuse + *(.fuse) + *(.lfuse) + *(.hfuse) + *(.efuse) + +.lock + *(.lock*) + +.signature + *(.signature*) + +.user_signatures + *(.user_signatures*) + +.stab 0x0000000000000000 0x1638 + *(.stab) + .stab 0x0000000000000000 0x1008 lcd.o + .stab 0x0000000000001008 0x30c comms.o + 0x4e0 (size before relaxing) + .stab 0x0000000000001314 0x324 main.o + 0x510 (size before relaxing) + +.stabstr 0x0000000000000000 0xf6f + *(.stabstr) + .stabstr 0x0000000000000000 0xf6f lcd.o + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x11 + *(.comment) + .comment 0x0000000000000000 0x11 lcd.o + 0x12 (size before relaxing) + .comment 0x0000000000000011 0x12 comms.o + .comment 0x0000000000000011 0x12 main.o + +.note.gnu.avr.deviceinfo + 0x0000000000000000 0x40 + .note.gnu.avr.deviceinfo + 0x0000000000000000 0x40 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + +.note.gnu.build-id + *(.note.gnu.build-id) + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges + *(.debug_aranges) + +.debug_pubnames + *(.debug_pubnames) + +.debug_info 0x0000000000000000 0x456 + *(.debug_info .gnu.linkonce.wi.*) + .debug_info 0x0000000000000000 0x456 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + +.debug_abbrev 0x0000000000000000 0x41b + *(.debug_abbrev) + .debug_abbrev 0x0000000000000000 0x41b /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + +.debug_line 0x0000000000000000 0x1a + *(.debug_line .debug_line.* .debug_line_end) + .debug_line 0x0000000000000000 0x1a /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + +.debug_frame + *(.debug_frame) + +.debug_str 0x0000000000000000 0x17b + *(.debug_str) + .debug_str 0x0000000000000000 0x17b /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr25/tiny-stack/crtattiny2313a.o + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +.debug_pubtypes + *(.debug_pubtypes) + +.debug_ranges + *(.debug_ranges) + +.debug_macro + *(.debug_macro) +OUTPUT(sd-reader.out elf32-avr) +LOAD linker stubs diff --git a/final_project/lcd_disp/sd-reader.out b/final_project/lcd_disp/sd-reader.out new file mode 100755 index 0000000..f2b6798 Binary files /dev/null and b/final_project/lcd_disp/sd-reader.out differ diff --git a/final_project/sd_reader/.vscode/c_cpp_properties.json b/final_project/sd_reader/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..d9993e3 --- /dev/null +++ b/final_project/sd_reader/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "Linux", + "intelliSenseMode": "gcc-x64", + "compilerPath": "/usr/lib/ccache/avr-gcc", + "cStandard": "c99", + "cppStandard": "c++17", + "compilerArgs": [ + "-Wall", "-pedantic", "-mmcu=atmega328" + ], + "defines": [ + "F_CPU=16000000" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/final_project/sd_reader/Makefile b/final_project/sd_reader/Makefile index 768bb62..80e40a1 100644 --- a/final_project/sd_reader/Makefile +++ b/final_project/sd_reader/Makefile @@ -7,8 +7,8 @@ SOURCES := $(wildcard *.c) HEADERS := $(wildcard *.h) OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) -MCU := atmega168 -MCU_AVRDUDE := m168 +MCU := atmega328 +MCU_AVRDUDE := m328 MCU_FREQ := 16000000UL CC := avr-gcc diff --git a/final_project/sd_reader/main.c b/final_project/sd_reader/main.c index 8565352..2eb64c7 100644 --- a/final_project/sd_reader/main.c +++ b/final_project/sd_reader/main.c @@ -15,7 +15,6 @@ #include "partition.h" #include "sd_raw.h" #include "sd_raw_config.h" -#include "lcd.h" #define DEBUG 1 @@ -212,7 +211,7 @@ int main() lcd_init(LCD_DISP_ON); /* we will just use ordinary idle mode */ - set_sleep_mode(SLEEP_MODE_IDLE); + //set_sleep_mode(SLEEP_MODE_IDLE); /* open first partition */ struct partition_struct* partition = partition_open(sd_raw_read, diff --git a/final_project/sd_reader/wav.h b/final_project/sd_reader/wav.h new file mode 100644 index 0000000..1d7bbf9 --- /dev/null +++ b/final_project/sd_reader/wav.h @@ -0,0 +1,43 @@ +#include +#include +#include + +/** @brief Struct to contain chunk header information + */ +typedef struct { + uint32_t ckID; //! Chunk type + uint32_t cksize; //! Size of chunk in bytes +} ck_hdr_t; + +/** @brief Struct to contain master WAV chunk info + */ +struct { + char WAVEID[4]; //! WAVE ID +} ck_master_t; + +/** @brief Types of extension that a fmt type chunk can have + */ +typedef enum { + CK_FMT_STD = 0U, + CK_FMT_NOEXT, + CK_FMT_EXT, +} ck_fmt_ext_t; + +/** @brief Struct to hold fmt chunk data + */ +struct { + struct data { + uint16_t wFormatTag; //! Type of data format. + uint16_t nChannels; //! Number of channels + uint32_t nSamplesPerSec; //! Sample rate + uint32_t nAvgBytesPerSec; //! Data rate + uint16_t nBlockAlign; //! Block size in bytes for data + uint16_t wBitsPerSample; //! Bits per sample + uint16_t cbSize; //! Size of fmt type extension. Only valid if chunk size is 18 or 40. + uint16_t wValidBitsPerSample; //! Number of valid bits per sample. Only valid if chunk size is 40 + uint32_t dwChannelMask; //! Speaker position mask. Only valid if chunk size is 40 + uint8_t[16] SubFormat; //! GUID for data format. Only vaid if chunk size is 40 + }; + + ck_fmt_ext_t type; +} ck_fmt_t; diff --git a/lab_3.zip b/lab_3.zip new file mode 100644 index 0000000..004aa41 Binary files /dev/null and b/lab_3.zip differ diff --git a/lab_3/i2cmaster/i2cmaster.zip b/lab_3/i2cmaster/i2cmaster.zip deleted file mode 100644 index b51c7dd..0000000 Binary files a/lab_3/i2cmaster/i2cmaster.zip and /dev/null differ