Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
904 Views

remove HAL device drivers (preprocessor options)

Hello, 

 

Is there a list anywhere of the available preprocessor options? 

 

I need it because I want to remove some HAL drivers but need some others... For example, I want to access directly the UART peripheral registers but I need the LCD HAL driver. 

 

On the SW Handbook, there is only the way to remove the HAL driver for the CFI_FLASH controller which is explained : We have to specify the option -DALT_NO_CFI_FLASH in the preprocessor options. 

 

Is there an option like this one which removes the UART HAL driver ? 

Is there another way to remove the UART HAL driver ? 

 

Thank you for any help, 

 

Jean LEE
0 Kudos
4 Replies
Highlighted
Valued Contributor III

Re: remove HAL device drivers (preprocessor options)

One way to disable the UART driver is to add a file named 'altera_avalon_uart.h' to your system library project. This file should contain the following: 

 

#define ALTERA_AVALON_UART_INSTANCE(name, device)   # define ALTERA_AVALON_UART_INIT(name, device)   

 

This will stop the HAL installing it's driver, and allow you to provide your own instead. If you want to initialise your driver before main(), you can use these macros - as described in the Nios II Software Developers' Handbook.
0 Kudos
Highlighted
Valued Contributor III

Re: remove HAL device drivers (preprocessor options)

Thank you, 

 

I will try.
0 Kudos
Highlighted
Valued Contributor III

Re: remove HAL device drivers (preprocessor options)

Hi, 

 

I tried and I think that I didn't all understood because the IDE doesn't seem to take my replacement in account. 

 

Well, a bit more explanation of what I am doing could be good : 

 

- I have a working project using HAL libraries which prints data coming from the UART to the LCD 

- I took the source of this project and try now to remove the UART HAL driver (for learning purpose) and replace it by my own HAL driver. 

- I've done what monkeyboy said before : I created an altera_avalon_uart.h in my project with the two lines. 

# ifndef __ALT_AVALON_UART_H__# define __ALT_AVALON_UART_H__ 

# define ALTERA_AVALON_UART_INSTANCE(name, device) NULL# define ALTERA_AVALON_UART_INIT(name, device) NULL 

# endif //__ALT_AVALON_UART_H__ 

 

- I created an empty altera_avalon_uart.c too and included "altera_avalon_uart.h" in my main.c file. 

 

After all of this, I thought that my project won't work anymore. But it stills compile well and runs on my NIOS II development kit Cyclone II. 

I don't really understand why.  

 

Can anybody explain me more in details the library substitution ? 

Do I have to create an alt_main() procedure ( I thought that it was not necesary) ? 

 

I already read the "Boot sequence an entry point" and "Paths to HAL library files" in the Nios II Software Developers' Handbook. 

 

Thank you for any help, 

 

Jean LEE
0 Kudos
Highlighted
Valued Contributor III

Re: remove HAL device drivers (preprocessor options)

Hi, 

 

I found my error : 

 

I put the altera_avalon_uart.h and altera_avalon_uart.c in my project directory but they must be placed in the System Library Project.. 

 

Regards, 

 

Jean
0 Kudos