f4ll_c/crcscheduler.h
2019-11-20 21:13:52 +01:00

62 lines
1.9 KiB
C

/*
* interrupt.h
*
* Created on: Aug 29, 2019
* Author: abody
*/
#ifndef CRC_HANDLER_H_
#define CRC_HANDLER_H_
#include <inttypes.h>
#ifdef HAVE_CONFIG
#include "config.h"
#endif // HAVE_CONFIG
#include <f4ll_c/dmahelper.h>
struct crcslottask_t {
void * volatile address;
uint16_t wordCount;
void (*callback)(void*, uint32_t, uint8_t);
void *callbackParam;
};
struct crcslotlistitem_t {
uint16_t count;
struct crcslotlistitem_t *next;
struct crcslottask_t *tasks;
};
struct crcstatus_t {
DMAINFO dmaInfo;
struct crcslotlistitem_t *activeSlot;
uint8_t activeTask;
struct crcslotlistitem_t *first;
};
void Crc_InitStatus(struct crcstatus_t *status, DMA_TypeDef *dma, uint32_t stream);
uint8_t Crc_GetActiveTask(struct crcslotlistitem_t **slot_out, struct crcstatus_t volatile *status);
static inline uint8_t Crc_IsSlotQueued(struct crcslotlistitem_t volatile *slot, uint8_t task) {
return slot->tasks[task].address != NULL;
}
static inline uint8_t Crc_IsSlotActive(struct crcslotlistitem_t volatile *slot, uint8_t task) {
return slot->tasks[task].callback != NULL || slot->tasks[task].callbackParam != NULL;
}
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);
void Crc_WaitResults(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task);
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 Crc_HandleDmaIrq(struct crcstatus_t *status);
#endif /* CRC_HANDLER_H_ */