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. * @brief AVR HAL subsystem low level driver code.
* *
* @addtogroup HAL * @addtogroup HAL
@ -24,25 +24,25 @@
#include "hal.h" #include "hal.h"
/*===========================================================================*/ /*==========================================================================*/
/* Driver exported variables. */ /* Driver exported variables. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver local variables and types. */ /* Driver local variables and types. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver local functions. */ /* Driver local functions. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver interrupt handlers. */ /* Driver interrupt handlers. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver exported functions. */ /* Driver exported functions. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Low level HAL driver initialization. * @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. * @brief AVR HAL subsystem low level driver header.
* *
* @addtogroup HAL * @addtogroup HAL
@ -25,9 +25,9 @@
#ifndef HAL_LLD_H #ifndef HAL_LLD_H
#define HAL_LLD_H #define HAL_LLD_H
/*===========================================================================*/ /*==========================================================================*/
/* Driver constants. */ /* Driver constants. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Defines the support for realtime counters in the HAL. * @brief Defines the support for realtime counters in the HAL.
@ -39,25 +39,25 @@
*/ */
#define PLATFORM_NAME "AVR" #define PLATFORM_NAME "AVR"
/*===========================================================================*/ /*==========================================================================*/
/* Driver pre-compile time settings. */ /* Driver pre-compile time settings. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Derived constants and error checks. */ /* Derived constants and error checks. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver data structures and types. */ /* Driver data structures and types. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver macros. */ /* Driver macros. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*==========================================================================*/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -26,26 +26,36 @@
#if HAL_USE_ADC || defined(__DOXYGEN__) #if HAL_USE_ADC || defined(__DOXYGEN__)
/*===========================================================================*/ /*==========================================================================*/
/* Driver local definitions. */ /* Driver local definitions. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver exported variables. */ /* Driver exported variables. */
/*===========================================================================*/ /*==========================================================================*/
/** @brief ADC1 driver identifier.*/ /** @brief ADC1 driver identifier.*/
#if AVR_ADC_USE_ADC1 || defined(__DOXYGEN__) #if AVR_ADC_USE_ADC1 || defined(__DOXYGEN__)
ADCDriver ADCD1; ADCDriver ADCD1;
#endif #endif
/*===========================================================================*/ /*==========================================================================*/
/* Driver local variables. */ /* Driver local variables. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver local functions. */ /* 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, static size_t getAdcChannelNumberFromMask(uint8_t mask,
uint8_t currentChannel) { uint8_t currentChannel) {
@ -59,17 +69,22 @@ static size_t getAdcChannelNumberFromMask(uint8_t mask,
} }
/* error, should never reach this line */ /* 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) { static void setAdcChannel(uint8_t channelNum) {
ADMUX = (ADMUX & 0xf8) | (channelNum & 0x07); ADMUX = (ADMUX & 0xf8) | (channelNum & 0x07);
} }
/*===========================================================================*/ /*==========================================================================*/
/* Driver interrupt handlers. */ /* Driver interrupt handlers. */
/*===========================================================================*/ /*==========================================================================*/
#include <util/delay.h> #include <util/delay.h>
@ -101,9 +116,9 @@ OSAL_IRQ_HANDLER(ADC_vect) {
OSAL_IRQ_EPILOGUE(); OSAL_IRQ_EPILOGUE();
} }
/*===========================================================================*/ /*==========================================================================*/
/* Driver exported functions. */ /* Driver exported functions. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Low level ADC driver initialization. * @brief Low level ADC driver initialization.
@ -114,10 +129,10 @@ void adc_lld_init(void) {
adcObjectInit(&ADCD1); 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); 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); ADMUX = (0 << REFS1) | (0 << REFS0);
} }
@ -131,7 +146,7 @@ void adc_lld_init(void) {
void adc_lld_start(ADCDriver *adcp) { void adc_lld_start(ADCDriver *adcp) {
if (adcp->state == ADC_STOP) { if (adcp->state == ADC_STOP) {
/* Clock activation.*/ /* Clock activation. */
ADCSRA |= (1 << ADEN); ADCSRA |= (1 << ADEN);
} }
@ -150,7 +165,7 @@ void adc_lld_start(ADCDriver *adcp) {
void adc_lld_stop(ADCDriver *adcp) { void adc_lld_stop(ADCDriver *adcp) {
if (adcp->state == ADC_READY) { if (adcp->state == ADC_READY) {
/* Clock de-activation.*/ /* Clock de-activation. */
ADCSRA &= ~(1 << ADEN); ADCSRA &= ~(1 << ADEN);
} }
} }

View File

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

View File

@ -26,26 +26,26 @@
#if HAL_USE_EXT || defined(__DOXYGEN__) #if HAL_USE_EXT || defined(__DOXYGEN__)
/*===========================================================================*/ /*==========================================================================*/
/* Driver local definitions. */ /* Driver local definitions. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver exported variables. */ /* Driver exported variables. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief EXTD1 driver identifier. * @brief EXTD1 driver identifier.
*/ */
EXTDriver EXTD1; EXTDriver EXTD1;
/*===========================================================================*/ /*==========================================================================*/
/* Driver local variables and types. */ /* Driver local variables and types. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver local functions. */ /* Driver local functions. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Set the INTx interrupt trigger front or state. * @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 #endif
} }
/*===========================================================================*/ /*==========================================================================*/
/* Driver interrupt handlers. */ /* Driver interrupt handlers. */
/*===========================================================================*/ /*==========================================================================*/
#if AVR_EXT_USE_INT0 || defined(__DOXYGEN__) #if AVR_EXT_USE_INT0 || defined(__DOXYGEN__)
/** /**
@ -236,9 +236,9 @@ OSAL_IRQ_HANDLER(INT5_vect) {
} }
#endif #endif
/*===========================================================================*/ /*==========================================================================*/
/* Driver functions. */ /* Driver functions. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Enables an EXT channel. * @brief Enables an EXT channel.
@ -331,7 +331,7 @@ void ext_lld_channel_disable(EXTDriver *extp, expchannel_t channel) {
*/ */
void ext_lld_init(void) { void ext_lld_init(void) {
/* Driver initialization.*/ /* Driver initialization. */
extObjectInit(&EXTD1); extObjectInit(&EXTD1);
} }

View File

@ -27,31 +27,31 @@
#if HAL_USE_EXT || defined(__DOXYGEN__) #if HAL_USE_EXT || defined(__DOXYGEN__)
/*===========================================================================*/ /*==========================================================================*/
/* Driver constants. */ /* Driver constants. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Maximum number of EXT channels. * @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. * @brief Available number of EXT channels.
*/ */
#define EXT_MAX_CHANNELS AVR_INT_NUM_LINES #define EXT_MAX_CHANNELS AVR_INT_NUM_LINES
/*===========================================================================*/ /*==========================================================================*/
/* Driver pre-compile time settings. */ /* Driver pre-compile time settings. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Derived constants and error checks. */ /* Derived constants and error checks. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver data structures and types. */ /* Driver data structures and types. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief EXT channel identifier. * @brief EXT channel identifier.
@ -89,7 +89,7 @@ typedef struct {
* @brief Channel configurations. * @brief Channel configurations.
*/ */
EXTChannelConfig channels[EXT_MAX_CHANNELS]; EXTChannelConfig channels[EXT_MAX_CHANNELS];
/* End of the mandatory fields.*/ /* End of the mandatory fields. */
} EXTConfig; } EXTConfig;
/** /**
@ -105,16 +105,16 @@ struct EXTDriver {
* @brief Current configuration data. * @brief Current configuration data.
*/ */
const EXTConfig *config; const EXTConfig *config;
/* End of the mandatory fields.*/ /* End of the mandatory fields. */
}; };
/*===========================================================================*/ /*==========================================================================*/
/* Driver macros. */ /* Driver macros. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*==========================================================================*/
extern EXTDriver EXTD1; extern EXTDriver EXTD1;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -26,29 +26,29 @@
#if HAL_USE_PAL || defined(__DOXYGEN__) #if HAL_USE_PAL || defined(__DOXYGEN__)
/*===========================================================================*/ /*==========================================================================*/
/* Driver exported variables. */ /* Driver exported variables. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Event records for the 16 GPIO EXTI channels. * @brief Event records for the 16 GPIO EXTI channels.
*/ */
palevent_t _pal_events[16]; palevent_t _pal_events[16];
/*===========================================================================*/ /*==========================================================================*/
/* Driver local variables and types. */ /* Driver local variables and types. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver local functions. */ /* Driver local functions. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver interrupt handlers. */ /* Driver interrupt handlers. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver exported functions. */ /* Driver exported functions. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief AVR GPIO ports configuration. * @brief AVR GPIO ports configuration.
@ -180,13 +180,6 @@ void _pal_lld_enablepadevent(ioportid_t port,
(void)arg; (void)arg;
/* TODO: Implement the interruption here. */ /* 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__) #if HAL_USE_PAL || defined(__DOXYGEN__)
/*===========================================================================*/ /*==========================================================================*/
/* Unsupported modes and specific modes. */ /* Unsupported modes and specific modes. */
/*===========================================================================*/ /*==========================================================================*/
#undef PAL_MODE_INPUT_PULLDOWN #undef PAL_MODE_INPUT_PULLDOWN
#undef PAL_MODE_OUTPUT_OPENDRAIN #undef PAL_MODE_OUTPUT_OPENDRAIN
/*===========================================================================*/ /*==========================================================================*/
/* I/O Ports Types and constants. */ /* I/O Ports Types and constants. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Width, in bits, of an I/O port. * @brief Width, in bits, of an I/O port.
@ -179,9 +179,9 @@ typedef struct {
*/ */
typedef uint8_t ioeventmode_t; typedef uint8_t ioeventmode_t;
/*===========================================================================*/ /*==========================================================================*/
/* I/O Ports Identifiers. */ /* I/O Ports Identifiers. */
/*===========================================================================*/ /*==========================================================================*/
#if defined(PORTA) || defined(__DOXYGEN__) #if defined(PORTA) || defined(__DOXYGEN__)
/** /**
@ -274,10 +274,10 @@ typedef uint8_t ioeventmode_t;
#define IOPORTSPI1 ((volatile avr_gpio_registers_t *)&PIN_SPI1) #define IOPORTSPI1 ((volatile avr_gpio_registers_t *)&PIN_SPI1)
#endif #endif
/*===========================================================================*/ /*==========================================================================*/
/* Implementation, some of the following macros could be implemented as */ /* Implementation, some of the following macros could be implemented as */
/* functions, if so please put them in hal_pal_lld.c. */ /* functions, if so please put them in hal_pal_lld.c. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Low level PAL subsystem initialization. * @brief Low level PAL subsystem initialization.

View File

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

View File

@ -27,40 +27,40 @@
#if HAL_USE_I2C || defined(__DOXYGEN__) #if HAL_USE_I2C || defined(__DOXYGEN__)
/*===========================================================================*/ /*==========================================================================*/
/* Driver constants. */ /* Driver constants. */
/*===========================================================================*/ /*==========================================================================*/
/** @brief START transmitted.*/ /** @brief START transmitted. */
#define TWI_START 0x08 #define TWI_START 0x08
/** @brief Repeated START transmitted.*/ /** @brief Repeated START transmitted. */
#define TWI_REPEAT_START 0x10 #define TWI_REPEAT_START 0x10
/** @brief Arbitration Lost.*/ /** @brief Arbitration Lost. */
#define TWI_ARBITRATION_LOST 0x38 #define TWI_ARBITRATION_LOST 0x38
/** @brief Bus errors.*/ /** @brief Bus errors. */
#define TWI_BUS_ERROR 0x00 #define TWI_BUS_ERROR 0x00
/** @brief SLA+W transmitted with ACK response.*/ /** @brief SLA+W transmitted with ACK response. */
#define TWI_MASTER_TX_ADDR_ACK 0x18 #define TWI_MASTER_TX_ADDR_ACK 0x18
/** @brief SLA+W transmitted with NACK response.*/ /** @brief SLA+W transmitted with NACK response. */
#define TWI_MASTER_TX_ADDR_NACK 0x20 #define TWI_MASTER_TX_ADDR_NACK 0x20
/** @brief DATA transmitted with ACK response.*/ /** @brief DATA transmitted with ACK response. */
#define TWI_MASTER_TX_DATA_ACK 0x28 #define TWI_MASTER_TX_DATA_ACK 0x28
/** @brief DATA transmitted with NACK response.*/ /** @brief DATA transmitted with NACK response. */
#define TWI_MASTER_TX_DATA_NACK 0x30 #define TWI_MASTER_TX_DATA_NACK 0x30
/** @brief SLA+R transmitted with ACK response.*/ /** @brief SLA+R transmitted with ACK response. */
#define TWI_MASTER_RX_ADDR_ACK 0x40 #define TWI_MASTER_RX_ADDR_ACK 0x40
/** @brief SLA+R transmitted with NACK response.*/ /** @brief SLA+R transmitted with NACK response. */
#define TWI_MASTER_RX_ADDR_NACK 0x48 #define TWI_MASTER_RX_ADDR_NACK 0x48
/** @brief DATA received with ACK response.*/ /** @brief DATA received with ACK response. */
#define TWI_MASTER_RX_DATA_ACK 0x50 #define TWI_MASTER_RX_DATA_ACK 0x50
/** @brief DATA received with NACK response.*/ /** @brief DATA received with NACK response. */
#define TWI_MASTER_RX_DATA_NACK 0x58 #define TWI_MASTER_RX_DATA_NACK 0x58
/*===========================================================================*/ /*==========================================================================*/
/* Driver pre-compile time settings. */ /* Driver pre-compile time settings. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @name Configuration options * @name Configuration options
@ -76,13 +76,13 @@
#endif #endif
/** @} */ /** @} */
/*===========================================================================*/ /*==========================================================================*/
/* Derived constants and error checks. */ /* Derived constants and error checks. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver data structures and types. */ /* Driver data structures and types. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Type representing I2C address. * @brief Type representing I2C address.
@ -133,7 +133,7 @@ struct I2CDriver {
#if defined(I2C_DRIVER_EXT_FIELDS) #if defined(I2C_DRIVER_EXT_FIELDS)
I2C_DRIVER_EXT_FIELDS I2C_DRIVER_EXT_FIELDS
#endif #endif
/* End of the mandatory fields.*/ /* End of the mandatory fields. */
/** /**
* @brief Thread waiting for I/O completion. * @brief Thread waiting for I/O completion.
*/ */
@ -173,9 +173,9 @@ struct I2CDriver {
*/ */
typedef struct I2CDriver I2CDriver; typedef struct I2CDriver I2CDriver;
/*===========================================================================*/ /*==========================================================================*/
/* Driver macros. */ /* Driver macros. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Get errors from I2C driver. * @brief Get errors from I2C driver.
@ -186,9 +186,9 @@ typedef struct I2CDriver I2CDriver;
*/ */
#define i2c_lld_get_errors(i2cp) ((i2cp)->errors) #define i2c_lld_get_errors(i2cp) ((i2cp)->errors)
/*===========================================================================*/ /*==========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*==========================================================================*/
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
#if AVR_I2C_USE_I2C1 #if AVR_I2C_USE_I2C1

View File

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

View File

@ -27,9 +27,9 @@
#if HAL_USE_SPI || defined(__DOXYGEN__) #if HAL_USE_SPI || defined(__DOXYGEN__)
/*===========================================================================*/ /*==========================================================================*/
/* Driver constants. */ /* Driver constants. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @name SPI Configuration Register * @name SPI Configuration Register
@ -72,9 +72,9 @@
#define SPI_SR_SCK_FOSC_128 (0 << SPI2X) #define SPI_SR_SCK_FOSC_128 (0 << SPI2X)
/** @} */ /** @} */
/*===========================================================================*/ /*==========================================================================*/
/* Driver pre-compile time settings. */ /* Driver pre-compile time settings. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @name Configuration options * @name Configuration options
@ -89,13 +89,13 @@
#endif #endif
/** @} */ /** @} */
/*===========================================================================*/ /*==========================================================================*/
/* Derived constants and error checks. */ /* Derived constants and error checks. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver data structures and types. */ /* Driver data structures and types. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Type of a structure representing an SPI driver. * @brief Type of a structure representing an SPI driver.
@ -120,7 +120,7 @@ typedef struct {
* @brief Operation complete callback. * @brief Operation complete callback.
*/ */
spicallback_t end_cb; spicallback_t end_cb;
/* End of the mandatory fields.*/ /* End of the mandatory fields. */
/** /**
* @brief Port used of Slave Select * @brief Port used of Slave Select
*/ */
@ -168,7 +168,7 @@ struct SPIDriver {
#if defined(SPI_DRIVER_EXT_FIELDS) #if defined(SPI_DRIVER_EXT_FIELDS)
SPI_DRIVER_EXT_FIELDS SPI_DRIVER_EXT_FIELDS
#endif #endif
/* End of the mandatory fields.*/ /* End of the mandatory fields. */
/** /**
* @brief Pointer to the buffer with data to send. * @brief Pointer to the buffer with data to send.
*/ */
@ -187,9 +187,9 @@ struct SPIDriver {
size_t exidx; size_t exidx;
}; };
/*===========================================================================*/ /*==========================================================================*/
/* Driver macros. */ /* Driver macros. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Ignores data on the SPI bus. * @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) #define spi_lld_receive(spip, n, rxbuf) spi_lld_exchange(spip, n, NULL, rxbuf)
/*===========================================================================*/ /*==========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*==========================================================================*/
#if AVR_SPI_USE_SPI1 && !defined(__DOXYGEN__) #if AVR_SPI_USE_SPI1 && !defined(__DOXYGEN__)
extern SPIDriver SPID1; extern SPIDriver SPID1;

View File

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

View File

@ -161,7 +161,7 @@ OSAL_IRQ_HANDLER(TIMER1_COMPA_vect) {
OSAL_IRQ_PROLOGUE(); OSAL_IRQ_PROLOGUE();
// TODO: reset status if required /* TODO: reset status if required. */
osalSysLockFromISR(); osalSysLockFromISR();
osalOsTimerHandlerI(); osalOsTimerHandlerI();
@ -189,11 +189,11 @@ void st_lld_init(void) {
* Periodic mode uses Timer 1 (16 bit). * Periodic mode uses Timer 1 (16 bit).
*/ */
/* CTC mode, no clock source */ /* CTC mode, no clock source. */
TCCR1A = 0; TCCR1A = 0;
TCCR1B = _BV(WGM12); TCCR1B = _BV(WGM12);
/* start disabled */ /* Start disabled. */
TCCR1C = 0; TCCR1C = 0;
OCR1A = 0; OCR1A = 0;
TCNT1 = 0; TCNT1 = 0;
@ -208,11 +208,11 @@ void st_lld_init(void) {
/* /*
* Periodic mode uses Timer 0 (8 bit). * 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. */ TCCR0A = (1 << WGM01) | (0 << WGM00) | /* CTC mode. */
(0 << COM0A1) | (0 << COM0A0); /* OC0A disabled. */ (0 << COM0A1) | (0 << COM0A0); /* OC0A disabled. */
//(0 << COM0B1) | (0 << COM0B0); /* OC0B 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. */ //TCCR0B = (0 << WGM02) | AVR_TIMER_PRESCALER_BITS; /* CTC mode. */
OCR0A = AVR_TIMER_COUNTER - 1; OCR0A = AVR_TIMER_COUNTER - 1;
TCNT0 = 0; /* Reset counter. */ TCNT0 = 0; /* Reset counter. */
@ -224,7 +224,8 @@ void st_lld_init(void) {
TIMSK0 = (1 << OCIE0A); /* IRQ on compare. */ TIMSK0 = (1 << OCIE0A); /* IRQ on compare. */
#endif #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. */ TCCR0A = (1 << WGM01) | (0 << WGM00) | /* CTC mode. */
(0 << COM0A1) | (0 << COM0A0); /* OC0A disabled. */ (0 << COM0A1) | (0 << COM0A0); /* OC0A disabled. */
OCR0A = AVR_TIMER_COUNTER - 1; OCR0A = AVR_TIMER_COUNTER - 1;

View File

@ -29,38 +29,33 @@
#include <avr/io.h> #include <avr/io.h>
/*===========================================================================*/ /*==========================================================================*/
/* Driver constants. */ /* Driver constants. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver pre-compile time settings. */ /* 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. */ /* 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 data structures and types. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* Driver macros. */ /* Driver macros. */
/*===========================================================================*/ /*==========================================================================*/
/*===========================================================================*/ /*==========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*==========================================================================*/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -79,9 +74,9 @@ extern "C" {
#define TIMSK_REG TIMSK1 #define TIMSK_REG TIMSK1
#endif #endif
/*===========================================================================*/ /*==========================================================================*/
/* Driver inline functions. */ /* Driver inline functions. */
/*===========================================================================*/ /*==========================================================================*/
/** /**
* @brief Returns the time counter value. * @brief Returns the time counter value.
@ -154,7 +149,7 @@ static inline systime_t st_lld_get_alarm(void) {
* *
* @return The alarm status. * @return The alarm status.
* @retval false if the alarm is not active. * @retval false if the alarm is not active.
* @retval true is the alarm is active * @retval true is the alarm is active.
* *
* @notapi * @notapi
*/ */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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