Krzysztof
Guest
Sat Sep 02, 2006 5:38 pm
Witam!
Jak zrobić coś takiego (w C):
Mam sobie funkcję, która wykonuje te same czynności dla różnych portów
i chciałbym przesłać do tej funkcji adres tego portu.
Jak można to zrobić?
Pozdrawiam
Krzysztof
Guest
Sat Sep 02, 2006 6:00 pm
To było głupie pytanie, przepraszam, dla potomnych:
#include <inttypes.h>
#include <avr/io.h>
void
set_bits_func_wrong (volatile uint8_t port, uint8_t mask)
{
port |= mask;
}
void
set_bits_func_correct (volatile uint8_t *port, uint8_t mask)
{
*port |= mask;
}
#define set_bits_macro(port,mask) ((port) |= (mask))
int main (void)
{
set_bits_func_wrong (PORTB, 0xaa);
set_bits_func_correct (&PORTB, 0x55);
set_bits_macro (PORTB, 0xf0);
return (0);
}