0

I have a piece of code I'd like to make Arduino editor friendly. The code is written in C and contains macros the Arduino IDE can't deal with. Is it a good idea to turn those macros into functions?

#define AN221_EXECUTE_Low cbi(PORTA, PIN0) //drive EXECUTE low
#define AN221_PORb_High sbi(PORTA, PIN1) //drive PORb high
#define AN221_ACTIVATE bit_is_set(PINA, PIN2) //sense ACTIVATE high
#define AN221_NO_ERROR bit_is_set(PINA, PIN3) //sense ERRb high i.e. no rror
#define AN221_ERRb_Input outp(0xEB, DDRA) //make uP drive ERRb
#define AN221_ERRb_Output outp(0xE3, DDRA) //make uP sense ERRb
asked Mar 11, 2017 at 14:14
1
  • Compiled ok for me - what were you expecting and what actually happened? Commented Mar 11, 2017 at 22:04

1 Answer 1

2

Is it a good idea to turn those macros into functions?

it depends.

macros are fast, but lack type checking.

functions offer type checking but incur overhead.

whether one is better than the other depends on your priorities.

answered Mar 11, 2017 at 15:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.