| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Typedefs | Enumerations | Functions
C:/pdl_v10/library/driver/wc/wc.h File Reference
`#include "mcu.h"`
`#include "pdl_user.h"`
Include dependency graph for wc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | stc_wc_pres_clk
| Structure to configure watch counter prescaler. More...
struct | stc_wc_config
| Structure to configure the watch counter. More...
## Typedefs
typedef enum en_input_clk | en_input_clk_t
| Enumeration to define source clock of watch counter precaler.
typedef enum en_output_clk | en_output_clk_t
| Enumeration to define output clock of watch counter precaler.
typedef struct stc_wc_pres_clk | stc_wc_pres_clk_t
| Structure to configure watch counter prescaler.
typedef enum en_wc_cnt_clk | en_wc_cnt_clk_t
| Enumeration to set the clock of watch counter.
typedef struct stc_wc_config | stc_wc_config_t
| Structure to configure the watch counter.
## Enumerations
enum | en_input_clk { WcPresInClkSubOsc = 0, WcPresInClkMainOsc, WcPresInClkHighCr, WcPresInClkLowCr }
| Enumeration to define source clock of watch counter precaler. More...
enum | en_output_clk { WcPresOutClkArray0 = 0, WcPresOutClkArray1, WcPresOutClkArray2, WcPresOutClkArray3, WcPresOutClkArray4, WcPresOutClkArray5, WcPresOutClkArray6 }
| Enumeration to define output clock of watch counter precaler. More...
enum | en_wc_cnt_clk { WcCntClkWcck0 = 0, WcCntClkWcck1, WcCntClkWcck2, WcCntClkWcck3 }
| Enumeration to set the clock of watch counter. More...
## Functions
en_result_t | Wc_Pres_SelClk (stc_wc_pres_clk_t *pstcWcPresClk)
| Select the input clock an and set the division clock to be output.
en_result_t | Wc_Pres_EnableDiv (void)
| Enable oscillation of the division clock.
en_result_t | Wc_Pres_DisableDiv (void)
| Disable oscillation of the division clock.
en_stat_flag_t | Wc_GetDivStat (void)
| Get the operation status of the division counter.
en_result_t | Wc_Init (stc_wc_config_t *pstcWcConfig)
| Select the input clock and set the division clock to be output.
en_result_t | Wc_EnableCount (void)
| Enable WC operation.
en_result_t | Wc_DisableCount (void)
| Disable WC operation.
en_result_t | Wc_EnableInt (func_ptr_t pfnIntCallback)
| Enable WC underflow interrupt.
en_result_t | Wc_DisableInt (void)
| Disable WC underflow interrupt.
en_result_t | Wc_WriteReloadVal (uint8_t u8Val)
| Set the counter value of WC.
uint8_t | Wc_ReadCurCnt (void)
| Read the value in the 6-bit down counter.
en_result_t | Wc_ClearIntFlag (void)
| Clear WC underflow flag.
en_int_flag_t | Wc_GetIntFlag (void)
| Get WC underflow flag status.
en_stat_flag_t | Wc_GetOperationFlag (void)
| Get WC operation state.
void | Wc_IrqHandler (void)
| Watch counter interrupt function.

## Detailed Description

Headerfile for WC functions

History:

- 2014-02-17 0.1 Edison Zhang First version.

Definition in file wc.h.

## Typedef Documentation

typedef enum en_input_clk en_input_clk_t

Enumeration to define source clock of watch counter precaler.

typedef enum en_output_clk en_output_clk_t

Enumeration to define output clock of watch counter precaler.

typedef enum en_wc_cnt_clk en_wc_cnt_clk_t

Enumeration to set the clock of watch counter.

typedef struct stc_wc_config stc_wc_config_t

Structure to configure the watch counter.

typedef struct stc_wc_pres_clk stc_wc_pres_clk_t

Structure to configure watch counter prescaler.

## Enumeration Type Documentation

enum en_input_clk

Enumeration to define source clock of watch counter precaler.

Enumerator:

  WcPresInClkSubOsc | Watch counter prescaler source clock: sub oscillator.
  WcPresInClkMainOsc | Watch counter prescaler source clock: main oscillator.
  WcPresInClkHighCr | Watch counter prescaler source clock: high-speed CR.
  WcPresInClkLowCr | Watch counter prescaler source clock: low-speed CR.

Definition at line 129 of file wc.h.

enum en_output_clk

Enumeration to define output clock of watch counter precaler.

Enumerator:

  WcPresOutClkArray0 | WCCk3 WCCk2 WCCk1 WCCk0. Watch counter prescaler output array0: 2^15/src clock, 2^14/src clock, 2^13/src clock, 2^12/src clock
  WcPresOutClkArray1 | Watch counter prescaler output array0: 2^25/src clock, 2^24/src clock, 2^23/src clock, 2^22/src clock.
  WcPresOutClkArray2 | Watch counter prescaler output array0: 2^4/src clock, 2^3/src clock, 2^2/src clock, 2/src clock.
  WcPresOutClkArray3 | Watch counter prescaler output array0: 2^8/src clock, 2^7/src clock, 2^6/src clock, 2^5/src clock.
  WcPresOutClkArray4 | Watch counter prescaler output array0: 2^12/src clock, 2^11/src clock, 2^10/src clock, 2^9/src clock.
  WcPresOutClkArray5 | Watch counter prescaler output array0: 2^19/src clock, 2^18/src clock, 2^17/src clock, 2^16/src clock.
  WcPresOutClkArray6 | Watch counter prescaler output array0: 2^23/src clock, 2^22/src clock, 2^21/src clock, 2^20/src clock.

Definition at line 142 of file wc.h.

enum en_wc_cnt_clk

Enumeration to set the clock of watch counter.

Enumerator:

  WcCntClkWcck0 | Watch counter source clock: WCCK0.
  WcCntClkWcck1 | Watch counter source clock: WCCK1.
  WcCntClkWcck2 | Watch counter source clock: WCCK2.
  WcCntClkWcck3 | Watch counter source clock: WCCK3.

Definition at line 170 of file wc.h.

## Function Documentation

en_result_t Wc_ClearIntFlag | ( | void |  | ) |

Clear WC underflow flag.

The Function clear WCIF to 0 of WC

Return values:

  Ok | Clear WC underflow flag normally

Definition at line 361 of file wc.c.

References Ok.

Referenced by Wc_IrqHandler().

Here is the caller graph for this function:

en_result_t Wc_DisableCount | ( | void |  | ) |

Disable WC operation.

The Function can clear WCCR:WCEN to 0 of WC

Return values:

  Ok | Disable WC operation normally

Definition at line 266 of file wc.c.

References Ok.

en_result_t Wc_DisableInt | ( | void |  | ) |

Disable WC underflow interrupt.

The Function can clear WCIE of WC

Return values:

  Ok | Disable WC underflow interrupt normally

Definition at line 308 of file wc.c.

References Ok, pWcfnIntCallback, and Wc_DeInitNvic().

Here is the call graph for this function:

en_result_t Wc_EnableCount | ( | void |  | ) |

Enable WC operation.

The Function can set WCCR:WCEN to 1 of WC

Return values:

  Ok | Enable WC operation normally

Definition at line 251 of file wc.c.

References Ok.

en_result_t Wc_EnableInt | ( | func_ptr_t | pfnIntCallback | ) |

Enable WC underflow interrupt.

The Function can set WCIE of WC

Parameters:

  [in] | pfnIntCallback | WC interrupt to be enabled

Return values:

  Ok | Write data successfully done or started.
  ErrorInvalidParameter | If one of following conditions are met: pfnIntCallback == NULL

Definition at line 286 of file wc.c.

References ErrorInvalidParameter, Ok, pWcfnIntCallback, and Wc_InitNvic().

Here is the call graph for this function:

en_stat_flag_t Wc_GetDivStat | ( | void |  | ) |

Get the operation status of the division counter.

The Function can get CLK_EN:CLK_EN_R to 0 of WCP

Return values:

  PdlClr | CLK_EN_R is 0, oscillation of the division clock is not performed
  PdlSet | CLK_EN R is 1, oscillation of the division clock is performed

Definition at line 198 of file wc.c.

en_int_flag_t Wc_GetIntFlag | ( | void |  | ) |

Get WC underflow flag status.

The Function get value WCIF of WC

Return values:

  PdlClr | WCIF is 0, WC underflow does not occur
  PdlSet | WCIF is 1, WC underflow occurs

Definition at line 377 of file wc.c.

Referenced by Wc_IrqHandler().

Here is the caller graph for this function:

en_stat_flag_t Wc_GetOperationFlag | ( | void |  | ) |

Get WC operation state.

The Function get value WCOP of WC

Return values:

  PdlClr | WCOP is 0, The WC is stopped
  PdlSet | WCOP is 1, The WC is active

Definition at line 392 of file wc.c.

en_result_t Wc_Init | ( | stc_wc_config_t * | pstcWcConfig | ) |

Select the input clock and set the division clock to be output.

The Function can set SEL_OUT, SEL_IN of Watch counter prescaler (hereafter WCP)

Parameters:

  [in] | pstcWcConfig | WC configuration

Return values:

  Ok | Write data successfully done or started.
  ErrorInvalidParameter | If one of following conditions are met: invalid value of pstcWcConfig->enCntClk

Definition at line 216 of file wc.c.

References stc_wc_config::enCntClk, ErrorInvalidParameter, Ok, stc_wc_config::u8ReloadValue, WcCntClkWcck0, WcCntClkWcck1, WcCntClkWcck2, and WcCntClkWcck3.

void Wc_IrqHandler | ( | void |  | ) |

Watch counter interrupt function.

Definition at line 99 of file wc.c.

References PdlSet, pWcfnIntCallback, Wc_ClearIntFlag(), and Wc_GetIntFlag().

Referenced by TIM_IRQHandler().

Here is the call graph for this function:

Here is the caller graph for this function:

en_result_t Wc_Pres_DisableDiv | ( | void |  | ) |

Disable oscillation of the division clock.

The Function can clear CLK_EN:CLK_EN to 0 of WCP

Return values:

  Ok | Disable oscillation of the division clock normally

Definition at line 182 of file wc.c.

References Ok.

en_result_t Wc_Pres_EnableDiv | ( | void |  | ) |

Enable oscillation of the division clock.

The Function can set CLK_EN:CLK_EN to 1 of WCP

Return values:

  Ok | Enable oscillation of the division clock normally

Definition at line 167 of file wc.c.

References Ok.

en_result_t Wc_Pres_SelClk | ( | stc_wc_pres_clk_t * | pstcWcPresClk | ) |

Select the input clock an and set the division clock to be output.

The Function can set SEL_OUT, SEL_IN of Watch counter prescaler (hereafter WCP)

Parameters:

  [in] | pstcWcPresClk | WC prescaler clock configuration

Return values:

  Ok | Write data successfully done or started.
  ErrorInvalidParameter | If one of following conditions are met: invalid value of pstcWcPresClk->enInputClk invalid value of pstcWcPresClk->enOutputClk

Definition at line 126 of file wc.c.

References stc_wc_pres_clk::enInputClk, stc_wc_pres_clk::enOutputClk, ErrorInvalidParameter, Ok, WcPresInClkHighCr, WcPresInClkLowCr, WcPresInClkMainOsc, WcPresInClkSubOsc, WcPresOutClkArray0, WcPresOutClkArray1, WcPresOutClkArray2, WcPresOutClkArray3, WcPresOutClkArray4, WcPresOutClkArray5, and WcPresOutClkArray6.

uint8_t Wc_ReadCurCnt | ( | void |  | ) |

Read the value in the 6-bit down counter.

The Function can read value of WCRD of WC

Return values:

  Current | count value of WC

Definition at line 347 of file wc.c.

en_result_t Wc_WriteReloadVal | ( | uint8_t | u8Val | ) |

Set the counter value of WC.

The Function can set value to WCRL of WC

Return values:

  Ok | Set the counter value of WC normally

Definition at line 332 of file wc.c.

References Ok.