rework #4

Merged
Steins7 merged 88 commits from rework into dev 2024-04-20 18:20:23 +00:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 0034dea774 - Show all commits

View File

@ -36,7 +36,7 @@ void gpio_configure(enum GpioPort port, enum GpioPin pin_mask,
rcc_enable(RCC_AHB_NONE, RCC_APB1_NONE, RCC_APB2_IOPA << port); rcc_enable(RCC_AHB_NONE, RCC_APB1_NONE, RCC_APB2_IOPA << port);
//reset outputs before configuring anything //reset outputs before configuring anything
regs->PORTS[port].BRR.word |= pin_mask; regs->PORTS[port].BRR.word = pin_mask;
//clear config for selected port, then apply new config, 8 first pins //clear config for selected port, then apply new config, 8 first pins
uint32_t mask = 0; uint32_t mask = 0;
@ -72,9 +72,9 @@ void gpio_reset(enum GpioPort port, enum GpioPin pin_mask)
void gpio_write(enum GpioPort port, enum GpioPin pin_mask, bool value) void gpio_write(enum GpioPort port, enum GpioPin pin_mask, bool value)
{ {
if (value) { if (value) {
regs->PORTS[port].BSRR.word |= pin_mask; regs->PORTS[port].BSRR.word = pin_mask;
} else { } else {
regs->PORTS[port].BRR.word |= pin_mask; regs->PORTS[port].BRR.word = pin_mask;
} }
} }

View File

@ -101,7 +101,8 @@ void gpio_reset(enum GpioPort port, enum GpioPin pin_mask);
/** /**
* Write a value to output gpios on a single port. The GpioPin enum can be used * Write a value to output gpios on a single port. The GpioPin enum can be used
* as mask to reset multiple pins at the same time. In push-pull input mode, * as mask to reset multiple pins at the same time. In push-pull input mode,
* configure the pull up/down. Has no effect otherwise * configure the pull up/down. Has no effect otherwise. Writes are atomic
* operations
*/ */
void gpio_write(enum GpioPort port, enum GpioPin pin_mask, bool value); void gpio_write(enum GpioPort port, enum GpioPin pin_mask, bool value);