Ioctl() - Freescale Semiconductor DSP56800E User Manual

Hide thumbs Also See for DSP56800E:
Table of Contents

Advertisement

Developing Software
ioctl, read and write commands instead of the direct access to the peripheral module registers.
The direct access to the peripheral registers is performed by periphMemWrite, periphMemRead
and other predefined macros described in Section 2.4.2.
4.3.1

ioctl()

The ioctl command is used to initialize a peripheral module (see Section 4.2) and to access a
peripheral module. Use of the ioctl command provides a very efficient and easy way to access a
peripheral module. It increases the code portability and readability and, thus, decrease the number
of bugs in the developed code.
The general syntax of the ioctl command is as follows:
ioctl(peripheral_module_identifier, command, command_specific_parameter);
or (if ioctl command returns a value):
var = ioctl(peripheral_module_identifier, command, command_specific_parameter);
Where:
Peripheral_module_identifier parameter is the base address of the peripheral module. Instead of
passing the raw base address (e.g. 0xF2D0) you can use the predefined symbolic constants OCCS,
QTIMER, INTC etc.
Command parameter specifies the action, which will be performed on the peripheral module. The
list of all commands available can be found in Chapter 5, "On-chip Drivers," .
Command_specific_parameter parameter specifies other data required to execute the command.
Example 4-2. Using ioctl
ioctl(GPIO_B, GPIO_SET_PIN, BIT_1 | BIT_2);
ioctl(ADC_A, ADC_START, NULL);
ioctl(QTIMER_D1, QT_CLEAR_FLAG, QT_COMPARE_FLAG);
This example shows a miscellaneous ioctl commands. Note, the parameters are: the first one
specifies the peripheral module (GPIO_B - General Purpose Input Output B, ADC_A - Analog to
Digital Converter A, QTIMER_D1 - timer/counter D1), the second one is the command
(GPIO_SET_PIN - to set pin, ADC_START - to start A/D conversion, QT_CLEAR_FLAG - to
clear flag) and the third one is the command specific parameter (BIT_1 | BIT_2 - to specify that
bits 1 and 2 will be set, NULL - no parameter is used, QT_COMPARE_FLAG - to clear timer
compare flag).
See Chapter 5, "On-chip Drivers," where all ioctl commands and their detailed descriptions can
be found.
Tip: To see all available ioctl commands and their parameters from within CodeWarrior IDE, just
open the appropriate <name_of_driver>.h include file (e.g. intc.h - Interrupt Controller driver
include file, pwm.h - Pulse Width Modulation driver include file, etc.) and, at the beginning of the
file, there is a list of all implemented ioctl commands.
4-4
Targeting 56F8xxx Platform
FREESCALE SEMICONDUCTOR

Advertisement

Table of Contents
loading

Table of Contents