Name

Peripheral clock control — Details

Synopsis

#include <cyg/hal/hal_io.h>
    

cyg_uint32 CYGHWR_HAL_ATMEL_CLOCK_ENABLE( pid );

CYGHWR_HAL_ATMEL_CLOCK_DISABLE ( pid );

Description

The HAL provides macros which may be used to enable or disable peripheral clocks. Effectively this indicates whether the peripheral is powered on (enabled) or powered down (disabled), and so may be used to ensure unused peripherals are turned off to save power. The CYGHWR_HAL_ATMEL_CLOCK_ENABLE macro will enforce the maximum frequency limitations for particular peripheral blocks, and will return the frequency of the clock used for the enabled peripheral. Such frequency information may be useful to device drivers if clock divider configuration is required.

It is important to remember that before a peripheral can be used, it must be enabled. It is safe to re-enable a peripheral that is already enabled, although usually a device driver will only do so once in its initialisation. eCos will automatically initialise some peripheral blocks where it needs to use the associated peripherals (such as memory controllers and some (but usually not all) PIO banks), and in eCos-supplied device drivers which are included in the eCos configuration. However this should not be relied on - it is always safest to enable the peripheral clocks anyway just in case. Finally, remember that each PIO bank must be enabled separately.

Each peripheral has a unique ID defined by the HAL, and these values are used as the pid parameter to the enable and disable macros.