From 85a0e75c602a4f86b72664ee4cfe85f026f3a64d Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 17 May 2013 20:34:13 +0200 Subject: Improve the BoardDriver build test, check for mismatches board hardware support macros or missing driver macros. --- BuildTests/BoardDriverTest/Board/Buttons.h | 2 ++ BuildTests/BoardDriverTest/Board/Dataflash.h | 30 +++++++++++++++------------- BuildTests/BoardDriverTest/Board/Joystick.h | 16 ++++++++------- BuildTests/BoardDriverTest/Board/LEDs.h | 20 ++++++++++--------- BuildTests/BoardDriverTest/Test.c | 26 +++++++++++++++++++++++- 5 files changed, 63 insertions(+), 31 deletions(-) (limited to 'BuildTests') diff --git a/BuildTests/BoardDriverTest/Board/Buttons.h b/BuildTests/BoardDriverTest/Board/Buttons.h index 9062a3682..315b66d4a 100644 --- a/BuildTests/BoardDriverTest/Board/Buttons.h +++ b/BuildTests/BoardDriverTest/Board/Buttons.h @@ -57,6 +57,8 @@ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. #endif + #define BOARD_DUMMY_BUTTONS_IMPLEMENTATION + /* Public Interface - May be used in end-application: */ /* Macros: */ /** Button mask for the first button on the board. */ diff --git a/BuildTests/BoardDriverTest/Board/Dataflash.h b/BuildTests/BoardDriverTest/Board/Dataflash.h index eae9b7f10..a3af99ca2 100644 --- a/BuildTests/BoardDriverTest/Board/Dataflash.h +++ b/BuildTests/BoardDriverTest/Board/Dataflash.h @@ -52,33 +52,35 @@ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead. #endif + #define BOARD_DUMMY_DATAFLASH_IMPLEMENTATION + /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Macros: */ - #define DATAFLASH_CHIPCS_MASK // TODO: Replace this with a mask of all the /CS pins of all Dataflashes - #define DATAFLASH_CHIPCS_DDR // TODO: Replace with the DDR register name for the board's Dataflash ICs - #define DATAFLASH_CHIPCS_PORT // TODO: Replace with the PORT register name for the board's Dataflash ICs + #define DATAFLASH_CHIPCS_MASK 0 + #define DATAFLASH_CHIPCS_DDR 0 + #define DATAFLASH_CHIPCS_PORT 0 #endif /* Public Interface - May be used in end-application: */ /* Macros: */ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */ - #define DATAFLASH_TOTALCHIPS 1 // TODO: Replace with the number of Dataflashes on the board, max 2 + #define DATAFLASH_TOTALCHIPS 1 /** Mask for no dataflash chip selected. */ #define DATAFLASH_NO_CHIP 0 /** Mask for the first dataflash chip selected. */ - #define DATAFLASH_CHIP1 // TODO: Replace with mask with the pin attached to the first Dataflash /CS set + #define DATAFLASH_CHIP1 0 /** Mask for the second dataflash chip selected. */ - #define DATAFLASH_CHIP2 // TODO: Replace with mask with the pin attached to the second Dataflash /CS set + #define DATAFLASH_CHIP2 0 /** Internal main memory page size for the board's dataflash ICs. */ - #define DATAFLASH_PAGE_SIZE // TODO: Replace with the page size for the Dataflash ICs + #define DATAFLASH_PAGE_SIZE 0 /** Total number of pages inside each of the board's dataflash ICs. */ - #define DATAFLASH_PAGES // TODO: Replace with the total number of pages inside one of the Dataflash ICs + #define DATAFLASH_PAGES 0 /* Inline Functions: */ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. @@ -140,14 +142,14 @@ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; static inline void Dataflash_SelectChip(const uint8_t ChipMask) { - + } /** Deselects the current dataflash chip, so that no dataflash is selected. */ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; static inline void Dataflash_DeselectChip(void) { - + } /** Selects a dataflash IC from the given page number, which should range from 0 to @@ -161,7 +163,7 @@ */ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) { - + } /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive @@ -169,7 +171,7 @@ */ static inline void Dataflash_ToggleSelectedChipCS(void) { - + } /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main @@ -177,7 +179,7 @@ */ static inline void Dataflash_WaitWhileBusy(void) { - + } /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with @@ -188,7 +190,7 @@ */ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte) { - + } #endif diff --git a/BuildTests/BoardDriverTest/Board/Joystick.h b/BuildTests/BoardDriverTest/Board/Joystick.h index 4d7135276..74a5d706c 100644 --- a/BuildTests/BoardDriverTest/Board/Joystick.h +++ b/BuildTests/BoardDriverTest/Board/Joystick.h @@ -57,33 +57,35 @@ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. #endif + #define BOARD_DUMMY_JOYSTICK_IMPLEMENTATION + /* Public Interface - May be used in end-application: */ /* Macros: */ /** Mask for the joystick being pushed in the left direction. */ - #define JOY_LEFT // TODO: Add mask to indicate joystick left position here + #define JOY_LEFT 0 /** Mask for the joystick being pushed in the right direction. */ - #define JOY_RIGHT // TODO: Add mask to indicate joystick right position here + #define JOY_RIGHT 0 /** Mask for the joystick being pushed in the upward direction. */ - #define JOY_UP // TODO: Add mask to indicate joystick up position here + #define JOY_UP 0 /** Mask for the joystick being pushed in the downward direction. */ - #define JOY_DOWN // TODO: Add mask to indicate joystick down position here + #define JOY_DOWN 0 /** Mask for the joystick being pushed inward. */ - #define JOY_PRESS // TODO: Add mask to indicate joystick pressed position here + #define JOY_PRESS 0 /* Inline Functions: */ #if !defined(__DOXYGEN__) static inline void Joystick_Init(void) { - + } static inline void Joystick_Disable(void) { - + } static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; diff --git a/BuildTests/BoardDriverTest/Board/LEDs.h b/BuildTests/BoardDriverTest/Board/LEDs.h index cdb057d1d..4857857c7 100644 --- a/BuildTests/BoardDriverTest/Board/LEDs.h +++ b/BuildTests/BoardDriverTest/Board/LEDs.h @@ -57,17 +57,19 @@ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. #endif + #define BOARD_DUMMY_LEDS_IMPLEMENTATION + /* Public Interface - May be used in end-application: */ /* Macros: */ /** LED mask for the first LED on the board. */ #define LEDS_LED1 (1 << 0) - + /** LED mask for the second LED on the board. */ #define LEDS_LED2 (1 << 1) /** LED mask for the third LED on the board. */ #define LEDS_LED3 (1 << 2) - + /** LED mask for the fourth LED on the board. */ #define LEDS_LED4 (1 << 3) @@ -81,37 +83,37 @@ #if !defined(__DOXYGEN__) static inline void LEDs_Init(void) { - + } static inline void LEDs_Disable(void) { - + } static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) { - + } static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) { - + } static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) { - + } static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) { - + } static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) { - + } static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; diff --git a/BuildTests/BoardDriverTest/Test.c b/BuildTests/BoardDriverTest/Test.c index c9f836eaa..896010e3c 100644 --- a/BuildTests/BoardDriverTest/Test.c +++ b/BuildTests/BoardDriverTest/Test.c @@ -35,6 +35,22 @@ #include #include +#if defined(BOARD_HAS_BUTTONS) == defined(BOARD_DUMMY_BUTTONS_IMPLEMENTATION) + #error Mismatch between BOARD_HAS_BUTTONS and implementation. +#endif + +#if defined(BOARD_HAS_DATAFLASH) == defined(BOARD_DUMMY_DATAFLASH_IMPLEMENTATION) + #error Mismatch between BOARD_HAS_DATAFLASH and implementation. +#endif + +#if defined(BOARD_HAS_LEDS) == defined(BOARD_DUMMY_LEDS_IMPLEMENTATION) + #error Mismatch between BOARD_HAS_LEDS and implementation. +#endif + +#if defined(BOARD_HAS_JOYSTICK) == defined(BOARD_DUMMY_JOYSTICK_IMPLEMENTATION) + #error Mismatch between BOARD_HAS_JOYSTICK and implementation. +#endif + int main(void) { uint_reg_t Dummy; @@ -42,6 +58,8 @@ int main(void) /* ============================= * Buttons Compile Check * ============================= */ + // cppcheck-suppress redundantAssignment + Dummy = BUTTONS_BUTTON1; Buttons_Init(); // cppcheck-suppress redundantAssignment Dummy = Buttons_GetStatus(); @@ -50,6 +68,8 @@ int main(void) /* ============================= * Dataflash Compile Check * ============================= */ + // cppcheck-suppress redundantAssignment + Dummy = DATAFLASH_TOTALCHIPS + DATAFLASH_NO_CHIP + DATAFLASH_CHIP1 + DATAFLASH_PAGE_SIZE + DATAFLASH_PAGES; Dataflash_Init(); Dataflash_TransferByte(0); Dataflash_SendByte(0); @@ -57,7 +77,7 @@ int main(void) Dummy = Dataflash_ReceiveByte(); // cppcheck-suppress redundantAssignment Dummy = Dataflash_GetSelectedChip(); - Dataflash_SelectChip(0); + Dataflash_SelectChip(DATAFLASH_CHIP1); Dataflash_DeselectChip(); Dataflash_SelectChipFromPage(0); Dataflash_ToggleSelectedChipCS(); @@ -67,6 +87,8 @@ int main(void) /* ============================= * LEDs Compile Check * ============================= */ + // cppcheck-suppress redundantAssignment + Dummy = LEDS_LED1 + LEDS_LED2 + LEDS_LED3 + LEDS_LED4; LEDs_Init(); LEDs_TurnOnLEDs(LEDS_ALL_LEDS); LEDs_TurnOffLEDs(LEDS_ALL_LEDS); @@ -80,6 +102,8 @@ int main(void) /* ============================= * Joystick Compile Check * ============================= */ + // cppcheck-suppress redundantAssignment + Dummy = JOY_LEFT + JOY_RIGHT + JOY_UP + JOY_DOWN + JOY_PRESS; Joystick_Init(); // cppcheck-suppress redundantAssignment Dummy = Joystick_GetStatus(); -- cgit v1.2.3