Added V2Protocol handlers to the AVRISP project to enter/exit programming mode, and read/write fuses, lockbits, OSCCAL and Signature bytes.
Added ShutDown functions for all hardware peripheral drivers, so that peripherals can be turned off after use.
This commit is contained in:
parent
d540276b44
commit
1e8df8951a
10 changed files with 303 additions and 45 deletions
|
@ -118,11 +118,11 @@
|
|||
* \param[in] Mode Mask of ADC settings, including adjustment, prescale, mode and reference
|
||||
*/
|
||||
static inline void ADC_Init(uint8_t Mode);
|
||||
|
||||
|
||||
/** Turns off the ADC. If this is called, any further ADC operations will require a call to
|
||||
* \ref ADC_Init() before the ADC can be used again.
|
||||
*/
|
||||
static inline void ADC_Off(void);
|
||||
static inline void ADC_ShutDown(void);
|
||||
|
||||
/** Indicates if the ADC is currently enabled.
|
||||
*
|
||||
|
@ -145,7 +145,7 @@
|
|||
#else
|
||||
#define ADC_Init(mode) MACROS{ ADCSRA = ((1 << ADEN) | mode); }MACROE
|
||||
|
||||
#define ADC_Off() MACROS{ ADCSRA = 0; }MACROE
|
||||
#define ADC_ShutDown() MACROS{ ADCSRA = 0; }MACROE
|
||||
|
||||
#define ADC_GetStatus() ((ADCSRA & (1 << ADEN)) ? true : false)
|
||||
|
||||
|
|
|
@ -108,6 +108,16 @@
|
|||
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
|
||||
|
|
|
@ -118,6 +118,19 @@
|
|||
UBRR1 = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate));
|
||||
}
|
||||
|
||||
/** Turns off the USART driver, disabling and returning used hardware to their default configuration. */
|
||||
static inline void Serial_ShutDown(void)
|
||||
{
|
||||
UCSR1A = 0;
|
||||
UCSR1B = 0;
|
||||
UCSR1C = 0;
|
||||
|
||||
DDRD &= ~(1 << 3);
|
||||
PORTD &= ~(1 << 2);
|
||||
|
||||
UBRR1 = 0;
|
||||
}
|
||||
|
||||
/** Transmits a given byte through the USART.
|
||||
*
|
||||
* \param[in] DataByte Byte to transmit through the USART
|
||||
|
|
|
@ -88,6 +88,14 @@
|
|||
|
||||
stdout = &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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue