Add USART support #1

Merged
alex merged 17 commits from uart into main 2025-01-01 12:52:15 +01:00
5 changed files with 9 additions and 9 deletions
Showing only changes of commit 2a1e3a41da - Show all commits

Binary file not shown.

View File

@@ -61,11 +61,11 @@ gpio_set_mode:
.loc 1 9 7
ldr r3, [r7, #12]
ldr r3, [r3]
.loc 1 9 34
.loc 1 9 32
ldr r2, [r7, #8]
lsls r2, r2, #1
.loc 1 9 27
movs r1, #17
.loc 1 9 25
movs r1, #3
lsl r2, r1, r2
.loc 1 9 18
mvns r2, r2
@@ -79,10 +79,10 @@ gpio_set_mode:
.loc 1 10 24
ldrb r2, [r7, #5] @ zero_extendqisi2
and r1, r2, #3
.loc 1 10 40
.loc 1 10 39
ldr r2, [r7, #8]
lsls r2, r2, #1
.loc 1 10 33
.loc 1 10 32
lsl r2, r1, r2
.loc 1 10 15
orrs r2, r2, r3

View File

@@ -2028,8 +2028,8 @@ void gpio_write(uint16_t pin,
void gpio_set_mode(uint16_t pin, GPIO_MODE mode) {
struct gpio *gpio = ((struct gpio*)(uintptr_t)((0x40020000U) + ((0x400U) * (pin >> 8))));
int pn = (pin & 0b1111);
gpio->MODER &= ~(0x0011 << (pn * 2));
gpio->MODER |= (mode & 0b011) << (pn * 2);
gpio->MODER &= ~(0b11 << (pn * 2));
gpio->MODER |= (mode & 0b11) << (pn * 2);
}
void gpio_write(uint16_t pin,

Binary file not shown.

View File

@@ -6,8 +6,8 @@
void gpio_set_mode(uint16_t pin, GPIO_MODE mode) {
struct gpio *gpio = GPIO(PINPORT(pin)); // GPIO port address
int pn = PINNUM(pin); // Pin number
gpio->MODER &= ~(0x0011 << (pn * 2)); // Clear existing setting. Each pin uses 2 bits
gpio->MODER |= (mode & 0b011) << (pn * 2); // Set new mode. Each pin uses 2 bits
gpio->MODER &= ~(0b11 << (pn * 2)); // Clear existing setting. Each pin uses 2 bits
gpio->MODER |= (mode & 0b11) << (pn * 2); // Set new mode. Each pin uses 2 bits
}
void gpio_write(uint16_t pin, bool val) {