diff --git a/build/final.elf b/build/final.elf index 0e569e0..64ba45f 100755 Binary files a/build/final.elf and b/build/final.elf differ diff --git a/build/final.elf.map b/build/final.elf.map index b6272e6..ba03548 100644 --- a/build/final.elf.map +++ b/build/final.elf.map @@ -116,8 +116,6 @@ Discarded input sections .text 0x00000000 0x0 build/usart.o .data 0x00000000 0x0 build/usart.o .bss 0x00000000 0x0 build/usart.o - .text.usart2_start - 0x00000000 0x20 build/usart.o .debug_macro 0x00000000 0x22 build/usart.o .debug_macro 0x00000000 0x75 build/usart.o .debug_macro 0x00000000 0x2a build/usart.o @@ -132,7 +130,7 @@ Discarded input sections .debug_macro 0x00000000 0x4cc build/usart.o .debug_macro 0x00000000 0x13e build/usart.o .debug_macro 0x00000000 0x22 build/usart.o - .debug_macro 0x00000000 0x5e build/usart.o + .debug_macro 0x00000000 0x76 build/usart.o Memory Configuration @@ -159,7 +157,7 @@ LOAD build/usart.o 0x08000000 interrupt_vector_table 0x08000198 . = ALIGN (0x4) -.text 0x08000198 0x458 +.text 0x08000198 0x4b0 0x08000198 . = ALIGN (0x4) *(.text) *(.text.*) @@ -172,116 +170,122 @@ LOAD build/usart.o *fill* 0x08000246 0x2 .text.system_clock_init 0x08000248 0x144 build/main.o - .text.main 0x0800038c 0x90 build/main.o + .text.main 0x0800038c 0x98 build/main.o 0x0800038c main .text.init_memory - 0x0800041c 0x64 build/startup.o - 0x0800041c init_memory - .text.reset 0x08000480 0x10 build/startup.o - 0x08000480 reset + 0x08000424 0x64 build/startup.o + 0x08000424 init_memory + .text.reset 0x08000488 0x10 build/startup.o + 0x08000488 reset .text.default_handler - 0x08000490 0x8 build/startup.o - 0x08000490 exti0 - 0x08000490 debug_monitor - 0x08000490 rcc - 0x08000490 x - 0x08000490 sdio - 0x08000490 usage_fault - 0x08000490 tim1_up_tim10 - 0x08000490 usart1 - 0x08000490 i2c3_er - 0x08000490 spi2 - 0x08000490 dma1_stream1 - 0x08000490 bus_fault - 0x08000490 spi5 - 0x08000490 exti3 - 0x08000490 dma2_stream5 - 0x08000490 tim2 - 0x08000490 dma1_stream6 - 0x08000490 default_handler - 0x08000490 i2c1_er - 0x08000490 hard_fault - 0x08000490 usart6 - 0x08000490 exti15_10 - 0x08000490 usart2 - 0x08000490 pend_sv - 0x08000490 i2c1_ev - 0x08000490 wwdg - 0x08000490 adc - 0x08000490 rtc_alarm - 0x08000490 spi3 - 0x08000490 exti1 - 0x08000490 mem_manage - 0x08000490 dma2_stream1 - 0x08000490 dma1_stream2 - 0x08000490 dma2_stream3 - 0x08000490 sv_call - 0x08000490 tim3 - 0x08000490 otg_fs - 0x08000490 dma1_stream5 - 0x08000490 dma2_stream6 - 0x08000490 flash - 0x08000490 tamp_stamp - 0x08000490 i2c3_ev - 0x08000490 rtc_wkup - 0x08000490 dma2_stream0 - 0x08000490 pvd - 0x08000490 fpu - 0x08000490 exti4 - 0x08000490 exti2 - 0x08000490 spi1 - 0x08000490 dma1_stream0 - 0x08000490 tim1_brk_tim9 - 0x08000490 i2c2_ev - 0x08000490 otg_fs_wkup - 0x08000490 spi4 - 0x08000490 dma2_stream2 - 0x08000490 tim1_cc - 0x08000490 tim1_trg_com_tim11 - 0x08000490 exti9_5 - 0x08000490 dma1_stream3 - 0x08000490 dma2_stream4 - 0x08000490 i2c2_er - 0x08000490 dma2_stream7 - 0x08000490 dma1_stream7 - 0x08000490 nmi - 0x08000490 systick - 0x08000490 tim4 - 0x08000490 tim5 - 0x08000490 dma1_stream4 + 0x08000498 0x8 build/startup.o + 0x08000498 exti0 + 0x08000498 debug_monitor + 0x08000498 rcc + 0x08000498 x + 0x08000498 sdio + 0x08000498 usage_fault + 0x08000498 tim1_up_tim10 + 0x08000498 usart1 + 0x08000498 i2c3_er + 0x08000498 spi2 + 0x08000498 dma1_stream1 + 0x08000498 bus_fault + 0x08000498 spi5 + 0x08000498 exti3 + 0x08000498 dma2_stream5 + 0x08000498 tim2 + 0x08000498 dma1_stream6 + 0x08000498 default_handler + 0x08000498 i2c1_er + 0x08000498 hard_fault + 0x08000498 usart6 + 0x08000498 exti15_10 + 0x08000498 usart2 + 0x08000498 pend_sv + 0x08000498 i2c1_ev + 0x08000498 wwdg + 0x08000498 adc + 0x08000498 rtc_alarm + 0x08000498 spi3 + 0x08000498 exti1 + 0x08000498 mem_manage + 0x08000498 dma2_stream1 + 0x08000498 dma1_stream2 + 0x08000498 dma2_stream3 + 0x08000498 sv_call + 0x08000498 tim3 + 0x08000498 otg_fs + 0x08000498 dma1_stream5 + 0x08000498 dma2_stream6 + 0x08000498 flash + 0x08000498 tamp_stamp + 0x08000498 i2c3_ev + 0x08000498 rtc_wkup + 0x08000498 dma2_stream0 + 0x08000498 pvd + 0x08000498 fpu + 0x08000498 exti4 + 0x08000498 exti2 + 0x08000498 spi1 + 0x08000498 dma1_stream0 + 0x08000498 tim1_brk_tim9 + 0x08000498 i2c2_ev + 0x08000498 otg_fs_wkup + 0x08000498 spi4 + 0x08000498 dma2_stream2 + 0x08000498 tim1_cc + 0x08000498 tim1_trg_com_tim11 + 0x08000498 exti9_5 + 0x08000498 dma1_stream3 + 0x08000498 dma2_stream4 + 0x08000498 i2c2_er + 0x08000498 dma2_stream7 + 0x08000498 dma1_stream7 + 0x08000498 nmi + 0x08000498 systick + 0x08000498 tim4 + 0x08000498 tim5 + 0x08000498 dma1_stream4 .text.tim4_init - 0x08000498 0x40 build/timer.o - 0x08000498 tim4_init + 0x080004a0 0x40 build/timer.o + 0x080004a0 tim4_init .text.tim4_start - 0x080004d8 0x20 build/timer.o - 0x080004d8 tim4_start + 0x080004e0 0x20 build/timer.o + 0x080004e0 tim4_start .text.usart2_init - 0x080004f8 0xf8 build/usart.o - 0x080004f8 usart2_init + 0x08000500 0xf8 build/usart.o + 0x08000500 usart2_init + .text.usart2_start + 0x080005f8 0x20 build/usart.o + 0x080005f8 usart2_start + .text.usart2_write_byte + 0x08000618 0x30 build/usart.o + 0x08000618 usart2_write_byte *(.rodata) *(.rodata.*) - 0x080005f0 . = ALIGN (0x4) - 0x080005f0 _data_addr = LOADADDR (.data) + 0x08000648 . = ALIGN (0x4) + 0x08000648 _data_addr = LOADADDR (.data) -.glue_7 0x080005f0 0x0 - .glue_7 0x080005f0 0x0 linker stubs +.glue_7 0x08000648 0x0 + .glue_7 0x08000648 0x0 linker stubs -.glue_7t 0x080005f0 0x0 - .glue_7t 0x080005f0 0x0 linker stubs +.glue_7t 0x08000648 0x0 + .glue_7t 0x08000648 0x0 linker stubs -.vfp11_veneer 0x080005f0 0x0 - .vfp11_veneer 0x080005f0 0x0 linker stubs +.vfp11_veneer 0x08000648 0x0 + .vfp11_veneer 0x08000648 0x0 linker stubs -.v4_bx 0x080005f0 0x0 - .v4_bx 0x080005f0 0x0 linker stubs +.v4_bx 0x08000648 0x0 + .v4_bx 0x08000648 0x0 linker stubs -.iplt 0x080005f0 0x0 - .iplt 0x080005f0 0x0 build/main.o +.iplt 0x08000648 0x0 + .iplt 0x08000648 0x0 build/main.o -.rel.dyn 0x080005f0 0x0 - .rel.iplt 0x080005f0 0x0 build/main.o +.rel.dyn 0x08000648 0x0 + .rel.iplt 0x08000648 0x0 build/main.o -.data 0x20000000 0x0 load address 0x080005f0 +.data 0x20000000 0x0 load address 0x08000648 0x20000000 . = ALIGN (0x4) 0x20000000 _data_start = . *(.data) @@ -289,10 +293,10 @@ LOAD build/usart.o 0x20000000 . = ALIGN (0x4) 0x20000000 _data_end = . -.igot.plt 0x20000000 0x0 load address 0x080005f0 +.igot.plt 0x20000000 0x0 load address 0x08000648 .igot.plt 0x20000000 0x0 build/main.o -.bss 0x20000000 0x0 load address 0x080005f0 +.bss 0x20000000 0x0 load address 0x08000648 0x20000000 . = ALIGN (0x4) 0x20000000 _bss_start = . *(.bss) @@ -302,21 +306,21 @@ LOAD build/usart.o OUTPUT(build/final.elf elf32-littlearm) LOAD linker stubs -.debug_info 0x00000000 0xe1d +.debug_info 0x00000000 0xe69 .debug_info 0x00000000 0x205 build/gpio.o - .debug_info 0x00000205 0x457 build/main.o - .debug_info 0x0000065c 0x188 build/startup.o - .debug_info 0x000007e4 0x335 build/timer.o - .debug_info 0x00000b19 0x304 build/usart.o + .debug_info 0x00000205 0x478 build/main.o + .debug_info 0x0000067d 0x188 build/startup.o + .debug_info 0x00000805 0x335 build/timer.o + .debug_info 0x00000b3a 0x32f build/usart.o -.debug_abbrev 0x00000000 0x4ee +.debug_abbrev 0x00000000 0x519 .debug_abbrev 0x00000000 0x119 build/gpio.o - .debug_abbrev 0x00000119 0x143 build/main.o - .debug_abbrev 0x0000025c 0x127 build/startup.o - .debug_abbrev 0x00000383 0xb5 build/timer.o - .debug_abbrev 0x00000438 0xb6 build/usart.o + .debug_abbrev 0x00000119 0x142 build/main.o + .debug_abbrev 0x0000025b 0x127 build/startup.o + .debug_abbrev 0x00000382 0xb5 build/timer.o + .debug_abbrev 0x00000437 0xe2 build/usart.o -.debug_aranges 0x00000000 0xd0 +.debug_aranges 0x00000000 0xd8 .debug_aranges 0x00000000 0x28 build/gpio.o .debug_aranges @@ -326,10 +330,10 @@ LOAD linker stubs .debug_aranges 0x00000080 0x28 build/timer.o .debug_aranges - 0x000000a8 0x28 build/usart.o + 0x000000a8 0x30 build/usart.o .debug_rnglists - 0x00000000 0x86 + 0x00000000 0x8c .debug_rnglists 0x00000000 0x19 build/gpio.o .debug_rnglists @@ -339,9 +343,9 @@ LOAD linker stubs .debug_rnglists 0x00000053 0x19 build/timer.o .debug_rnglists - 0x0000006c 0x1a build/usart.o + 0x0000006c 0x20 build/usart.o -.debug_macro 0x00000000 0x4885 +.debug_macro 0x00000000 0x489d .debug_macro 0x00000000 0xb56 build/gpio.o .debug_macro 0x00000b56 0x22 build/gpio.o .debug_macro 0x00000b78 0x75 build/gpio.o @@ -362,33 +366,33 @@ LOAD linker stubs .debug_macro 0x00002358 0x46 build/main.o .debug_macro 0x0000239e 0x2e build/main.o .debug_macro 0x000023cc 0x22 build/main.o - .debug_macro 0x000023ee 0x5e build/main.o - .debug_macro 0x0000244c 0xb02 build/startup.o - .debug_macro 0x00002f4e 0x56 build/startup.o - .debug_macro 0x00002fa4 0x51 build/startup.o - .debug_macro 0x00002ff5 0xb5c build/timer.o - .debug_macro 0x00003b51 0x13e build/timer.o - .debug_macro 0x00003c8f 0xb74 build/usart.o - .debug_macro 0x00004803 0x82 build/usart.o + .debug_macro 0x000023ee 0x76 build/main.o + .debug_macro 0x00002464 0xb02 build/startup.o + .debug_macro 0x00002f66 0x56 build/startup.o + .debug_macro 0x00002fbc 0x51 build/startup.o + .debug_macro 0x0000300d 0xb5c build/timer.o + .debug_macro 0x00003b69 0x13e build/timer.o + .debug_macro 0x00003ca7 0xb74 build/usart.o + .debug_macro 0x0000481b 0x82 build/usart.o -.debug_line 0x00000000 0x605 +.debug_line 0x00000000 0x63b .debug_line 0x00000000 0x116 build/gpio.o - .debug_line 0x00000116 0x1e1 build/main.o - .debug_line 0x000002f7 0xea build/startup.o - .debug_line 0x000003e1 0xdf build/timer.o - .debug_line 0x000004c0 0x145 build/usart.o + .debug_line 0x00000116 0x1e4 build/main.o + .debug_line 0x000002fa 0xea build/startup.o + .debug_line 0x000003e4 0xdf build/timer.o + .debug_line 0x000004c3 0x178 build/usart.o -.debug_str 0x00000000 0x62fd +.debug_str 0x00000000 0x6393 .debug_str 0x00000000 0x550b build/gpio.o 0x56b3 (size before relaxing) - .debug_str 0x0000550b 0xd3a build/main.o - 0x639d (size before relaxing) - .debug_str 0x00006245 0x88 build/startup.o + .debug_str 0x0000550b 0xddd build/main.o + 0x6440 (size before relaxing) + .debug_str 0x000062e8 0x88 build/startup.o 0x3cdf (size before relaxing) - .debug_str 0x000062cd 0xc build/timer.o + .debug_str 0x00006370 0xc build/timer.o 0x5bc5 (size before relaxing) - .debug_str 0x000062d9 0x24 build/usart.o - 0x5ffb (size before relaxing) + .debug_str 0x0000637c 0x17 build/usart.o + 0x6091 (size before relaxing) .comment 0x00000000 0x45 .comment 0x00000000 0x45 build/gpio.o @@ -429,9 +433,9 @@ LOAD linker stubs 0x0000028b 0x8 build/usart.o 0x26f (size before relaxing) -.debug_frame 0x00000000 0x1bc +.debug_frame 0x00000000 0x1e4 .debug_frame 0x00000000 0x60 build/gpio.o .debug_frame 0x00000060 0x50 build/main.o .debug_frame 0x000000b0 0x6c build/startup.o .debug_frame 0x0000011c 0x50 build/timer.o - .debug_frame 0x0000016c 0x50 build/usart.o + .debug_frame 0x0000016c 0x78 build/usart.o diff --git a/build/main.S b/build/main.S index 145501f..1f0a81d 100644 --- a/build/main.S +++ b/build/main.S @@ -266,7 +266,7 @@ main: .loc 1 82 3 bl tim4_start .loc 1 83 3 - bl tim4_start + bl usart2_start .loc 1 85 12 movw r3, #525 strh r3, [r7, #2] @ movhi @@ -330,10 +330,13 @@ main: mov r1, r2 mov r0, r3 bl gpio_write - .loc 1 96 45 + .loc 1 96 3 + movs r0, #97 + bl usart2_write_byte + .loc 1 98 45 ldr r3, .L10+4 ldr r3, [r3, #36] - .loc 1 96 11 + .loc 1 98 11 strh r3, [r7, #6] @ movhi .loc 1 92 5 b .L9 @@ -357,16 +360,16 @@ main: .file 9 "src/usart.h" .section .debug_info,"",%progbits .Ldebug_info0: - .4byte 0x453 + .4byte 0x474 .2byte 0x5 .byte 0x1 .byte 0x4 .4byte .Ldebug_abbrev0 .uleb128 0xd - .4byte .LASF1036 + .4byte .LASF1042 .byte 0x1d - .4byte .LASF1037 - .4byte .LASF1038 + .4byte .LASF1043 + .4byte .LASF1044 .4byte .LLRL0 .4byte 0 .4byte .Ldebug_line0 @@ -374,17 +377,17 @@ main: .uleb128 0x3 .byte 0x1 .byte 0x6 - .4byte .LASF969 + .4byte .LASF973 .uleb128 0x3 .byte 0x1 .byte 0x8 - .4byte .LASF970 + .4byte .LASF974 .uleb128 0x3 .byte 0x2 .byte 0x5 - .4byte .LASF971 + .4byte .LASF975 .uleb128 0x4 - .4byte .LASF974 + .4byte .LASF978 .byte 0x2 .byte 0x39 .byte 0x1c @@ -392,13 +395,13 @@ main: .uleb128 0x3 .byte 0x2 .byte 0x7 - .4byte .LASF972 + .4byte .LASF976 .uleb128 0x3 .byte 0x4 .byte 0x5 - .4byte .LASF973 + .4byte .LASF977 .uleb128 0x4 - .4byte .LASF975 + .4byte .LASF979 .byte 0x2 .byte 0x4f .byte 0x1b @@ -406,15 +409,15 @@ main: .uleb128 0x3 .byte 0x4 .byte 0x7 - .4byte .LASF976 + .4byte .LASF980 .uleb128 0x3 .byte 0x8 .byte 0x5 - .4byte .LASF977 + .4byte .LASF981 .uleb128 0x3 .byte 0x8 .byte 0x7 - .4byte .LASF978 + .4byte .LASF982 .uleb128 0xe .byte 0x4 .byte 0x5 @@ -422,22 +425,22 @@ main: .uleb128 0x3 .byte 0x4 .byte 0x7 - .4byte .LASF979 + .4byte .LASF983 .uleb128 0x4 - .4byte .LASF980 + .4byte .LASF984 .byte 0x3 .byte 0x24 .byte 0x14 .4byte 0x3f .uleb128 0x4 - .4byte .LASF981 + .4byte .LASF985 .byte 0x3 .byte 0x30 .byte 0x14 .4byte 0x59 - .uleb128 0x8 - .4byte 0x94 .uleb128 0x9 + .4byte 0x94 + .uleb128 0xa .ascii "rcc\000" .byte 0x8c .byte 0x4 @@ -449,13 +452,13 @@ main: .4byte 0xa0 .byte 0 .uleb128 0x1 - .4byte .LASF982 + .4byte .LASF986 .byte 0x4 .byte 0x8 .4byte 0xa0 .byte 0x4 .uleb128 0x1 - .4byte .LASF983 + .4byte .LASF987 .byte 0x4 .byte 0x9 .4byte 0xa0 @@ -467,115 +470,115 @@ main: .4byte 0xa0 .byte 0xc .uleb128 0x1 - .4byte .LASF984 + .4byte .LASF988 .byte 0x4 .byte 0xb .4byte 0xa0 .byte 0x10 .uleb128 0x1 - .4byte .LASF985 + .4byte .LASF989 .byte 0x4 .byte 0xc .4byte 0xa0 .byte 0x14 .uleb128 0x1 - .4byte .LASF986 + .4byte .LASF990 .byte 0x4 .byte 0xd .4byte 0x210 .byte 0x18 .uleb128 0x1 - .4byte .LASF987 + .4byte .LASF991 .byte 0x4 .byte 0xe .4byte 0xa0 .byte 0x20 .uleb128 0x1 - .4byte .LASF988 + .4byte .LASF992 .byte 0x4 .byte 0xf .4byte 0xa0 .byte 0x24 .uleb128 0x1 - .4byte .LASF989 + .4byte .LASF993 .byte 0x4 .byte 0x10 .4byte 0x210 .byte 0x28 .uleb128 0x1 - .4byte .LASF990 + .4byte .LASF994 .byte 0x4 .byte 0x11 .4byte 0xa0 .byte 0x30 .uleb128 0x1 - .4byte .LASF991 + .4byte .LASF995 .byte 0x4 .byte 0x12 .4byte 0xa0 .byte 0x34 .uleb128 0x1 - .4byte .LASF992 + .4byte .LASF996 .byte 0x4 .byte 0x13 .4byte 0x210 .byte 0x38 .uleb128 0x1 - .4byte .LASF993 + .4byte .LASF997 .byte 0x4 .byte 0x14 .4byte 0xa0 .byte 0x40 .uleb128 0x1 - .4byte .LASF994 + .4byte .LASF998 .byte 0x4 .byte 0x15 .4byte 0xa0 .byte 0x44 .uleb128 0x1 - .4byte .LASF995 + .4byte .LASF999 .byte 0x4 .byte 0x16 .4byte 0x210 .byte 0x48 .uleb128 0x1 - .4byte .LASF996 + .4byte .LASF1000 .byte 0x4 .byte 0x17 .4byte 0xa0 .byte 0x50 .uleb128 0x1 - .4byte .LASF997 + .4byte .LASF1001 .byte 0x4 .byte 0x18 .4byte 0xa0 .byte 0x54 .uleb128 0x1 - .4byte .LASF998 + .4byte .LASF1002 .byte 0x4 .byte 0x19 .4byte 0x210 .byte 0x58 .uleb128 0x1 - .4byte .LASF999 + .4byte .LASF1003 .byte 0x4 .byte 0x1a .4byte 0xa0 .byte 0x60 .uleb128 0x1 - .4byte .LASF1000 + .4byte .LASF1004 .byte 0x4 .byte 0x1b .4byte 0xa0 .byte 0x64 .uleb128 0x1 - .4byte .LASF1001 + .4byte .LASF1005 .byte 0x4 .byte 0x1c .4byte 0x210 .byte 0x68 .uleb128 0x1 - .4byte .LASF1002 + .4byte .LASF1006 .byte 0x4 .byte 0x1d .4byte 0xa0 @@ -587,25 +590,25 @@ main: .4byte 0xa0 .byte 0x74 .uleb128 0x1 - .4byte .LASF1003 + .4byte .LASF1007 .byte 0x4 .byte 0x1f .4byte 0x210 .byte 0x78 .uleb128 0x1 - .4byte .LASF1004 + .4byte .LASF1008 .byte 0x4 .byte 0x20 .4byte 0xa0 .byte 0x80 .uleb128 0x1 - .4byte .LASF1005 + .4byte .LASF1009 .byte 0x4 .byte 0x21 .4byte 0xa0 .byte 0x84 .uleb128 0x1 - .4byte .LASF1006 + .4byte .LASF1010 .byte 0x4 .byte 0x22 .4byte 0xa0 @@ -618,7 +621,7 @@ main: .4byte 0x81 .byte 0x1 .byte 0 - .uleb128 0x8 + .uleb128 0x9 .4byte 0x200 .uleb128 0x11 .byte 0x7 @@ -628,27 +631,27 @@ main: .byte 0x3a .byte 0xe .4byte 0x23c - .uleb128 0x5 - .4byte .LASF1007 + .uleb128 0x6 + .4byte .LASF1011 .byte 0 - .uleb128 0x5 - .4byte .LASF1008 + .uleb128 0x6 + .4byte .LASF1012 .byte 0x1 - .uleb128 0x5 - .4byte .LASF1009 + .uleb128 0x6 + .4byte .LASF1013 .byte 0x2 - .uleb128 0x5 - .4byte .LASF1010 + .uleb128 0x6 + .4byte .LASF1014 .byte 0x3 .byte 0 .uleb128 0x4 - .4byte .LASF1011 + .4byte .LASF1015 .byte 0x5 .byte 0x3f .byte 0x3 .4byte 0x215 - .uleb128 0xa - .4byte .LASF1012 + .uleb128 0xb + .4byte .LASF1016 .byte 0x18 .byte 0x6 .4byte 0x29a @@ -659,13 +662,13 @@ main: .4byte 0xa0 .byte 0 .uleb128 0x1 - .4byte .LASF1013 + .4byte .LASF1017 .byte 0x6 .byte 0x8 .4byte 0xa0 .byte 0x4 .uleb128 0x1 - .4byte .LASF1014 + .4byte .LASF1018 .byte 0x6 .byte 0x9 .4byte 0xa0 @@ -683,13 +686,13 @@ main: .4byte 0xa0 .byte 0x10 .uleb128 0x1 - .4byte .LASF1015 + .4byte .LASF1019 .byte 0x6 .byte 0xc .4byte 0xa0 .byte 0x14 .byte 0 - .uleb128 0x9 + .uleb128 0xa .ascii "pwr\000" .byte 0x8 .byte 0x7 @@ -707,8 +710,8 @@ main: .4byte 0xa0 .byte 0x4 .byte 0 - .uleb128 0xa - .4byte .LASF1016 + .uleb128 0xb + .4byte .LASF1020 .byte 0x50 .byte 0x8 .4byte 0x3b8 @@ -725,13 +728,13 @@ main: .4byte 0xa0 .byte 0x4 .uleb128 0x1 - .4byte .LASF1017 + .4byte .LASF1021 .byte 0x8 .byte 0x9 .4byte 0xa0 .byte 0x8 .uleb128 0x1 - .4byte .LASF1018 + .4byte .LASF1022 .byte 0x8 .byte 0xa .4byte 0xa0 @@ -749,19 +752,19 @@ main: .4byte 0xa0 .byte 0x14 .uleb128 0x1 - .4byte .LASF1019 + .4byte .LASF1023 .byte 0x8 .byte 0xd .4byte 0xa0 .byte 0x18 .uleb128 0x1 - .4byte .LASF1020 + .4byte .LASF1024 .byte 0x8 .byte 0xe .4byte 0xa0 .byte 0x1c .uleb128 0x1 - .4byte .LASF1021 + .4byte .LASF1025 .byte 0x8 .byte 0xf .4byte 0xa0 @@ -791,31 +794,31 @@ main: .4byte 0xa0 .byte 0x30 .uleb128 0x1 - .4byte .LASF1022 + .4byte .LASF1026 .byte 0x8 .byte 0x14 .4byte 0xa0 .byte 0x34 .uleb128 0x1 - .4byte .LASF1023 + .4byte .LASF1027 .byte 0x8 .byte 0x15 .4byte 0xa0 .byte 0x38 .uleb128 0x1 - .4byte .LASF1024 + .4byte .LASF1028 .byte 0x8 .byte 0x16 .4byte 0xa0 .byte 0x3c .uleb128 0x1 - .4byte .LASF1025 + .4byte .LASF1029 .byte 0x8 .byte 0x17 .4byte 0xa0 .byte 0x40 .uleb128 0x1 - .4byte .LASF1026 + .4byte .LASF1030 .byte 0x8 .byte 0x18 .4byte 0xa0 @@ -827,48 +830,66 @@ main: .4byte 0xa0 .byte 0x48 .uleb128 0x1 - .4byte .LASF1027 + .4byte .LASF1031 .byte 0x8 .byte 0x1a .4byte 0xa0 .byte 0x4c .byte 0 - .uleb128 0xb - .4byte .LASF1029 + .uleb128 0x8 + .4byte .LASF1032 + .byte 0x9 + .byte 0x37 + .4byte 0x3c9 + .uleb128 0x5 + .4byte 0x3c9 + .byte 0 + .uleb128 0x3 + .byte 0x1 + .byte 0x8 + .4byte .LASF510 + .uleb128 0x8 + .4byte .LASF1033 + .byte 0x5 .byte 0x42 - .4byte 0x3cd - .uleb128 0x6 + .4byte 0x3e6 + .uleb128 0x5 .4byte 0x88 - .uleb128 0x6 - .4byte 0x3cd + .uleb128 0x5 + .4byte 0x3e6 .byte 0 .uleb128 0x3 .byte 0x1 .byte 0x2 - .4byte .LASF1028 - .uleb128 0xb - .4byte .LASF1030 + .4byte .LASF1034 + .uleb128 0x8 + .4byte .LASF1035 + .byte 0x5 .byte 0x41 - .4byte 0x3e9 - .uleb128 0x6 + .4byte 0x403 + .uleb128 0x5 .4byte 0x88 - .uleb128 0x6 + .uleb128 0x5 .4byte 0x23c .byte 0 .uleb128 0x7 - .4byte .LASF1031 + .4byte .LASF1036 + .byte 0x9 + .byte 0x35 + .uleb128 0x7 + .4byte .LASF1037 .byte 0x8 .byte 0x24 .uleb128 0x7 - .4byte .LASF1032 + .4byte .LASF1038 .byte 0x9 - .byte 0x2b + .byte 0x34 .uleb128 0x7 - .4byte .LASF1033 + .4byte .LASF1039 .byte 0x8 .byte 0x23 .uleb128 0x12 - .4byte .LASF1039 + .4byte .LASF1045 .byte 0x1 .byte 0x4d .byte 0x5 @@ -877,7 +898,7 @@ main: .4byte .LFE1-.LFB1 .uleb128 0x1 .byte 0x9c - .4byte 0x444 + .4byte 0x465 .uleb128 0x13 .ascii "led\000" .byte 0x1 @@ -888,7 +909,7 @@ main: .byte 0x91 .sleb128 -14 .uleb128 0xc - .4byte .LASF1034 + .4byte .LASF1040 .byte 0x59 .byte 0xc .4byte 0x88 @@ -896,16 +917,16 @@ main: .byte 0x91 .sleb128 -10 .uleb128 0xc - .4byte .LASF1035 + .4byte .LASF1041 .byte 0x5a .byte 0x7 - .4byte 0x3cd + .4byte 0x3e6 .uleb128 0x2 .byte 0x91 .sleb128 -11 .byte 0 .uleb128 0x14 - .4byte .LASF1040 + .4byte .LASF1046 .byte 0x1 .byte 0xd .byte 0xd @@ -979,6 +1000,13 @@ main: .byte 0 .byte 0 .uleb128 0x5 + .uleb128 0x5 + .byte 0 + .uleb128 0x49 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x6 .uleb128 0x28 .byte 0 .uleb128 0x3 @@ -987,13 +1015,6 @@ main: .uleb128 0xb .byte 0 .byte 0 - .uleb128 0x6 - .uleb128 0x5 - .byte 0 - .uleb128 0x49 - .uleb128 0x13 - .byte 0 - .byte 0 .uleb128 0x7 .uleb128 0x2e .byte 0 @@ -1015,13 +1036,35 @@ main: .byte 0 .byte 0 .uleb128 0x8 + .uleb128 0x2e + .byte 0x1 + .uleb128 0x3f + .uleb128 0x19 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x39 + .uleb128 0x21 + .sleb128 6 + .uleb128 0x27 + .uleb128 0x19 + .uleb128 0x3c + .uleb128 0x19 + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x9 .uleb128 0x35 .byte 0 .uleb128 0x49 .uleb128 0x13 .byte 0 .byte 0 - .uleb128 0x9 + .uleb128 0xa .uleb128 0x13 .byte 0x1 .uleb128 0x3 @@ -1040,7 +1083,7 @@ main: .uleb128 0x13 .byte 0 .byte 0 - .uleb128 0xa + .uleb128 0xb .uleb128 0x13 .byte 0x1 .uleb128 0x3 @@ -1059,29 +1102,6 @@ main: .uleb128 0x13 .byte 0 .byte 0 - .uleb128 0xb - .uleb128 0x2e - .byte 0x1 - .uleb128 0x3f - .uleb128 0x19 - .uleb128 0x3 - .uleb128 0xe - .uleb128 0x3a - .uleb128 0x21 - .sleb128 5 - .uleb128 0x3b - .uleb128 0xb - .uleb128 0x39 - .uleb128 0x21 - .sleb128 6 - .uleb128 0x27 - .uleb128 0x19 - .uleb128 0x3c - .uleb128 0x19 - .uleb128 0x1 - .uleb128 0x13 - .byte 0 - .byte 0 .uleb128 0xc .uleb128 0x34 .byte 0 @@ -2790,7 +2810,7 @@ main: .byte 0x4 .byte 0x5 .uleb128 0xb - .4byte .LASF968 + .4byte .LASF972 .byte 0x4 .byte 0 .section .debug_macro,"G",%progbits,wm4._newlib_version.h.4.6d111ab2e95434b664b53815e5c8ccba,comdat @@ -4389,7 +4409,7 @@ main: .uleb128 0x21 .4byte .LASF952 .byte 0 - .section .debug_macro,"G",%progbits,wm4.usart.h.2.0debbac628af0f73f2055baa828e03f0,comdat + .section .debug_macro,"G",%progbits,wm4.usart.h.2.499ef099adc8b232d514889834b2ea6a,comdat .Ldebug_macro20: .2byte 0x5 .byte 0 @@ -4415,29 +4435,41 @@ main: .uleb128 0x1a .4byte .LASF959 .byte 0x5 - .uleb128 0x1d + .uleb128 0x1e .4byte .LASF960 .byte 0x5 - .uleb128 0x1e + .uleb128 0x1f .4byte .LASF961 .byte 0x5 - .uleb128 0x21 + .uleb128 0x22 .4byte .LASF962 .byte 0x5 - .uleb128 0x22 + .uleb128 0x23 .4byte .LASF963 .byte 0x5 - .uleb128 0x25 + .uleb128 0x26 .4byte .LASF964 .byte 0x5 - .uleb128 0x26 + .uleb128 0x27 .4byte .LASF965 .byte 0x5 - .uleb128 0x28 + .uleb128 0x2a .4byte .LASF966 .byte 0x5 - .uleb128 0x29 + .uleb128 0x2b .4byte .LASF967 + .byte 0x5 + .uleb128 0x2e + .4byte .LASF968 + .byte 0x5 + .uleb128 0x2f + .4byte .LASF969 + .byte 0x5 + .uleb128 0x31 + .4byte .LASF970 + .byte 0x5 + .uleb128 0x32 + .4byte .LASF971 .byte 0 .section .debug_line,"",%progbits .Ldebug_line0: @@ -4454,7 +4486,7 @@ main: .ascii "__UHA_FBIT__ 8\000" .LASF814: .ascii "PRIiFAST64 __PRI64FAST(i)\000" -.LASF970: +.LASF974: .ascii "unsigned char\000" .LASF225: .ascii "__FLT64_DENORM_MIN__ 4.9406564584124654e-324F64\000" @@ -4484,7 +4516,7 @@ main: .ascii "__WINT_MIN__ 0U\000" .LASF90: .ascii "__INTMAX_MAX__ 0x7fffffffffffffffLL\000" -.LASF1009: +.LASF1013: .ascii "GPIO_MODE_AF\000" .LASF335: .ascii "__TQ_IBIT__ 0\000" @@ -4500,7 +4532,7 @@ main: .ascii "__int20__\000" .LASF906: .ascii "RCC_APB1ENR_TIM4_BIT 2\000" -.LASF967: +.LASF971: .ascii "USART_BRR_FRACTION_MASK (0b111)\000" .LASF18: .ascii "__SIZEOF_LONG_LONG__ 8\000" @@ -4512,7 +4544,7 @@ main: .ascii "__FRACT_MIN__ (-0.5R-0.5R)\000" .LASF324: .ascii "__ULLACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULLK\000" -.LASF1012: +.LASF1016: .ascii "flash\000" .LASF294: .ascii "__USACCUM_MAX__ 0XFFFFP-8UHK\000" @@ -4629,7 +4661,7 @@ main: .ascii "__need_wchar_t\000" .LASF199: .ascii "__FLT32_MIN_EXP__ (-125)\000" -.LASF1036: +.LASF1042: .ascii "GNU C2X 12.3.1 20230626 -mcpu=cortex-m4 -mthumb -mf" .ascii "loat-abi=hard -mfpu=fpv4-sp-d16 -march=armv7e-m+fp " .ascii "-g3 -ggdb -O0 -std=c2x -ffunction-sections -fdata-s" @@ -4650,7 +4682,7 @@ main: .ascii "__int_fast32_t_defined 1\000" .LASF133: .ascii "__INT_FAST64_WIDTH__ 64\000" -.LASF1027: +.LASF1031: .ascii "DMAR\000" .LASF659: .ascii "___int_wchar_t_h \000" @@ -4703,13 +4735,13 @@ main: .ascii "SCNo32 __SCN32(o)\000" .LASF540: .ascii "_NOTHROW \000" -.LASF1022: +.LASF1026: .ascii "CCR1\000" .LASF633: .ascii "WCHAR_MAX (__WCHAR_MAX__)\000" -.LASF1024: +.LASF1028: .ascii "CCR3\000" -.LASF1025: +.LASF1029: .ascii "CCR4\000" .LASF307: .ascii "__LACCUM_IBIT__ 32\000" @@ -4733,7 +4765,7 @@ main: .ascii "__INT64 \"ll\"\000" .LASF138: .ascii "__INTPTR_MAX__ 0x7fffffff\000" -.LASF997: +.LASF1001: .ascii "AHB2LPENR\000" .LASF499: .ascii "__RAND_MAX\000" @@ -4776,7 +4808,7 @@ main: .ascii " RCC_PLLCFGR_PLLP_BIT)\000" .LASF302: .ascii "__UACCUM_IBIT__ 16\000" -.LASF973: +.LASF977: .ascii "long int\000" .LASF719: .ascii "SCNd16 __SCN16(d)\000" @@ -4829,7 +4861,7 @@ main: .ascii "__FLT32_MAX_EXP__ 128\000" .LASF824: .ascii "__PRIMAX(x) __STRINGIFY(ll ##x)\000" -.LASF1039: +.LASF1045: .ascii "main\000" .LASF435: .ascii "__THUMB_INTERWORK__ 1\000" @@ -4837,6 +4869,8 @@ main: .ascii "__ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR\000" .LASF697: .ascii "PRIiFAST8 __PRI8FAST(i)\000" +.LASF959: + .ascii "USART_SR_RXNE_READY (1 <AHB1ENR |= (1 << (led >> 8)); @@ -2417,6 +2428,8 @@ int main(void) { led_on = !led_on; gpio_write(led, led_on); + usart2_write_byte('a'); + counter = ((struct timer *) (0x40000800U))->CNT; } }; diff --git a/build/main.o b/build/main.o index 22ca011..7937152 100644 Binary files a/build/main.o and b/build/main.o differ diff --git a/build/usart.S b/build/usart.S index 367db15..8f5b9b4 100644 --- a/build/usart.S +++ b/build/usart.S @@ -230,6 +230,64 @@ usart2_start: .cfi_endproc .LFE1: .size usart2_start, .-usart2_start + .section .text.usart2_write_byte,"ax",%progbits + .align 1 + .global usart2_write_byte + .syntax unified + .thumb + .thumb_func + .type usart2_write_byte, %function +usart2_write_byte: +.LFB2: + .loc 1 65 32 + .cfi_startproc + @ args = 0, pretend = 0, frame = 8 + @ frame_needed = 1, uses_anonymous_args = 0 + @ link register save eliminated. + push {r7} + .cfi_def_cfa_offset 4 + .cfi_offset 7, -4 + sub sp, sp, #12 + .cfi_def_cfa_offset 16 + add r7, sp, #0 + .cfi_def_cfa_register 7 + mov r3, r0 + strb r3, [r7, #7] + .loc 1 67 35 + ldr r2, .L9 + .loc 1 67 40 + ldrb r3, [r7, #7] @ zero_extendqisi2 + str r3, [r2, #4] + .loc 1 70 9 + nop +.L8: + .loc 1 70 43 discriminator 1 + ldr r3, .L9 + ldr r3, [r3] + .loc 1 70 48 discriminator 1 + and r3, r3, #128 + .loc 1 70 60 discriminator 1 + cmp r3, #0 + beq .L8 + .loc 1 71 1 + nop + nop + adds r7, r7, #12 + .cfi_def_cfa_offset 4 + mov sp, r7 + .cfi_def_cfa_register 13 + @ sp needed + ldr r7, [sp], #4 + .cfi_restore 7 + .cfi_def_cfa_offset 0 + bx lr +.L10: + .align 2 +.L9: + .word 1073759232 + .cfi_endproc +.LFE2: + .size usart2_write_byte, .-usart2_write_byte .text .Letext0: .file 2 "/nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/arm-none-eabi/include/machine/_default_types.h" @@ -239,16 +297,16 @@ usart2_start: .file 6 "src/usart.h" .section .debug_info,"",%progbits .Ldebug_info0: - .4byte 0x300 + .4byte 0x32b .2byte 0x5 .byte 0x1 .byte 0x4 .4byte .Ldebug_abbrev0 .uleb128 0x8 - .4byte .LASF994 + .4byte .LASF998 .byte 0x1d - .4byte .LASF995 - .4byte .LASF996 + .4byte .LASF999 + .4byte .LASF1000 .4byte .LLRL0 .4byte 0 .4byte .Ldebug_line0 @@ -256,25 +314,25 @@ usart2_start: .uleb128 0x3 .byte 0x1 .byte 0x6 - .4byte .LASF945 + .4byte .LASF949 .uleb128 0x3 .byte 0x1 .byte 0x8 - .4byte .LASF946 + .4byte .LASF950 .uleb128 0x3 .byte 0x2 .byte 0x5 - .4byte .LASF947 + .4byte .LASF951 .uleb128 0x3 .byte 0x2 .byte 0x7 - .4byte .LASF948 + .4byte .LASF952 .uleb128 0x3 .byte 0x4 .byte 0x5 - .4byte .LASF949 + .4byte .LASF953 .uleb128 0x4 - .4byte .LASF954 + .4byte .LASF958 .byte 0x2 .byte 0x4f .byte 0x1b @@ -282,15 +340,15 @@ usart2_start: .uleb128 0x3 .byte 0x4 .byte 0x7 - .4byte .LASF950 + .4byte .LASF954 .uleb128 0x3 .byte 0x8 .byte 0x5 - .4byte .LASF951 + .4byte .LASF955 .uleb128 0x3 .byte 0x8 .byte 0x7 - .4byte .LASF952 + .4byte .LASF956 .uleb128 0x9 .byte 0x4 .byte 0x5 @@ -298,9 +356,9 @@ usart2_start: .uleb128 0x3 .byte 0x4 .byte 0x7 - .4byte .LASF953 + .4byte .LASF957 .uleb128 0x4 - .4byte .LASF955 + .4byte .LASF959 .byte 0x3 .byte 0x30 .byte 0x14 @@ -321,13 +379,13 @@ usart2_start: .4byte 0x88 .byte 0 .uleb128 0x1 - .4byte .LASF956 + .4byte .LASF960 .byte 0x4 .byte 0x8 .4byte 0x88 .byte 0x4 .uleb128 0x1 - .4byte .LASF957 + .4byte .LASF961 .byte 0x4 .byte 0x9 .4byte 0x88 @@ -339,115 +397,115 @@ usart2_start: .4byte 0x88 .byte 0xc .uleb128 0x1 - .4byte .LASF958 + .4byte .LASF962 .byte 0x4 .byte 0xb .4byte 0x88 .byte 0x10 .uleb128 0x1 - .4byte .LASF959 + .4byte .LASF963 .byte 0x4 .byte 0xc .4byte 0x88 .byte 0x14 .uleb128 0x1 - .4byte .LASF960 + .4byte .LASF964 .byte 0x4 .byte 0xd .4byte 0x1fa .byte 0x18 .uleb128 0x1 - .4byte .LASF961 + .4byte .LASF965 .byte 0x4 .byte 0xe .4byte 0x88 .byte 0x20 .uleb128 0x1 - .4byte .LASF962 + .4byte .LASF966 .byte 0x4 .byte 0xf .4byte 0x88 .byte 0x24 .uleb128 0x1 - .4byte .LASF963 + .4byte .LASF967 .byte 0x4 .byte 0x10 .4byte 0x1fa .byte 0x28 .uleb128 0x1 - .4byte .LASF964 + .4byte .LASF968 .byte 0x4 .byte 0x11 .4byte 0x88 .byte 0x30 .uleb128 0x1 - .4byte .LASF965 + .4byte .LASF969 .byte 0x4 .byte 0x12 .4byte 0x88 .byte 0x34 .uleb128 0x1 - .4byte .LASF966 + .4byte .LASF970 .byte 0x4 .byte 0x13 .4byte 0x1fa .byte 0x38 .uleb128 0x1 - .4byte .LASF967 + .4byte .LASF971 .byte 0x4 .byte 0x14 .4byte 0x88 .byte 0x40 .uleb128 0x1 - .4byte .LASF968 + .4byte .LASF972 .byte 0x4 .byte 0x15 .4byte 0x88 .byte 0x44 .uleb128 0x1 - .4byte .LASF969 + .4byte .LASF973 .byte 0x4 .byte 0x16 .4byte 0x1fa .byte 0x48 .uleb128 0x1 - .4byte .LASF970 + .4byte .LASF974 .byte 0x4 .byte 0x17 .4byte 0x88 .byte 0x50 .uleb128 0x1 - .4byte .LASF971 + .4byte .LASF975 .byte 0x4 .byte 0x18 .4byte 0x88 .byte 0x54 .uleb128 0x1 - .4byte .LASF972 + .4byte .LASF976 .byte 0x4 .byte 0x19 .4byte 0x1fa .byte 0x58 .uleb128 0x1 - .4byte .LASF973 + .4byte .LASF977 .byte 0x4 .byte 0x1a .4byte 0x88 .byte 0x60 .uleb128 0x1 - .4byte .LASF974 + .4byte .LASF978 .byte 0x4 .byte 0x1b .4byte 0x88 .byte 0x64 .uleb128 0x1 - .4byte .LASF975 + .4byte .LASF979 .byte 0x4 .byte 0x1c .4byte 0x1fa .byte 0x68 .uleb128 0x1 - .4byte .LASF976 + .4byte .LASF980 .byte 0x4 .byte 0x1d .4byte 0x88 @@ -459,25 +517,25 @@ usart2_start: .4byte 0x88 .byte 0x74 .uleb128 0x1 - .4byte .LASF977 + .4byte .LASF981 .byte 0x4 .byte 0x1f .4byte 0x1fa .byte 0x78 .uleb128 0x1 - .4byte .LASF978 + .4byte .LASF982 .byte 0x4 .byte 0x20 .4byte 0x88 .byte 0x80 .uleb128 0x1 - .4byte .LASF979 + .4byte .LASF983 .byte 0x4 .byte 0x21 .4byte 0x88 .byte 0x84 .uleb128 0x1 - .4byte .LASF980 + .4byte .LASF984 .byte 0x4 .byte 0x22 .4byte 0x88 @@ -493,31 +551,31 @@ usart2_start: .uleb128 0x5 .4byte 0x1ea .uleb128 0x6 - .4byte .LASF981 + .4byte .LASF985 .byte 0x28 .byte 0x5 .byte 0x7 .4byte 0x284 .uleb128 0x1 - .4byte .LASF982 + .4byte .LASF986 .byte 0x5 .byte 0x8 .4byte 0x88 .byte 0 .uleb128 0x1 - .4byte .LASF983 + .4byte .LASF987 .byte 0x5 .byte 0x9 .4byte 0x88 .byte 0x4 .uleb128 0x1 - .4byte .LASF984 + .4byte .LASF988 .byte 0x5 .byte 0xa .4byte 0x88 .byte 0x8 .uleb128 0x1 - .4byte .LASF985 + .4byte .LASF989 .byte 0x5 .byte 0xb .4byte 0x88 @@ -535,32 +593,32 @@ usart2_start: .4byte 0x88 .byte 0x14 .uleb128 0x1 - .4byte .LASF986 + .4byte .LASF990 .byte 0x5 .byte 0xe .4byte 0x88 .byte 0x18 .uleb128 0x1 - .4byte .LASF987 + .4byte .LASF991 .byte 0x5 .byte 0xf .4byte 0x88 .byte 0x1c .uleb128 0x1 - .4byte .LASF988 + .4byte .LASF992 .byte 0x5 .byte 0x10 .4byte 0x88 .byte 0x20 .uleb128 0x1 - .4byte .LASF989 + .4byte .LASF993 .byte 0x5 .byte 0x11 .4byte 0x88 .byte 0x24 .byte 0 .uleb128 0x6 - .4byte .LASF990 + .4byte .LASF994 .byte 0x1c .byte 0x6 .byte 0x6 @@ -602,21 +660,45 @@ usart2_start: .4byte 0x88 .byte 0x14 .uleb128 0x1 - .4byte .LASF991 + .4byte .LASF995 .byte 0x6 .byte 0xd .4byte 0x88 .byte 0x18 .byte 0 + .uleb128 0xd + .4byte .LASF1001 + .byte 0x1 + .byte 0x41 + .byte 0x6 + .4byte .LFB2 + .4byte .LFE2-.LFB2 + .uleb128 0x1 + .byte 0x9c + .4byte 0x307 + .uleb128 0xe + .ascii "c\000" + .byte 0x1 + .byte 0x41 + .byte 0x1d + .4byte 0x307 + .uleb128 0x2 + .byte 0x91 + .sleb128 -9 + .byte 0 + .uleb128 0x3 + .byte 0x1 + .byte 0x8 + .4byte .LASF511 .uleb128 0x7 - .4byte .LASF992 + .4byte .LASF996 .byte 0x3d .4byte .LFB1 .4byte .LFE1-.LFB1 .uleb128 0x1 .byte 0x9c .uleb128 0x7 - .4byte .LASF993 + .4byte .LASF997 .byte 0x5 .4byte .LFB0 .4byte .LFE0-.LFB0 @@ -806,9 +888,53 @@ usart2_start: .uleb128 0xb .byte 0 .byte 0 + .uleb128 0xd + .uleb128 0x2e + .byte 0x1 + .uleb128 0x3f + .uleb128 0x19 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x39 + .uleb128 0xb + .uleb128 0x27 + .uleb128 0x19 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x6 + .uleb128 0x40 + .uleb128 0x18 + .uleb128 0x7a + .uleb128 0x19 + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0xe + .uleb128 0x5 + .byte 0 + .uleb128 0x3 + .uleb128 0x8 + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x39 + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x2 + .uleb128 0x18 + .byte 0 + .byte 0 .byte 0 .section .debug_aranges,"",%progbits - .4byte 0x24 + .4byte 0x2c .2byte 0x2 .4byte .Ldebug_info0 .byte 0x4 @@ -819,6 +945,8 @@ usart2_start: .4byte .LFE0-.LFB0 .4byte .LFB1 .4byte .LFE1-.LFB1 + .4byte .LFB2 + .4byte .LFE2-.LFB2 .4byte 0 .4byte 0 .section .debug_rnglists,"",%progbits @@ -836,6 +964,9 @@ usart2_start: .byte 0x7 .4byte .LFB1 .uleb128 .LFE1-.LFB1 + .byte 0x7 + .4byte .LFB2 + .uleb128 .LFE2-.LFB2 .byte 0 .Ldebug_ranges3: .section .debug_macro,"",%progbits @@ -3852,7 +3983,7 @@ usart2_start: .uleb128 0x38 .4byte .LASF929 .byte 0 - .section .debug_macro,"G",%progbits,wm4.usart.h.2.0debbac628af0f73f2055baa828e03f0,comdat + .section .debug_macro,"G",%progbits,wm4.usart.h.2.499ef099adc8b232d514889834b2ea6a,comdat .Ldebug_macro17: .2byte 0x5 .byte 0 @@ -3878,29 +4009,41 @@ usart2_start: .uleb128 0x1a .4byte .LASF936 .byte 0x5 - .uleb128 0x1d + .uleb128 0x1e .4byte .LASF937 .byte 0x5 - .uleb128 0x1e + .uleb128 0x1f .4byte .LASF938 .byte 0x5 - .uleb128 0x21 + .uleb128 0x22 .4byte .LASF939 .byte 0x5 - .uleb128 0x22 + .uleb128 0x23 .4byte .LASF940 .byte 0x5 - .uleb128 0x25 + .uleb128 0x26 .4byte .LASF941 .byte 0x5 - .uleb128 0x26 + .uleb128 0x27 .4byte .LASF942 .byte 0x5 - .uleb128 0x28 + .uleb128 0x2a .4byte .LASF943 .byte 0x5 - .uleb128 0x29 + .uleb128 0x2b .4byte .LASF944 + .byte 0x5 + .uleb128 0x2e + .4byte .LASF945 + .byte 0x5 + .uleb128 0x2f + .4byte .LASF946 + .byte 0x5 + .uleb128 0x31 + .4byte .LASF947 + .byte 0x5 + .uleb128 0x32 + .4byte .LASF948 .byte 0 .section .debug_line,"",%progbits .Ldebug_line0: @@ -3915,7 +4058,7 @@ usart2_start: .ascii "__UHA_FBIT__ 8\000" .LASF815: .ascii "PRIiFAST64 __PRI64FAST(i)\000" -.LASF946: +.LASF950: .ascii "unsigned char\000" .LASF225: .ascii "__FLT64_DENORM_MIN__ 4.9406564584124654e-324F64\000" @@ -3943,7 +4086,7 @@ usart2_start: .ascii "__PTRDIFF_MAX__ 0x7fffffff\000" .LASF542: .ascii "_LONG_DOUBLE long double\000" -.LASF981: +.LASF985: .ascii "gpio\000" .LASF592: .ascii "INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1)\000" @@ -3967,7 +4110,7 @@ usart2_start: .ascii "__int20__\000" .LASF901: .ascii "RCC_APB1ENR_TIM4_BIT 2\000" -.LASF944: +.LASF948: .ascii "USART_BRR_FRACTION_MASK (0b111)\000" .LASF18: .ascii "__SIZEOF_LONG_LONG__ 8\000" @@ -4010,6 +4153,8 @@ usart2_start: .ascii "PRIo16 __PRI16(o)\000" .LASF203: .ascii "__FLT32_DECIMAL_DIG__ 9\000" +.LASF379: + .ascii "__GCC_ATOMIC_LLONG_LOCK_FREE 1\000" .LASF182: .ascii "__LDBL_MIN_EXP__ (-1021)\000" .LASF180: @@ -4040,8 +4185,8 @@ usart2_start: .ascii "SCNiFAST8 __SCN8FAST(i)\000" .LASF909: .ascii "GPIOA_BASE_ADDR (0x40020000U)\000" -.LASF120: - .ascii "__UINT_LEAST16_MAX__ 0xffff\000" +.LASF791: + .ascii "__SCN64FAST(x) __FAST64 __STRINGIFY(x)\000" .LASF617: .ascii "INT_FAST16_MAX (__INT_FAST16_MAX__)\000" .LASF281: @@ -4082,7 +4227,7 @@ usart2_start: .ascii "__need_wchar_t\000" .LASF199: .ascii "__FLT32_MIN_EXP__ (-125)\000" -.LASF994: +.LASF998: .ascii "GNU C2X 12.3.1 20230626 -mcpu=cortex-m4 -mthumb -mf" .ascii "loat-abi=hard -mfpu=fpv4-sp-d16 -march=armv7e-m+fp " .ascii "-g3 -ggdb -O0 -std=c2x -ffunction-sections -fdata-s" @@ -4156,7 +4301,7 @@ usart2_start: .ascii "CC_CFGR_SW_BIT)\000" .LASF134: .ascii "__UINT_FAST8_MAX__ 0xffffffffU\000" -.LASF943: +.LASF947: .ascii "USART_BRR_FRACTION_BIT 0\000" .LASF541: .ascii "_NOTHROW \000" @@ -4182,7 +4327,7 @@ usart2_start: .ascii "__INT64 \"ll\"\000" .LASF138: .ascii "__INTPTR_MAX__ 0x7fffffff\000" -.LASF971: +.LASF975: .ascii "AHB2LPENR\000" .LASF500: .ascii "__RAND_MAX\000" @@ -4225,7 +4370,7 @@ usart2_start: .ascii " RCC_PLLCFGR_PLLP_BIT)\000" .LASF302: .ascii "__UACCUM_IBIT__ 16\000" -.LASF949: +.LASF953: .ascii "long int\000" .LASF720: .ascii "SCNd16 __SCN16(d)\000" @@ -4282,6 +4427,8 @@ usart2_start: .ascii "__ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR\000" .LASF698: .ascii "PRIiFAST8 __PRI8FAST(i)\000" +.LASF936: + .ascii "USART_SR_RXNE_READY (1 <CR1 |= (1 << 15); ((struct usart *) (0x40004400U))->BRR &= ~((0b111111111111) << 4); - ((struct usart *) (0x40004400U))->BRR |= (52 << 4); + ((struct usart *) (0x40004400U))->BRR |= (0x34 << 4); ((struct usart *) (0x40004400U))->BRR &= ~((0b111) << 0); - ((struct usart *) (0x40004400U))->BRR |= (0 << 0); + ((struct usart *) (0x40004400U))->BRR |= (0x0 << 0); ((struct usart *) (0x40004400U))->CR1 |= (1 << 3); @@ -2266,3 +2277,11 @@ void usart2_init(void) { void usart2_start(void) { ((struct usart *) (0x40004400U))->CR1 |= (1 << 13); } + +void usart2_write_byte(char c) { + + ((struct usart *) (0x40004400U))->DR = c; + + + while ((((struct usart *) (0x40004400U))->SR & (1 << 7)) == 0); +} diff --git a/build/usart.o b/build/usart.o index be35d2b..d9bad2b 100644 Binary files a/build/usart.o and b/build/usart.o differ diff --git a/src/main.c b/src/main.c index ec063ee..329baf3 100644 --- a/src/main.c +++ b/src/main.c @@ -80,7 +80,7 @@ int main(void) { (void) usart2_init(); (void) tim4_start(); - (void) tim4_start(); + (void) usart2_start(); uint16_t led = PIN('C', 13); // Blue LED RCC->AHB1ENR |= BIT(PINPORT(led)); // Enable GPIO clock for LED @@ -93,8 +93,7 @@ int main(void) { led_on = !led_on; gpio_write(led, led_on); -while ((USART2->ISR & USART_ISR_TC) != USART_ISR_TC); - USART2->TDR = '#'; + usart2_write_byte('a'); counter = TIM4->CNT; } diff --git a/src/usart.c b/src/usart.c index ba79f7f..846bc5a 100644 --- a/src/usart.c +++ b/src/usart.c @@ -49,9 +49,9 @@ void usart2_init(void) { USART2->CR1 |= USART_CR1_OVER8_8; USART2->BRR &= ~(USART_BRR_MANTISSA_MASK << USART_BRR_MANTISSA_BIT); - USART2->BRR |= (52 << USART_BRR_MANTISSA_BIT); + USART2->BRR |= (0x34 << USART_BRR_MANTISSA_BIT); USART2->BRR &= ~(USART_BRR_FRACTION_MASK << USART_BRR_FRACTION_BIT); - USART2->BRR |= (0 << USART_BRR_FRACTION_BIT); + USART2->BRR |= (0x0 << USART_BRR_FRACTION_BIT); // Enable transmitter and receiver USART2->CR1 |= USART_CR1_TE_ENABLE; @@ -61,3 +61,11 @@ void usart2_init(void) { void usart2_start(void) { USART2->CR1 |= USART_CR1_UE_ENABLE; } + +void usart2_write_byte(char c) { + // Send data + USART2->DR = c; + + // Wait indefinitely for transmission to be ready for data + while ((USART2->SR & USART_SR_TXE_TRANSMITTED) == 0); +} diff --git a/src/usart.h b/src/usart.h index 27f3408..873df4e 100644 --- a/src/usart.h +++ b/src/usart.h @@ -16,6 +16,15 @@ struct usart { #define USART2_BASE_ADDR (0x40004400U) #define USART2 ((struct usart *) USART2_BASE_ADDR) +// SR Register +// Transmission data register empty +#define USART_SR_TXE_BIT 7 +#define USART_SR_TXE_TRANSMITTED (1 << USART_SR_TXE_BIT) + +// Read data register not empty +#define USART_SR_RXNE_BIT 5 +#define USART_SR_RXNE_READY (1 <