Skip to content

Commit

Permalink
Moves the interrupt operations to the TivaRailcomDriver from RailcomD…
Browse files Browse the repository at this point in the history
…riverBase. (#699)

This is needed to refactor the base class to be non tivaware-specific.
  • Loading branch information
balazsracz authored Mar 6, 2023
1 parent 465b36a commit 95f15f2
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/freertos_drivers/ti/TivaRailcom.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,17 @@ public:
, readableNotifiable_(nullptr)
{
HW::hw_init();
MAP_IntPrioritySet(HW::OS_INTERRUPT, configKERNEL_INTERRUPT_PRIORITY);
MAP_IntEnable(HW::OS_INTERRUPT);
}

~RailcomDriverBase()
{
MAP_IntDisable(HW::OS_INTERRUPT);
}

private:
/// Sets a given software interrupt pending.
/// @param int_nr interrupt number (will be HW::OS_INTERRUPT)
virtual void int_set_pending(unsigned int_nr) = 0;

ssize_t write(File *, const void *, size_t) OVERRIDE
{
// This device is read-only.
Expand Down Expand Up @@ -271,7 +272,7 @@ protected:
uint32_t tick_timer = HW::get_timer_tick();
memcpy(feedbackQueue_.back().ch2Data, &tick_timer, 4);
feedbackQueue_.increment_back();
MAP_IntPendSet(HW::OS_INTERRUPT);
int_set_pending(HW::OS_INTERRUPT);
}

/** Notify this when we have data in our buffers. */
Expand All @@ -294,15 +295,31 @@ template <class HW> class TivaRailcomDriver : public RailcomDriverBase<HW>
{
public:
/// Constructor. @param path is the device node path (e.g. "/dev/railcom0").
TivaRailcomDriver(const char *path) : RailcomDriverBase<HW>(path)
TivaRailcomDriver(const char *path)
: RailcomDriverBase<HW>(path)
{
MAP_IntPrioritySet(HW::OS_INTERRUPT, configKERNEL_INTERRUPT_PRIORITY);
MAP_IntEnable(HW::OS_INTERRUPT);
}

~TivaRailcomDriver()
{
MAP_IntDisable(HW::OS_INTERRUPT);
}

private:
/// True when we are currently within a cutout.
bool inCutout_ = false;

using RailcomDriverBase<HW>::returnedPackets_;

/// Sets a given software interrupt pending.
/// @param int_nr interrupt number (will be HW::OS_INTERRUPT)
void int_set_pending(unsigned int_nr) override
{
MAP_IntPendSet(int_nr);
}

// File node interface
void enable() OVERRIDE
{
Expand Down

0 comments on commit 95f15f2

Please sign in to comment.