Nios® V Processor Software Developer Handbook

ID 743810
Date 4/01/2024
Public
Document Table of Contents

7.9.2.1. altera_avalon_jtag_uart.h Defining Macros

For example, altera_avalon_jtag_uart_regs.h defines specific I/O macros based on HAL I/O macros. It is written to access the DATA and CONTROL registers of the JTAG UART IP. Refer to Embedded Peripheral IP User Guide – JTAG UART Core Software Programming Model for more information on the soft IP’s register map.

Using predefined REGNUM (DATA = 0 and CONTROL = 1), the new I/O macros simplify the HAL I/O macros to two basic parameters – BASE and DATA.

  • IORD_ALTERA_AVALON_JTAG_UART_DATA(BASE)- Simplify IORD(BASE, REGNUM) to IORD(BASE, 0)
  • IOWR_ALTERA_AVALON_JTAG_UART_DATA(BASE, DATA)- Simplify IOWR(BASE, REGNUM, DATA) to IOWR(BASE, 0, DATA)
  • IORD_ALTERA_AVALON_JTAG_UART_CONTROL(BASE)- Simplify IORD(BASE, REGNUM) to IORD(BASE, 1)
  • IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(BASE, DATA)- Simplify IOWR(BASE, REGNUM, DATA) to IOWR(BASE, 1, DATA)

These specific I/O macros are later applied intensively throughout the soft IP device driver source codes,

  • altera_avalon_jtag_uart_fd.c
  • altera_avalon_jtag_uart_init.c
  • altera_avalon_jtag_uart_ioctl.c
  • altera_avalon_jtag_uart_read.c
  • altera_avalon_jtag_uart_write.c

Besides defining new I/O macros, you can adopt similar practice with defining the mask and offset macros in altera_avalon_jtag_uart_regs.h. They are commonly used in bitwise operations with register bit fields.

For more information about a complete example, refer to any of the Intel supplied device drivers, such as the JTAG UART driver in <Intel Quartus Prime installation>/ip/sopc_builder_ip/altera_avalon_jtag_uart.