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:
parent
c267327975
commit
caaf7837a5
|
@ -59,12 +59,12 @@ static void swdptap_turnaround(const swdio_status_t dir)
|
||||||
SWDIO_MODE_DRIVE();
|
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(const 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)
|
||||||
{
|
{
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
while (clock_cycles--) {
|
for (size_t cycle = 0; cycle < clock_cycles; ++cycle) {
|
||||||
if (gpio_get(SWDIO_PORT, SWDIO_PIN))
|
if (gpio_get(SWDIO_PORT, SWDIO_PIN))
|
||||||
value |= (1U << index);
|
value |= (1U << index);
|
||||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||||
|
@ -78,12 +78,12 @@ static uint32_t swdptap_seq_in_swd_delay(size_t clock_cycles)
|
||||||
return value;
|
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(const 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)
|
||||||
{
|
{
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
while (clock_cycles--) {
|
for (size_t cycle = 0; cycle < clock_cycles; ++cycle) {
|
||||||
if (gpio_get(SWDIO_PORT, SWDIO_PIN))
|
if (gpio_get(SWDIO_PORT, SWDIO_PIN))
|
||||||
value |= (1U << index);
|
value |= (1U << index);
|
||||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||||
|
|
Loading…
Reference in New Issue