Obsolete the old MACROS and MACROE convenience macros.

This commit is contained in:
Dean Camera 2014-09-14 11:45:02 +10:00
parent 6c8ebd70c7
commit 41634c4530
14 changed files with 91 additions and 91 deletions

View File

@ -55,9 +55,9 @@
* \param[in] Acode New SCSI additional sense key to set the additional sense code to * \param[in] Acode New SCSI additional sense key to set the additional sense code to
* \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to * \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to
*/ */
#define SCSI_SET_SENSE(Key, Acode, Aqual) MACROS{ SenseData.SenseKey = (Key); \ #define SCSI_SET_SENSE(Key, Acode, Aqual) do { SenseData.SenseKey = (Key); \
SenseData.AdditionalSenseCode = (Acode); \ SenseData.AdditionalSenseCode = (Acode); \
SenseData.AdditionalSenseQualifier = (Aqual); }MACROE SenseData.AdditionalSenseQualifier = (Aqual); } while (0)
/** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */ /** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */
#define DATA_READ true #define DATA_READ true

View File

@ -56,9 +56,9 @@
* \param[in] Acode New SCSI additional sense key to set the additional sense code to * \param[in] Acode New SCSI additional sense key to set the additional sense code to
* \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to * \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to
*/ */
#define SCSI_SET_SENSE(Key, Acode, Aqual) MACROS{ SenseData.SenseKey = (Key); \ #define SCSI_SET_SENSE(Key, Acode, Aqual) do { SenseData.SenseKey = (Key); \
SenseData.AdditionalSenseCode = (Acode); \ SenseData.AdditionalSenseCode = (Acode); \
SenseData.AdditionalSenseQualifier = (Aqual); }MACROE SenseData.AdditionalSenseQualifier = (Aqual); } while (0)
/** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */ /** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */
#define DATA_READ true #define DATA_READ true

View File

@ -56,9 +56,9 @@
* \param[in] Acode New SCSI additional sense key to set the additional sense code to * \param[in] Acode New SCSI additional sense key to set the additional sense code to
* \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to * \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to
*/ */
#define SCSI_SET_SENSE(Key, Acode, Aqual) MACROS{ SenseData.SenseKey = (Key); \ #define SCSI_SET_SENSE(Key, Acode, Aqual) do { SenseData.SenseKey = (Key); \
SenseData.AdditionalSenseCode = (Acode); \ SenseData.AdditionalSenseCode = (Acode); \
SenseData.AdditionalSenseQualifier = (Aqual); }MACROE SenseData.AdditionalSenseQualifier = (Aqual); } while (0)
/** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */ /** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */
#define DATA_READ true #define DATA_READ true

View File

@ -118,32 +118,32 @@
* *
* \param[in] Buffer Application buffer to lock * \param[in] Buffer Application buffer to lock
*/ */
#define TCP_APP_CAPTURE_BUFFER(Buffer) MACROS{ Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->InUse = true; }MACROE #define TCP_APP_CAPTURE_BUFFER(Buffer) do { Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->InUse = true; } while (0)
/** Application macro: Releases a captured application buffer, allowing for host-to-device packets to be received. /** Application macro: Releases a captured application buffer, allowing for host-to-device packets to be received.
* *
* \param[in] Buffer Application buffer to release * \param[in] Buffer Application buffer to release
*/ */
#define TCP_APP_RELEASE_BUFFER(Buffer) MACROS{ Buffer->InUse = false; }MACROE #define TCP_APP_RELEASE_BUFFER(Buffer) do { Buffer->InUse = false; } while (0)
/** Application macro: Sends the contents of the given application buffer to the host. /** Application macro: Sends the contents of the given application buffer to the host.
* *
* \param[in] Buffer Application buffer to send * \param[in] Buffer Application buffer to send
* \param[in] Len Length of data contained in the buffer * \param[in] Len Length of data contained in the buffer
*/ */
#define TCP_APP_SEND_BUFFER(Buffer, Len) MACROS{ Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->Length = Len; Buffer->Ready = true; }MACROE #define TCP_APP_SEND_BUFFER(Buffer, Len) do { Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->Length = Len; Buffer->Ready = true; } while (0)
/** Application macro: Clears the application buffer, ready for a packet to be written to it. /** Application macro: Clears the application buffer, ready for a packet to be written to it.
* *
* \param[in] Buffer Application buffer to clear * \param[in] Buffer Application buffer to clear
*/ */
#define TCP_APP_CLEAR_BUFFER(Buffer) MACROS{ Buffer->Ready = false; Buffer->Length = 0; }MACROE #define TCP_APP_CLEAR_BUFFER(Buffer) do { Buffer->Ready = false; Buffer->Length = 0; } while (0)
/** Application macro: Closes an open connection to a host. /** Application macro: Closes an open connection to a host.
* *
* \param[in] Connection Open TCP connection to close * \param[in] Connection Open TCP connection to close
*/ */
#define TCP_APP_CLOSECONNECTION(Connection) MACROS{ Connection->State = TCP_Connection_Closing; }MACROE #define TCP_APP_CLOSECONNECTION(Connection) do { Connection->State = TCP_Connection_Closing; } while (0)
/* Enums: */ /* Enums: */
/** Enum for possible TCP port states. */ /** Enum for possible TCP port states. */

View File

@ -56,9 +56,9 @@
* \param[in] Acode New SCSI additional sense key to set the additional sense code to * \param[in] Acode New SCSI additional sense key to set the additional sense code to
* \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to * \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to
*/ */
#define SCSI_SET_SENSE(Key, Acode, Aqual) MACROS{ SenseData.SenseKey = (Key); \ #define SCSI_SET_SENSE(Key, Acode, Aqual) do { SenseData.SenseKey = (Key); \
SenseData.AdditionalSenseCode = (Acode); \ SenseData.AdditionalSenseCode = (Acode); \
SenseData.AdditionalSenseQualifier = (Aqual); }MACROE SenseData.AdditionalSenseQualifier = (Aqual); } while (0)
/** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */ /** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */
#define DATA_READ true #define DATA_READ true

View File

@ -57,9 +57,9 @@
* \param[in] Acode New SCSI additional sense key to set the additional sense code to * \param[in] Acode New SCSI additional sense key to set the additional sense code to
* \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to * \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to
*/ */
#define SCSI_SET_SENSE(Key, Acode, Aqual) MACROS{ SenseData.SenseKey = (Key); \ #define SCSI_SET_SENSE(Key, Acode, Aqual) do { SenseData.SenseKey = (Key); \
SenseData.AdditionalSenseCode = (Acode); \ SenseData.AdditionalSenseCode = (Acode); \
SenseData.AdditionalSenseQualifier = (Aqual); }MACROE SenseData.AdditionalSenseQualifier = (Aqual); } while (0)
/** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */ /** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */
#define DATA_READ true #define DATA_READ true

View File

@ -119,32 +119,32 @@
* *
* \param[in] Buffer Application buffer to lock * \param[in] Buffer Application buffer to lock
*/ */
#define TCP_APP_CAPTURE_BUFFER(Buffer) MACROS{ Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->InUse = true; }MACROE #define TCP_APP_CAPTURE_BUFFER(Buffer) do { Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->InUse = true; } while (0)
/** Application macro: Releases a captured application buffer, allowing for host-to-device packets to be received. /** Application macro: Releases a captured application buffer, allowing for host-to-device packets to be received.
* *
* \param[in] Buffer Application buffer to release * \param[in] Buffer Application buffer to release
*/ */
#define TCP_APP_RELEASE_BUFFER(Buffer) MACROS{ Buffer->InUse = false; }MACROE #define TCP_APP_RELEASE_BUFFER(Buffer) do { Buffer->InUse = false; } while (0)
/** Application macro: Sends the contents of the given application buffer to the host. /** Application macro: Sends the contents of the given application buffer to the host.
* *
* \param[in] Buffer Application buffer to send * \param[in] Buffer Application buffer to send
* \param[in] Len Length of data contained in the buffer * \param[in] Len Length of data contained in the buffer
*/ */
#define TCP_APP_SEND_BUFFER(Buffer, Len) MACROS{ Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->Length = Len; Buffer->Ready = true; }MACROE #define TCP_APP_SEND_BUFFER(Buffer, Len) do { Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->Length = Len; Buffer->Ready = true; } while (0)
/** Application macro: Clears the application buffer, ready for a packet to be written to it. /** Application macro: Clears the application buffer, ready for a packet to be written to it.
* *
* \param[in] Buffer Application buffer to clear * \param[in] Buffer Application buffer to clear
*/ */
#define TCP_APP_CLEAR_BUFFER(Buffer) MACROS{ Buffer->Ready = false; Buffer->Length = 0; }MACROE #define TCP_APP_CLEAR_BUFFER(Buffer) do { Buffer->Ready = false; Buffer->Length = 0; } while (0)
/** Application macro: Closes an open connection to a host. /** Application macro: Closes an open connection to a host.
* *
* \param[in] Connection Open TCP connection to close * \param[in] Connection Open TCP connection to close
*/ */
#define TCP_APP_CLOSECONNECTION(Connection) MACROS{ Connection->State = TCP_Connection_Closing; }MACROE #define TCP_APP_CLOSECONNECTION(Connection) do { Connection->State = TCP_Connection_Closing; } while (0)
/* Enums: */ /* Enums: */
/** Enum for possible TCP port states. */ /** Enum for possible TCP port states. */

View File

@ -70,18 +70,18 @@
* *
* \note This macro is not available for all architectures. * \note This macro is not available for all architectures.
*/ */
#define JTAG_ENABLE() MACROS{ \ #define JTAG_ENABLE() do { \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"in __tmp_reg__,__SREG__" "\n\t" \ "in __tmp_reg__,__SREG__" "\n\t" \
"cli" "\n\t" \ "cli" "\n\t" \
"out %1, %0" "\n\t" \ "out %1, %0" "\n\t" \
"out __SREG__, __tmp_reg__" "\n\t" \ "out __SREG__, __tmp_reg__" "\n\t" \
"out %1, %0" "\n\t" \ "out %1, %0" "\n\t" \
: \ : \
: "r" (MCUCR & ~(1 << JTD)), \ : "r" (MCUCR & ~(1 << JTD)), \
"M" (_SFR_IO_ADDR(MCUCR)) \ "M" (_SFR_IO_ADDR(MCUCR)) \
: "r0"); \ : "r0"); \
}MACROE } while (0)
/** Disables the AVR's JTAG bus in software, until a system reset. This will override the current JTAG /** Disables the AVR's JTAG bus in software, until a system reset. This will override the current JTAG
* status as set by the JTAGEN fuse, disabling JTAG debugging and reverting the JTAG pins back to GPIO * status as set by the JTAGEN fuse, disabling JTAG debugging and reverting the JTAG pins back to GPIO
@ -89,18 +89,18 @@
* *
* \note This macro is not available for all architectures. * \note This macro is not available for all architectures.
*/ */
#define JTAG_DISABLE() MACROS{ \ #define JTAG_DISABLE() do { \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"in __tmp_reg__,__SREG__" "\n\t" \ "in __tmp_reg__,__SREG__" "\n\t" \
"cli" "\n\t" \ "cli" "\n\t" \
"out %1, %0" "\n\t" \ "out %1, %0" "\n\t" \
"out __SREG__, __tmp_reg__" "\n\t" \ "out __SREG__, __tmp_reg__" "\n\t" \
"out %1, %0" "\n\t" \ "out %1, %0" "\n\t" \
: \ : \
: "r" (MCUCR | (1 << JTD)), \ : "r" (MCUCR | (1 << JTD)), \
"M" (_SFR_IO_ADDR(MCUCR)) \ "M" (_SFR_IO_ADDR(MCUCR)) \
: "r0"); \ : "r0"); \
}MACROE } while (0)
#endif #endif
/** Defines a volatile \c NOP statement which cannot be optimized out by the compiler, and thus can always /** Defines a volatile \c NOP statement which cannot be optimized out by the compiler, and thus can always
@ -124,7 +124,10 @@
* *
* \param[in] Condition Condition that will be evaluated. * \param[in] Condition Condition that will be evaluated.
*/ */
#define JTAG_ASSERT(Condition) MACROS{ if (!(Condition)) { JTAG_DEBUG_BREAK(); } }MACROE #define JTAG_ASSERT(Condition) do { \
if (!(Condition)) \
JTAG_DEBUG_BREAK(); \
} while (0)
/** Macro for testing condition \c "x" and writing debug data to the stdout stream if \c false. The stdout stream /** Macro for testing condition \c "x" and writing debug data to the stdout stream if \c false. The stdout stream
* must be pre-initialized before this macro is run and linked to an output device, such as the microcontroller's * must be pre-initialized before this macro is run and linked to an output device, such as the microcontroller's
@ -136,17 +139,17 @@
* *
* \param[in] Condition Condition that will be evaluated, * \param[in] Condition Condition that will be evaluated,
*/ */
#define STDOUT_ASSERT(Condition) MACROS{ if (!(Condition)) { \ #define STDOUT_ASSERT(Condition) do { \
printf_P(PSTR("%s: Function \"%s\", Line %d: " \ if (!(Condition)) \
"Assertion \"%s\" failed.\r\n"), \ printf_P(PSTR("%s: Function \"%s\", Line %d: " \
__FILE__, __func__, __LINE__, #Condition); } }MACROE "Assertion \"%s\" failed.\r\n"), \
__FILE__, __func__, __LINE__, #Condition); \
} while (0)
#if !defined(pgm_read_ptr) || defined(__DOXYGEN__) #if !defined(pgm_read_ptr) || defined(__DOXYGEN__)
/** Reads a pointer out of PROGMEM space on the AVR8 architecture. This is currently a wrapper for the /** Reads a pointer out of PROGMEM space on the AVR8 architecture. This is a wrapper for the avr-libc
* avr-libc \c pgm_read_word() macro with a \c void* cast, so that its value can be assigned directly * \c pgm_read_word() macro with a \c void* cast, so that its value can be assigned directly to a
* to a pointer variable or used in pointer arithmetic without further casting in C. In a future * pointer variable or used in pointer arithmetic without further casting in C.
* avr-libc distribution this will be part of the standard API and will be implemented in a more formal
* manner.
* *
* \note This macro is not available for all architectures. * \note This macro is not available for all architectures.
* *
@ -154,16 +157,21 @@
* *
* \return Pointer retrieved from PROGMEM space. * \return Pointer retrieved from PROGMEM space.
*/ */
#define pgm_read_ptr(Address) (void*)pgm_read_word(Address) #define pgm_read_ptr(Address) (void*)pgm_read_word(Address)
#endif #endif
#elif (ARCH == ARCH_UC3) #elif (ARCH == ARCH_UC3)
#define JTAG_DEBUG_POINT() __asm__ __volatile__ ("nop" ::) #define JTAG_DEBUG_POINT() __asm__ __volatile__ ("nop" ::)
#define JTAG_DEBUG_BREAK() __asm__ __volatile__ ("breakpoint" ::) #define JTAG_DEBUG_BREAK() __asm__ __volatile__ ("breakpoint" ::)
#define JTAG_ASSERT(Condition) MACROS{ if (!(Condition)) { JTAG_DEBUG_BREAK(); } }MACROE #define JTAG_ASSERT(Condition) do { \
#define STDOUT_ASSERT(Condition) MACROS{ if (!(Condition)) { \ if (!(Condition)) \
printf("%s: Function \"%s\", Line %d: " \ JTAG_DEBUG_BREAK(); \
"Assertion \"%s\" failed.\r\n"), \ } while (0)
__FILE__, __func__, __LINE__, #Condition); } }MACROE #define STDOUT_ASSERT(Condition) do { \
if (!(Condition)) \
printf("%s: Function \"%s\", Line %d: " \
"Assertion \"%s\" failed.\r\n", \
__FILE__, __func__, __LINE__, #Condition); \
} while (0)
#endif #endif
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */

View File

@ -145,19 +145,11 @@
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */ /* Macros: */
/** Macro for encasing other multi-statement macros. This should be used along with an opening brace #if !defined(__DOXYGEN__)
* before the start of any multi-statement macro, so that the macros contents as a whole are treated // Obsolete, retained for compatibility with user code
* as a discrete block and not as a list of separate statements which may cause problems when used as #define MACROS do
* a block (such as inline \c if statements). #define MACROE while (0)
*/ #endif
#define MACROS do
/** Macro for encasing other multi-statement macros. This should be used along with a preceding closing
* brace at the end of any multi-statement macro, so that the macros contents as a whole are treated
* as a discrete block and not as a list of separate statements which may cause problems when used as
* a block (such as inline \c if statements).
*/
#define MACROE while (0)
/** Convenience macro to determine the larger of two values. /** Convenience macro to determine the larger of two values.
* *

View File

@ -186,9 +186,9 @@
#endif #endif
/* Macros: */ /* Macros: */
#define HOST_TASK_NONBLOCK_WAIT(Duration, NextState) MACROS{ USB_HostState = HOST_STATE_WaitForDevice; \ #define HOST_TASK_NONBLOCK_WAIT(Duration, NextState) do { USB_HostState = HOST_STATE_WaitForDevice; \
WaitMSRemaining = (Duration); \ WaitMSRemaining = (Duration); \
PostWaitState = (NextState); }MACROE PostWaitState = (NextState); } while (0)
#endif #endif
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */

View File

@ -63,7 +63,7 @@
// #define XCK_RESCUE_CLOCK_ENABLE // #define XCK_RESCUE_CLOCK_ENABLE
// #define INVERTED_ISP_MISO // #define INVERTED_ISP_MISO
// #define LIBUSB_DRIVER_COMPAT #define LIBUSB_DRIVER_COMPAT
// #define RESET_TOGGLES_LIBUSB_COMPAT // #define RESET_TOGGLES_LIBUSB_COMPAT
// #define FIRMWARE_VERSION_MINOR 0x11 // #define FIRMWARE_VERSION_MINOR 0x11

View File

@ -11,10 +11,10 @@
# Run "make help" for target help. # Run "make help" for target help.
MCU = at90usb162 MCU = at90usb1287
ARCH = AVR8 ARCH = AVR8
BOARD = USBTINYMKII BOARD = USBKEY
F_CPU = 16000000 F_CPU = 8000000
F_USB = $(F_CPU) F_USB = $(F_CPU)
OPTIMIZATION = s OPTIMIZATION = s
TARGET = AVRISP-MKII TARGET = AVRISP-MKII

View File

@ -56,9 +56,9 @@
* \param[in] Acode New SCSI additional sense key to set the additional sense code to * \param[in] Acode New SCSI additional sense key to set the additional sense code to
* \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to * \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to
*/ */
#define SCSI_SET_SENSE(Key, Acode, Aqual) MACROS{ SenseData.SenseKey = (Key); \ #define SCSI_SET_SENSE(Key, Acode, Aqual) do { SenseData.SenseKey = (Key); \
SenseData.AdditionalSenseCode = (Acode); \ SenseData.AdditionalSenseCode = (Acode); \
SenseData.AdditionalSenseQualifier = (Aqual); }MACROE SenseData.AdditionalSenseQualifier = (Aqual); } while (0)
/** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */ /** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */
#define DATA_READ true #define DATA_READ true

View File

@ -54,9 +54,9 @@
* \param[in] Acode New SCSI additional sense key to set the additional sense code to * \param[in] Acode New SCSI additional sense key to set the additional sense code to
* \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to * \param[in] Aqual New SCSI additional sense key qualifier to set the additional sense qualifier code to
*/ */
#define SCSI_SET_SENSE(Key, Acode, Aqual) MACROS{ SenseData.SenseKey = (Key); \ #define SCSI_SET_SENSE(Key, Acode, Aqual) do { SenseData.SenseKey = (Key); \
SenseData.AdditionalSenseCode = (Acode); \ SenseData.AdditionalSenseCode = (Acode); \
SenseData.AdditionalSenseQualifier = (Aqual); }MACROE SenseData.AdditionalSenseQualifier = (Aqual); } while (0)
/** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */ /** Macro for the \ref SCSI_Command_ReadWrite_10() function, to indicate that data is to be read from the storage medium. */
#define DATA_READ true #define DATA_READ true