Загрузить исходник bits.h
/*
* Author: MultiMote
* Date: 03.06.2016
* URL: http://multimote.ru/avr-gcc-cvports
*/
#ifndef __BITS_OPS_H_
#define __BITS_OPS_H_
#define CVPORTS
#include <stdbool.h>
struct port_byte {
bool P0 : 1;
bool P1 : 1;
bool P2 : 1;
bool P3 : 1;
bool P4 : 1;
bool P5 : 1;
bool P6 : 1;
bool P7 : 1;
};
#define _B_DECLPORT(port) struct port_byte *_##port = (struct port_byte *)&(port)
#ifdef CVPORTS
#ifdef PORTA
struct port_byte *CVPORTA = (struct port_byte *) &(PORTA);
struct port_byte *CVPINA = (struct port_byte *) &(PINA);
struct port_byte *CVDDRA = (struct port_byte *) &(DDRA);
#endif
#ifdef PORTB
struct port_byte *CVPORTB = (struct port_byte *) &(PORTB);
struct port_byte *CVPINB = (struct port_byte *) &(PINB);
struct port_byte *CVDDRB = (struct port_byte *) &(DDRB);
#endif
#ifdef PORTC
struct port_byte *CVPORTC = (struct port_byte *) &(PORTC);
struct port_byte *CVPINC = (struct port_byte *) &(PINC);
struct port_byte *CVDDRC = (struct port_byte *) &(DDRC);
#endif
#ifdef PORTD
struct port_byte *CVPORTD = (struct port_byte *) &(PORTD);
struct port_byte *CVPIND = (struct port_byte *) &(PIND);
struct port_byte *CVDDRD = (struct port_byte *) &(DDRD);
#endif
#endif
#define bit_on(dest, pos) ((dest) |= (1 << (pos)))
#define bit_off(dest, pos) ((dest) &= ~(1 << (pos)))
#define bit_set(dest, pos, val) ((dest)^= (-(val) ^ (dest)) & (1 << (pos)))
#define bit_get(dest, pos) (((dest) & (1 << (pos))) != 0)
#endif