packetusart unit tests

This commit is contained in:
Attila Body 2019-12-04 15:57:18 +01:00
parent c2f84b23ee
commit 5d26fdc64d
8 changed files with 219 additions and 151 deletions

View file

@ -46,29 +46,36 @@ void Crc_InitStatus(struct crcstatus_t *status, CRC_TypeDef *crcUnit, DMA_TypeDe
uint8_t Crc_GetActiveTask(struct crcslotlistitem_t **slot_out, struct crcstatus_t volatile *status);
static inline uint8_t Crc_IsSlotQueued(struct crcslotlistitem_t *slot, uint8_t task) {
return ((struct crcslottask_t volatile)slot->tasks[task]).address != NULL;
}
uint8_t Crc_IsSlotQueued(struct crcslotlistitem_t *slot, uint8_t task);
static inline uint8_t Crc_IsSlotBusy(struct crcslotlistitem_t *slot, uint8_t task) {
struct crcslottask_t volatile *taskPtr = &slot->tasks[task];
return taskPtr->callback != NULL || taskPtr->callbackParam != NULL;
}
uint8_t Crc_IsSlotBusy(struct crcslotlistitem_t *slot, uint8_t task);
static inline void Crc_WaitResults(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task) {
while(Crc_IsSlotBusy(slot, task));
}
void Crc_WaitResults(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task);
void Crc_AttachTask(struct crcstatus_t *status, struct crcslotlistitem_t *slot, struct crcslottask_t *tasks, uint8_t taskCount);
uint8_t Crc_Enqueue(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task,
uint8_t *address, uint16_t len, void (*callback)(void*, uint32_t, uint8_t), void* callbackParam);
uint32_t Crc_Compute(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task, uint8_t *address, uint16_t len);
void Crc_ComputeAsync(struct crcstatus_t *status, uint8_t slot,
uint8_t *address, uint16_t len,
void (*callback)(void*, uint32_t, uint8_t), void* callbackParam);
void *address, uint16_t len, void (*callback)(void*, uint32_t, uint8_t), void* callbackParam);
uint32_t Crc_Compute(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task, void *address, uint16_t len);
void Crc_HandleDmaIrq(struct crcstatus_t *status);
// !!!PRIVATE!!! exposed only to make mocking possible
void Crc_StartNextTask(struct crcstatus_t *status);
#ifdef UNITTEST
DECLARE_MOCK(Crc_InitStatus);
DECLARE_MOCK(Crc_GetActiveTask);
DECLARE_MOCK(Crc_IsSlotQueued);
DECLARE_MOCK(Crc_IsSlotBusy);
DECLARE_MOCK(Crc_WaitResults);
DECLARE_MOCK(Crc_AttachTask);
DECLARE_MOCK(Crc_Enqueue);
DECLARE_MOCK(Crc_Compute);
DECLARE_MOCK(Crc_HandleDmaIrq);
DECLARE_MOCK(Crc_StartNextTask);
#endif // UNITTEST
#ifdef __cplusplus
}
#endif