From 282bc3a8f0c8357737dda060c24abb439763ffd6 Mon Sep 17 00:00:00 2001 From: Theodore Ateba Date: Sat, 20 Jan 2018 22:33:54 +0000 Subject: AVR: Cleanup code source. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11377 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.c | 61 +++++++++++++--------- os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.h | 36 ++++++------- os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.c | 38 +++++++------- os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.h | 42 ++++++++-------- os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c | 37 ++++++-------- os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h | 26 +++++----- os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.c | 54 ++++++++++---------- os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.h | 62 +++++++++++------------ os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.c | 70 +++++++++++++------------- os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.h | 40 +++++++-------- 10 files changed, 237 insertions(+), 229 deletions(-) (limited to 'os/hal/ports/AVR/MEGA/LLD') diff --git a/os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.c b/os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.c index f742cf580..79f71def1 100644 --- a/os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.c +++ b/os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.c @@ -26,26 +26,36 @@ #if HAL_USE_ADC || defined(__DOXYGEN__) -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver local definitions. */ +/*==========================================================================*/ -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver exported variables. */ +/*==========================================================================*/ /** @brief ADC1 driver identifier.*/ #if AVR_ADC_USE_ADC1 || defined(__DOXYGEN__) ADCDriver ADCD1; #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, 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. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver interrupt handlers. */ +/*==========================================================================*/ #include @@ -101,9 +116,9 @@ OSAL_IRQ_HANDLER(ADC_vect) { OSAL_IRQ_EPILOGUE(); } -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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); } @@ -131,7 +146,7 @@ void adc_lld_init(void) { void adc_lld_start(ADCDriver *adcp) { if (adcp->state == ADC_STOP) { - /* Clock activation.*/ + /* Clock activation. */ ADCSRA |= (1 << ADEN); } @@ -150,7 +165,7 @@ void adc_lld_start(ADCDriver *adcp) { void adc_lld_stop(ADCDriver *adcp) { if (adcp->state == ADC_READY) { - /* Clock de-activation.*/ + /* Clock de-activation. */ ADCSRA &= ~(1 << ADEN); } } diff --git a/os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.h b/os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.h index c0bd82f0c..8183dc819 100644 --- a/os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.h +++ b/os/hal/ports/AVR/MEGA/LLD/ADCv1/hal_adc_lld.h @@ -27,30 +27,30 @@ #if HAL_USE_ADC || defined(__DOXYGEN__) -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver pre-compile time settings. */ +/*==========================================================================*/ -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver data structures and types. */ +/*==========================================================================*/ /** * @brief ADC sample data type. @@ -167,13 +167,13 @@ struct ADCDriver { size_t currentBufferPosition; }; -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver macros. */ +/*==========================================================================*/ -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* External declarations. */ +/*==========================================================================*/ #if AVR_ADC_USE_ADC1 && !defined(__DOXYGEN__) extern ADCDriver ADCD1; diff --git a/os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.c b/os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.c index 31bd13b14..07a6f1523 100644 --- a/os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.c +++ b/os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.c @@ -26,26 +26,26 @@ #if HAL_USE_EXT || defined(__DOXYGEN__) -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver local definitions. */ +/*==========================================================================*/ -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver exported variables. */ +/*==========================================================================*/ /** * @brief EXTD1 driver identifier. */ 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. @@ -159,9 +159,9 @@ void ext_lld_set_intx_edges(expchannel_t channel, uint8_t edge) { #endif } -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver interrupt handlers. */ +/*==========================================================================*/ #if AVR_EXT_USE_INT0 || defined(__DOXYGEN__) /** @@ -236,9 +236,9 @@ OSAL_IRQ_HANDLER(INT5_vect) { } #endif -/*===========================================================================*/ -/* Driver functions. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver functions. */ +/*==========================================================================*/ /** * @brief Enables an EXT channel. @@ -331,7 +331,7 @@ void ext_lld_channel_disable(EXTDriver *extp, expchannel_t channel) { */ void ext_lld_init(void) { - /* Driver initialization.*/ + /* Driver initialization. */ extObjectInit(&EXTD1); } diff --git a/os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.h b/os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.h index 2d14150e3..27255350a 100644 --- a/os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.h +++ b/os/hal/ports/AVR/MEGA/LLD/EXTv1/hal_ext_lld.h @@ -27,31 +27,31 @@ #if HAL_USE_EXT || defined(__DOXYGEN__) -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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. @@ -89,7 +89,7 @@ typedef struct { * @brief Channel configurations. */ EXTChannelConfig channels[EXT_MAX_CHANNELS]; - /* End of the mandatory fields.*/ + /* End of the mandatory fields. */ } EXTConfig; /** @@ -105,16 +105,16 @@ struct EXTDriver { * @brief Current configuration data. */ const EXTConfig *config; - /* End of the mandatory fields.*/ + /* End of the mandatory fields. */ }; -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver macros. */ +/*==========================================================================*/ -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* External declarations. */ +/*==========================================================================*/ extern EXTDriver EXTD1; #ifdef __cplusplus diff --git a/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c b/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c index f43b2c501..3ed8db37f 100644 --- a/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c +++ b/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c @@ -26,29 +26,29 @@ #if HAL_USE_PAL || defined(__DOXYGEN__) -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver exported variables. */ +/*==========================================================================*/ /** * @brief Event records for the 16 GPIO EXTI channels. */ 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. @@ -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. - */ - //} } /** diff --git a/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h b/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h index eb27f739c..dbf14a8c0 100644 --- a/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h +++ b/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h @@ -29,16 +29,16 @@ #if HAL_USE_PAL || defined(__DOXYGEN__) -/*===========================================================================*/ -/* Unsupported modes and specific modes. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Unsupported modes and specific modes. */ +/*==========================================================================*/ #undef PAL_MODE_INPUT_PULLDOWN #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. @@ -179,9 +179,9 @@ typedef struct { */ typedef uint8_t ioeventmode_t; -/*===========================================================================*/ -/* I/O Ports Identifiers. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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. diff --git a/os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.c b/os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.c index 3052ffdbf..907a3b1a7 100644 --- a/os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.c +++ b/os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.c @@ -26,30 +26,30 @@ #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__) I2CDriver I2CD1; #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__) /** @@ -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. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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. diff --git a/os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.h b/os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.h index 5afec3382..b1a663022 100644 --- a/os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.h +++ b/os/hal/ports/AVR/MEGA/LLD/I2Cv1/hal_i2c_lld.h @@ -27,40 +27,40 @@ #if HAL_USE_I2C || defined(__DOXYGEN__) -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver constants. */ +/*==========================================================================*/ -/** @brief START transmitted.*/ +/** @brief START transmitted. */ #define TWI_START 0x08 -/** @brief Repeated START transmitted.*/ +/** @brief Repeated START transmitted. */ #define TWI_REPEAT_START 0x10 -/** @brief Arbitration Lost.*/ +/** @brief Arbitration Lost. */ #define TWI_ARBITRATION_LOST 0x38 -/** @brief Bus errors.*/ +/** @brief Bus errors. */ #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 -/** @brief SLA+W transmitted with NACK response.*/ +/** @brief SLA+W transmitted with NACK response. */ #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 -/** @brief DATA transmitted with NACK response.*/ +/** @brief DATA transmitted with NACK response. */ #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 -/** @brief SLA+R transmitted with NACK response.*/ +/** @brief SLA+R transmitted with NACK response. */ #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 -/** @brief DATA received with NACK response.*/ +/** @brief DATA received with NACK response. */ #define TWI_MASTER_RX_DATA_NACK 0x58 -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver pre-compile time settings. */ +/*==========================================================================*/ /** * @name Configuration options @@ -76,13 +76,13 @@ #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. @@ -133,7 +133,7 @@ struct I2CDriver { #if defined(I2C_DRIVER_EXT_FIELDS) I2C_DRIVER_EXT_FIELDS #endif - /* End of the mandatory fields.*/ + /* End of the mandatory fields. */ /** * @brief Thread waiting for I/O completion. */ @@ -173,9 +173,9 @@ struct I2CDriver { */ typedef struct I2CDriver I2CDriver; -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* External declarations. */ +/*==========================================================================*/ #if !defined(__DOXYGEN__) #if AVR_I2C_USE_I2C1 diff --git a/os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.c b/os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.c index e8d772e20..1a4dce95d 100644 --- a/os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.c +++ b/os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.c @@ -26,15 +26,15 @@ #if HAL_USE_SPI || defined(__DOXYGEN__) -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver local definitions. */ +/*==========================================================================*/ #define DUMMY_SPI_SEND_VALUE 0xFF -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver exported variables. */ +/*==========================================================================*/ /** * @brief SPI1 driver identifier. @@ -43,17 +43,17 @@ SPIDriver SPID1; #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__) /** @@ -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; } } @@ -95,7 +95,7 @@ OSAL_IRQ_HANDLER(SPI_STC_vect) { void spi_lld_init(void) { #if AVR_SPI_USE_SPI1 - /* Driver initialization.*/ + /* Driver initialization. */ spiObjectInit(&SPID1); #endif /* AVR_SPI_USE_SPI1 */ } @@ -112,10 +112,10 @@ void spi_lld_start(SPIDriver *spip) { uint8_t dummy; if (spip->state == SPI_STOP) { - /* Enables the peripheral.*/ + /* 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) @@ -127,20 +127,20 @@ void spi_lld_start(SPIDriver *spip) { #if AVR_SPI_USE_SPI1 if (&SPID1 == spip) { - /* Configures the peripheral.*/ + /* Configures the peripheral. */ /* 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 */ @@ -156,14 +156,14 @@ void spi_lld_start(SPIDriver *spip) { void spi_lld_stop(SPIDriver *spip) { if (spip->state == SPI_READY) { - /* Resets the peripheral.*/ + /* Resets the peripheral. */ - /* Disables the peripheral.*/ + /* Disables the peripheral. */ #if AVR_SPI_USE_SPI1 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; diff --git a/os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.h b/os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.h index ca0e15543..4617a1cfb 100644 --- a/os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.h +++ b/os/hal/ports/AVR/MEGA/LLD/SPIv1/hal_spi_lld.h @@ -27,9 +27,9 @@ #if HAL_USE_SPI || defined(__DOXYGEN__) -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver constants. */ +/*==========================================================================*/ /** * @name SPI Configuration Register @@ -72,9 +72,9 @@ #define SPI_SR_SCK_FOSC_128 (0 << SPI2X) /** @} */ -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* Driver pre-compile time settings. */ +/*==========================================================================*/ /** * @name Configuration options @@ -89,13 +89,13 @@ #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. @@ -120,7 +120,7 @@ typedef struct { * @brief Operation complete callback. */ spicallback_t end_cb; - /* End of the mandatory fields.*/ + /* End of the mandatory fields. */ /** * @brief Port used of Slave Select */ @@ -168,7 +168,7 @@ struct SPIDriver { #if defined(SPI_DRIVER_EXT_FIELDS) SPI_DRIVER_EXT_FIELDS #endif - /* End of the mandatory fields.*/ + /* End of the mandatory fields. */ /** * @brief Pointer to the buffer with data to send. */ @@ -187,9 +187,9 @@ struct SPIDriver { size_t exidx; }; -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* 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. */ -/*===========================================================================*/ +/*==========================================================================*/ +/* External declarations. */ +/*==========================================================================*/ #if AVR_SPI_USE_SPI1 && !defined(__DOXYGEN__) extern SPIDriver SPID1; -- cgit v1.2.3