45static void (*CRC_EventHandler)(void) = NULL;
104 CRCCONLbits.CRCEN = 1;
134static bool CRC_ProgramTask(
void)
142 size = (uint16_t)0xFFFE - (uint16_t)(crcObj.
ptr.
program & (uint16_t)0xFFFF);
145 CRCCONLbits.CRCGO =
false;
146 IFS3bits.CRCIF =
false;
148 TBLPAG = (uint16_t)(crcObj.
ptr.
program >> 16);
150 while((!CRCCONLbits.CRCFUL) && (crcObj.
remainingSize) && (size))
152 lowWord = __builtin_tblrdl((uint16_t)(crcObj.
ptr.
program & (uint16_t)0xFFFF));
154 highWord = __builtin_tblrdh((uint16_t)(crcObj.
ptr.
program & (uint16_t)0xFFFF));
166 CRCCONLbits.CRCGO =
true;
177static bool CRC_BufferTask(
void)
181 if(CRCCONLbits.CRCFUL != 0U)
187 IFS3bits.CRCIF =
false;
219 CRCCONLbits.CRCGO =
true;
230static bool CRC_FlushTask(
void)
234 if(IFS3bits.CRCIF != 0U)
237 CRCCONLbits.CRCGO =
false;
238 IFS3bits.CRCIF =
false;
240 CRCCONHbits.DWIDTH = crcObj.
polyWidth - (uint8_t)1;
244 *((uint8_t *)&CRCDATL) = 0;
256 CRCCONLbits.CRCGO =
true;
264static bool CRC_CleanUpTask(
void)
268 if(IFS3bits.CRCIF != 0U)
271 CRCCONHbits.DWIDTH = crcObj.
dataWidth - (uint8_t)1;
272 CRCCONLbits.CRCGO =
false;
273 IFS3bits.CRCIF =
false;
281static uint32_t CRC_ReverseValue(uint32_t crc)
285 uint32_t crctemp = crc;
288 mask <<= (crcObj.
polyWidth - (uint8_t)1);
293 if((crctemp & (uint32_t)0x01) != 0U)
306static uint32_t CRC_PolynomialMask(
void)
311 for(idx = 0; idx < crcObj.
polyWidth; idx++)
324 uint8_t direction = CRCCONLbits.LENDIAN;
330 CRCWDATL = (uint16_t)seed;
331 CRCWDATH = (uint16_t)(seed >> 16);
336 CRCCONHbits.DWIDTH = CRCCONHbits.PLEN;
337 CRCCONLbits.LENDIAN = seedDirection;
341 *((uint8_t *)&CRCDATL) = (uint8_t)seed;
345 CRCDATL = (uint16_t)seed;
349 CRCDATL = (uint16_t)seed;
350 CRCDATH = (uint16_t)(seed >> 16);
354 IFS3bits.CRCIF =
false;
356 CRCCONLbits.CRCGO =
true;
358 if(IFS3bits.CRCIF ==
true){
364 CRCCONLbits.CRCGO =
false;
366 CRCCONLbits.LENDIAN = direction;
367 IFS3bits.CRCIF =
false;
375 crcObj.
dataWidth = CRCCONHbits.DWIDTH + 1;
382 CRCCONLbits.CRCGO =
true;
387 crcObj.
dataWidth = CRCCONHbits.DWIDTH + 1;
390 if(startAddr % 2 == 0)
401 CRCCONHbits.DWIDTH = 32 - 1;
403 CRCCONLbits.CRCGO =
true;
410 CRC_EventHandler = handler;
431 result = (uint32_t)CRCWDATL & (uint16_t)0xFF;
435 result = (uint32_t)CRCWDATL;
439 result = (uint32_t)CRCWDATH;
441 result |= (uint32_t)CRCWDATL;
453 return CRC_ReverseValue(result);
464 return result & CRC_PolynomialMask();
484 return result & CRC_PolynomialMask();
494 if(CRC_ProgramTask())
516 if(CRC_CleanUpTask())
531 if(IFS3bits.CRCIF != 0U)
533 if(NULL != CRC_EventHandler)
535 (*CRC_EventHandler)();
This is the generated driver header file for the CRC driver.
@ CRC_SEED_METHOD_INDIRECT
void __attribute__((__interrupt__, auto_psv))
Executes the power converter control loop.
const struct CRC_INTERFACE CRC
Structure object of type CRC_INTERFACE with the custom name given by the user in the Melody Driver Us...
void CRC_Initialize(void)
Initializes the CRC module. This function sets the polynomial and data width; data and seed shift; up...
uint32_t CRC_CalculationResultRawGet(void)
Gets the CRC raw result if the calculation is done.
void CRC_EventCallbackRegister(void(*handler)(void))
This function can be used to override default callback and to define custom callback for CRC Event ev...
uint32_t CRC_CalculationResultGet(bool reverse, uint32_t xorValue)
Gets the CRC result if the calculation is done.
void CRC_SeedSet(uint32_t seed, enum CRC_SEED_METHOD seedMethod, enum CRC_SEED_DIRECTION seedDirection)
Sets the CRC seed with method and direction.
void CRC_CalculateBufferStart(void *buffer, uint32_t sizeBytes)
CRC module calculation on a buffer in data space.
CRC_SEED_DIRECTION
Defines the CRC calculation seed direction in direct method CRC_SeedSet.
void CRC_Tasks(void)
This function cycles through the CRC calculations. This function will load the CRC module FIFO with...
void CRC_EventCallback(void)
This is the default callback with weak attribute. The user can override and implement the default cal...
void CRC_Deinitialize(void)
Deinitializes CRC to POR values.
uint32_t CRC_CalculationResultXORGet(uint32_t xorValue)
Gets the CRC XOR'd value of the result if the calculation is done.
CRC_SEED_METHOD
Defines the CRC calculation seed method CRC_SeedSet. The direct method refers to the seed being place...
uint32_t CRC_CalculationResultReverseGet(void)
Gets the CRC reversed value of result if the calculation is done.
void CRC_CalculateProgramStart(uint32_t startAddr, uint32_t sizeBytes)
Starts the CRC calculation on a buffer in program space.
bool CRC_CalculationIsDone(void)
Returns the CRC calculation complete status
CRC_STATE
Defines the CRC calculation states.
Structure containing the function pointers of CRC driver.