git subrepo pull components/f4ll_c
subrepo: subdir: "components/f4ll_c" merged: "5d26fdc" upstream: origin: "git@git.pcmuhely.hu:compi/f4ll_c.git" branch: "master" commit: "5d26fdc" git-subrepo: version: "0.4.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "5d6aba9"
This commit is contained in:
parent
357b30b344
commit
b9114f049a
10 changed files with 243 additions and 189 deletions
|
@ -27,13 +27,14 @@
|
|||
# define DIAG_INTERRUPT_OUT()
|
||||
#endif
|
||||
|
||||
#ifdef UNITTEST
|
||||
#define STATIC_MOCKME
|
||||
#else
|
||||
#define STATIC_MOCKME static
|
||||
#ifndef MOCKABLE
|
||||
#define MOCKABLE(x) x
|
||||
#endif
|
||||
|
||||
void Crc_InitStatus(struct crcstatus_t *st, CRC_TypeDef *crcUnit, DMA_TypeDef *dma, uint32_t stream)
|
||||
void Crc_StartNextTask(struct crcstatus_t *status);
|
||||
|
||||
|
||||
void MOCKABLE(Crc_InitStatus)(struct crcstatus_t *st, CRC_TypeDef *crcUnit, DMA_TypeDef *dma, uint32_t stream)
|
||||
{
|
||||
st->crcUnit = crcUnit;
|
||||
Dma_Init(&st->dmaInfo, dma, stream);
|
||||
|
@ -44,7 +45,8 @@ void Crc_InitStatus(struct crcstatus_t *st, CRC_TypeDef *crcUnit, DMA_TypeDef *d
|
|||
st->firstSlot = NULL;
|
||||
}
|
||||
|
||||
void Crc_AttachTask(struct crcstatus_t *status, struct crcslotlistitem_t *slot, struct crcslottask_t *tasks, uint8_t taskCount)
|
||||
|
||||
void MOCKABLE(Crc_AttachTask)(struct crcstatus_t *status, struct crcslotlistitem_t *slot, struct crcslottask_t *tasks, uint8_t taskCount)
|
||||
{
|
||||
slot->count = taskCount;
|
||||
slot->tasks = tasks;
|
||||
|
@ -57,7 +59,8 @@ void Crc_AttachTask(struct crcstatus_t *status, struct crcslotlistitem_t *slot,
|
|||
__set_PRIMASK(prim);
|
||||
}
|
||||
|
||||
uint8_t Crc_GetActiveTask(struct crcslotlistitem_t **slot_out, struct crcstatus_t volatile *status)
|
||||
|
||||
uint8_t MOCKABLE(Crc_GetActiveTask)(struct crcslotlistitem_t **slot_out, struct crcstatus_t volatile *status)
|
||||
{
|
||||
uint8_t ret;
|
||||
|
||||
|
@ -72,8 +75,24 @@ uint8_t Crc_GetActiveTask(struct crcslotlistitem_t **slot_out, struct crcstatus_
|
|||
}
|
||||
|
||||
|
||||
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)
|
||||
uint8_t MOCKABLE(Crc_IsSlotQueued)(struct crcslotlistitem_t *slot, uint8_t task) {
|
||||
return ((struct crcslottask_t volatile)slot->tasks[task]).address != NULL;
|
||||
}
|
||||
|
||||
|
||||
uint8_t MOCKABLE(Crc_IsSlotBusy)(struct crcslotlistitem_t *slot, uint8_t task) {
|
||||
struct crcslottask_t volatile *taskPtr = &slot->tasks[task];
|
||||
return taskPtr->callback != NULL || taskPtr->callbackParam != NULL;
|
||||
}
|
||||
|
||||
|
||||
void MOCKABLE(Crc_WaitResults)(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task) {
|
||||
while(Crc_IsSlotBusy(slot, task));
|
||||
}
|
||||
|
||||
|
||||
uint8_t MOCKABLE(Crc_Enqueue)(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task,
|
||||
void *address, uint16_t len, void (*callback)(void*, uint32_t, uint8_t), void* callbackParam)
|
||||
{
|
||||
uint32_t prim = __get_PRIMASK();
|
||||
uint16_t need_start;
|
||||
|
@ -93,6 +112,7 @@ uint8_t Crc_Enqueue(struct crcstatus_t *status, struct crcslotlistitem_t *slot,
|
|||
__set_PRIMASK(prim);
|
||||
|
||||
if(need_start) {
|
||||
DIAG_CRC_CALC_START();
|
||||
status->crcUnit->CR = 1;
|
||||
LL_DMA_SetM2MSrcAddress(status->dmaInfo.dma, status->dmaInfo.stream, (uint32_t)address);
|
||||
LL_DMA_SetDataLength(status->dmaInfo.dma, status->dmaInfo.stream, (len+3)/4);
|
||||
|
@ -102,7 +122,8 @@ uint8_t Crc_Enqueue(struct crcstatus_t *status, struct crcslotlistitem_t *slot,
|
|||
return need_start;
|
||||
}
|
||||
|
||||
uint32_t Crc_Compute(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task, uint8_t *address, uint16_t len)
|
||||
|
||||
uint32_t MOCKABLE(Crc_Compute)(struct crcstatus_t *status, struct crcslotlistitem_t *slot, uint8_t task, void *address, uint16_t len)
|
||||
{
|
||||
uint32_t result;
|
||||
Crc_Enqueue(status, slot, task, address, len, NULL, &result);
|
||||
|
@ -110,8 +131,9 @@ uint32_t Crc_Compute(struct crcstatus_t *status, struct crcslotlistitem_t *slot,
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
// only called from ISR context
|
||||
STATIC_MOCKME void Crc_StartNextTask(struct crcstatus_t *status)
|
||||
void MOCKABLE(Crc_StartNextTask)(struct crcstatus_t *status)
|
||||
{
|
||||
char moreTasks;
|
||||
uint8_t index = 0;
|
||||
|
@ -122,6 +144,7 @@ STATIC_MOCKME void Crc_StartNextTask(struct crcstatus_t *status)
|
|||
while(slot) {
|
||||
if(index < slot->count) {
|
||||
if(slot->tasks[index].address) {
|
||||
DIAG_CRC_CALC_START();
|
||||
status->activeSlot = slot;
|
||||
status->activeTask = index;
|
||||
status->crcUnit->CR = 1;
|
||||
|
@ -141,8 +164,9 @@ STATIC_MOCKME void Crc_StartNextTask(struct crcstatus_t *status)
|
|||
status->activeSlot = NULL;
|
||||
}
|
||||
|
||||
// !!!PORTABILITY WARNING!!! using registers and bits directly. should be reviewed extremely t
|
||||
void Crc_HandleDmaIrq(struct crcstatus_t *status)
|
||||
|
||||
// !!!PORTABILITY WARNING!!! using registers and bits directly. should be reviewed extremely when porting to a different MCU
|
||||
void MOCKABLE(Crc_HandleDmaIrq)(struct crcstatus_t *status)
|
||||
{
|
||||
uint8_t success = 1;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue