|
Typical Usage of Component in User Code This chapter describes usage of methods and events that are defined in most hardware oriented components. Usage of other component specific methods is described in the component documentation, in the section "Typical Usage" (if available). Peripheral Initialization ComponentsPeripheral Initialization Components are the components at the lowest level of peripheral abstraction. These components contain only one method Init providing the initialization of the used peripheral. See chapter Typical Peripheral Initialization Components Usage for details. Peripheral Initialization ComponentsPlese see the chapter For typical usage and hints on Logical Device Drivers (LDD components) please see the chapter High level componentsMethods Enable, DisableMost of the hardware components support the methods Enable and Disable. These methods enable or disable peripheral functionality, which causes disabling of functionality of the component as well. Overview of the method behavior according to the component type:
If the component is disabled, some methods may not be used. Please refer to components documentation for details. MAIN.C void main(void) { ... B1_Enable(); /* enable the component functionality */ /* handle the component data or settings */ B1_Disable(); /* disable the component functionality */ ... } Methods EnableEvent, DisableEventThese methods enable or disable invocation of all component events. These methods are usually supported only if the component services any interrupt vector. The method DisableEvent may cause disabling of the interrupt, if it is not required by the component functionality or shared with another component. The method usually does not disable either peripheral or the component functionality. MAIN.C void main(void) { ... B1_EnableEvent(); /* enable the component events */ /* component events may be invoked */ B1_DisableEvent(); /* disable the component events */ /* component events are disabled */ ... } Events BeforeNewSpeed, AfterNewSpeedTimed components that depend on the MCU clock such as timers, communication and conversion components, may support speed modes defined in the CPU component (in EXPERT view level). The event BeforeNewSpeed is invoked before the speed mode changes and AfterNewSpeed is invoked after the speed mode changes. Speed mode may be changed using the CPU component methods SetHigh, SetLow, or SetSlow. EVENT.C int changing_speed_mode = 0; void B1_BeforeNewSpeed(void) { ++changing_speed_mode; } void B1_AfterNewSpeed(void) { --changing_speed_mode; } Note: If the speed mode is not supported by the component, the component functionality is disabled, as if the method Disable is used. If the supported speed mode is selected again, the component status is restored. TRUE and FALSE Values of bool TypeProcessor Expert defines the TRUE symbol as 1, however true and false logical values in C language are defined according to ANSI-C:
It follows from this definition, that the bool value cannot be tested using the expressions, such as if (value == TRUE) ... Processor Expert methods returning bool value often benefit from this definition and they return any non-zero value as TRUE value instead of 1. The correct C expression for such test is: if (value) .... In our documentation, the "true" or "false" are considered as logical states, not any particular numeric values. The capitalized "TRUE" and "FALSE" are constants defined as FALSE=0 and TRUE=1. Copyright 2013 Freescale Semiconductor, Inc.
PROCESSOR EXPERT is trademark of Freescale Semiconductor, Inc. |