NIOS II common function finishing-thanks to slam original

Source: Internet
Author: User

IO operation function
Function prototypes: Iord (BASE, REGNUM)
Input parameters: Base for register, Regnum as register offset
Function Description: Reads the value in the register from the base site-based device with the offset in the Regnum cell. The value of the register is within the range of address bus.
return value:-

Function prototypes: Iowr (BASE, REGNUM, DATA)
Input parameters: Base for register, Regnum for register offset, data for write
Function Description: Writes data to an offset of regnum registers. The value of the register is within the range of address bus.
return value:-

Function prototype: Iord_32direct (BASE, OFFSET)
Input parameters: Base for the register, offset for register
Function Description: Reads 32Bit of data directly from a register with an address location of Base+offset
return value:-

Function prototype: Iord_16direct (BASE, OFFSET)
Input parameters: Base for the register, offset for register
Function Description: Reads 16Bit of data directly from a register with an address location of Base+offset
return value:-

Function prototype: Iord_8direct (BASE, OFFSET)
Input parameters: Base for the register, offset for register
Function Description: Reads 8Bit of data directly from a register with an address location of Base+offset
return value:-


Function prototypes: Iowr_32direct (BASE, OFFSET, DATA)
Input parameters: Base for register, Regnum for register offset, data for write
Function Description: Writes 32Bit of data directly to a register in the address location of Base+offset
return value:-

Function prototypes: Iowr_16direct (BASE, OFFSET, DATA)
Input parameters: Base for register, Regnum for register offset, data for write
Function Description: Writes 16Bit of data directly to a register in the address location of Base+offset
return value:-

Function prototypes: Iowr_8direct (BASE, OFFSET, DATA)
Input parameters: Base for register, Regnum for register offset, data for write
Function Description: Writes 8Bit of data directly to a register in the address location of Base+offset
return value:-

Dma:
Function prototype: int alt_dma_rxchan_close (Alt_dma_rxchan Rxchan)
Input parameter: Rxchan to receive channel
Function Description: function alt_dma_rxchan_close () Notification System: application has completed DMA
Receive channel Rxchan, the current execution is successful
Return value: Successful return is 0, and vice versa is-1

Function prototype: alt_dma_rxchan_depth (Alt_dma_rxchan DMA)
Input parameters: DMA
Function Description: function alt_dma_rxchan_depth () returns the maximum number (depth) of receive requests that are transmitted to the special DMA
Return value: Maximum number of DMA


function prototypes: int alt_dma_rxchan_ioctl (Alt_dma_rxchan DMA, int req, void* Arg)
Input parameters: DMA Direct Memory name, req for enumeration of request operations, ARG determined by request
Function Description: Perform the specific I/O operation of the device through the DMA receive channel
Return value: The request specific value is returned successfully, and the inverse is returned as a negative number
Request type
Request Type Request type description
Alt_dma_set_mode_8 transmission of data in 8Bit, arg value ignored
ALT_DMA_SET_MODE_16 transmission of data in 16Bit, arg value ignored
ALT_DMA_SET_MODE_32 transmission of data in 32Bit, arg value ignored
ALT_DMA_SET_MODE_64 transmission of data in 64Bit, arg value ignored
ALT_DMA_SET_MODE_128 transmission of data in 128Bit, arg value ignored
ALT_DMA_TX_ONLY_ON (1) software can only be sent under the control
Alt_dma_tx_only_off (1) Custom mode, software control can receive, send
ALT_DMA_RX_ONLY_ON (1) Under software control can only receive
Alt_dma_rx_only_off (1) Custom mode, software control can receive, send

Function prototypes: Alt_dma_rxchan alt_dma_rxchan_open (const char* name)
Input parameter: Name is a constant digit character pointer, such as/DEV/DMA_0
Function Description: Get a Alt_dma_rxchan descriptor for the DMA receive channel
Return value: Successful return of non 0, reverse returned to 0

function prototypes: int alt_dma_rxchan_prepare (Alt_dma_rxchan DMA, void* data,
Alt_u32 length, Alt_rxchan_done * done, void* handle)
Input parameters: The channel used by DMA, the data receives the pointer to the location of information, the length of the maximum received data, and done once the data is received, call the return function; handle, non-transparent values are passed to done
Function Description: Send a receive request to the DMA receive channel,
Return value: Successful return of 0, reverse returned as negative

Function prototype: int alt_dma_rxchan_reg (Alt_dma_rxchan_dev * dev)
Input parameters: Dev Receive channel device name
Function Description: To register the DMA receiver channel to the system
Return value: Successful return of 0, reverse returned as negative

Function prototype: int alt_dma_txchan_close (Alt_dma_txchan Txchan)
Input parameters: Txchan Send channel name
Function Description: Notification System: Application has completed DMA send channel Txchan
Return value: Successful return of 0, reverse returned as negative

function prototypes: int alt_dma_txchan_ioctl (Alt_dma_txchan DMA, int req, void* Arg)
Input parameters: DMA Direct memory name; Req for enumeration of request operations; Additional parameters for ARG request, determined by request
Function Description: Perform the specific I/O operation of the device via DMA send Channel
Return value: The request specific value is returned successfully, and the inverse is returned as a negative number

Function prototypes: Alt_dma_txchan alt_dma_txchan_open (const char* name)
Input parameter: Name is a constant digit character pointer, such as/DEV/DMA_0
Function Description: Get a Alt_dma_rxchan descriptor for the DMA send channel
Return value: Successful return of non 0, reverse returned to 0

function prototypes: int alt_dma_txchan_reg (alt_dma_txchan_dev* dev)
Input parameters: Dev Receive channel device name
Function Description: To register DMA transmit channel to System
Return value: Successful return of 0, reverse returned as negative

function prototypes: int alt_dma_txchan_send (Alt_dma_txchan DMA, const void* from,
Alt_u32 length, alt_txchan_done* done, void* handle)
Input parameters: The channel used by DMA, the data receives the pointer to the location of information, the length of the maximum received data, and done once the data is received, call the return function; handle, non-transparent values are passed to done
Function Description: Send a Send request to the DMA send channel,
Return value: Send successful return 0, reverse return to negative

Function prototype: NT Alt_dma_txchan_space (Alt_dma_txchan DMA)
Input parameters: DMA Direct Memory name
Function Description: Returns the number of send requests transmitted to the specific DMA send channel
Return value: Returns the number of Send requests

Flash
Function prototype: int alt_erase_flash_block (alt_flash_fd* fd, int offset, int length)
Input parameters: FD for the specific flash device; offset erase flash module offsets; length Erase flash module
Function Description: Erase a separate flash module
Return value: Send successful return 0, reverse return to negative

Function prototype: void Alt_flash_close_dev (ALT_FLASH_FD * fd)
Input parameters: FD for specific flash device
Function Description: Turn off the flash device
return value:-

Function prototype: ALT_FLASH_FD * ALT_FLASH_OPEN_DEV (const char* name)
Input parameters:
Function Description: Open the flash device. Once opened, the function Alt_write_flash () is used to write, the function Alt_read_flash () is used to read the data, or use the function Alt_get_flash_info (), Alt_erase_flash_block (), Alt_ Write_flash_block (), controlling a single module
Return value: Failed return 0, other value succeeded

function prototypes: int alt_get_flash_info (alt_flash_fd* fd, flash_region * * info,
int* number_of_regions)
Input parameters: FD flash device; info point pointer to flash_region structure; number_of_regions
Function Description: Get the details of the erase Flash area
Return value: Send successful return 0, reverse return to negative

function prototypes: int Alt_read_flash (alt_flash_fd* fd, int offset, void* dest_addr, int length)
Input parameters: DEST_ADDR Target Address pointer
Function Description: Start reading data from Flash offset to offset byte and write to destination address dest_addr
Return value: Successful return 0, not 0
function prototypes: int Alt_write_flash (alt_flash_fd* fd, int offset, const void* SRC_ADDR,
int length)
Input parameters: src_addr Source Address, fd,flash device, offset offset, length byte
Function Description: Write data to Flsah, the data to be written in the source address src_addr
Return value: Successful return 0, not 0

function prototypes: int alt_write_flash_block (alt_flash_fd* fd, int block_offset, int data_offset,
const void *data, int length)
Input parameter: Fd;data_offset The offset of the starting write data; length is the amount of data to write
Function Description: Write to an erased Flash module
Return value: Successful return 0, not 0

Irq
Function prototype: Alt_irq_context alt_irq_disable_all (void)
Input parameter: void
Function Description: Disable all interrupts
Return value: The value passed as an input parameter for subsequent function calls


Function prototype: void Alt_irq_enable_all (Alt_irq_context context)
Input parameters: The return value of the previously called Function Alt_irq_disable_all (void),
Function Description: Start all interrupts
return value:-

Function prototype: int alt_irq_enabled (void)
Input parameter: void
Function Description: Start interrupt
Return value: Prohibit interrupt return 0, instead of 0

function prototypes: int alt_irq_register (alt_u32 ID, void* context, void (*ISR) (void*, alt_u32))
Input parameters: id,32 bit unsigned number, interrupt enable, context and ID are two input parameters of ISR, call ISR on interrupt activation
Function Description: Register an ISR
Return value: Successful return 0, not 0


function prototypes: int Alt_write_flash (alt_flash_fd* fd, int offset, const void* SRC_ADDR,
int length)
Input parameters: src_addr Source Address, fd,flash device, offset offset, length byte
Function Description: Write data to Flsah, the data to be written in the source address src_addr
Return value: Successful return 0, not 0

function prototypes: int alt_write_flash_block (alt_flash_fd* fd, int block_offset, int data_offset,
const void *data, int length)
Input parameter: Fd;data_offset The offset of the starting write data; length is the amount of data to write
Function Description: Write to an erased Flash module
Return value: Successful return 0, not 0

Function prototype: int close (int filedes)
Input parameters: Filedes, descriptor
Function Description: Standard UNIX function close (), close file descriptor Filedes
Return value: Successful return 0, reverse 1

Function prototypes: int open (const char* pathname, int flags, mode_t mode)
Input parameters: Pathname, path name, flags,o_rdonly or o_wronly or O_RDWR, corresponding to read-only, write-only, or read-write operations; mode, using license instructions
Function Description: Open file or device, return a file descriptor (non-negative integer used in read and write)
Return value: Successful return of the file descriptor, reverse 1

function prototypes: int read (int file, void *ptr, size_t len)
Input parameters: file descriptor; PTR is the position pointer of the read data, Len reads the length of the data in bytes
Function Description: Reads a block of data from a file or device
Return value: The number of bytes read successfully returned, reverse 1

Function prototypes: clock_t times (struct TMS *buf)
Input parameters: BUF struct pointer
Function Description: NEWLIB,TMS-compatible struct pointers are as follows:
Type struct
{clock_t tms_utime;
clock_t Tms_stime;
clock_t Tms_cutime;
clock_t Tms_sutime;
};
TMS_UTIME:CPU request execution time of user instruction
TMS_STIME:CPU request execution time of the process represented by the system
Tms_cutime: The sum of the time of all child processes Tms_utime and Tms_cutime
Tms_sutime: The sum of the time of all child processes Tms_stime and Tms_sutime
Return value: Returns the number of clocks and returns 0 without a clock

Function prototype: int usleep (int us)
Input parameter: US, in microseconds
Function Description: Not unblocked until US microseconds, i.e. its function is equivalent to the delay of US microseconds
Return value: Successful return 0, vice versa-1, there is an error occurred showing the cause of the error

Function prototype: int wait (int *status)
Input parameters: Status process state pointer
Function Description: function is to wait for all child processes to exit, since HAL does not support the dispersal of child processes, the function immediately returns
Return value: Status content clear 0, indicating no child process; return value is-1, and errno is set to Echild, indicating that no child processes are waiting

function prototypes: int write (int file, const void *ptr, size_t len)
Input parameters: file descriptor; PTR is the position pointer of the read data, Len reads the length of the data in bytes
Function Description: Writes a data block to a file or device,
Return value: The number of bytes written successfully, or less than the requested length, or 1, in case an error occurs, errno is set to the cause of the occurrence

Standard types of data
Type description
Alt_8 symbol 8-bit integer
Alt_u8 unsigned 8-bit integer
Alt_16 symbol 16-bit integer
Alt_u16 unsigned 16-bit integer
Alt_32 symbol 32-bit integer
Alt_u32 unsigned 32-bit integer

The following to organize themselves
function prototypes: int fopen (char * file_name, way_use);
Input parameters: file_name file name, way_use using files, such as R,w, respectively, corresponding to read and write
Function Description: Open file, do some kind of file operation on it
Return value: Error when not open, return a null pointer null

function prototypes: int fclose (FP)
Input parameters: FP is defined as: FILE *FP
Function Description: Close file fp
Return value: Successful return 0, reverse 1 (EOF)


function prototypes: int fread (void *ptr, int size, int count, FILE * fp);
Input parameters: Buffer is the pointer, the address is read into the data, the size reads bytes, the count reads the number of bytes, and the FP file type pointer
Function Description: Reading data from a stream
Return value: The successful return value is count

function prototypes: int fwrite (void *ptr, int size, int count, FILE *FP)
Input parameter: Buffer is the pointer, the address is read into the data, the size reads bytes, the count reads the number of bytes, and the FP file type pointer,
Function Description: Write content into the stream
Return value: The successful return value is count


function prototypes: int fprintf (FILE *fp, char *format[, argument,...]);
Input parameters: FP file type pointer; format format string; [, Argument,...] Output list, such as:
fprintf (FP, "%d,%f", i,t)
Function Description: Transfer formatted output to a stream
return value:-

function prototypes: int fscanf (FILE * fp, char *format[,argument ...])
Input parameters: FP file type pointer; format format string; [, Argument,...] Enter a list, such as:
FSCANF (FP, "%d,%f", i,t)
Function Description: Performs a formatted input from a stream
return value:-

function prototypes: int FPUTC (int ch, FILE *FP)
Input parameters: ch character; fp: file-Type pointer
Function Description: Send a character to a stream
Return value: Successful return character, Reverse 1 (EOF)

Function prototype: int fgetc (FILE *fp);
Input parameters: fp: file-Type pointer
Function Description: Reading characters from the stream
Return value: Encountered end of File return-1 (EOF)

function prototypes: int putw (int w, FILE *FP)
Input parameter: w: character or word; fp: file-Type pointer
Function Description: Send a character or word to the stream
return value:-

Function prototype: int GETW (FILE *fp)
Input parameters: fp: file-Type pointer
Function Description: Take an integer from the stream
return value:-

Function prototype: Int rewind (FILE *fp)
Input parameters: fp: file-Type pointer
Function Description: Re-point the file pointer to the beginning of a stream
return value:-

function prototypes: int fseek (FILE *fp, long offset, int fromwhere);
Input parameters: fp: file-type pointer; offset:long-type offset; Fromwhere: starting point
The starting point for 0,1,2 is the beginning of the file, the current position, the end of the file
Function Description: Reposition the file pointer on the stream
return value:-

Function prototype: int ferror (FILE *fp)
Input parameters: fp: file-Type pointer
Function Description: Detect errors on the stream
Return value: No error The return value is 0, and vice versa is not 0

Function prototype: Long Ftell (FILE *FP)
Input parameters: fp: file-Type pointer
Function Description: Returns the current file pointer and gets the current position
Return value: 1 indicates an error, and vice versa is not 0

Function prototype: void Clearerr (FILE *fp)
Input parameters: fp: file-Type pointer
Function Description: RESET Error flag
Return value: Error is not 0, and vice versa is 0

Function prototypes: Char *fgets (char *string, int n, FILE *fp)
Input parameters: string: string pointer; fp: file-Type pointer
Function Description: Reads a string from the stream, but only enters n-1 characters from the file, and the last one is the ' \ S ' End flag bit
return value:-

Function prototypes: NT fputs (char *string, FILE *FP)
Input parameters: string: string pointer; fp: file-Type pointer
Function Description: Send a string into a stream
return value:-

Function prototype: int feof (FILE *fp)
Input parameters: fp: file-Type pointer
Function Description: Detect file Terminator on stream
return value:-


Nios II IDE Command line Tools
Tool Descriptor
Nios2-create-system-library creating a new System library project
Nios2-create-application-project to create a C + + library project
Nios2-build-project Use the Nios II IDE to compile the project, create or update a file to compile the project, the operation must be present in the current Nios II IDE workspace
Nios2-import-project Import a previously created Nios II IDE project to the current working range
Nios2-delete-project removing a project from the Nios II IDE working range


Altera command-line Tools
Tool Descriptor
Nios2-download downloading code to the target processor for debugging or running
Nios2-flash-programmer programming data to flash memory on the target board
Nios2-gdb-server the GNU Debugger Remote serial protocol is translated into a common Test action Group (JTAG) transaction via TCP with the target Nios II processor
Nios2-terminal using the JTAG Universal Asynchronous Transceiver (UART) to terminate I/O in the Nios II system
Validate_zip verifying that the specified ZIP file is compatible with Altera read-only zip file system


File Conversion Utilities
Utility Descriptor
Bin2flash to download to flash memory, convert the binary file to a. flash file
Elf2dat to adapt the Verilog HDL hardware emulation, convert the. Elf executable format to the. dat file format
Elf2flash to download to flash memory, convert the. Elf executable file format to a. Flash file
Elf2hex Convert. Elf executable file format to intel.hex file format
Elf2mem Generating storage content for storage devices in the specified Nios II system
ELF2MIF Convert. Elf executable file format to Quartus II memory initialization file (. mif) format
Flash2dat for Verilog HDL hardware emulation, convert. Flash executable file format to. dat file format
Mk-nios2-signaltap-mnemonic-table get an. elf file and Sopc Builder System file (. PTF), create a. STP containing Nios II child token set memory table and Altera's Signaltap ® II file for Logic Analyzer symbols
Sof2flash to download to flash memory, convert the FPGA configuration file (. sof) to a. Flash file


Backward compatibility Tools
Tool Descriptor
Nios2-build compiled and linked software engineering based on the traditional SDK library
Nios2-run Download program to Nios II processor, terminating I/O becomes
Nios2-debug Download program to Nios II processor, start the Insight debugger
Nios2-console Open FS2 Command line interface (CLI), connect to Nios II processor, (selectively download code)

――
Irq


Iord_16direct (BASE, OFFSET)
Reads 16Bit of data directly from a register with an address location of Base+offset
Iord_8direct (BASE, OFFSET)
Reads 8Bit of data directly from a register with an address location of Base+offset

Iowr_32direct (BASE, OFFSET, DATA)
Writes 32Bit of data directly to a register in the address location of Base+offset

Iowr_16direct (BASE, OFFSET, DATA)
Writes 16Bit of data directly to a register in the address location of Base+offset
Iowr_8direct (BASE, OFFSET, DATA)
Writes 8Bit of data directly to a register in the address location of Base+offset
Iord (BASE, REGNUM)
The value in the register of Regnum is read from the base site-based device. The value of the register is within the range of address bus.
IOWR (BASE, REGNUM, DATA)
Base is the base address, and the data is written to the offset of the Regnum register. The value of the register is within the range of address bus.
Iord_32direct (BASE, OFFSET)
Base is the base address of the register, offset is the amount of the register.
Reads 32Bit of data directly from a register with an address location of Base+offset
Iord_16direct (BASE, OFFSET)
Reads 16Bit of data directly from a register with an address location of Base+offset
Iord_8direct (BASE, OFFSET)
Reads 8Bit of data directly from a register with an address location of Base+offset

Iowr_32direct (BASE, OFFSET, DATA)
Writes 32Bit of data directly to a register in the address location of Base+offset

Iowr_16direct (BASE, OFFSET, DATA)
Writes 16Bit of data directly to a register in the address location of Base+offset
Iowr_8direct (BASE, OFFSET, DATA)
Writes 8Bit of data directly to a register in the address location of Base+offset

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.