Commit c24027f3 authored by Dean Camera's avatar Dean Camera
Browse files

Fixed software PDI/TPI programming mode in the AVRISP project not correctly...

Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin.

Fix broken AVR8 Serial peripheral driver.
parent 25904521
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
#include "Atomic.h" #include "Atomic.h"
#define PROGMEM #define PROGMEM const
#else #else
#include <avr/io.h> #include <avr/io.h>
#endif #endif
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#define __SPI_AVR32_H__ #define __SPI_AVR32_H__
/* Includes: */ /* Includes: */
#include <avr32/io.h>
#include <stdbool.h> #include <stdbool.h>
/* Preprocessor Checks: */ /* Preprocessor Checks: */
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#define __SPI_AVR8_H__ #define __SPI_AVR8_H__
/* Includes: */ /* Includes: */
#include <avr/io.h>
#include <stdbool.h> #include <stdbool.h>
/* Preprocessor Checks: */ /* Preprocessor Checks: */
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
*/ */
static inline bool Serial_IsCharReceived(void); static inline bool Serial_IsCharReceived(void);
#else #else
#define Serial_IsCharReceived() /* TODO */ #define Serial_IsCharReceived() ((UCSR1A & (1 << RXC1)) ? true : false)
#endif #endif
/* Inline Functions: */ /* Inline Functions: */
...@@ -92,13 +92,27 @@ ...@@ -92,13 +92,27 @@
*/ */
static inline void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed) static inline void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed)
{ {
// TODO UCSR1A = (DoubleSpeed ? (1 << U2X1) : 0);
UCSR1B = ((1 << TXEN1) | (1 << RXEN1));
UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10));
DDRD |= (1 << 3);
PORTD |= (1 << 2);
UBRR1 = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate));
} }
/** Turns off the USART driver, disabling and returning used hardware to their default configuration. */ /** Turns off the USART driver, disabling and returning used hardware to their default configuration. */
static inline void Serial_ShutDown(void) static inline void Serial_ShutDown(void)
{ {
// TODO UCSR1A = 0;
UCSR1B = 0;
UCSR1C = 0;
DDRD &= ~(1 << 3);
PORTD &= ~(1 << 2);
UBRR1 = 0;
} }
/** Transmits a given byte through the USART. /** Transmits a given byte through the USART.
...@@ -107,7 +121,8 @@ ...@@ -107,7 +121,8 @@
*/ */
static inline void Serial_TxByte(const char DataByte) static inline void Serial_TxByte(const char DataByte)
{ {
// TODO while (!(UCSR1A & (1 << UDRE1)));
UDR1 = DataByte;
} }
/** Receives a byte from the USART. /** Receives a byte from the USART.
...@@ -116,7 +131,8 @@ ...@@ -116,7 +131,8 @@
*/ */
static inline uint8_t Serial_RxByte(void) static inline uint8_t Serial_RxByte(void)
{ {
// TODO while (!(UCSR1A & (1 << RXC1)));
return UDR1;
} }
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
*/ */
/** \ingroup Group_TWI /** \ingroup Group_TWI
* @defgroup Group_TWI_AVR8 Series U4, U6 and U7 Model TWI Driver * @defgroup Group_TWI_AVR8 8-Bit AVR TWI Driver
* *
* Master mode TWI driver for the 8-Bit AVRs containing a hardware TWI module. * Master mode TWI driver for the 8-Bit AVRs containing a hardware TWI module.
* *
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* \section Sec_ChangeLogXXXXXX Version XXXXXX * \section Sec_ChangeLogXXXXXX Version XXXXXX
* *
* <b>New:</b> * <b>New:</b>
* - (None) * - Added support for the UC3B0256 AVR32 microcontroller
* *
* <b>Changed:</b> * <b>Changed:</b>
* - AVRISP programmer project now has a more robust timeout system, allowing for a doubling of the software USART speed * - AVRISP programmer project now has a more robust timeout system, allowing for a doubling of the software USART speed
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* - Increased the speed of both software and hardware TPI/PDI programming modes of the AVRISP project * - Increased the speed of both software and hardware TPI/PDI programming modes of the AVRISP project
* *
* <b>Fixed:</b> * <b>Fixed:</b>
* - (None) * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin
* *
* \section Sec_ChangeLog100219 Version 100219 * \section Sec_ChangeLog100219 Version 100219
* *
......
...@@ -53,7 +53,7 @@ volatile uint16_t SoftUSART_Data; ...@@ -53,7 +53,7 @@ volatile uint16_t SoftUSART_Data;
ISR(TIMER1_COMPA_vect, ISR_BLOCK) ISR(TIMER1_COMPA_vect, ISR_BLOCK)
{ {
/* Toggle CLOCK pin in a single cycle (see AVR datasheet) */ /* Toggle CLOCK pin in a single cycle (see AVR datasheet) */
BITBANG_PDICLOCK_PIN |= BITBANG_PDICLOCK_MASK; BITBANG_PDICLOCK_PIN = BITBANG_PDICLOCK_MASK;
/* If not sending or receiving, just exit */ /* If not sending or receiving, just exit */
if (!(SoftUSART_BitCount)) if (!(SoftUSART_BitCount))
...@@ -103,7 +103,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK) ...@@ -103,7 +103,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
ISR(TIMER1_CAPT_vect, ISR_BLOCK) ISR(TIMER1_CAPT_vect, ISR_BLOCK)
{ {
/* Toggle CLOCK pin in a single cycle (see AVR datasheet) */ /* Toggle CLOCK pin in a single cycle (see AVR datasheet) */
BITBANG_TPICLOCK_PIN |= BITBANG_TPICLOCK_MASK; BITBANG_TPICLOCK_PIN = BITBANG_TPICLOCK_MASK;
/* If not sending or receiving, just exit */ /* If not sending or receiving, just exit */
if (!(SoftUSART_BitCount)) if (!(SoftUSART_BitCount))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment