enhancement/39-digio-cmd-profile-language #44

Merged
mhu merged 5 commits from enhancement/39-digio-cmd-profile-language into dev 2021-12-26 21:20:15 +01:00
Showing only changes of commit 3bb4607798 - Show all commits

View File

@ -67,12 +67,22 @@ void digio_setup_pin(uint8_t num, uint8_t in_out, uint8_t alt_func)
void digio_set(uint8_t num, int val) void digio_set(uint8_t num, int val)
{ {
uint8_t pin;
if (num >= COUNT_OF(digio_pins)) if (num >= COUNT_OF(digio_pins))
return; return;
pin = digio_pins[num];
/* Check if port is an output. If not, do noting. */
if ((DIGIO_PORT->MODER & (0x3<<pin)) != OUTPUT(pin)) {
return;
}
if (val) if (val)
DIGIO_PORT->ODR |= (1<<digio_pins[num]); DIGIO_PORT->ODR |= (1<<pin);
else else
DIGIO_PORT->ODR &= ~(1<<digio_pins[num]); DIGIO_PORT->ODR &= ~(1<<pin);
} }
int digio_get(uint8_t num) int digio_get(uint8_t num)