From f51c87b9160dd89810bac7579246ae14f61e0a8b Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 14 Jan 2013 20:57:04 +0000 Subject: Code style fixes to the AVRISP-MKII Clone programmer project. --- Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c | 4 ++-- Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h | 32 +++++++++++++++------------- Projects/AVRISP-MKII/Lib/V2ProtocolParams.c | 4 ++-- Projects/AVRISP-MKII/Lib/V2ProtocolParams.h | 2 +- Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c | 24 +++++++++++++++------ Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h | 27 +++++++++++++++-------- Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h | 2 +- 7 files changed, 58 insertions(+), 37 deletions(-) (limited to 'Projects/AVRISP-MKII/Lib') diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c index 5228eede0..8112038e6 100644 --- a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c +++ b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c @@ -134,7 +134,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK) TCCR1B = 0; TIFR1 = (1 << OCF1A); } - + if (PINB & (1 << 3)) SoftSPI_Data |= (1 << 0); } @@ -309,7 +309,7 @@ void ISPTarget_LoadExtendedAddress(void) { ISPTarget_SendByte(LOAD_EXTENDED_ADDRESS_CMD); ISPTarget_SendByte(0x00); - ISPTarget_SendByte((CurrentAddress & 0x00FF0000) >> 16); + ISPTarget_SendByte(CurrentAddress >> 16); ISPTarget_SendByte(0x00); } diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h index 34c40d677..72ec0b1ec 100644 --- a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h +++ b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h @@ -47,7 +47,7 @@ #include "../V2Protocol.h" #include "ISPProtocol.h" #include "Config/AppConfig.h" - + /* Preprocessor Checks: */ #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) #undef ENABLE_ISP_PROTOCOL @@ -106,16 +106,17 @@ */ static inline uint8_t ISPTarget_ReceiveByte(void) { - #if !defined(INVERTED_ISP_MISO) + uint8_t ReceivedByte; + if (HardwareSPIMode) - return SPI_ReceiveByte(); + ReceivedByte = SPI_ReceiveByte(); else - return ISPTarget_TransferSoftSPIByte(0x00); + ReceivedByte = ISPTarget_TransferSoftSPIByte(0x00); + + #if defined(INVERTED_ISP_MISO) + return ~ReceivedByte; #else - if (HardwareSPIMode) - return ~SPI_ReceiveByte(); - else - return ~ISPTarget_TransferSoftSPIByte(0x00); + return ReceivedByte; #endif } @@ -128,16 +129,17 @@ */ static inline uint8_t ISPTarget_TransferByte(const uint8_t Byte) { - #if !defined(INVERTED_ISP_MISO) + uint8_t ReceivedByte; + if (HardwareSPIMode) - return SPI_TransferByte(Byte); + ReceivedByte = SPI_TransferByte(Byte); else - return ISPTarget_TransferSoftSPIByte(Byte); + ReceivedByte = ISPTarget_TransferSoftSPIByte(Byte); + + #if defined(INVERTED_ISP_MISO) + return ~ReceivedByte; #else - if (HardwareSPIMode) - return ~SPI_TransferByte(Byte); - else - return ~ISPTarget_TransferSoftSPIByte(Byte); + return ReceivedByte; #endif } diff --git a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c index 585bb6521..3b5656846 100644 --- a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c +++ b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c @@ -37,10 +37,10 @@ #include "V2ProtocolParams.h" /* Non-Volatile Parameter Values for EEPROM storage */ -static uint8_t EEMEM EEPROM_Reset_Polarity = 0x01; +static uint8_t EEMEM EEPROM_Reset_Polarity = 0x01; /* Non-Volatile Parameter Values for EEPROM storage */ -static uint8_t EEMEM EEPROM_SCK_Duration = 0x06; +static uint8_t EEMEM EEPROM_SCK_Duration = 0x06; /* Volatile Parameter Values for RAM storage */ static ParameterItem_t ParameterTable[] = diff --git a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.h b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.h index 21e4e81ca..9a30c4f1a 100644 --- a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.h +++ b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.h @@ -62,7 +62,7 @@ #if (!defined(FIRMWARE_VERSION_MINOR) || defined(__DOXYGEN__)) /** Minor firmware version, reported to the host on request; must match the version * the host is expecting, or it (may) reject further communications with the programmer. */ - #define FIRMWARE_VERSION_MINOR 0x11 + #define FIRMWARE_VERSION_MINOR 0x14 #endif /* Type Defines: */ diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c index 47a757d2e..adb9b3ca6 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c @@ -172,7 +172,8 @@ void XMEGANVM_DisablePDI(void) * * \return Boolean true if the command sequence complete successfully */ -bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest) +bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, + uint32_t* const CRCDest) { *CRCDest = 0; @@ -222,7 +223,9 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest) * * \return Boolean true if the command sequence complete successfully */ -bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t ReadSize) +bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, + uint8_t* ReadBuffer, + uint16_t ReadSize) { /* Wait until the NVM controller is no longer busy */ if (!(XMEGANVM_WaitWhileNVMControllerBusy())) @@ -257,7 +260,9 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16 * * \return Boolean true if the command sequence complete successfully */ -bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand, const uint32_t WriteAddress, const uint8_t Byte) +bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand, + const uint32_t WriteAddress, + const uint8_t Byte) { /* Wait until the NVM controller is no longer busy */ if (!(XMEGANVM_WaitWhileNVMControllerBusy())) @@ -288,9 +293,13 @@ bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand, const uint32_t WriteAd * * \return Boolean true if the command sequence complete successfully */ -bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t EraseBuffCommand, - const uint8_t WritePageCommand, const uint8_t PageMode, const uint32_t WriteAddress, - const uint8_t* WriteBuffer, uint16_t WriteSize) +bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, + const uint8_t EraseBuffCommand, + const uint8_t WritePageCommand, + const uint8_t PageMode, + const uint32_t WriteAddress, + const uint8_t* WriteBuffer, + uint16_t WriteSize) { if (PageMode & XPRG_PAGEMODE_ERASE) { @@ -361,7 +370,8 @@ bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t Eras * * \return Boolean true if the command sequence complete successfully */ -bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address) +bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, + const uint32_t Address) { /* Wait until the NVM controller is no longer busy */ if (!(XMEGANVM_WaitWhileNVMControllerBusy())) diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h index fd2b4cbf4..c8450cbef 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h +++ b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h @@ -46,7 +46,7 @@ #include "XPROGProtocol.h" #include "XPROGTarget.h" #include "Config/AppConfig.h" - + /* Preprocessor Checks: */ #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) #undef ENABLE_ISP_PROTOCOL @@ -71,7 +71,7 @@ #define XMEGA_NVM_REG_INTCTRL 0x0D #define XMEGA_NVM_REG_STATUS 0x0F #define XMEGA_NVM_REG_LOCKBITS 0x10 - + #define XMEGA_NVM_BIT_CTRLA_CMDEX (1 << 0) #define XMEGA_NVM_CMD_NOOP 0x00 @@ -113,13 +113,22 @@ bool XMEGANVM_WaitWhileNVMControllerBusy(void); bool XMEGANVM_EnablePDI(void); void XMEGANVM_DisablePDI(void); - bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest); - bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t ReadSize); - bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand, const uint32_t WriteAddress, const uint8_t Byte); - bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t EraseBuffCommand, - const uint8_t WritePageCommand, const uint8_t PageMode, const uint32_t WriteAddress, - const uint8_t* WriteBuffer, uint16_t WriteSize); - bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address); + bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, + uint32_t* const CRCDest); + bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, + uint8_t* ReadBuffer, uint16_t ReadSize); + bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand, + const uint32_t WriteAddress, + const uint8_t Byte); + bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, + const uint8_t EraseBuffCommand, + const uint8_t WritePageCommand, + const uint8_t PageMode, + const uint32_t WriteAddress, + const uint8_t* WriteBuffer, + uint16_t WriteSize); + bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, + const uint32_t Address); #if defined(INCLUDE_FROM_XMEGANVM_C) static void XMEGANVM_SendNVMRegAddress(const uint8_t Register); diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h index 21bd3e486..8189d29b8 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h +++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h @@ -46,7 +46,7 @@ #include "../V2Protocol.h" #include "XPROGProtocol.h" #include "Config/AppConfig.h" - + /* Preprocessor Checks: */ #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) #undef ENABLE_ISP_PROTOCOL -- cgit v1.2.3