Skip to content

Commit

Permalink
As we will always be using the fullTimerHardware, we just need to con…
Browse files Browse the repository at this point in the history
…figure the pin mapping.

This is done in the config.h as

#define TIMER_PIN_MAPPING   \
    TIMER_PIN_MAP(0, PA0, 1, 0) \
    TIMER_PIN_MAP(0, PA1, 1, 0)

timerHardware[] dependencies to be removed in another PR
  • Loading branch information
blckmn committed Feb 10, 2023
1 parent f6d5cea commit 995b7c7
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions src/main/pg/timerio.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,15 @@

#include "timerio.h"

#define TIMER_PIN_MAP(idx, pin, pos, dmaOpt) \
{ config[idx].ioTag = IO_TAG(pin); config[idx].index = pos; config[idx].dmaopt = dmaOpt; }

PG_REGISTER_ARRAY_WITH_RESET_FN(timerIOConfig_t, MAX_TIMER_PINMAP_COUNT, timerIOConfig, PG_TIMER_IO_CONFIG, 0);

void pgResetFn_timerIOConfig(timerIOConfig_t *config)
{
#if defined(USE_TIMER_MGMT) && USABLE_TIMER_CHANNEL_COUNT > 0
unsigned configIndex = 0;
for (unsigned timerIndex = 0; timerIndex < USABLE_TIMER_CHANNEL_COUNT; timerIndex++) {
const timerHardware_t *configuredTimer = &timerHardware[timerIndex];
unsigned positionIndex = 1;
for (unsigned fullTimerIndex = 0; fullTimerIndex < FULL_TIMER_CHANNEL_COUNT; fullTimerIndex++) {
const timerHardware_t *timer = &fullTimerHardware[fullTimerIndex];
if (timer->tag == configuredTimer->tag) {
if (timer->tim == configuredTimer->tim && timer->channel == configuredTimer->channel) {
config[configIndex].ioTag = timer->tag;
config[configIndex].index = positionIndex;

config[configIndex].dmaopt = dmaGetOptionByTimer(configuredTimer);

configIndex++;

break;
} else {
positionIndex++;
}
}
}
}
#ifdef TIMER_PIN_MAPPING
TIMER_PIN_MAPPING
#else
UNUSED(config);
#endif
Expand Down

0 comments on commit 995b7c7

Please sign in to comment.