/Designs/Tools/i2c_AVR_USB/SW/firmware/usbtiny/def.h
1,7 → 1,7
// ======================================================================
// Common definitions for the USB driver
//
// Copyright (C) 2006 Dick Streefland
// Copyright 2006-2010 Dick Streefland
//
// This is free software, licensed under the terms of the GNU General
// Public License as published by the Free Software Foundation.
19,12 → 19,12
#define CAT3(a,b,c) CAT3EXP(a, b, c)
#define CAT3EXP(a,b,c) a ## b ## c
 
// I/O Ports
// I/O Ports for USB
#define USB_IN CAT2(PIN, USBTINY_PORT)
#define USB_OUT CAT2(PORT, USBTINY_PORT)
#define USB_DDR CAT2(DDR, USBTINY_PORT)
 
// I/O bit masks
// I/O bit masks for USB
#define USB_MASK_DMINUS (1 << (USBTINY_DMINUS))
#define USB_MASK_DPLUS (1 << (USBTINY_DPLUS))
#define USB_MASK (USB_MASK_DMINUS | USB_MASK_DPLUS)
36,11 → 36,7
# define USB_INT_CONFIG MCUCR
#endif
#define USB_INT_CONFIG_SET ((1 << CAT3(ISC,USBTINY_INT,1)) | (1 << CAT3(ISC,USBTINY_INT,0)))
#if defined SIG_INT0
# define USB_INT_VECTOR CAT2(SIG_INT, USBTINY_INT)
#else
# define USB_INT_VECTOR CAT2(SIG_INTERRUPT, USBTINY_INT)
#endif
#define USB_INT_VECTOR CAT3(INT, USBTINY_INT, _vect)
 
// Interrupt enable
#if defined GIMSK
59,6 → 55,9
# define USB_INT_PENDING GIFR
#endif
#define USB_INT_PENDING_BIT CAT2(INTF,USBTINY_INT)
#if defined INF0 && ! defined INTF0
# define INTF0 INF0 // fix for incorrect definition in iotn13.h
#endif
 
// USB PID values
#define USB_PID_SETUP 0x2d
72,3 → 71,26
 
// Various constants
#define USB_BUFSIZE 11 // PID + data + CRC
 
// Bit manipulation macros
#define BIT_CLR(reg,bit) { (reg) &= ~ _BV(bit); }
#define BIT_SET(reg,bit) { (reg) |= _BV(bit); }
#define BIT_TST(reg,bit) (((reg) & _BV(bit)) != 0)
 
// I/O port manipulation macros
#define DDR_CLR(p,b) BIT_CLR(DDR ## p, b)
#define DDR_SET(p,b) BIT_SET(DDR ## p, b)
#define PORT_CLR(p,b) BIT_CLR(PORT ## p, b)
#define PORT_SET(p,b) BIT_SET(PORT ## p, b)
#define PORT_TST(p,b) BIT_TST(PORT ## p, b)
#define PIN_TST(p,b) BIT_TST(PIN ## p, b)
#define PIN_SET(p,b) BIT_SET(PIN ## p, b)
 
// Macros that can be used with an argument of the form (port,bit)
#define INPUT(bit) DDR_CLR bit
#define OUTPUT(bit) DDR_SET bit
#define CLR(bit) PORT_CLR bit
#define SET(bit) PORT_SET bit
#define ISSET(bit) PORT_TST bit
#define TST(bit) PIN_TST bit
#define TOGGLE(bit) PIN_SET bit