Digital Signal Processing Reference
In-Depth Information
#include <sys/alt_alarm.h>
int main( void ) {
int first_val, second_val;
second_val = 0;
first_val = alt_nticks();
while( (second_val - first_val) < 1000000 ) {
second_val = alt_nticks();
}
}
Figure 16.5 This is the C code necessary for providing a one second delay by using the HAL
interface functions.
HAL Interface
A layer of software called a hardware abstraction layer (HAL) has been created
that resides between the user code and the peripheral hardware registers. The
HAL interface contains a number of very useful functions that allow the user to
communicate with peripherals at a higher functional level. For example, the
HAL interface provides functions alt_flash_open_dev , alt_read_flash ,
alt_write_flash , and alt_ flash_close_dev for communication with Flash
memory. By providing these functions, Flash memory can be accessed by
opening the device and reading from it and writing to it without having to
create user functions that provide the read and write functionality from low-
level peripheral register accesses.
For the timer device, a function called alt_nticks provides convenient access to
the timer. As illustrated in Figure 16.5, the HAL functions provide a more
straight-forward method of creating a one second delay.
#include <unistd.h>
int main( void ) {
usleep( 1000000 );
}
Figure 16.6 This is the C code necessary for providing a one second delay by using the standard
ANSI C library functions.
Standard Library Functions
Access to most of Nios II's peripherals has been incorporated into the standard
ANSI C library functions. Using standard ANSI C libraries such as stdlib , stdio ,
Search WWH ::




Custom Search