Clean up excessive whitespace at the end of each line using the wspurify tool made by Laszlo Monda
This commit is contained in:
parent
a8871c7fba
commit
5a4def7478
760 changed files with 12883 additions and 12164 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
* ADC present on many AVR models, for the conversion of analogue signals into the
|
||||
* digital domain.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ADC_H__
|
||||
#define __ADC_H__
|
||||
|
||||
|
|
@ -67,5 +67,6 @@
|
|||
#else
|
||||
#error "ADC is not available for the currently selected AVR model."
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -49,16 +49,16 @@
|
|||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ADC_AVRU4U6U7_H__
|
||||
#define __ADC_AVRU4U6U7_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/* Macros: */
|
||||
/** Reference mask, for using the voltage present at the AVR's AREF pin for the ADC reference. */
|
||||
#define ADC_REFERENCE_AREF 0
|
||||
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
|
||||
/** Reference mask, for using the internally generated 2.56V reference voltage as the ADC reference. */
|
||||
#define ADC_REFERENCE_INT2560MV ((1 << REFS1) | (1 << REFS0))
|
||||
|
||||
|
||||
/** Left-adjusts the 10-bit ADC result, so that the upper 8 bits of the value returned by the
|
||||
* ADC_GetResult() macro contain the 8 most significant bits of the result. */
|
||||
#define ADC_LEFT_ADJUSTED (1 << ADLAR)
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
/** Right-adjusts the 10-bit ADC result, so that the lower 8 bits of the value returned by the
|
||||
* ADC_GetResult() macro contain the 8 least significant bits of the result. */
|
||||
#define ADC_RIGHT_ADJUSTED (0 << ADLAR)
|
||||
|
||||
|
||||
/** Sets the ADC mode to free running, so that conversions take place continuously as fast as the ADC
|
||||
* is capable of at the given input clock speed. */
|
||||
#define ADC_FREE_RUNNING (1 << ADATE)
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
/** Sets the ADC mode to single conversion, so that only a single conversion will take place before
|
||||
* the ADC returns to idle. */
|
||||
#define ADC_SINGLE_CONVERSION (0 << ADATE)
|
||||
|
||||
|
||||
/** Sets the ADC input clock to prescale by a factor of 2 the AVR's system clock. */
|
||||
#define ADC_PRESCALE_2 (1 << ADPS0)
|
||||
|
||||
|
|
@ -116,7 +116,7 @@
|
|||
|
||||
/** Sets the ADC input clock to prescale by a factor of 128 the AVR's system clock. */
|
||||
#define ADC_PRESCALE_128 ((1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0))
|
||||
|
||||
|
||||
//@{
|
||||
/** MUX mask define for the ADC0 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */
|
||||
#define ADC_CHANNEL0 (0x00 << MUX0)
|
||||
|
|
@ -152,7 +152,7 @@
|
|||
|
||||
/** MUX mask define for the internal 1.1V bandgap channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */
|
||||
#define ADC_1100MV_BANDGAP (0x1E << MUX0)
|
||||
|
||||
|
||||
#if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
|
||||
/** MUX mask define for the ADC8 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.
|
||||
*
|
||||
|
|
@ -198,7 +198,7 @@
|
|||
#define ADC_INT_TEMP_SENS ((1 << 8) | (0x07 << MUX0))
|
||||
#endif
|
||||
//@}
|
||||
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Configures the given ADC channel, ready for ADC conversions. This function sets the
|
||||
* associated port pin as an input and disables the digital portion of the I/O to reduce
|
||||
|
|
@ -216,7 +216,7 @@
|
|||
{
|
||||
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
|
||||
defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
|
||||
defined(__AVR_ATmega32U6__))
|
||||
defined(__AVR_ATmega32U6__))
|
||||
DDRF &= ~(1 << ChannelIndex);
|
||||
DIDR0 |= (1 << ChannelIndex);
|
||||
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
|
||||
|
|
@ -242,7 +242,7 @@
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** De-configures the given ADC channel, re-enabling digital I/O mode instead of analog. This
|
||||
* function sets the associated port pin as an input and re-enabled the digital portion of
|
||||
* the I/O.
|
||||
|
|
@ -259,7 +259,7 @@
|
|||
{
|
||||
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
|
||||
defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
|
||||
defined(__AVR_ATmega32U6__))
|
||||
defined(__AVR_ATmega32U6__))
|
||||
DDRF &= ~(1 << ChannelIndex);
|
||||
DIDR0 &= ~(1 << ChannelIndex);
|
||||
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
|
||||
|
|
@ -299,14 +299,14 @@
|
|||
static inline void ADC_StartReading(const uint16_t MUXMask)
|
||||
{
|
||||
ADMUX = MUXMask;
|
||||
|
||||
|
||||
#if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
|
||||
if (MUXMask & (1 << 8))
|
||||
ADCSRB |= (1 << MUX5);
|
||||
else
|
||||
ADCSRB &= ~(1 << MUX5);
|
||||
#endif
|
||||
|
||||
|
||||
ADCSRA |= (1 << ADSC);
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +320,7 @@
|
|||
{
|
||||
return ((ADCSRA & (1 << ADIF)) ? true : false);
|
||||
}
|
||||
|
||||
|
||||
/** Retrieves the conversion value of the last completed ADC conversion and clears the reading
|
||||
* completion flag.
|
||||
*
|
||||
|
|
@ -346,9 +346,9 @@
|
|||
static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask)
|
||||
{
|
||||
ADC_StartReading(MUXMask);
|
||||
|
||||
|
||||
while (!(ADC_IsReadingComplete()));
|
||||
|
||||
|
||||
return ADC_GetResult();
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +372,7 @@
|
|||
{
|
||||
ADCSRA = 0;
|
||||
}
|
||||
|
||||
|
||||
/** Indicates if the ADC is currently enabled.
|
||||
*
|
||||
* \return Boolean true if the ADC subsystem is currently enabled, false otherwise.
|
||||
|
|
@ -382,12 +382,13 @@
|
|||
{
|
||||
return ((ADCSRA & (1 << ADEN)) ? true : false);
|
||||
}
|
||||
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -53,12 +53,12 @@
|
|||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
#include <util/twi.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
|
|
@ -79,10 +79,10 @@
|
|||
{
|
||||
TWCR |= (1 << TWEN);
|
||||
}
|
||||
|
||||
|
||||
/** Turns off the TWI driver hardware. If this is called, any further TWI operations will require a call to
|
||||
* \ref TWI_Init() before the TWI can be used again.
|
||||
*/
|
||||
*/
|
||||
static inline void TWI_ShutDown(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void TWI_ShutDown(void)
|
||||
{
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
static inline bool TWI_SendByte(const uint8_t Byte)
|
||||
{
|
||||
TWDR = Byte;
|
||||
TWCR = ((1 << TWINT) | (1 << TWEN));
|
||||
TWCR = ((1 << TWINT) | (1 << TWEN));
|
||||
while (!(TWCR & (1 << TWINT)));
|
||||
|
||||
return ((TWSR & TW_STATUS_MASK) == TW_MT_DATA_ACK);
|
||||
|
|
@ -122,7 +122,7 @@
|
|||
const bool LastByte)
|
||||
{
|
||||
uint8_t TWCRMask = ((1 << TWINT) | (1 << TWEN));
|
||||
|
||||
|
||||
if (!(LastByte))
|
||||
TWCRMask |= (1 << TWEA);
|
||||
|
||||
|
|
@ -152,3 +152,4 @@
|
|||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
/* Macros: */
|
||||
#define SPI_USE_DOUBLESPEED (1 << SPE)
|
||||
#endif
|
||||
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 2. */
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
|
||||
/** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 128. */
|
||||
#define SPI_SPEED_FCPU_DIV_128 ((1 << SPR1) | (1 << SPR0))
|
||||
|
||||
|
||||
/** SPI clock polarity mask for SPI_Init(). Indicates that the SCK should lead on the rising edge. */
|
||||
#define SPI_SCK_LEAD_RISING (0 << CPOL)
|
||||
|
||||
|
|
@ -124,25 +124,25 @@
|
|||
DDRB |= ((1 << 1) | (1 << 2));
|
||||
DDRB &= ((1 << 0) | (1 << 3));
|
||||
PORTB |= ((1 << 0) | (1 << 3));
|
||||
|
||||
|
||||
SPCR = ((1 << SPE) | SPIOptions);
|
||||
|
||||
|
||||
if (SPIOptions & SPI_USE_DOUBLESPEED)
|
||||
SPSR |= (1 << SPI2X);
|
||||
else
|
||||
SPSR &= ~(1 << SPI2X);
|
||||
}
|
||||
|
||||
|
||||
/** Turns off the SPI driver, disabling and returning used hardware to their default configuration. */
|
||||
static inline void SPI_ShutDown(void)
|
||||
{
|
||||
DDRB &= ~((1 << 1) | (1 << 2));
|
||||
PORTB &= ~((1 << 0) | (1 << 3));
|
||||
|
||||
|
||||
SPCR = 0;
|
||||
SPSR = 0;
|
||||
}
|
||||
|
||||
|
||||
/** 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.
|
||||
|
|
@ -186,7 +186,8 @@
|
|||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -51,3 +51,4 @@ void Serial_TxString(const char* StringPtr)
|
|||
StringPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
*
|
||||
* Driver for the USART subsystem on supported USB AVRs.
|
||||
*/
|
||||
|
||||
|
||||
/** \ingroup Group_PeripheralDrivers
|
||||
* @defgroup Group_Serial Serial USART Driver - LUFA/Drivers/Peripheral/Serial.h
|
||||
*
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __SERIAL_H__
|
||||
#define __SERIAL_H__
|
||||
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#include "../../Common/Common.h"
|
||||
#include "../Misc/TerminalCodes.h"
|
||||
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10));
|
||||
UCSR1A = (DoubleSpeed ? (1 << U2X1) : 0);
|
||||
UCSR1B = ((1 << TXEN1) | (1 << RXEN1));
|
||||
|
||||
|
||||
DDRD |= (1 << 3);
|
||||
PORTD |= (1 << 2);
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@
|
|||
UCSR1C = 0;
|
||||
|
||||
UBRR1 = 0;
|
||||
|
||||
|
||||
DDRD &= ~(1 << 3);
|
||||
PORTD &= ~(1 << 2);
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@
|
|||
{
|
||||
return ((UCSR1A & (1 << RXC1)) ? true : false);
|
||||
}
|
||||
|
||||
|
||||
/** Transmits a given byte through the USART.
|
||||
*
|
||||
* \param[in] DataByte Byte to transmit through the USART.
|
||||
|
|
@ -153,14 +153,15 @@
|
|||
static inline char Serial_RxByte(void)
|
||||
{
|
||||
while (!(UCSR1A & (1 << RXC1)));
|
||||
return UDR1;
|
||||
return UDR1;
|
||||
}
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -37,7 +37,7 @@ static int SerialStream_TxByte(char DataByte,
|
|||
FILE *Stream)
|
||||
{
|
||||
(void)Stream;
|
||||
|
||||
|
||||
Serial_TxByte(DataByte);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -45,9 +45,10 @@ static int SerialStream_TxByte(char DataByte,
|
|||
static int SerialStream_RxByte(FILE *Stream)
|
||||
{
|
||||
(void)Stream;
|
||||
|
||||
|
||||
if (!(Serial_IsCharReceived()))
|
||||
return _FDEV_EOF;
|
||||
|
||||
return Serial_RxByte();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -59,15 +59,15 @@
|
|||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "Serial.h"
|
||||
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* External Variables: */
|
||||
extern FILE USARTStream;
|
||||
|
|
@ -92,18 +92,18 @@
|
|||
const bool DoubleSpeed)
|
||||
{
|
||||
Serial_Init(BaudRate, DoubleSpeed);
|
||||
|
||||
|
||||
stdout = &USARTStream;
|
||||
stdin = &USARTStream;
|
||||
}
|
||||
|
||||
|
||||
/** Turns off the serial stream (and regular USART driver), disabling and returning used hardware to
|
||||
* their default configuration.
|
||||
*/
|
||||
static inline void SerialStream_ShutDown(void)
|
||||
{
|
||||
Serial_ShutDown();
|
||||
}
|
||||
}
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
|
|
@ -113,3 +113,4 @@
|
|||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -15,7 +15,7 @@ bool TWI_StartTransmission(const uint8_t SlaveAddress,
|
|||
bool BusCaptured = false;
|
||||
uint16_t TimeoutRemaining;
|
||||
|
||||
TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));
|
||||
TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));
|
||||
|
||||
TimeoutRemaining = (TimeoutMS * 100);
|
||||
while (TimeoutRemaining-- && !(BusCaptured))
|
||||
|
|
@ -29,35 +29,35 @@ bool TWI_StartTransmission(const uint8_t SlaveAddress,
|
|||
BusCaptured = true;
|
||||
break;
|
||||
case TW_MT_ARB_LOST:
|
||||
TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));
|
||||
TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));
|
||||
continue;
|
||||
default:
|
||||
TWCR = (1 << TWEN);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_delay_us(10);
|
||||
}
|
||||
|
||||
|
||||
if (!(BusCaptured))
|
||||
{
|
||||
TWCR = (1 << TWEN);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
TWDR = SlaveAddress;
|
||||
TWCR = ((1 << TWINT) | (1 << TWEN));
|
||||
|
||||
|
||||
TimeoutRemaining = (TimeoutMS * 100);
|
||||
while (TimeoutRemaining--)
|
||||
{
|
||||
if (TWCR & (1 << TWINT))
|
||||
break;
|
||||
|
||||
|
||||
_delay_us(10);
|
||||
}
|
||||
|
||||
|
||||
if (!(TimeoutRemaining))
|
||||
return false;
|
||||
|
||||
|
|
@ -72,3 +72,4 @@ bool TWI_StartTransmission(const uint8_t SlaveAddress,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
* Master Mode Hardware TWI driver. This module provides an easy to use driver for the hardware
|
||||
* TWI present on many AVR models, for the transmission and reception of data on a TWI bus.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __TWI_H__
|
||||
#define __TWI_H__
|
||||
|
||||
|
|
@ -67,5 +67,6 @@
|
|||
#else
|
||||
#error "TWI is not available for the currently selected AVR model."
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue