From 7388c270069c2d1418539bca1d2789a6d468ecc2 Mon Sep 17 00:00:00 2001 From: Jacques Comeaux Date: Mon, 20 May 2024 23:19:14 -0500 Subject: Make shared object for setup routines --- hexedit/Makefile | 6 +++--- hexedit/clocks.s | 31 ------------------------------- hexedit/gpio.s | 23 ----------------------- hexedit/uart.s | 53 +---------------------------------------------------- hexedit/xosc.s | 23 ----------------------- 5 files changed, 4 insertions(+), 132 deletions(-) delete mode 100644 hexedit/clocks.s delete mode 100644 hexedit/gpio.s delete mode 100644 hexedit/xosc.s (limited to 'hexedit') diff --git a/hexedit/Makefile b/hexedit/Makefile index 23941da..2ff0812 100644 --- a/hexedit/Makefile +++ b/hexedit/Makefile @@ -5,10 +5,10 @@ build: echo.uf2 echo.uf2: echo.elf ../elf/elf2uf2 echo.elf echo.uf2 -objects = main.o xosc.o clocks.o gpio.o uart.o +objects = main.o uart.o echo.elf: $(objects) - arm-none-eabi-ld -T pico_ram_only.ld -o echo.elf $(objects) + arm-none-eabi-ld -T pico_ram_only.ld -o echo.elf $(objects) ../setup/setup.so $(objects): %.o: %.s arm-none-eabi-as -o $@ $< @@ -17,5 +17,5 @@ clean: rm echo.elf echo.uf2 *.o flash: echo.uf2 - [ -h /dev/disk/by-label/RPI-RP2 ] || sleep 2s + [ -h /dev/disk/by-label/RPI-RP2 ] || sleep 3s cat echo.uf2 > /dev/disk/by-label/RPI-RP2 diff --git a/hexedit/clocks.s b/hexedit/clocks.s deleted file mode 100644 index 83bc9ff..0000000 --- a/hexedit/clocks.s +++ /dev/null @@ -1,31 +0,0 @@ -.syntax unified -.cpu cortex-m0plus -.thumb - -.equ CLOCKS_BASE, 0x40008000 -.equ CLK_REF_CTRL_OFST, 0x30 -.equ CLK_SYS_CTRL_OFST, 0x3c -.equ CLK_PERI_CTRL_OFST, 0x48 - -.type setup_clocks, %function -.global setup_clocks - -setup_clocks: - - ldr r1, =CLOCKS_BASE - - // Reference clock - movs r0, 0x2 // src = xosc - str r0, [r1, CLK_REF_CTRL_OFST] - - // System clock - movs r0, 0x0 // src = clk_ref - str r0, [r1, CLK_SYS_CTRL_OFST] - - // Peripheral clock - movs r0, 1 // set enable - lsls r0, 11 - adds r0, 0x4 << 5 // src = xosc - str r0, [r1, CLK_PERI_CTRL_OFST] - - bx lr diff --git a/hexedit/gpio.s b/hexedit/gpio.s deleted file mode 100644 index 32e2c37..0000000 --- a/hexedit/gpio.s +++ /dev/null @@ -1,23 +0,0 @@ -.syntax unified -.cpu cortex-m0plus -.thumb - -.equ RESETS_BASE, 0x4000c000 -.equ RESET_OFST, 0x0 -.equ RESET_DONE_OFST, 0x8 - -.equ ATOMIC_CLEAR, 0x3000 - -.type setup_gpio, %function -.global setup_gpio - -setup_gpio: - ldr r1, =(RESETS_BASE + ATOMIC_CLEAR) - movs r0, 0b1 << 5 // IO_BANK0 - str r0, [r1, RESET_OFST] - ldr r1, =RESETS_BASE -1: - ldr r2, [r1, RESET_DONE_OFST] - tst r2, r0 - beq 1b - bx lr diff --git a/hexedit/uart.s b/hexedit/uart.s index 9804e53..b845c8b 100644 --- a/hexedit/uart.s +++ b/hexedit/uart.s @@ -2,60 +2,9 @@ .cpu cortex-m0plus .thumb -.equ RESETS_BASE, 0x4000c000 -.equ RESET_OFST, 0x0 -.equ RESET_DONE_OFST, 0x8 - -.equ IO_BANK0_BASE, 0x40014000 -.equ GPIO0_CTRL_OFST, 0x04 -.equ GPIO1_CTRL_OFST, 0x0c - .equ UART0_BASE, 0x40034000 .equ UARTDR_OFST, 0x00 .equ UARTFR_OFST, 0x18 -.equ UARTIBRD_OFST, 0x24 -.equ UARTFBRD_OFST, 0x28 -.equ UARTLCR_H_OFST, 0x2c -.equ UARTCR_OFST, 0x30 - -.equ ATOMIC_SET, 0x2000 -.equ ATOMIC_CLEAR, 0x3000 - -.type setup_uart, %function -.global setup_uart - -setup_uart: - - // Deassert reset - ldr r1, =(RESETS_BASE + ATOMIC_CLEAR) - movs r0, 0b1 // UART0 - lsls r0, 22 - str r0, [r1, RESET_OFST] - ldr r1, =RESETS_BASE -1: - ldr r2, [r1, RESET_DONE_OFST] - tst r2, r0 - beq 1b - - // Configure and enable - ldr r1, =UART0_BASE - movs r0, 6 - str r0, [r1, UARTIBRD_OFST] - movs r0, 33 - str r0, [r1, UARTFBRD_OFST] - movs r0, 0b111 << 4 // 0b11 = word len 8 bits, 0b1 = FIFO enabled - str r0, [r1, UARTLCR_H_OFST] - ldr r1, =(UART0_BASE + ATOMIC_SET) - movs r0, 0b1 // UART enable - str r0, [r1, UARTCR_OFST] - - // Configure GPIO 0 and 1 as TX and RX - ldr r1, =IO_BANK0_BASE - movs r0, 2 // UART function - str r0, [r1, GPIO0_CTRL_OFST] - str r0, [r1, GPIO1_CTRL_OFST] - - bx lr .type uart_send, %function .global uart_send @@ -104,7 +53,7 @@ send_hex: adds r0, '0 b 2f 1: - adds r0, 'A - 0xA + adds r0, ('A - 0xA) 2: bl uart_send subs r5, 1 diff --git a/hexedit/xosc.s b/hexedit/xosc.s deleted file mode 100644 index 63760da..0000000 --- a/hexedit/xosc.s +++ /dev/null @@ -1,23 +0,0 @@ -.syntax unified -.cpu cortex-m0plus -.thumb - -.equ XOSC_BASE, 0x40024000 -.equ CTRL_OFST, 0x0 -.equ STATUS_OFST, 0x4 -.equ STARTUP_OFST, 0xc - -.type start_xosc, %function -.global start_xosc - -start_xosc: - ldr r1, =XOSC_BASE - movs r0, 47 // startup delay for 12Mhz crystal - str r0, [r1, STARTUP_OFST] - ldr r0, =0x00fabaa0 // enable - str r0, [r1, CTRL_OFST] -1: - ldr r0, [r1, STATUS_OFST] - lsrs r0, 31 // stable bit - beq 1b - bx lr -- cgit v1.2.3