Skip to content

Intra-library class instantiations #341

@adamgarbo

Description

@adamgarbo

Hi folks,

When @oclyke rewrote the RTC library for v.2.0.x, he adopted an approach of instantiating the RTC class from directly within the library:

extern Apollo3RTC RTC;

I've rewritten the WDT library for v2.0.x, however, if I instantiate the class using extern Apollo3WDT WDT;, there are conflicts when writing directly to the WDT registers. Two examples of such functions are shown below:

// Set number of watchdog timer ticks allowed before a watchdog interrupt event is generated
void Apollo3WDT::setInterrupt(uint8_t interrupt)
{
  WDT->CFG_b.INTVAL = interrupt;   
}

// Set number of watchdog timer ticks allowed before the watchdog will issue a system reset
void Apollo3WDT::setReset(uint8_t reset)
{
  WDT->CFG_b.RESVAL = reset; 
}

Is there a particular reason for instantiating the class from within the library? I'm unfamiliar if this is a standard Mbed OS approach.

One solution could be to simply rename the instantiated object to "wdt" instead of "WDT", but then I'd likely also want to rename "RTC" to "rtc" to have greater consistency on the Core.

Cheers,
Adam

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions