swdptap: Made the cycle code a little easier to reason about

This doesn't actually change the resulting binary size, so worth doing
This commit is contained in:
dragonmux 2022-07-16 02:45:25 +01:00 committed by Piotr Esden-Tempski
parent c267327975
commit caaf7837a5
1 changed files with 6 additions and 6 deletions

View File

@ -59,12 +59,12 @@ static void swdptap_turnaround(const swdio_status_t dir)
SWDIO_MODE_DRIVE();
}
static uint32_t swdptap_seq_in_swd_delay(size_t clock_cycles) __attribute__((optimize(3)));
static uint32_t swdptap_seq_in_swd_delay(size_t clock_cycles)
static uint32_t swdptap_seq_in_swd_delay(const size_t clock_cycles) __attribute__((optimize(3)));
static uint32_t swdptap_seq_in_swd_delay(const size_t clock_cycles)
{
size_t index = 0;
uint32_t value = 0;
while (clock_cycles--) {
for (size_t cycle = 0; cycle < clock_cycles; ++cycle) {
if (gpio_get(SWDIO_PORT, SWDIO_PIN))
value |= (1U << index);
gpio_set(SWCLK_PORT, SWCLK_PIN);
@ -78,12 +78,12 @@ static uint32_t swdptap_seq_in_swd_delay(size_t clock_cycles)
return value;
}
static uint32_t swdptap_seq_in_no_delay(size_t clock_cycles) __attribute__((optimize(3)));
static uint32_t swdptap_seq_in_no_delay(size_t clock_cycles)
static uint32_t swdptap_seq_in_no_delay(const size_t clock_cycles) __attribute__((optimize(3)));
static uint32_t swdptap_seq_in_no_delay(const size_t clock_cycles)
{
size_t index = 0;
uint32_t value = 0;
while (clock_cycles--) {
for (size_t cycle = 0; cycle < clock_cycles; ++cycle) {
if (gpio_get(SWDIO_PORT, SWDIO_PIN))
value |= (1U << index);
gpio_set(SWCLK_PORT, SWCLK_PIN);