PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
Clock Supervisor Functions (CSV)

What is CSV? The CSV module includes CSV and FCS function. CSV uses the high and low CR to monitor main and sub clock, if the abnormal state is detected, a reset occurs. FCS uses high-speed CR to monitor the main clock, a range can be set in advance. If the monitor cycle exeeds the range, either interrupt or reset will occurs. More...

Data Structures

struct  stc_csv_status
 Structure of CSV status. More...
 

Typedefs

typedef enum en_fcs_cr_div en_fcs_cr_div_t
 Enumeration to define an index for each BT instance. More...
 
typedef struct stc_csv_status stc_csv_status_t
 Structure of CSV status. More...
 
typedef void fn_fcs_int_callback (void)
 FCS interrupt callback function type. More...
 

Enumerations

enum  en_fcs_cr_div {
  FcsCrDiv256 = 5,
  FcsCrDiv512 = 6,
  FcsCrDiv1024 = 7
}
 Enumeration to define an index for each BT instance. More...
 

Functions

void Csv_IrqHandler (void)
 CSV interrupt handler. More...
 
en_result_t Csv_EnableFcsInt (fn_fcs_int_callback *pfnIntCallback)
 Enables FCS interrupts. More...
 
void Csv_DisableFcsInt (void)
 Disables FCS interrupts. More...
 
void Csv_EnableMainCsv (void)
 The main CSV function is enabled. More...
 
void Csv_DisableMainCsv (void)
 The main CSV function is disabled. More...
 
void Csv_EnableSubCsv (void)
 The sub CSV function is enabled. More...
 
void Csv_DisableSubCsv (void)
 The sub CSV function is disabled¡£ More...
 
uint8_t Csv_GetCsvFailCause (stc_csv_status_t *pstcCsvStatus)
 Get CSV status. More...
 
void Csv_EnableFcs (void)
 The FCS function is enabled. More...
 
void Csv_DisableFcs (void)
 The FCS function is disabled. More...
 
void Csv_EnableFcsReset (void)
 The FCS reset is enabled. More...
 
void Csv_DisableFcsReset (void)
 The FCS reset is disabled. More...
 
void Csv_ClrFcsIntFlag (void)
 Clears the FCS interrupt cause. More...
 
uint8_t Csv_GetFcsIntFlag (void)
 Get Anomalous frequency detection interrupt status. More...
 
en_result_t Csv_SetFcsCrDiv (en_fcs_cr_div_t enDiv)
 FCS count cycle setting. More...
 
void Csv_SetFcsDetectRange (uint16_t u16LowerVal, uint16_t u16UpperVal)
 Frequency lower detection window setting. More...
 
uint16_t Csv_GetFcsDetectCount (void)
 Get the counter value of frequency detection using the main clock. More...
 

Variables

static fn_fcs_int_callback * m_pfnIntCallback = NULL
 

Detailed Description

What is CSV? The CSV module includes CSV and FCS function. CSV uses the high and low CR to monitor main and sub clock, if the abnormal state is detected, a reset occurs. FCS uses high-speed CR to monitor the main clock, a range can be set in advance. If the monitor cycle exeeds the range, either interrupt or reset will occurs.

Provided functions of CSV module:

How to use CSV module with the APIs provided? First, Enable the CSV function with Csv_EnableMainCsv() or Csv_EnableSubCsv() When the abnormal status is detected, a CSV reset occurs, then read the the CSV failure cause by Csv_GetCsvFailCause(). Disable the CSV function with Csv_DisableMainCsv() or Csv_DisableSubCsv()

How to use FCS module with the APIs provided? First, set the CR dividor with Csv_SetFcsCrDiv() and set the expected range of main clok cycle with Csv_SetFcsDetectRange(). Second, enable the FCS interrupt with Csv_EnableFcsInt() or enable FCS reset with Csv_EnableFcsReset(). Then start FCS function with Csv_EnableFcs(). When abnormal frequency is detected, an interrupt occurs when FCS interrupt is enabled, then read the interrupt flag by Csv_GetFcsIntFlag() and clear the interrupt flag by Csv_ClrFcsIntFlag(). When abnormal frequency is detected, a reset issues when FCS reset is enabled. When abnormal frequency is detected, current main clock cycle can be read by Csv_GetFcsDetectCount(). Disable FCS by Csv_DisableFcs(), disable FCS reset by Csv_DisableFcsReset() and disable FCS interrupt by Csv_DisableFcsInt().

Typedef Documentation

Enumeration to define an index for each BT instance.

typedef void fn_fcs_int_callback(void)

FCS interrupt callback function type.

Definition at line 146 of file csv.h.

Structure of CSV status.

Enumeration Type Documentation

Enumeration to define an index for each BT instance.

Enumerator
FcsCrDiv256 

1/256 frequency of high-speed CR oscillation

FcsCrDiv512 

1/512 frequency of high-speed CR oscillation

FcsCrDiv1024 

1/1024 frequency of high-speed CR oscillation

Definition at line 123 of file csv.h.

Function Documentation

void Csv_ClrFcsIntFlag ( void  )

Clears the FCS interrupt cause.

Definition at line 260 of file csv.c.

void Csv_DisableFcs ( void  )

The FCS function is disabled.

Definition at line 229 of file csv.c.

void Csv_DisableFcsInt ( void  )

Disables FCS interrupts.

Definition at line 127 of file csv.c.

References PDL_DEFAULT_INTERRUPT_LEVEL.

void Csv_DisableFcsReset ( void  )

The FCS reset is disabled.

Definition at line 250 of file csv.c.

void Csv_DisableMainCsv ( void  )

The main CSV function is disabled.

Definition at line 153 of file csv.c.

void Csv_DisableSubCsv ( void  )

The sub CSV function is disabled¡£

Definition at line 173 of file csv.c.

void Csv_EnableFcs ( void  )

The FCS function is enabled.

Definition at line 219 of file csv.c.

en_result_t Csv_EnableFcsInt ( fn_fcs_int_callback *  pfnIntCallback)

Enables FCS interrupts.

Definition at line 105 of file csv.c.

References ErrorInvalidParameter, m_pfnIntCallback, Ok, and PDL_IRQ_LEVEL_CSV.

void Csv_EnableFcsReset ( void  )

The FCS reset is enabled.

Definition at line 239 of file csv.c.

void Csv_EnableMainCsv ( void  )

The main CSV function is enabled.

Definition at line 143 of file csv.c.

void Csv_EnableSubCsv ( void  )

The sub CSV function is enabled.

Definition at line 163 of file csv.c.

uint8_t Csv_GetCsvFailCause ( stc_csv_status_t *  pstcCsvStatus)

Get CSV status.

Parameters
pstcCsvStatusPointer to status information struture of CSV
Return values
Ok

Definition at line 187 of file csv.c.

References stc_csv_status::bCsvMainClockStatus, stc_csv_status::bCsvSubClockStatus, FALSE, Ok, TRUE, and u8Status.

uint16_t Csv_GetFcsDetectCount ( void  )

Get the counter value of frequency detection using the main clock.

Returns
Frequency detection counter value

Definition at line 328 of file csv.c.

uint8_t Csv_GetFcsIntFlag ( void  )

Get Anomalous frequency detection interrupt status.

Returns
interrupt status
Return values
0No FCS interrupt has been asserted.
1An FCS interrupt has been asserted.

Definition at line 274 of file csv.c.

void Csv_IrqHandler ( void  )

CSV interrupt handler.

Definition at line 94 of file csv.c.

References m_pfnIntCallback.

en_result_t Csv_SetFcsCrDiv ( en_fcs_cr_div_t  enDiv)

FCS count cycle setting.

Parameters
enDiv
  • FcsCrDiv256 1/256 frequency of high-speed CR oscillation
  • FcsCrDiv512 1/512 frequency of high-speed CR oscillation
  • FcsCrDiv1024 1/1024 frequency of high-speed CR oscillation
Return values
Ok

Definition at line 291 of file csv.c.

References ErrorInvalidParameter, FcsCrDiv1024, FcsCrDiv256, FcsCrDiv512, and Ok.

void Csv_SetFcsDetectRange ( uint16_t  u16LowerVal,
uint16_t  u16UpperVal 
)

Frequency lower detection window setting.

Parameters
u16LowerValLower value
u16UpperVallimit value

Definition at line 315 of file csv.c.

Variable Documentation

fn_fcs_int_callback* m_pfnIntCallback = NULL
static

Definition at line 75 of file csv.c.

Referenced by Csv_EnableFcsInt(), and Csv_IrqHandler().