Files
microchip-application-pec93…/Drivers/PEC930/HAL_Lib/inc/hal_dsp.h
T

108 lines
3.2 KiB
C

/**
* Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
*/
/** @file hal_dsp.h
*
* @author Wei-Lun Hsu
* @version 0.1
* @date 2024/10/17
* @license
* @description
*/
#ifndef __hal_dsp_H_we15xl18_lz2k_Hix7_sTLr_uIRwmlwU5wH6__
#define __hal_dsp_H_we15xl18_lz2k_Hix7_sTLr_uIRwmlwU5wH6__
#ifdef __cplusplus
extern "C" {
#endif
#include "hal_def.h"
//=============================================================================
// Constant Definition
//=============================================================================
//=============================================================================
// Macro Definition
//=============================================================================
/**
* \brief H/W DSP Divide operation
*
* \param [in] numerator The numerator of Fraction
* \param [in] denominator The denominator of Fraction
* \param [in] pQuotient Pointer to a 32-bits signed value (Quotient)
* \param [in] pRemainder Pointer to a 32-bits signed value (Remainder)
* \return
* 0: ok
* others: fail
*/
__STATIC_FORCEINLINE int DSP_Div32(int numerator, int denominator, int *pQuotient, int *pRemainder)
{
DSP->CR_b.MODE = DSP_CR_MODE_DIV;
REG_WRITE(DSP->SDAT1, numerator);
REG_WRITE(DSP->SDAT2, denominator);
while( !REG_READ(DSP->SR) ) {}
if( pQuotient ) *pQuotient = REG_READ(DSP->RSLT1);
if( pRemainder ) *pRemainder = REG_READ(DSP->RSLT2);
return 0;
}
//=============================================================================
// Structure Definition
//=============================================================================
/**
* the paraments of dsp square root calculate
*/
typedef struct
{
union {
uint64_t value64;
uint32_t value32[2];
};
} DSP_SqrtParamTypeDef;
//=============================================================================
// Global Data Definition
//=============================================================================
//=============================================================================
// Private Function Definition
//=============================================================================
//=============================================================================
// Public Function Definition
//=============================================================================
#if 0
/**
* \brief H/W DSP Divide operation
*
* \param [in] numerator The numerator of Fraction
* \param [in] denominator The denominator of Fraction
* \param [in] pQuotient Pointer to a 32-bits signed value (Quotient)
* \param [in] pRemainder Pointer to a 32-bits signed value (Remainder)
* \return
* 0: ok
* others: fail
*/
int DSP_Div32(int numerator, int denominator, int *pQuotient, int *pRemainder);
#endif
/**
* \brief H/w DSP Square root operation (unsigned 64-bits)
*
* \param [in] pParam The input paraments of Square root operation
* \return
* the calculated value
*/
uint32_t DSP_Sqrt32(DSP_SqrtParamTypeDef *pParam);
#ifdef __cplusplus
}
#endif
#endif