Update Temperature board driver to be AVR32 compatible when the ADC peripheral driver is eventually ported. Make architecture includes explicit for both the AVR32 and the AVR8, to make way for future architecture ports.

Add SPI driver aliases for the old function names in the AVR8 driver, so that existing code will still compile against the new version.
pull/1469/head
Dean Camera 15 years ago
parent c24027f3b5
commit e11fddfe66

@ -63,7 +63,7 @@
#include "Atomic.h" #include "Atomic.h"
#define PROGMEM const #define PROGMEM const
#else #elif defined(__AVR__)
#include <avr/io.h> #include <avr/io.h>
#endif #endif
@ -195,7 +195,7 @@
/** Type define for a signed native word-sized chunk of data. */ /** Type define for a signed native word-sized chunk of data. */
typedef int32_t intN_t; typedef int32_t intN_t;
#else #elif defined(__AVR__)
/** Type define for an unsigned native word-sized chunk of data. */ /** Type define for an unsigned native word-sized chunk of data. */
typedef uint8_t uintN_t; typedef uint8_t uintN_t;

@ -127,7 +127,7 @@
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)
{ {
return SPI_TransferByte(Byte); return SPI_Transfer(Byte);
} }
/** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.
@ -137,7 +137,7 @@
static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline void Dataflash_SendByte(const uint8_t Byte) static inline void Dataflash_SendByte(const uint8_t Byte)
{ {
SPI_SendByte(Byte); SPI_Send(Byte);
} }
/** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash. /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.
@ -147,7 +147,7 @@
static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Dataflash_ReceiveByte(void) static inline uint8_t Dataflash_ReceiveByte(void)
{ {
return SPI_ReceiveByte(); return SPI_Receive();
} }
/* Includes: */ /* Includes: */

@ -47,6 +47,16 @@ int8_t Temperature_GetTemperature(void)
{ {
uint16_t Temp_ADC = ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | TEMP_ADC_CHANNEL_MASK); uint16_t Temp_ADC = ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | TEMP_ADC_CHANNEL_MASK);
#if defined(__AVR32__)
if (Temp_ADC > Temperature_Lookup[0])
return TEMP_MIN_TEMP;
for (uint16_t Index = 0; Index < TEMP_TABLE_SIZE; Index++)
{
if (Temp_ADC > Temperature_Lookup[Index])
return (Index + TEMP_TABLE_OFFSET);
}
#elif defined(__AVR__)
if (Temp_ADC > pgm_read_word(&Temperature_Lookup[0])) if (Temp_ADC > pgm_read_word(&Temperature_Lookup[0]))
return TEMP_MIN_TEMP; return TEMP_MIN_TEMP;
@ -55,6 +65,7 @@ int8_t Temperature_GetTemperature(void)
if (Temp_ADC > pgm_read_word(&Temperature_Lookup[Index])) if (Temp_ADC > pgm_read_word(&Temperature_Lookup[Index]))
return (Index + TEMP_TABLE_OFFSET); return (Index + TEMP_TABLE_OFFSET);
} }
#endif
return TEMP_MAX_TEMP; return TEMP_MAX_TEMP;
} }

@ -54,8 +54,10 @@
/* Includes: */ /* Includes: */
#if defined(__AVR32__) #if defined(__AVR32__)
#include <avr32/io.h>
#include <stdint.h> #include <stdint.h>
#else #elif defined(__AVR__)
#include <avr/io.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#endif #endif

@ -58,6 +58,8 @@
#endif #endif
/* Includes: */ /* Includes: */
#include "../../Common/Common.h"
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \

@ -82,12 +82,19 @@
/** Initialises the SPI subsystem, ready for transfers. Must be called before calling any other /** Initialises the SPI subsystem, ready for transfers. Must be called before calling any other
* SPI routines. * SPI routines.
* *
* \note The individual AVR32 chip select control registers are left at their defaults; it is up to the user
* to configure these seperately once the SPI module has been initialized.
*
* \note The physical GPIO pins for the AVR32's SPI are not altered; it is up to the user to
* configure these seperately to connect the SPI module to the desired GPIO pins via the
* GPIO MUX registers.
*
* \param[in] SPIOptions SPI Options, a mask consisting of one of each of the SPI_SPEED_* * \param[in] SPIOptions SPI Options, a mask consisting of one of each of the SPI_SPEED_*
* and SPI_MODE_* masks * and SPI_MODE_* masks
*/ */
static inline void SPI_Init(const uint8_t SPIOptions) static inline void SPI_Init(const uintN_t SPIOptions)
{ {
AVR32_SPI.cr = AVR32_SPI_CR_SPIEN_MASK | AVR32_SPI_CR_SWRST_MASK; AVR32_SPI.cr = (AVR32_SPI_CR_SPIEN_MASK | AVR32_SPI_CR_SWRST_MASK);
AVR32_SPI.mr = SPIOptions; AVR32_SPI.mr = SPIOptions;
} }
@ -97,43 +104,47 @@
AVR32_SPI.cr = AVR32_SPI_CR_SPIDIS_MASK; AVR32_SPI.cr = AVR32_SPI_CR_SPIDIS_MASK;
} }
/** Sends and receives a byte through the SPI interface, blocking until the transfer is complete. /** Sends and receives a transfer through the SPI interface, blocking until the transfer is complete.
* The width of the data that is transferred is dependant on the settings of the currently selected
* peripheral.
* *
* \param[in] Byte Byte to send through the SPI interface * \param[in] Data Data to send through the SPI interface
* *
* \return Response byte from the attached SPI device * \return Response data from the attached SPI device
*/ */
static inline uint8_t SPI_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline uint16_t SPI_Transfer(const uint16_t Data) ATTR_ALWAYS_INLINE;
static inline uint8_t SPI_TransferByte(const uint8_t Byte) static inline uint16_t SPI_Transfer(const uint16_t Data)
{ {
AVR32_SPI.tdr = Byte; AVR32_SPI.TDR.td = Data;
// TODO: Wait for receive while (!(AVR32_SPI.SR.tdre));
return AVR32_SPI.rdr; return AVR32_SPI.rdr;
} }
/** Sends a byte through the SPI interface, blocking until the transfer is complete. The response /** Sends a transfer through the SPI interface, blocking until the transfer is complete. The response
* byte sent to from the attached SPI device is ignored. * data sent to from the attached SPI device is ignored. The width of the data that is transferred is
* dependant on the settings of the currently selected peripheral.
* *
* \param[in] Byte Byte to send through the SPI interface * \param[in] Data Data to send through the SPI interface
*/ */
static inline void SPI_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline void SPI_Send(const uint16_t Data) ATTR_ALWAYS_INLINE;
static inline void SPI_SendByte(const uint8_t Byte) static inline void SPI_Send(const uint16_t Data)
{ {
AVR32_SPI.tdr = Byte; AVR32_SPI.TDR.td = Data;
// TODO: Wait for receive while (!(AVR32_SPI.SR.tdre));
} }
/** Sends a dummy byte through the SPI interface, blocking until the transfer is complete. The response /** Sends a dummy transfer through the SPI interface, blocking until the transfer is complete. The response
* byte from the attached SPI device is returned. * data from the attached SPI device is returned. The width of the data that is transferred is dependant on
* the settings of the currently selected peripheral.
* *
* \return The response byte from the attached SPI device * \return The response data from the attached SPI device
*/ */
static inline uint8_t SPI_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline uint16_t SPI_Receive(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
static inline uint8_t SPI_ReceiveByte(void) static inline uint16_t SPI_Receive(void)
{ {
AVR32_SPI.tdr = 0x00; AVR32_SPI.TDR.td = 0x0000;
// TODO: Wait for receive while (!(AVR32_SPI.SR.tdre));
return AVR32_SPI.rdr; return AVR32_SPI.RDR.rd;
} }
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */

@ -51,8 +51,6 @@
#define __ADC_AVR8_H__ #define __ADC_AVR8_H__
/* Includes: */ /* Includes: */
#include "../../../Common/Common.h"
#include <avr/io.h> #include <avr/io.h>
#include <stdbool.h> #include <stdbool.h>

@ -118,7 +118,7 @@
* \param[in] SPIOptions SPI Options, a mask consisting of one of each of the SPI_SPEED_*, * \param[in] SPIOptions SPI Options, a mask consisting of one of each of the SPI_SPEED_*,
* SPI_SCK_*, SPI_SAMPLE_* and SPI_MODE_* masks * SPI_SCK_*, SPI_SAMPLE_* and SPI_MODE_* masks
*/ */
static inline void SPI_Init(const uint8_t SPIOptions) static inline void SPI_Init(const uintN_t SPIOptions)
{ {
DDRB |= ((1 << 1) | (1 << 2)); DDRB |= ((1 << 1) | (1 << 2));
PORTB |= ((1 << 0) | (1 << 3)); PORTB |= ((1 << 0) | (1 << 3));
@ -143,14 +143,14 @@
/** Sends and receives a byte through the SPI interface, blocking until the transfer is complete. /** Sends and receives a byte through the SPI interface, blocking until the transfer is complete.
* *
* \param[in] Byte Byte to send through the SPI interface * \param[in] Data Byte to send through the SPI interface
* *
* \return Response byte from the attached SPI device * \return Response byte from the attached SPI device
*/ */
static inline uint8_t SPI_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline uint8_t SPI_Transfer(const uint8_t Data) ATTR_ALWAYS_INLINE;
static inline uint8_t SPI_TransferByte(const uint8_t Byte) static inline uint8_t SPI_Transfer(const uint8_t Data)
{ {
SPDR = Byte; SPDR = Data;
while (!(SPSR & (1 << SPIF))); while (!(SPSR & (1 << SPIF)));
return SPDR; return SPDR;
} }
@ -158,12 +158,12 @@
/** Sends a byte through the SPI interface, blocking until the transfer is complete. The response /** Sends a byte through the SPI interface, blocking until the transfer is complete. The response
* byte sent to from the attached SPI device is ignored. * byte sent to from the attached SPI device is ignored.
* *
* \param[in] Byte Byte to send through the SPI interface * \param[in] Data Byte to send through the SPI interface
*/ */
static inline void SPI_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline void SPI_Send(const uint8_t Data) ATTR_ALWAYS_INLINE;
static inline void SPI_SendByte(const uint8_t Byte) static inline void SPI_Send(const uint8_t Data)
{ {
SPDR = Byte; SPDR = Data;
while (!(SPSR & (1 << SPIF))); while (!(SPSR & (1 << SPIF)));
} }
@ -172,14 +172,29 @@
* *
* \return The response byte from the attached SPI device * \return The response byte from the attached SPI device
*/ */
static inline uint8_t SPI_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline uint8_t SPI_Receive(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
static inline uint8_t SPI_ReceiveByte(void) static inline uint8_t SPI_Receive(void)
{ {
SPDR = 0x00; SPDR = 0x00;
while (!(SPSR & (1 << SPIF))); while (!(SPSR & (1 << SPIF)));
return SPDR; return SPDR;
} }
#if defined(__DOXYGEN__)
/** Alias for \ref SPI_Transfer(), for compatibility with legacy LUFA applications. */
static inline uint8_t SPI_TransferByte(const uint8_t Byte) ATTR_DEPRECATED;
/** Alias for \ref SPI_Send(), for compatibility with legacy LUFA applications. */
static inline void SPI_SendByte(const uint8_t Byte) ATTR_DEPRECATED;
/** Alias for \ref SPI_Receive(), for compatibility with legacy LUFA applications. */
static inline uint8_t SPI_ReceiveByte(void) ATTR_DEPRECATED;
#else
#define SPI_TransferByte(x) SPI_Transfer(x)
#define SPI_SendByte(x) SPI_Send(x)
#define SPI_ReceiveByte() SPI_Receive()
#endif
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)
} }

@ -51,8 +51,6 @@
#define __TWI_AVR8_H__ #define __TWI_AVR8_H__
/* Includes: */ /* Includes: */
#include "../../../Common/Common.h"
#include <avr/io.h> #include <avr/io.h>
#include <stdbool.h> #include <stdbool.h>
#include <util/twi.h> #include <util/twi.h>

@ -59,9 +59,11 @@
#endif #endif
/* Includes: */ /* Includes: */
#include "../../Common/Common.h"
#if defined(__AVR32__) #if defined(__AVR32__)
#include "AVR32/SPI.h" #include "AVR32/SPI.h"
#else #elif defined(__AVR__)
#include "AVR8/SPI.h" #include "AVR8/SPI.h"
#endif #endif

@ -60,15 +60,15 @@
#endif #endif
/* Includes: */ /* Includes: */
#include "../../Common/Common.h"
#include "../Misc/TerminalCodes.h"
#if defined(__AVR32__) #if defined(__AVR32__)
#include "AVR32/Serial.h" #include "AVR32/Serial.h"
#else #elif defined(__AVR__)
#include "AVR8/Serial.h" #include "AVR8/Serial.h"
#endif #endif
#include "../../Common/Common.h"
#include "../Misc/TerminalCodes.h"
/* Enable C linkage for C++ Compilers: */ /* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {

@ -57,6 +57,8 @@
#include <avr/io.h> #include <avr/io.h>
#include <stdio.h> #include <stdio.h>
#include "../../Common/Common.h"
#include "Serial.h" #include "Serial.h"
/* Enable C linkage for C++ Compilers: */ /* Enable C linkage for C++ Compilers: */

@ -57,6 +57,8 @@
#endif #endif
/* Includes: */ /* Includes: */
#include "../../Common/Common.h"
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \

@ -41,13 +41,14 @@
* - Joystick Board Driver * - Joystick Board Driver
* - Buttons Board Driver * - Buttons Board Driver
* - LEDs Board Driver * - LEDs Board Driver
* - Simple Scheduler
* - Temperature Board Driver
* *
* The following drivers have been partially ported: * The following drivers have been partially ported:
* - SPI Peripheral Driver * - SPI Peripheral Driver
* *
* The following drivers have not yet been ported: * The following drivers have not yet been ported:
* - Dataflash Board Driver * - Dataflash Board Driver
* - Temperature Board Driver
* - Serial Peripheral Driver * - Serial Peripheral Driver
* - ADC Peripheral Driver * - ADC Peripheral Driver
* - TWI Peripheral Driver * - TWI Peripheral Driver

@ -13,7 +13,9 @@
* \section Sec_MigrationXXXXXX Migrating from 100219 to XXXXXX * \section Sec_MigrationXXXXXX Migrating from 100219 to XXXXXX
* *
* \section Sec_Migration100219 Migrating from 091223 to 100219 * \section Sec_Migration100219 Migrating from 091223 to 100219
* - (None) * <b>Non-USB Library Components</b>
* - The "Byte" suffix on the SPI peripheral driver's send and receive routines has been dropped, to make the interface consistant
* between the AVR8 driver and the new AVR32 driver, which supports variable width transfers.
* *
* <b>Non-USB Library Components</b> * <b>Non-USB Library Components</b>
* - Due to some ADC channels not being identical to their ADC MUX selection masks for single-ended conversions on some AVR models, * - Due to some ADC channels not being identical to their ADC MUX selection masks for single-ended conversions on some AVR models,

@ -61,7 +61,7 @@
* { * {
* { .Task = MyTask1, .TaskStatus = TASK_RUN, .GroupID = 1 }, * { .Task = MyTask1, .TaskStatus = TASK_RUN, .GroupID = 1 },
* { .Task = MyTask2, .TaskStatus = TASK_RUN, .GroupID = 1 }, * { .Task = MyTask2, .TaskStatus = TASK_RUN, .GroupID = 1 },
* } * };
* *
* int main(void) * int main(void)
* { * {
@ -89,7 +89,7 @@
#if defined(__AVR32__) #if defined(__AVR32__)
#include <avr32/io.h> #include <avr32/io.h>
#include <stdbool.h> #include <stdbool.h>
#else #elif defined(__AVR__)
#include <avr/io.h> #include <avr/io.h>
#include <util/atomic.h> #include <util/atomic.h>
#include <stdbool.h> #include <stdbool.h>

@ -85,7 +85,7 @@ void ISPProtocol_EnterISPMode(void)
for (uint8_t RByte = 0; RByte < sizeof(ResponseBytes); RByte++) for (uint8_t RByte = 0; RByte < sizeof(ResponseBytes); RByte++)
{ {
ISPProtocol_DelayMS(Enter_ISP_Params.ByteDelay); ISPProtocol_DelayMS(Enter_ISP_Params.ByteDelay);
ResponseBytes[RByte] = SPI_TransferByte(Enter_ISP_Params.EnterProgBytes[RByte]); ResponseBytes[RByte] = SPI_Transfer(Enter_ISP_Params.EnterProgBytes[RByte]);
} }
/* Check if polling disabled, or if the polled value matches the expected value */ /* Check if polling disabled, or if the polled value matches the expected value */
@ -204,10 +204,10 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
bool IsOddByte = (CurrentByte & 0x01); bool IsOddByte = (CurrentByte & 0x01);
uint8_t ByteToWrite = *(NextWriteByte++); uint8_t ByteToWrite = *(NextWriteByte++);
SPI_SendByte(Write_Memory_Params.ProgrammingCommands[0]); SPI_Send(Write_Memory_Params.ProgrammingCommands[0]);
SPI_SendByte(CurrentAddress >> 8); SPI_Send(CurrentAddress >> 8);
SPI_SendByte(CurrentAddress & 0xFF); SPI_Send(CurrentAddress & 0xFF);
SPI_SendByte(ByteToWrite); SPI_Send(ByteToWrite);
/* AVR FLASH addressing requires us to modify the write command based on if we are writing a high /* AVR FLASH addressing requires us to modify the write command based on if we are writing a high
* or low byte at the current word address */ * or low byte at the current word address */
@ -230,10 +230,10 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
/* If the current page must be committed, send the PROGRAM PAGE command to the target */ /* If the current page must be committed, send the PROGRAM PAGE command to the target */
if (Write_Memory_Params.ProgrammingMode & PROG_MODE_COMMIT_PAGE_MASK) if (Write_Memory_Params.ProgrammingMode & PROG_MODE_COMMIT_PAGE_MASK)
{ {
SPI_SendByte(Write_Memory_Params.ProgrammingCommands[1]); SPI_Send(Write_Memory_Params.ProgrammingCommands[1]);
SPI_SendByte(StartAddress >> 8); SPI_Send(StartAddress >> 8);
SPI_SendByte(StartAddress & 0xFF); SPI_Send(StartAddress & 0xFF);
SPI_SendByte(0x00); SPI_Send(0x00);
/* Check if polling is possible, if not switch to timed delay mode */ /* Check if polling is possible, if not switch to timed delay mode */
if (!(PollAddress)) if (!(PollAddress))
@ -254,10 +254,10 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
bool IsOddByte = (CurrentByte & 0x01); bool IsOddByte = (CurrentByte & 0x01);
uint8_t ByteToWrite = *(NextWriteByte++); uint8_t ByteToWrite = *(NextWriteByte++);
SPI_SendByte(Write_Memory_Params.ProgrammingCommands[0]); SPI_Send(Write_Memory_Params.ProgrammingCommands[0]);
SPI_SendByte(CurrentAddress >> 8); SPI_Send(CurrentAddress >> 8);
SPI_SendByte(CurrentAddress & 0xFF); SPI_Send(CurrentAddress & 0xFF);
SPI_SendByte(ByteToWrite); SPI_Send(ByteToWrite);
/* AVR FLASH addressing requires us to modify the write command based on if we are writing a high /* AVR FLASH addressing requires us to modify the write command based on if we are writing a high
* or low byte at the current word address */ * or low byte at the current word address */
@ -325,10 +325,10 @@ void ISPProtocol_ReadMemory(uint8_t V2Command)
for (uint16_t CurrentByte = 0; CurrentByte < Read_Memory_Params.BytesToRead; CurrentByte++) for (uint16_t CurrentByte = 0; CurrentByte < Read_Memory_Params.BytesToRead; CurrentByte++)
{ {
/* Read the next byte from the desired memory space in the device */ /* Read the next byte from the desired memory space in the device */
SPI_SendByte(Read_Memory_Params.ReadMemoryCommand); SPI_Send(Read_Memory_Params.ReadMemoryCommand);
SPI_SendByte(CurrentAddress >> 8); SPI_Send(CurrentAddress >> 8);
SPI_SendByte(CurrentAddress & 0xFF); SPI_Send(CurrentAddress & 0xFF);
Endpoint_Write_Byte(SPI_ReceiveByte()); Endpoint_Write_Byte(SPI_Receive());
/* Check if the endpoint bank is currently full, if so send the packet */ /* Check if the endpoint bank is currently full, if so send the packet */
if (!(Endpoint_IsReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))
@ -381,7 +381,7 @@ void ISPProtocol_ChipErase(void)
/* Send the chip erase commands as given by the host to the device */ /* Send the chip erase commands as given by the host to the device */
for (uint8_t SByte = 0; SByte < sizeof(Erase_Chip_Params.EraseCommandBytes); SByte++) for (uint8_t SByte = 0; SByte < sizeof(Erase_Chip_Params.EraseCommandBytes); SByte++)
SPI_SendByte(Erase_Chip_Params.EraseCommandBytes[SByte]); SPI_Send(Erase_Chip_Params.EraseCommandBytes[SByte]);
/* Use appropriate command completion check as given by the host (delay or busy polling) */ /* Use appropriate command completion check as given by the host (delay or busy polling) */
if (!(Erase_Chip_Params.PollMethod)) if (!(Erase_Chip_Params.PollMethod))
@ -416,7 +416,7 @@ void ISPProtocol_ReadFuseLockSigOSCCAL(uint8_t V2Command)
/* Send the Fuse or Lock byte read commands as given by the host to the device, store response */ /* Send the Fuse or Lock byte read commands as given by the host to the device, store response */
for (uint8_t RByte = 0; RByte < sizeof(ResponseBytes); RByte++) for (uint8_t RByte = 0; RByte < sizeof(ResponseBytes); RByte++)
ResponseBytes[RByte] = SPI_TransferByte(Read_FuseLockSigOSCCAL_Params.ReadCommandBytes[RByte]); ResponseBytes[RByte] = SPI_Transfer(Read_FuseLockSigOSCCAL_Params.ReadCommandBytes[RByte]);
Endpoint_Write_Byte(V2Command); Endpoint_Write_Byte(V2Command);
Endpoint_Write_Byte(STATUS_CMD_OK); Endpoint_Write_Byte(STATUS_CMD_OK);
@ -444,7 +444,7 @@ void ISPProtocol_WriteFuseLock(uint8_t V2Command)
/* Send the Fuse or Lock byte program commands as given by the host to the device */ /* Send the Fuse or Lock byte program commands as given by the host to the device */
for (uint8_t SByte = 0; SByte < sizeof(Write_FuseLockSig_Params.WriteCommandBytes); SByte++) for (uint8_t SByte = 0; SByte < sizeof(Write_FuseLockSig_Params.WriteCommandBytes); SByte++)
SPI_SendByte(Write_FuseLockSig_Params.WriteCommandBytes[SByte]); SPI_Send(Write_FuseLockSig_Params.WriteCommandBytes[SByte]);
Endpoint_Write_Byte(V2Command); Endpoint_Write_Byte(V2Command);
Endpoint_Write_Byte(STATUS_CMD_OK); Endpoint_Write_Byte(STATUS_CMD_OK);
@ -479,9 +479,9 @@ void ISPProtocol_SPIMulti(void)
while (CurrTxPos < SPI_Multi_Params.RxStartAddr) while (CurrTxPos < SPI_Multi_Params.RxStartAddr)
{ {
if (CurrTxPos < SPI_Multi_Params.TxBytes) if (CurrTxPos < SPI_Multi_Params.TxBytes)
SPI_SendByte(SPI_Multi_Params.TxData[CurrTxPos]); SPI_Send(SPI_Multi_Params.TxData[CurrTxPos]);
else else
SPI_SendByte(0); SPI_Send(0);
CurrTxPos++; CurrTxPos++;
} }
@ -490,9 +490,9 @@ void ISPProtocol_SPIMulti(void)
while (CurrRxPos < SPI_Multi_Params.RxBytes) while (CurrRxPos < SPI_Multi_Params.RxBytes)
{ {
if (CurrTxPos < SPI_Multi_Params.TxBytes) if (CurrTxPos < SPI_Multi_Params.TxBytes)
Endpoint_Write_Byte(SPI_TransferByte(SPI_Multi_Params.TxData[CurrTxPos++])); Endpoint_Write_Byte(SPI_Transfer(SPI_Multi_Params.TxData[CurrTxPos++]));
else else
Endpoint_Write_Byte(SPI_ReceiveByte()); Endpoint_Write_Byte(SPI_Receive());
/* Check to see if we have filled the endpoint bank and need to send the packet */ /* Check to see if we have filled the endpoint bank and need to send the packet */
if (!(Endpoint_IsReadWriteAllowed())) if (!(Endpoint_IsReadWriteAllowed()))

@ -131,11 +131,11 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1
TimeoutMSRemaining--; TimeoutMSRemaining--;
} }
SPI_SendByte(ReadMemCommand); SPI_Send(ReadMemCommand);
SPI_SendByte(PollAddress >> 8); SPI_Send(PollAddress >> 8);
SPI_SendByte(PollAddress & 0xFF); SPI_Send(PollAddress & 0xFF);
} }
while ((SPI_TransferByte(0x00) == PollValue) && TimeoutMSRemaining); while ((SPI_Transfer(0x00) == PollValue) && TimeoutMSRemaining);
if (!(TimeoutMSRemaining)) if (!(TimeoutMSRemaining))
ProgrammingStatus = STATUS_CMD_TOUT; ProgrammingStatus = STATUS_CMD_TOUT;
@ -169,11 +169,11 @@ uint8_t ISPTarget_WaitWhileTargetBusy(void)
TimeoutMSRemaining--; TimeoutMSRemaining--;
} }
SPI_SendByte(0xF0); SPI_Send(0xF0);
SPI_SendByte(0x00); SPI_Send(0x00);
SPI_SendByte(0x00); SPI_Send(0x00);
} }
while ((SPI_ReceiveByte() & 0x01) && TimeoutMSRemaining); while ((SPI_Receive() & 0x01) && TimeoutMSRemaining);
if (TimeoutMSRemaining) if (TimeoutMSRemaining)
{ {
@ -192,10 +192,10 @@ uint8_t ISPTarget_WaitWhileTargetBusy(void)
*/ */
void ISPTarget_LoadExtendedAddress(void) void ISPTarget_LoadExtendedAddress(void)
{ {
SPI_SendByte(LOAD_EXTENDED_ADDRESS_CMD); SPI_Send(LOAD_EXTENDED_ADDRESS_CMD);
SPI_SendByte(0x00); SPI_Send(0x00);
SPI_SendByte((CurrentAddress & 0x00FF0000) >> 16); SPI_Send((CurrentAddress & 0x00FF0000) >> 16);
SPI_SendByte(0x00); SPI_Send(0x00);
} }
#endif #endif

Loading…
Cancel
Save