Hardware Configuration Support on IMX Processors — Details
cyg_uint32 desc = CYGHWR_HAL_IMX_PAD(
cyg_uint32 desc = CYGHWR_HAL_IMX_DAISY(
cyg_uint32 desc = CYGHWR_HAL_IMX_CLOCK_GATE(
cyg_uint32 desc = CYGHWR_HAL_IMX_GPIO(
The IMX HAL provides a number of macros to support the encoding of various hardware configuration options into a 32-bit descriptor. This is useful to drivers and other packages that need to configure the hardware.
Many of the IO pads on the chip can be connected to a
variety of different devices and have a variety of
properties that need to be configured. A pad descriptor is
created by the
pad argument defines the pad
to be configured, and follows the hardware naming
convention, for example
argument is the terminal part of a
CYGHWR_HAL_IMX_PAD_MODE_XXXX macro; this
may be one supplied in the HAL, or one constructed by the
driver or application. This macro is defined as a
combination of the
CYGHWR_HAL_IMX_PAD_MODE_ definitions in
cyg/hal/var_io.h, which correspond to
the definitions in the hardware pad MUX and CTL registers.
used to configure a pad according to the descriptor.
The following example shows how the LPUART pads are configured.
#define CYGHWR_HAL_IMX_PAD_MODE_LPUART_PAD(__alt) \ CYGHWR_HAL_IMX_PAD_MODE_MUX(__alt) | \ CYGHWR_HAL_IMX_PAD_MODE_PUE | \ CYGHWR_HAL_IMX_PAD_MODE_PKE | \ CYGHWR_HAL_IMX_PAD_MODE_PUS_47K_PU | \ CYGHWR_HAL_IMX_PAD_MODE_DSE(6) | \ CYGHWR_HAL_IMX_PAD_MODE_SPEED_MED2 #define CYGHWR_HAL_IMX_LPUART1_TX CYGHWR_HAL_IMX_PAD( AD_B0(12), LPUART_PAD(2) ) #define CYGHWR_HAL_IMX_LPUART1_RX CYGHWR_HAL_IMX_PAD( AD_B0(13), LPUART_PAD(2) )
PAD Daisy Chaining
Some device IO lines can connect to multiple pads, the daisy
chain registers select which pad is to be used for the
device. A daisy chain descriptor is created by the
CYGHWR_HAL_IMX_DAISY macro. The
reg argument selects which daisy chain
device line is to be programmed, and the
val argument defines the pad
selection. Both of these arguments are fragments of macros
registers and values currently used are defined there, new
ones can be added there or defined in the driver or
CYGHWR_HAL_IMX_DAISY_SET macro is
called to program the configuration from a descriptor into
The following example shows some daisy chain descriptor definitions.
# define CYGHWR_HAL_NXP_LPUART3_TXD_DAISY CYGHWR_HAL_IMX_DAISY(LPUART3_TX, AD_B1_06_ALT2) # define CYGHWR_HAL_NXP_LPUART3_RXD_DAISY CYGHWR_HAL_IMX_DAISY(LPUART3_RX, AD_B1_07_ALT2) # define CYGHWR_HAL_NXP_LPUART3_CTS_DAISY CYGHWR_HAL_IMX_DAISY(LPUART3_CTS_B, AD_B1_04_ALT2) # define CYGHWR_HAL_NXP_LPUART3_RTS_DAISY CYGHWR_HAL_IMX_DAISY_NONE
Clock Gating Control
Most device clocks are controlled by a gate that needs to be
switched on or off. 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
a clock gate descriptor. The
CCGR register to be used and
gate argument selects the clock gate
bit in that register. Clock gate descriptors are defined in
cyg/hal/var_io.h and new values will be
added there as needed.
and disable the clock described by the descriptor. At
present clocks are either fully on or fully off, the option
to switch clocks off in WAIT mode is not implemented.
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 initialization. eCos will automatically initialize some peripheral blocks where it needs to use the associated peripherals, 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.
A descriptor is created by the
CYGHWR_HAL_IMX_GPIO() macro. The
ctlr argument selects the GPIO controller
pin argument selects the GPIO pin
in the controller. The
configures the pin within the GPIO controller. At present
interrupt configuration is not supported, so the mode may only
In addition to GPIO configuration, the matching pad will need
to be configured using a PAD descriptor.
If a GPIO pin has been configured as an output then its value
may be set using
CYGHWR_HAL_IMX_GPIO_OUT(). Similarly the
current value of an input pin can be read using
|2022-01-07||eCosPro Non-Commercial Public License|