Checkpoint
This commit is contained in:
parent
83f510bb59
commit
491062cac6
13 changed files with 95 additions and 221 deletions
|
@ -21,10 +21,10 @@
|
|||
#endif
|
||||
|
||||
struct crcslottask_t {
|
||||
void *address;
|
||||
void * volatile address;
|
||||
uint16_t wordCount;
|
||||
void (*callback)(void*, uint32_t, uint8_t);
|
||||
void *callbackParam;
|
||||
void (* volatile callback)(void*, uint32_t, uint8_t);
|
||||
void * volatile callbackParam;
|
||||
};
|
||||
|
||||
struct crcslotlistitem_t {
|
||||
|
@ -35,8 +35,8 @@ struct crcslotlistitem_t {
|
|||
|
||||
struct crcstatus_t {
|
||||
DMAINFO dmaInfo;
|
||||
volatile struct crcslotlistitem_t *activeSlot;
|
||||
volatile uint8_t activeTask;
|
||||
struct crcslotlistitem_t * volatile activeSlot;
|
||||
uint8_t volatile activeTask;
|
||||
|
||||
struct crcslotlistitem_t *first;
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* Created on: Aug 29, 2019
|
||||
* Author: abody
|
||||
*/
|
||||
#include "main.h"
|
||||
#include <string.h>
|
||||
#include <platform/crc_ll.h>
|
||||
#include "diag.h"
|
||||
|
@ -26,6 +27,17 @@
|
|||
# define DIAG_INTERRUPT_OUT()
|
||||
#endif
|
||||
|
||||
#define SLOTHITORYSIZE 8192
|
||||
|
||||
typedef struct crcstatus_t * CRCSTATUSPTR;
|
||||
typedef struct crcslotlistitem_t * CRCSLOTPTR;
|
||||
|
||||
CRCSLOTPTR slot0History[SLOTHITORYSIZE];
|
||||
CRCSLOTPTR slot1History[SLOTHITORYSIZE];
|
||||
CRCSLOTPTR *slotHistoryPtrs[2] = { slot0History, slot1History };
|
||||
uint32_t slotIndexes[2] = {0, 0};
|
||||
|
||||
uint32_t volatile spuriousCount = 0;
|
||||
|
||||
void InitCrcStatus(struct crcstatus_t *st, DMA_TypeDef *dma, uint32_t stream)
|
||||
{
|
||||
|
@ -71,15 +83,19 @@ uint8_t EnqueueCrcTask(struct crcstatus_t *status, struct crcslotlistitem_t *slo
|
|||
uint32_t prim = __get_PRIMASK();
|
||||
uint16_t need_start;
|
||||
|
||||
while(status->activeSlot == slot);
|
||||
LL_GPIO_SetOutputPin(DBG0_GPIO_Port, task ? DBG1_Pin : DBG0_Pin);
|
||||
|
||||
while(status->activeSlot == slot && status->activeTask == task);
|
||||
__disable_irq();
|
||||
need_start = (status->activeSlot == NULL);
|
||||
slot->tasks[task].address = need_start ? NULL : address;
|
||||
slot->tasks[task].wordCount = (len+3)/4;
|
||||
slot->tasks[task].callback = callback;
|
||||
slot->tasks[task].callbackParam = callbackParam;
|
||||
if(need_start)
|
||||
if(need_start) {
|
||||
status->activeSlot = slot;
|
||||
status->activeTask = task;
|
||||
}
|
||||
__set_PRIMASK(prim);
|
||||
|
||||
if(need_start) {
|
||||
|
@ -89,6 +105,7 @@ uint8_t EnqueueCrcTask(struct crcstatus_t *status, struct crcslotlistitem_t *slo
|
|||
DIAG_CRC_CALC_START();
|
||||
LL_DMA_EnableStream(status->dmaInfo.dma, status->dmaInfo.stream);
|
||||
}
|
||||
LL_GPIO_ResetOutputPin(DBG0_GPIO_Port, task ? DBG1_Pin : DBG0_Pin);
|
||||
return need_start;
|
||||
}
|
||||
|
||||
|
@ -142,11 +159,17 @@ static void StartNextCrcTask(struct crcstatus_t *status)
|
|||
|
||||
void HandleCrcDmaIrq(struct crcstatus_t *status)
|
||||
{
|
||||
LL_GPIO_SetOutputPin(DBG0_GPIO_Port, DBG2_Pin);
|
||||
|
||||
DIAG_INTERRUPT_IN();
|
||||
if(*status->dmaInfo.isReg & status->dmaInfo.tcMask) { // DMA transfer complete
|
||||
*status->dmaInfo.ifcReg = status->dmaInfo.tcMask;
|
||||
LL_DMA_DisableStream(status->dmaInfo.dma, status->dmaInfo.stream);
|
||||
if(status->activeSlot) {
|
||||
|
||||
// (slotHistoryPtrs[status->activeTask][slotIndexes[status->activeTask]++]) = status->activeSlot;
|
||||
// while(slotIndexes[status->activeTask] >= SLOTHITORYSIZE);
|
||||
|
||||
struct crcslottask_t *tsk = &status->activeSlot->tasks[status->activeTask];
|
||||
if(tsk->callback)
|
||||
tsk->callback(tsk->callbackParam, CRC->DR, 1);
|
||||
|
@ -171,6 +194,13 @@ void HandleCrcDmaIrq(struct crcstatus_t *status)
|
|||
StartNextCrcTask(status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++spuriousCount;
|
||||
}
|
||||
|
||||
DIAG_INTERRUPT_OUT();
|
||||
|
||||
LL_GPIO_ResetOutputPin(DBG0_GPIO_Port, DBG2_Pin);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,9 +105,13 @@ static inline uint8_t CheckHeader(USARTPACKET *packet)
|
|||
|
||||
uint8_t PostPacket(USARTSTATUS *status, uint8_t const *payload, uint16_t length, struct crcstatus_t *crcStatus, uint8_t waitForCrcQueue)
|
||||
{
|
||||
// static uint32_t count = 0;
|
||||
// ITM->PORT[1].u32 = count++;
|
||||
|
||||
if(length > 256)
|
||||
return 1;
|
||||
|
||||
|
||||
BuildHeader(&status->txBuffer, status->txSerial++, length);
|
||||
uint16_t payloadLength = RoundUpTo4(length);
|
||||
if(payload)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue