c code refactor
This commit is contained in:
parent
76ba80db36
commit
180f2ef624
14 changed files with 369 additions and 130 deletions
|
@ -20,34 +20,48 @@
|
|||
#define CRCTASKCOUNT 2
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
DMAINFO dmaInfo;
|
||||
volatile uint8_t activeSlot;
|
||||
struct crctask_t {
|
||||
void *address;
|
||||
uint16_t wordCount;
|
||||
void (*callback)(void*, uint32_t, uint8_t);
|
||||
void *callbackParam;
|
||||
} volatile crcTasks[CRCTASKCOUNT];
|
||||
} CRCSTATUS;
|
||||
struct crcslottask_t {
|
||||
void *address;
|
||||
uint16_t wordCount;
|
||||
void (*callback)(void*, uint32_t, uint8_t);
|
||||
void *callbackParam;
|
||||
};
|
||||
|
||||
void InitCrcStatus(CRCSTATUS *status, DMA_TypeDef *dma, uint32_t stream);
|
||||
static inline uint8_t GetActiveSlot(CRCSTATUS *status) {
|
||||
return status->activeSlot;
|
||||
struct crcslotlistitem_t {
|
||||
uint16_t count;
|
||||
struct crcslotlistitem_t *next;
|
||||
struct crcslottask_t *tasks;
|
||||
};
|
||||
|
||||
struct crcstatus_t {
|
||||
DMAINFO dmaInfo;
|
||||
volatile struct crcslotlistitem_t *activeSlot;
|
||||
volatile uint8_t activeTask;
|
||||
|
||||
struct crcslotlistitem_t *first;
|
||||
};
|
||||
|
||||
void InitCrcStatus(struct crcstatus_t *status, DMA_TypeDef *dma, uint32_t stream);
|
||||
|
||||
uint8_t GetActiveSlot(struct crcslotlistitem_t **slot_out, struct crcstatus_t *status);
|
||||
|
||||
static inline uint8_t IsSlotQueued(struct crcslotlistitem_t *slot, uint8_t task) {
|
||||
return slot->tasks[task].address != NULL;
|
||||
}
|
||||
static inline uint8_t IsSlotQueued(CRCSTATUS *status, uint8_t slot) {
|
||||
return status->crcTasks[slot].address != NULL;
|
||||
|
||||
static inline uint8_t IsSlotActive(struct crcslotlistitem_t *slot, uint8_t task) {
|
||||
return slot->tasks[task].callback != NULL || slot->tasks[task].callbackParam != NULL;
|
||||
}
|
||||
static inline uint8_t IsSlotActive(CRCSTATUS *status, uint8_t slot) {
|
||||
return status->crcTasks[slot].callback != NULL || status->crcTasks[slot].callbackParam != NULL;
|
||||
}
|
||||
uint8_t EnqueueCrcTask(CRCSTATUS *crcStatus, uint8_t slot, uint8_t *address, uint16_t len,
|
||||
void (*callback)(void*, uint32_t, uint8_t), void* callbackParam);
|
||||
void WaitCrcResults(CRCSTATUS *status, uint8_t slot);
|
||||
uint32_t ComputeCrc(CRCSTATUS *status, uint8_t slot, uint8_t *address, uint16_t len);
|
||||
void ComputeCrcAsync(CRCSTATUS *status, uint8_t slot,
|
||||
|
||||
void AttachCrcTask(struct crcstatus_t *status, struct crcslotlistitem_t *slot, struct crcslottask_t *tasks, uint8_t taskCount);
|
||||
|
||||
uint8_t EnqueueCrcTask(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 WaitCrcResults(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task);
|
||||
uint32_t ComputeCrc(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task, uint8_t *address, uint16_t len);
|
||||
void ComputeCrcAsync(struct crcstatus_t *status, uint8_t slot,
|
||||
uint8_t *address, uint16_t len,
|
||||
void (*callback)(void*, uint32_t, uint8_t), void* callbackParam);
|
||||
void HandleCrcDmaIrq(CRCSTATUS *status);
|
||||
void HandleCrcDmaIrq(struct crcstatus_t *status);
|
||||
|
||||
#endif /* CRC_HANDLER_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue