mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -04:00
Updated AVR32 demos and added AVR32 UC3B demo.
This commit is contained in:
parent
45e7e5ac55
commit
94c94d3c0e
164 changed files with 21458 additions and 3994 deletions
|
@ -11,7 +11,7 @@
|
|||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support email: avr32@atmel.com
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
@ -70,9 +70,12 @@ static __inline__ int usart_mode_is_multidrop(volatile avr32_usart_t *usart)
|
|||
/*! \brief Calculates a clock divider (\e CD) that gets the USART as close to a
|
||||
* wanted baudrate as possible.
|
||||
*
|
||||
* \todo manage the FP fractal part to avoid big errors
|
||||
*
|
||||
* Baudrate calculation:
|
||||
* \f$ baudrate = \frac{Selected Clock}{16 \times CD} \f$ with 16x oversampling or
|
||||
* \f$ baudrate = \frac{Selected Clock}{8 \times CD} \f$ with 8x oversampling.
|
||||
* \f$ baudrate = \frac{Selected Clock}{8 \times CD} \f$ with 8x oversampling or
|
||||
* \f$ baudrate = \frac{Selected Clock}{CD} \f$ with SYNC bit set to allow high speed.
|
||||
*
|
||||
* \param usart Base address of the USART instance.
|
||||
* \param baudrate Wanted baudrate.
|
||||
|
@ -90,20 +93,30 @@ static int usart_set_baudrate(volatile avr32_usart_t *usart, unsigned int baudra
|
|||
// Baudrate calculation.
|
||||
if (baudrate < pba_hz / 16)
|
||||
{
|
||||
// Use 16x oversampling.
|
||||
usart->mr &=~ AVR32_USART_MR_OVER_MASK;
|
||||
cd = pba_hz / (16 * baudrate);
|
||||
// Use 16x oversampling, clear SYNC bit.
|
||||
usart->mr &=~ (AVR32_USART_MR_OVER_MASK | AVR32_USART_MR_SYNC_MASK);
|
||||
cd = (pba_hz + 8 * baudrate) / (16 * baudrate);
|
||||
|
||||
if ((cd >65535)) return USART_INVALID_INPUT;
|
||||
}
|
||||
else
|
||||
else if (baudrate < pba_hz / 8)
|
||||
{
|
||||
// Use 8x oversampling.
|
||||
usart->mr |= AVR32_USART_MR_OVER_MASK;
|
||||
cd = pba_hz / (8 * baudrate);
|
||||
// clear SYNC bit
|
||||
usart->mr &=~ AVR32_USART_MR_SYNC_MASK;
|
||||
|
||||
cd = (pba_hz + 4 * baudrate) / (8 * baudrate);
|
||||
|
||||
if ((cd < 1)||(cd >65535)) return USART_INVALID_INPUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
// set SYNC to 1
|
||||
usart->mr |= AVR32_USART_MR_SYNC_MASK;
|
||||
// use PBA/BaudRate
|
||||
cd = (pba_hz / baudrate);
|
||||
}
|
||||
usart->brgr = cd << AVR32_USART_BRGR_CD_OFFSET;
|
||||
|
||||
return USART_SUCCESS;
|
||||
|
@ -303,8 +316,6 @@ int usart_init_iso7816(volatile avr32_usart_t *usart, const iso7816_options_t *o
|
|||
|
||||
return USART_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* - AppNote:
|
||||
*
|
||||
* \author Atmel Corporation: http://www.atmel.com \n
|
||||
* Support email: avr32@atmel.com
|
||||
* Support and FAQ: http://support.atmel.no/
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
@ -46,14 +46,7 @@
|
|||
#ifndef _USART_H_
|
||||
#define _USART_H_
|
||||
|
||||
#if __GNUC__
|
||||
# include <avr32/io.h>
|
||||
#elif __ICCAVR32__
|
||||
# include <avr32/iouc3a0512.h>
|
||||
#else
|
||||
# error Unknown compiler
|
||||
#endif
|
||||
|
||||
#include <avr32/io.h>
|
||||
#include "compiler.h"
|
||||
|
||||
|
||||
|
@ -97,6 +90,7 @@
|
|||
#define USART_MODE_SW_HSH AVR32_USART_MR_MODE_SOFTWARE //!< RS232 mode with software handshaking.
|
||||
//! @}
|
||||
|
||||
|
||||
/*! \name Channel Modes
|
||||
*/
|
||||
//! @{
|
||||
|
@ -171,6 +165,26 @@ typedef struct
|
|||
int bit_order;
|
||||
} iso7816_options_t;
|
||||
|
||||
//! Input parameters when initializing ISO7816 modes.
|
||||
typedef struct
|
||||
{
|
||||
//! Set the frequency of the SPI clock.
|
||||
unsigned long baudrate;
|
||||
|
||||
//! Number of bits to transmit as a character (5 to 9).
|
||||
unsigned char charlength;
|
||||
|
||||
//! Run the channel in testmode: \ref USART_NORMAL_CHMODE, \ref USART_AUTO_ECHO,
|
||||
//! \ref USART_LOCAL_LOOPBACK or \ref USART_REMOTE_LOOPBACK.
|
||||
unsigned char channelmode;
|
||||
|
||||
//! Which SPI mode to use when transmitting.
|
||||
unsigned char spimode;
|
||||
} usart_spi_options_t;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*! \name Initialization Functions
|
||||
|
@ -254,8 +268,50 @@ extern int usart_init_rs485(volatile avr32_usart_t *usart, const usart_options_t
|
|||
*/
|
||||
extern int usart_init_iso7816(volatile avr32_usart_t *usart, const iso7816_options_t *opt, int t, long pba_hz);
|
||||
|
||||
/*! \brief Sets up the USART to use the SPI mode as master.
|
||||
*
|
||||
* \param usart Base address of the USART instance.
|
||||
* \param opt Options needed to set up SPI mode (see \ref usart_spi_options_t).
|
||||
* \param pba_hz USART module input clock frequency (PBA clock, Hz).
|
||||
*
|
||||
* \retval USART_SUCCESS Mode successfully initialized.
|
||||
* \retval USART_INVALID_INPUT One or more of the arguments is out of valid range.
|
||||
*/
|
||||
extern int usart_init_spi_master(volatile avr32_usart_t *usart, const usart_spi_options_t *opt, long pba_hz);
|
||||
|
||||
|
||||
/*! \brief Sets up the USART to use the SPI mode as slave.
|
||||
*
|
||||
* \param usart Base address of the USART instance.
|
||||
* \param opt Options needed to set up SPI mode (see \ref usart_spi_options_t).
|
||||
* \param pba_hz USART module input clock frequency (PBA clock, Hz).
|
||||
*
|
||||
* \retval USART_SUCCESS Mode successfully initialized.
|
||||
* \retval USART_INVALID_INPUT One or more of the arguments is out of valid range.
|
||||
*/
|
||||
extern int usart_init_spi_slave(volatile avr32_usart_t *usart, const usart_spi_options_t *opt, long pba_hz);
|
||||
|
||||
//! @}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*! \brief Selects slave chip.
|
||||
*
|
||||
* \param usart Base address of the USART instance.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval USART_SUCCESS Success.
|
||||
*/
|
||||
extern int usart_spi_selectChip(volatile avr32_usart_t *usart);
|
||||
|
||||
/*! \brief Unselects slave chip.
|
||||
*
|
||||
* \param usart Base address of the USART instance.
|
||||
*
|
||||
* \return Status.
|
||||
* \retval USART_SUCCESS Success.
|
||||
* \retval USART_FAILURE Time out.
|
||||
*/
|
||||
extern int usart_spi_unselectChip(volatile avr32_usart_t *usart);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*! \name Read and Reset Error Status Bits
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue