Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

The section describes the programming interface of the COP Peripheral driver. The COP driver configures the COP and provides a simple way to initialize and configure the COP.

COP Initialization

To initialize the COP module, call the COP_DRV_Init() function and pass in the user configuration structure. This function automatically enables the COP module and clock.
After the COP_DRV_Init() function is called, the COP is enabled and its counter is working. Therefore, the COP_DRV_Refresh() function should be called before the COP times out.

This example code shows how to initialize and configure the driver:

// Define device configuration.
cop_user_config_t copInit =
{
.copWindowModeEnable = (uint8_t)false, //Disable COP window mode
#if FSL_FEATURE_COP_HAS_LONGTIME_MODE
.copTimeoutMode = kCopShortTimeoutMode, //configure COP timeout mode
#else
.copClockSelect = kCopLpoClock, //configure COP clock source
#endif
.copTimeout = kCopTimeout_short_2to5_or_long_2to13, //configure COP timeout cycles
#if FSL_FEATURE_COP_HAS_LONGTIME_MODE
.copStopModeEnable = (uint8_t)false, //Disable COP in stop mode
.copDebugModeEnable = (uint8_t)false, //Disable COP in debug mode
.copClockSource = kCopLpoClock, //configure COP clock source
#endif
};
// Initialize COP.
COP_DRV_Init(instance, &init);

COP Refresh

After the COP is enabled, the COP_DRV_Refresh() function should be called periodically to prevent the COP from timing out.
Otherwise, a reset is asserted. This is called the "Feed Dog".

COP Reset Count

The COP can reset the system.

  1. After COP_DRV_Reset(), the chip is be reset.

Variables

SIM_Type *const g_copBase []
 Table of base addresses for COP instances. More...
 

COP Driver

cop_status_t COP_DRV_Init (uint32_t instance, const cop_config_t *initPtr)
 Initializes the COP. More...
 
void COP_DRV_Disable (uint32_t instance)
 Disables the COP Watchdog. More...
 
void COP_DRV_Refresh (uint32_t instance)
 Resets the COP timeout counter. More...
 
bool COP_DRV_IsRunning (uint32_t instance)
 Gets the COP running status. More...
 
void COP_DRV_ResetSystem (uint32_t instance)
 Resets the system. More...
 

Function Documentation

cop_status_t COP_DRV_Init ( uint32_t  instance,
const cop_config_t initPtr 
)

This function initializes the COP. After it is called, the COP starts running according to the configuration. Because all COP control registers are write-once only, the cop_init function and the cop_shutdown function can be called only once. A second call has no effect.

Parameters
instanceThe COP peripheral instance number.
initPtrCOP Initialize data structure.
Returns
The initialization status.
void COP_DRV_Disable ( uint32_t  instance)

This function disables the COP Watchdog. Note: The COP configuration register is write-once after reset. To disable the COP Watchdog, call this function first.

Parameters
instanceThe COP peripheral instance number.
void COP_DRV_Refresh ( uint32_t  instance)

This function feeds the COP. It sets the COP timer count to zero and should be called before the COP timer expires. Otherwise, a RESET is asserted.

Parameters
instanceThe COP peripheral instance number.
bool COP_DRV_IsRunning ( uint32_t  instance)

This function gets the COP running status.

Parameters
instanceThe COP peripheral instance number.
Returns
COP running status; 0 means not running; 1 means running
void COP_DRV_ResetSystem ( uint32_t  instance)

This function resets the device.

Parameters
instanceThe COP peripheral instance number.

Variable Documentation

SIM_Type* const g_copBase[]