Author Topic: avrlib macros  (Read 3054 times)

0 Members and 1 Guest are viewing this topic.

Offline pomprockerTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
avrlib macros
« on: July 31, 2008, 05:15:54 PM »
Here are a couple good avrlib macros I came across while hanging out in arduino land

#define set_output(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define set_input(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))


#define high(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define low(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: avrlib macros
« Reply #1 on: July 31, 2008, 09:10:25 PM »
that's nice, but IMO it's always better to use the bit operators instead of macros.
this way everyone who reads your code will know easily what's going on.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

 

SMF spam blocked by CleanTalk