adres portu w C (AVR)

Sep 02, 2006 1 Replies

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



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); }

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required