/*********************************************************************************************************                                               
*                                     MCU ACH118X driver library
*                             COPYRIGHT(c) 2019 Amped RF Technology (ART)
*                                        All Rights Reserved
*
* File    : ach118x_util.h
* Version : V1.0.0
* Brief   : Various utilities
**********************************************************************************************************/

#ifndef __ACH118X_UTIL_H
#define __ACH118X_UTIL_H


typedef struct {
    uint32_t SAMPLERATE;
    uint32_t REFDIV;
    uint32_t FBDIV;
    uint32_t POSTDIV1;
    uint32_t POSTDIV2;
    uint32_t FRAC;
    uint32_t FREQ;
} PLL_SampleRate_Table_t;
extern uint8_t PLL_SampleRate_TableSize;

// prototypes
void wait(void);
void util_waitMS(uint16_t ms);
void util_waitFast(void);
void CheckHex(char *name, uint32_t actual, uint32_t expected);
void util_ShowCPU(void);
uint32_t util_GetMainFreq(void);
uint32_t util_GetPLLFreq(volatile PLL_REG0_Typedef *r0, volatile PLL_REG1_Typedef *r1);
void util_SetMainFreqMHz(uint32_t MHz);
void util_FineTunePLL(uint32_t PLLr0, uint32_t PLLr1, int32_t Hz);
int util_ConfigAudioI2S_SampleRate(uint32_t SampleRate);

#endif // __ACH118X_UTIL_H
/************************ (C) COPYRIGHT ART *****END OF FILE****/
