Define varables in .ino used in a library

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I have ported microchip's cryptoauthlib to be used with an ATMEGA2560. The Lib implements a HAL interface for either i2c or SWI. I have implemented a SWI. In my implementation within the lib I need to define the SWI pin, port etc...

 

#define		SWI_PORT 		PORTC
#define 	SWI_INPUT_PIN 	        PINC
#define		SWI_DDR			DDRC
#define 	SWI_PIN 		PC0

This is currently defined within the "{path}\Arduino\libraries\cryptoauthlibmega\hal_swi_bitbang.c". I have 2 options that I know of, keep this defines within the library, but this makes it a pain to change. I could also define it in "platform.local.txt".

 

Is there any other way to define it in the .ino file where the compiler will recognize it in my library?

 

 

 

 

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you mean library in the lib.a sense of the word?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Do you mean library in the lib.a sense of the word?

 

Hi - No. The library is in the Arduino's Libraries folders... something like this:

 

My Documents\Arduino\libraries\cryptoauthlibmega

 

 

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So it's built from source? Well in that case the only requirement is surely the the .h to configure it is #included.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
So it's built from source? Well in that case the only requirement is surely the the .h to configure it is #included.

 

Yes. I was hoping I can define them in the .ino file. Since I have the source, there are a number of ways I can pass the data down. No worries. Thanks for the help.

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But the library where the macros are to be used needs to "see" the definitions. So I don't see how you could define them in the .ino. But you could have a project_config.h (or whatever) where you make all common project definitions that need to be "seen everywhere" then just #include that into all the places in which anything that is used from it needs to be seen.

 

One of the slightly annoying things about Arduino is that to simplify things it educates folks to not need to use #include because it has some kind of auto-scanning system which finds the right things to be included anyway. But I don't anything precludes the use of #include in the traditional way.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
One of the slightly annoying things about Arduino is that to simplify things it educates folks to not need to use #include because it has some kind of auto-scanning system which finds the right things to be included anyway. But I don't anything precludes the use of #include in the traditional way.

 

Understood - It's not magic. It is c++ and c in the end. i wasn't sure if I was missing something. I wasn't. You can't do it.

 

I will modify the library to pass in the parameters I need.

 

Thanks for the help 

 

 

"When all else fails, read the directions"