fweiss / tm4c-led-pwm

Simple exploration of tm4c123g using PIO and C++
0 stars 0 forks source link

inaccessible base class in PWTimer #3

Open fweiss opened 2 months ago

fweiss commented 2 months ago

In PWTimer the Register class is used as a base class twice. Getting a compiler warning, but maybe only in env:asm-listing.

The full compiler warning is:

include/timers.h:88:8: warning: direct base 'Register' inaccessible in 'PWMTimer<(TimerBlockIndex)1, (TimerIndex)1>' due to ambiguity [enabled by default]
 struct PWMTimer : Timer<timerBlockIndex, timerIndex>, Register {

Solution may be:


// #pragma warning(suppress: 4250) // inherits via dominance
#pragma GCC diagnostic ignored "-Winaccessible-base"
struct PWTimer
fweiss commented 1 month ago

The intention of subclassing PWMTimer from Timer is to interpret the GPTMTBILR and GPTMTBPR as a single 24-bit value. Although Register is inherited in Timer, if it's left out of the PWMTimer declaration, the compiler then complains with error:

include/timers.h:92:5: error: 'RegisterSpan' does not name a type
     RegisterSpan<R.GPTMTBILR, 16, R.GPTMTBPR, 8> pwmInterval;

So there are two puzzles here: