AVR: Cleanup code source.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11377 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Theodore Ateba 2018-01-20 22:33:54 +00:00
parent 386f0d66f7
commit 282bc3a8f0
22 changed files with 454 additions and 452 deletions

View File

@ -15,7 +15,7 @@
*/
/**
* @file hal_lld.c
* @file ATMEGAxx/hal_lld.c
* @brief AVR HAL subsystem low level driver code.
*
* @addtogroup HAL
@ -24,25 +24,25 @@
#include "hal.h"
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Low level HAL driver initialization.

View File

@ -15,7 +15,7 @@
*/
/**
* @file hal_lld.h
* @file ATMEGAxx/hal_lld.h
* @brief AVR HAL subsystem low level driver header.
*
* @addtogroup HAL
@ -25,9 +25,9 @@
#ifndef HAL_LLD_H
#define HAL_LLD_H
/*===========================================================================*/
/*==========================================================================*/
/* Driver constants. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Defines the support for realtime counters in the HAL.
@ -39,25 +39,25 @@
*/
#define PLATFORM_NAME "AVR"
/*===========================================================================*/
/*==========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* External declarations. */
/*===========================================================================*/
/*==========================================================================*/
#ifdef __cplusplus
extern "C" {

View File

@ -26,26 +26,36 @@
#if HAL_USE_ADC || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/** @brief ADC1 driver identifier.*/
#if AVR_ADC_USE_ADC1 || defined(__DOXYGEN__)
ADCDriver ADCD1;
#endif
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Get the ADC channel.
*
* @param[in] mask the mask containing the channel number
* @param[in] currentChannel the current channel.
*
* @return the channel number.
* @retval ADC channel number
* @retval -1 in case of error.
*/
static size_t getAdcChannelNumberFromMask(uint8_t mask,
uint8_t currentChannel) {
@ -59,17 +69,22 @@ static size_t getAdcChannelNumberFromMask(uint8_t mask,
}
/* error, should never reach this line */
return -1; // To check
return -1;
}
/**
* @brief Configure the ADC channel.
*
* @param[in] channelNum the channel number to set.
*/
static void setAdcChannel(uint8_t channelNum) {
ADMUX = (ADMUX & 0xf8) | (channelNum & 0x07);
}
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
#include <util/delay.h>
@ -101,9 +116,9 @@ OSAL_IRQ_HANDLER(ADC_vect) {
OSAL_IRQ_EPILOGUE();
}
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Low level ADC driver initialization.
@ -114,10 +129,10 @@ void adc_lld_init(void) {
adcObjectInit(&ADCD1);
//prescaler 128, only value possible at 20Mhz, interrupt
/* Prescaler 128, only value possible at 20Mhz, interrupt. */
ADCSRA = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0) | (1 << ADIE);
//uso aref, only valid for arduino. arduino ha aref collegato
/* uso aref, only valid for arduino. arduino ha aref collegato. */
ADMUX = (0 << REFS1) | (0 << REFS0);
}

View File

@ -27,30 +27,30 @@
#if HAL_USE_ADC || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver constants. */
/*===========================================================================*/
/*==========================================================================*/
#define ANALOG_REFERENCE_AREF 0
#define ANALOG_REFERENCE_AVCC 1
#define ANALOG_REFERENCE_1V1 2
#define ANALOG_REFERENCE_2V56 3
/*===========================================================================*/
/*==========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*==========================================================================*/
#if !CH_CFG_USE_SEMAPHORES
#error "the ADC driver requires CH_CFG_USE_SEMAPHORES"
#endif
/*===========================================================================*/
/*==========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief ADC sample data type.
@ -167,13 +167,13 @@ struct ADCDriver {
size_t currentBufferPosition;
};
/*===========================================================================*/
/*==========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* External declarations. */
/*===========================================================================*/
/*==========================================================================*/
#if AVR_ADC_USE_ADC1 && !defined(__DOXYGEN__)
extern ADCDriver ADCD1;

View File

@ -26,26 +26,26 @@
#if HAL_USE_EXT || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief EXTD1 driver identifier.
*/
EXTDriver EXTD1;
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Set the INTx interrupt trigger front or state.
@ -159,9 +159,9 @@ void ext_lld_set_intx_edges(expchannel_t channel, uint8_t edge) {
#endif
}
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
#if AVR_EXT_USE_INT0 || defined(__DOXYGEN__)
/**
@ -236,9 +236,9 @@ OSAL_IRQ_HANDLER(INT5_vect) {
}
#endif
/*===========================================================================*/
/*==========================================================================*/
/* Driver functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Enables an EXT channel.

View File

@ -27,31 +27,31 @@
#if HAL_USE_EXT || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver constants. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Maximum number of EXT channels.
*/
#define AVR_INT_NUM_LINES 6 /**< INT0 to INT5 */
#define AVR_INT_NUM_LINES 6 /**< INT0 to INT5. */
/**
* @brief Available number of EXT channels.
*/
#define EXT_MAX_CHANNELS AVR_INT_NUM_LINES
/*===========================================================================*/
/*==========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief EXT channel identifier.
@ -108,13 +108,13 @@ struct EXTDriver {
/* End of the mandatory fields. */
};
/*===========================================================================*/
/*==========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* External declarations. */
/*===========================================================================*/
/*==========================================================================*/
extern EXTDriver EXTD1;
#ifdef __cplusplus

View File

@ -26,29 +26,29 @@
#if HAL_USE_PAL || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Event records for the 16 GPIO EXTI channels.
*/
palevent_t _pal_events[16];
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief AVR GPIO ports configuration.
@ -180,13 +180,6 @@ void _pal_lld_enablepadevent(ioportid_t port,
(void)arg;
/* TODO: Implement the interruption here. */
/*
#if (port == IOPORT4)
#elif (port == IOPORT5)
#else
#error The selected port dont have an EXT INTx pin.
*/
//}
}
/**

View File

@ -29,16 +29,16 @@
#if HAL_USE_PAL || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Unsupported modes and specific modes. */
/*===========================================================================*/
/*==========================================================================*/
#undef PAL_MODE_INPUT_PULLDOWN
#undef PAL_MODE_OUTPUT_OPENDRAIN
/*===========================================================================*/
/*==========================================================================*/
/* I/O Ports Types and constants. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Width, in bits, of an I/O port.
@ -179,9 +179,9 @@ typedef struct {
*/
typedef uint8_t ioeventmode_t;
/*===========================================================================*/
/*==========================================================================*/
/* I/O Ports Identifiers. */
/*===========================================================================*/
/*==========================================================================*/
#if defined(PORTA) || defined(__DOXYGEN__)
/**
@ -274,10 +274,10 @@ typedef uint8_t ioeventmode_t;
#define IOPORTSPI1 ((volatile avr_gpio_registers_t *)&PIN_SPI1)
#endif
/*===========================================================================*/
/*==========================================================================*/
/* Implementation, some of the following macros could be implemented as */
/* functions, if so please put them in hal_pal_lld.c. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Low level PAL subsystem initialization.

View File

@ -26,30 +26,30 @@
#if HAL_USE_I2C || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/** @brief I2C driver identifier. */
#if AVR_I2C_USE_I2C1 || defined(__DOXYGEN__)
I2CDriver I2CD1;
#endif
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
#if AVR_I2C_USE_I2C1 || defined(__DOXYGEN__)
/**
@ -120,7 +120,7 @@ OSAL_IRQ_HANDLER(TWI_vect) {
i2cp->errors |= I2C_BUS_ERROR;
break;
default:
/* FIXME: only gets here if there are other MASTERs in the bus */
/* FIXME: only gets here if there are other MASTERs in the bus. */
TWCR = ((1 << TWSTO) | (1 << TWINT) | (1 << TWEN));
_i2c_wakeup_error_isr(i2cp);
}
@ -134,9 +134,9 @@ OSAL_IRQ_HANDLER(TWI_vect) {
}
#endif /* AVR_I2C_USE_I2C1 */
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Low level I2C driver initialization.
@ -160,15 +160,15 @@ void i2c_lld_start(I2CDriver *i2cp) {
uint32_t clock_speed = 100000;
/* TODO: Test TWI without external pull-ups (use internal) */
/* TODO: Test TWI without external pull-ups (use internal). */
/* Configure prescaler to 1 */
/* Configure prescaler to 1. */
TWSR &= 0xF8;
if (i2cp->config != NULL)
clock_speed = i2cp->config->clock_speed;
/* Configure baudrate */
/* Configure baudrate. */
TWBR = ((F_CPU / clock_speed) - 16) / 2;
}
@ -182,7 +182,7 @@ void i2c_lld_start(I2CDriver *i2cp) {
void i2c_lld_stop(I2CDriver *i2cp) {
if (i2cp->state != I2C_STOP) {
/* Disable TWI subsystem and stop all operations */
/* Disable TWI subsystem and stop all operations. */
TWCR &= ~(1 << TWEN);
}
}
@ -196,7 +196,7 @@ void i2c_lld_stop(I2CDriver *i2cp) {
* @param[in] rxbytes number of bytes to be received
* @param[in] timeout the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_INFINITE no timeout.
* - @a TIME_INFINITE no timeout
*
* @return The operation status.
* @retval MSG_OK if the function succeeded.
@ -221,7 +221,7 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
i2cp->rxbytes = rxbytes;
i2cp->rxidx = 0;
/* Send START */
/* Send START. */
TWCR = ((1 << TWSTA) | (1 << TWINT) | (1 << TWEN) | (1 << TWIE));
return osalThreadSuspendTimeoutS(&i2cp->thread, TIME_INFINITE);
@ -238,7 +238,7 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
* @param[in] rxbytes number of bytes to be received
* @param[in] timeout the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_INFINITE no timeout.
* - @a TIME_INFINITE no timeout
*
* @return The operation status.
* @retval MSG_OK if the function succeeded.

View File

@ -27,9 +27,9 @@
#if HAL_USE_I2C || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver constants. */
/*===========================================================================*/
/*==========================================================================*/
/** @brief START transmitted. */
#define TWI_START 0x08
@ -58,9 +58,9 @@
/** @brief DATA received with NACK response. */
#define TWI_MASTER_RX_DATA_NACK 0x58
/*===========================================================================*/
/*==========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @name Configuration options
@ -76,13 +76,13 @@
#endif
/** @} */
/*===========================================================================*/
/*==========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Type representing I2C address.
@ -173,9 +173,9 @@ struct I2CDriver {
*/
typedef struct I2CDriver I2CDriver;
/*===========================================================================*/
/*==========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Get errors from I2C driver.
@ -186,9 +186,9 @@ typedef struct I2CDriver I2CDriver;
*/
#define i2c_lld_get_errors(i2cp) ((i2cp)->errors)
/*===========================================================================*/
/*==========================================================================*/
/* External declarations. */
/*===========================================================================*/
/*==========================================================================*/
#if !defined(__DOXYGEN__)
#if AVR_I2C_USE_I2C1

View File

@ -26,15 +26,15 @@
#if HAL_USE_SPI || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*==========================================================================*/
#define DUMMY_SPI_SEND_VALUE 0xFF
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief SPI1 driver identifier.
@ -43,17 +43,17 @@
SPIDriver SPID1;
#endif
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
#if AVR_SPI_USE_SPI1 || defined(__DOXYGEN__)
/**
@ -66,16 +66,16 @@ OSAL_IRQ_HANDLER(SPI_STC_vect) {
SPIDriver *spip = &SPID1;
/* a new value has arrived, store it if we are interested in it */
/* A new value has arrived, store it if we are interested in it. */
if (spip->rxbuf) spip->rxbuf[spip->exidx] = SPDR;
/* check if we are done */
/* Check if we are done. */
if (++(spip->exidx) >= spip->exbytes) {
_spi_isr_code(spip);
} else { /* if not done send the next byte */
if (spip->txbuf) { /* if there is a buffer with values to be send then use it*/
} else { /* If not done send the next byte. */
if (spip->txbuf) { /* If there is a buffer with values to be send then use it. */
SPDR = spip->txbuf[spip->exidx];
} else { /* if there isn't a buffer with values to be send then send a the dummy value*/
} else { /* If there isn't a buffer with values to be send then send a the dummy value. */
SPDR = DUMMY_SPI_SEND_VALUE;
}
}
@ -115,7 +115,7 @@ void spi_lld_start(SPIDriver *spip) {
/* Enables the peripheral. */
#if AVR_SPI_USE_SPI1
if (&SPID1 == spip) {
/* Enable SPI clock using Power Reduction Register */
/* Enable SPI clock using Power Reduction Register. */
#if defined(PRR0)
PRR0 &= ~(1 << PRSPI);
#elif defined(PRR)
@ -131,16 +131,16 @@ void spi_lld_start(SPIDriver *spip) {
/* Note that some bits are forced:
SPI interrupt disabled,
SPI enabled,
SPI master enabled */
SPI master enabled. */
SPCR = (spip->config->spcr & ~(SPI_CR_SPIE)) | SPI_CR_MSTR | SPI_CR_SPE;
SPSR = spip->config->spsr;
/* dummy reads before enabling interrupt */
/* Dummy reads before enabling interrupt. */
dummy = SPSR;
dummy = SPDR;
(void) dummy; /* suppress warning about unused variable */
(void) dummy; /* Suppress warning about unused variable. */
/* Enable SPI interrupts */
/* Enable SPI interrupts. */
SPCR |= SPI_CR_SPIE;
}
#endif /* AVR_SPI_USE_SPI1 */
@ -163,7 +163,7 @@ void spi_lld_stop(SPIDriver *spip) {
if (&SPID1 == spip) {
SPCR &= (SPI_CR_SPIE | SPI_CR_SPE);
}
/* Disable SPI clock using Power Reduction Register */
/* Disable SPI clock using Power Reduction Register. */
#if defined(PRR0)
PRR0 |= (1 << PRSPI);
#elif defined(PRR)
@ -251,7 +251,7 @@ uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame) {
uint8_t dummy;
(void)spip;
/* disable interrupt */
/* Disable interrupt. */
SPCR &= ~(SPI_CR_SPIE);
SPDR = frame >> 8;
@ -264,7 +264,7 @@ uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame) {
dummy = SPSR;
dummy = SPDR;
(void) dummy; /* suppress warning about unused variable */
(void) dummy; /* Suppress warning about unused variable. */
SPCR |= SPI_CR_SPIE;
return spdr;
@ -276,7 +276,7 @@ uint8_t spi_lld_polled_exchange(SPIDriver *spip, uint8_t frame) {
uint8_t dummy;
(void)spip;
/* disable interrupt */
/* Disable interrupt. */
SPCR &= ~(SPI_CR_SPIE);
SPDR = frame;
@ -285,7 +285,7 @@ uint8_t spi_lld_polled_exchange(SPIDriver *spip, uint8_t frame) {
dummy = SPSR;
dummy = SPDR;
(void) dummy; /* suppress warning about unused variable */
(void) dummy; /* Suppress warning about unused variable. */
SPCR |= SPI_CR_SPIE;
return spdr;

View File

@ -27,9 +27,9 @@
#if HAL_USE_SPI || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver constants. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @name SPI Configuration Register
@ -72,9 +72,9 @@
#define SPI_SR_SCK_FOSC_128 (0 << SPI2X)
/** @} */
/*===========================================================================*/
/*==========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @name Configuration options
@ -89,13 +89,13 @@
#endif
/** @} */
/*===========================================================================*/
/*==========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Type of a structure representing an SPI driver.
@ -187,9 +187,9 @@ struct SPIDriver {
size_t exidx;
};
/*===========================================================================*/
/*==========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Ignores data on the SPI bus.
@ -234,9 +234,9 @@ struct SPIDriver {
*/
#define spi_lld_receive(spip, n, rxbuf) spi_lld_exchange(spip, n, NULL, rxbuf)
/*===========================================================================*/
/*==========================================================================*/
/* External declarations. */
/*===========================================================================*/
/*==========================================================================*/
#if AVR_SPI_USE_SPI1 && !defined(__DOXYGEN__)
extern SPIDriver SPID1;

View File

@ -26,25 +26,25 @@
#if HAL_USE_PAL || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief AVR GPIO ports configuration.

View File

@ -161,7 +161,7 @@ OSAL_IRQ_HANDLER(TIMER1_COMPA_vect) {
OSAL_IRQ_PROLOGUE();
// TODO: reset status if required
/* TODO: reset status if required. */
osalSysLockFromISR();
osalOsTimerHandlerI();
@ -189,11 +189,11 @@ void st_lld_init(void) {
* Periodic mode uses Timer 1 (16 bit).
*/
/* CTC mode, no clock source */
/* CTC mode, no clock source. */
TCCR1A = 0;
TCCR1B = _BV(WGM12);
/* start disabled */
/* Start disabled. */
TCCR1C = 0;
OCR1A = 0;
TCNT1 = 0;
@ -208,11 +208,11 @@ void st_lld_init(void) {
/*
* Periodic mode uses Timer 0 (8 bit).
*/
#if defined(TCCR0B) /* Timer has multiple output comparators */
#if defined(TCCR0B) /* Timer has multiple output comparators. */
TCCR0A = (1 << WGM01) | (0 << WGM00) | /* CTC mode. */
(0 << COM0A1) | (0 << COM0A0); /* OC0A disabled. */
//(0 << COM0B1) | (0 << COM0B0); /* OC0B disabled. */
// FIXME: See if the line bellow must be delate or recoded.
/* FIXME: See if the line bellow must be delate or recoded. */
//TCCR0B = (0 << WGM02) | AVR_TIMER_PRESCALER_BITS; /* CTC mode. */
OCR0A = AVR_TIMER_COUNTER - 1;
TCNT0 = 0; /* Reset counter. */
@ -224,7 +224,8 @@ void st_lld_init(void) {
TIMSK0 = (1 << OCIE0A); /* IRQ on compare. */
#endif
#elif defined(TCCR0A) /* AT90CAN doesn't have TCCR0B and slightly different TCCR0A */
#elif defined(TCCR0A) /* AT90CAN doesn't have TCCR0B and slightly different */
/* TCCR0A. */
TCCR0A = (1 << WGM01) | (0 << WGM00) | /* CTC mode. */
(0 << COM0A1) | (0 << COM0A0); /* OC0A disabled. */
OCR0A = AVR_TIMER_COUNTER - 1;

View File

@ -29,38 +29,33 @@
#include <avr/io.h>
/*===========================================================================*/
/*==========================================================================*/
/* Driver constants. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/*==========================================================================*/
/*
* TODO: for models that have many timers,
* could add AVR_ST_USE_TIMER
*/
/* TODO: for models that have many timers, could add AVR_ST_USE_TIMER. */
/*===========================================================================*/
/*==========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*==========================================================================*/
/*
* TODO: error checks for valid timer selected
*/
/* TODO: error checks for valid timer selected. */
/*===========================================================================*/
/*==========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* External declarations. */
/*===========================================================================*/
/*==========================================================================*/
#ifdef __cplusplus
extern "C" {
@ -79,9 +74,9 @@ extern "C" {
#define TIMSK_REG TIMSK1
#endif
/*===========================================================================*/
/*==========================================================================*/
/* Driver inline functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Returns the time counter value.
@ -154,7 +149,7 @@ static inline systime_t st_lld_get_alarm(void) {
*
* @return The alarm status.
* @retval false if the alarm is not active.
* @retval true is the alarm is active
* @retval true is the alarm is active.
*
* @notapi
*/

View File

@ -31,13 +31,13 @@
/*==========================================================================*/
#define UBRR(b) (((F_CPU / b) >> 5) - 1)
/*===========================================================================*/
/*==========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/** @brief USART1 UART driver identifier.*/
#if AVR_UART_USE_USART1 || defined(__DOXYGEN__)
@ -49,13 +49,13 @@ UARTDriver UARTD1;
UARTDriver UARTD2;
#endif
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief USART de-initialization.
@ -94,9 +94,9 @@ static void usart_start(UARTDriver *uartp) {
#endif
}
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
#if AVR_UART_USE_USART1 || defined(__DOXYGEN__)
/**
@ -108,15 +108,15 @@ OSAL_IRQ_HANDLER(LIN_TC_vect) {
OSAL_IRQ_PROLOGUE();
// TODO: Manage the UART IRQ.
/* TODO: Manage the UART IRQ. */
OSAL_IRQ_EPILOGUE();
}
#endif /* AVR_UART_USE_USART1 */
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Low level UART driver initialization.
@ -219,7 +219,7 @@ void uart_lld_start_send(UARTDriver *uartp, size_t n, const uint8_t *txbuf) {
void uart_lld_start_receive(UARTDriver *uartp, size_t n, void *rxbuf) {
/* Stopping previous activity (idle state).*/
// TODO: Implement this function.
/* TODO: Implement this function. */
}
#endif /* HAL_USE_UART */

View File

@ -25,9 +25,9 @@
#ifndef HAL_LLD_H
#define HAL_LLD_H
/*===========================================================================*/
/*==========================================================================*/
/* Driver constants. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Defines the support for realtime counters in the HAL.
@ -39,25 +39,25 @@
*/
#define PLATFORM_NAME "AVR XMEGA"
/*===========================================================================*/
/*==========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* External declarations. */
/*===========================================================================*/
/*==========================================================================*/
#ifdef __cplusplus
extern "C" {

View File

@ -26,25 +26,25 @@
#if HAL_USE_PAL || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief AVR GPIO ports configuration.

View File

@ -27,16 +27,16 @@
#if HAL_USE_PAL || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Unsupported modes and specific modes. */
/*===========================================================================*/
/*==========================================================================*/
#undef PAL_MODE_INPUT_PULLDOWN
#undef PAL_MODE_OUTPUT_OPENDRAIN
/*===========================================================================*/
/*==========================================================================*/
/* I/O Ports Types and constants. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Width, in bits, of an I/O port.
@ -177,9 +177,9 @@ typedef struct {
*/
typedef uint8_t ioeventmode_t;
/*===========================================================================*/
/*==========================================================================*/
/* I/O Ports Identifiers. */
/*===========================================================================*/
/*==========================================================================*/
#if defined(PORTA) || defined(__DOXYGEN__)
/**
@ -258,10 +258,10 @@ typedef uint8_t ioeventmode_t;
#define IOPORT11 (&PORTL)
#endif
/*===========================================================================*/
/*==========================================================================*/
/* Implementation, some of the following macros could be implemented as */
/* functions, if so please put them in hal_pal_lld.c. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Low level PAL subsystem initialization.

View File

@ -26,29 +26,29 @@
#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__)
/*===========================================================================*/
/*==========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*==========================================================================*/
#if (OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC) || defined(__DOXYGEN__)

View File

@ -29,38 +29,36 @@
#include <avr/io.h>
/*===========================================================================*/
/*==========================================================================*/
/* Driver constants. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/*==========================================================================*/
/*
* TODO: for models that have many timers,
* could add AVR_XMEGA_ST_USE_TIMER
* could add AVR_XMEGA_ST_USE_TIMER.
*/
/*===========================================================================*/
/*==========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*==========================================================================*/
/*
* TODO: error checks for valid timer selected
*/
/* TODO: error checks for valid timer selected. */
/*===========================================================================*/
/*==========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/*==========================================================================*/
/*===========================================================================*/
/*==========================================================================*/
/* External declarations. */
/*===========================================================================*/
/*==========================================================================*/
#ifdef __cplusplus
extern "C" {
@ -72,9 +70,9 @@ extern "C" {
#define TIFR_REG TCC0.INTFLAGS
/*===========================================================================*/
/*==========================================================================*/
/* Driver inline functions. */
/*===========================================================================*/
/*==========================================================================*/
/**
* @brief Returns the time counter value.
@ -142,7 +140,7 @@ static inline systime_t st_lld_get_alarm(void) {
*
* @return The alarm status.
* @retval false if the alarm is not active.
* @retval true is the alarm is active
* @retval true is the alarm is active.
*
* @notapi
*/