New solution for CRC generator slots
This commit is contained in:
parent
9670e6d397
commit
9dba241466
4 changed files with 55 additions and 54 deletions
|
@ -27,44 +27,46 @@ public:
|
|||
virtual void CrcFailed(uintptr_t callbackParam, uint32_t crc, int prio) = 0;
|
||||
};
|
||||
|
||||
class Slot
|
||||
class SlotBase
|
||||
{
|
||||
friend class LL_CrcHandler;
|
||||
public:
|
||||
struct CrcTask {
|
||||
void const * volatile m_address; // changed to nullptr when execution starts
|
||||
uint16_t volatile m_wordCount;
|
||||
void const * volatile m_address; // changed to nullptr when execution starts
|
||||
uint16_t volatile m_wordCount;
|
||||
LL_CrcHandler::ICallback *m_callback;
|
||||
uintptr_t m_callbackParam;
|
||||
};
|
||||
|
||||
private:
|
||||
Slot *m_next = nullptr;
|
||||
SlotBase *m_next = nullptr;
|
||||
uint8_t m_taskCount;
|
||||
CrcTask m_tasks[1];
|
||||
virtual CrcTask& operator[](int index) = 0;
|
||||
|
||||
protected:
|
||||
Slot(unsigned int taskCount) : m_taskCount(taskCount) {}
|
||||
Slot() = delete;
|
||||
Slot(Slot const &other) = delete;
|
||||
SlotBase(unsigned int taskCount) : m_taskCount(taskCount) {}
|
||||
SlotBase() = delete;
|
||||
SlotBase(SlotBase const &other) = delete;
|
||||
};
|
||||
|
||||
// DON't try this at home! we "extend" LL_CrcHandler::m_tasks this way
|
||||
template <uint8_t n> class TSlot : public Slot
|
||||
template <uint8_t n> class Slot : public SlotBase
|
||||
{
|
||||
public:
|
||||
TSlot() : Slot(n) {}
|
||||
Slot() : SlotBase(n) {}
|
||||
virtual CrcTask& operator[](int index) { return m_tasks[index]; }
|
||||
|
||||
private:
|
||||
TSlot::CrcTask _m_tasks[n-1];
|
||||
Slot::CrcTask m_tasks[n];
|
||||
};
|
||||
|
||||
void AttachSlot(Slot &slot);
|
||||
bool Enqueue(Slot &slot, uint8_t prio, void const *address, uint16_t len, ICallback *cb, uintptr_t cbParam);
|
||||
uint32_t Compute(Slot &slot, uint8_t prio, void const *address, uint16_t len);
|
||||
void AttachSlot(SlotBase &slot);
|
||||
bool Enqueue(SlotBase &slot, uint8_t prio, void const *address, uint16_t len, ICallback *cb, uintptr_t cbParam);
|
||||
uint32_t Compute(SlotBase &slot, uint8_t prio, void const *address, uint16_t len);
|
||||
|
||||
bool IsActive(Slot &slot, uint8_t prio) const;
|
||||
bool IsQueued(Slot &slot, uint8_t prio) const;
|
||||
bool IsRunning(Slot &slot, uint8_t prio) const;
|
||||
bool IsActive(SlotBase &slot, uint8_t prio) const;
|
||||
bool IsQueued(SlotBase &slot, uint8_t prio) const;
|
||||
bool IsRunning(SlotBase &slot, uint8_t prio) const;
|
||||
|
||||
|
||||
private:
|
||||
|
@ -73,11 +75,11 @@ private:
|
|||
friend void ::_HandleCrcDmaIrq(void);
|
||||
void DmaTransferCompleted(void);
|
||||
void StartNextTask(void);
|
||||
void WaitResults(Slot &slot, uint8_t prio) const;
|
||||
void WaitResults(SlotBase &slot, uint8_t prio) const;
|
||||
|
||||
LL_DmaHelper m_dma;
|
||||
Slot * volatile m_firstSlot = nullptr;
|
||||
Slot * volatile m_activeSlot = nullptr;
|
||||
SlotBase * volatile m_firstSlot = nullptr;
|
||||
SlotBase * volatile m_activeSlot = nullptr;
|
||||
int volatile m_activePrio;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue