[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] simple macro to dig w/ ports

From: Jkx
Subject: Re: [avr-gcc-list] simple macro to dig w/ ports
Date: Thu, 23 Mar 2006 15:11:12 +0100

On Thu, 23 Mar 2006 08:33:51 -0500
"David VanHorn" <address@hidden> wrote:

> >
> > I'm wondering if one of you have some macros or interesting
> > idea to simplifie the sbi/cbi code. A example is nicer than
> > a long talk.
> >
> > I want to transform this:
> > - sbi(PORTD,PD6)
> > - to something like sbi(PD6) (yes i use a the old fashion
> > sbi/cbi code, because I'm a old fashion guy:)

> This also makes porting this module of code to another AVR, or another
> design as trivial as possible.
> .equ  led_port = portd
> .equ  led_ddr = ddrd
> .equ  led_pin = pind
> .equ  led_bit  = 4
> led_init:
>        sbi   led_ddr,led_bit    ;make sure it's an output
>        cbi   led_port,led_bit   ;off at first
>        ret
> led_on:
>        sbi    led_ddr,led_bit  ;Someone might have messed with my port!
>        sbi    led_port,led_bit
>        ret
> led_off:
>        sbi  led_ddr,led_bit
>        cbi  led_por,led_bit

That's what I first try this kind off recipe. But, I quickly discover this 
doesn't feet really well. Take for example, you want to drive a graphic LCD
which has a bunch of pins, you have to declare a lot of var for the port, 
and DDR. and this is a bit overkill. I think the best way to do this, is to
have something like this:

#define LCD_RW PB6


I think clearly simply the code no ? 

Bye bye

reply via email to

[Prev in Thread] Current Thread [Next in Thread]