From 2f425af647ea861e7fd5dd6886b05a19f89f8a42 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Fri, 5 Jul 2013 20:35:13 -0700 Subject: [PATCH] [Style] A small coding style fixing session. --- include/libopencm3/cm3/common.h | 8 ++++---- include/libopencm3/lm4f/gpio.h | 2 +- include/libopencm3/stm32/f1/gpio.h | 2 +- include/libopencm3/stm32/f4/adc.h | 2 +- include/libopencm3/stm32/tools.h | 3 ++- lib/lm4f/usb_lm4f.c | 3 +-- lib/sam/common/gpio.c | 2 +- lib/stm32/common/gpio_common_f24.c | 4 ++-- lib/stm32/common/pwr_common_all.c | 5 ++--- lib/stm32/common/rtc_common_bcd.c | 2 +- lib/stm32/f1/adc.c | 2 +- lib/stm32/f1/gpio.c | 2 +- lib/stm32/f4/pwr.c | 2 +- lib/usb/usb_f103.c | 17 ++++++++++------- 14 files changed, 29 insertions(+), 27 deletions(-) diff --git a/include/libopencm3/cm3/common.h b/include/libopencm3/cm3/common.h index 7e758822..1d89b843 100644 --- a/include/libopencm3/cm3/common.h +++ b/include/libopencm3/cm3/common.h @@ -53,11 +53,11 @@ #define MMIO64(addr) (*(volatile uint64_t *)(addr)) /* Generic bit-band I/O accessor functions */ -#define BBIO_SRAM(addr,bit) \ - MMIO8(((addr) & 0x0FFFFF) * 32 | 0x22000000 + (bit) * 4 ) +#define BBIO_SRAM(addr, bit) \ + MMIO8(((addr) & 0x0FFFFF) * 32 | 0x22000000 + (bit) * 4) -#define BBIO_PERIPH(addr,bit) \ - MMIO8(((addr) & 0x0FFFFF) * 32 | 0x42000000 + (bit) * 4 ) +#define BBIO_PERIPH(addr, bit) \ + MMIO8(((addr) & 0x0FFFFF) * 32 | 0x42000000 + (bit) * 4) /* Generic bit definition */ #define BIT0 (1<<0) diff --git a/include/libopencm3/lm4f/gpio.h b/include/libopencm3/lm4f/gpio.h index eebcf9c6..5f90ad37 100644 --- a/include/libopencm3/lm4f/gpio.h +++ b/include/libopencm3/lm4f/gpio.h @@ -244,7 +244,7 @@ void gpio_unlock_commit(uint32_t gpioport, uint8_t gpios); * by OR'ing then together. * * @return The level of the GPIO port. The pins not specified in gpios are - * masked to zero. + * masked to zero. */ static inline uint8_t gpio_read(uint32_t gpioport, uint8_t gpios) { diff --git a/include/libopencm3/stm32/f1/gpio.h b/include/libopencm3/stm32/f1/gpio.h index 836f72a1..6fa27941 100644 --- a/include/libopencm3/stm32/f1/gpio.h +++ b/include/libopencm3/stm32/f1/gpio.h @@ -778,7 +778,7 @@ Line Devices only @{*/ /* ADC2_ETRGREG_REMAP: */ -/** +/** * ADC2 external trigger regulator conversion remapping * (only low-, medium-, high- and XL-density devices) */ diff --git a/include/libopencm3/stm32/f4/adc.h b/include/libopencm3/stm32/f4/adc.h index ed6d4e8d..6ca03123 100644 --- a/include/libopencm3/stm32/f4/adc.h +++ b/include/libopencm3/stm32/f4/adc.h @@ -738,7 +738,7 @@ injected channels. #define ADC_CCR_MULTI_INDEPENDENT (0x00 << 0) /* Dual modes (ADC1 + ADC2) */ -/** +/** * Dual modes (ADC1 + ADC2) Combined regular simultaneous + * injected simultaneous mode. */ diff --git a/include/libopencm3/stm32/tools.h b/include/libopencm3/stm32/tools.h index bb152dd1..e1724339 100644 --- a/include/libopencm3/stm32/tools.h +++ b/include/libopencm3/stm32/tools.h @@ -55,8 +55,9 @@ do { \ register uint16_t toggle_mask = GET_REG(REG) & (MSK); \ register uint16_t bit_selector; \ for (bit_selector = 1; bit_selector; bit_selector <<= 1) { \ - if ((bit_selector & (BIT)) != 0) \ + if ((bit_selector & (BIT)) != 0) { \ toggle_mask ^= bit_selector; \ + } \ } \ SET_REG(REG, toggle_mask); \ } while (0) diff --git a/lib/lm4f/usb_lm4f.c b/lib/lm4f/usb_lm4f.c index 2dc3d830..e2c640e3 100644 --- a/lib/lm4f/usb_lm4f.c +++ b/lib/lm4f/usb_lm4f.c @@ -321,8 +321,7 @@ static void lm4f_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, } else { (USB_TXCSRL(ep)) &= ~USB_TXCSRL_STALL; } - } - else { + } else { if (stall) { (USB_RXCSRL(ep)) |= USB_RXCSRL_STALL; } else { diff --git a/lib/sam/common/gpio.c b/lib/sam/common/gpio.c index 999630c3..75929f82 100644 --- a/lib/sam/common/gpio.c +++ b/lib/sam/common/gpio.c @@ -1,4 +1,4 @@ -/* +/* * This file is part of the libopencm3 project. * * Copyright (C) 2012 Gareth McMullin diff --git a/lib/stm32/common/gpio_common_f24.c b/lib/stm32/common/gpio_common_f24.c index d99e11b5..9d79074d 100644 --- a/lib/stm32/common/gpio_common_f24.c +++ b/lib/stm32/common/gpio_common_f24.c @@ -137,9 +137,9 @@ void gpio_set_output_options(uint32_t gpioport, uint8_t otype, uint8_t speed, if (otype == 0x1) { GPIO_OTYPER(gpioport) |= gpios; - } - else + } else { GPIO_OTYPER(gpioport) &= ~gpios; + } ospeedr = GPIO_OSPEEDR(gpioport); diff --git a/lib/stm32/common/pwr_common_all.c b/lib/stm32/common/pwr_common_all.c index cf63652d..bf9442d0 100644 --- a/lib/stm32/common/pwr_common_all.c +++ b/lib/stm32/common/pwr_common_all.c @@ -172,7 +172,7 @@ threshold. bool pwr_voltage_high(void) { - return (PWR_CSR & PWR_CSR_PVDO); + return PWR_CSR & PWR_CSR_PVDO; } /*---------------------------------------------------------------------------*/ @@ -186,7 +186,7 @@ cleared by software (see @ref pwr_clear_standby_flag). bool pwr_get_standby_flag(void) { - return (PWR_CSR & PWR_CSR_SBF); + return PWR_CSR & PWR_CSR_SBF; } /*---------------------------------------------------------------------------*/ @@ -203,4 +203,3 @@ bool pwr_get_wakeup_flag(void) return PWR_CSR & PWR_CSR_WUF; } /**@}*/ - diff --git a/lib/stm32/common/rtc_common_bcd.c b/lib/stm32/common/rtc_common_bcd.c index 8b33ae8f..7579dfdc 100644 --- a/lib/stm32/common/rtc_common_bcd.c +++ b/lib/stm32/common/rtc_common_bcd.c @@ -1,4 +1,4 @@ -/** @addtogroup rtc_file +/** @addtogroup rtc_file @author @htmlonly © @endhtmlonly 2012 Karl Palsson diff --git a/lib/stm32/f1/adc.c b/lib/stm32/f1/adc.c index 2c90bcdb..21f1cb3d 100644 --- a/lib/stm32/f1/adc.c +++ b/lib/stm32/f1/adc.c @@ -1066,7 +1066,7 @@ void adc_set_regular_sequence(uint32_t adc, uint8_t length, uint8_t channel[]) reg32_1 |= (channel[i - 1] << ((i - 12 - 1) * 5)); } } - reg32_1 |= ((length -1) << ADC_SQR1_L_LSB); + reg32_1 |= ((length - 1) << ADC_SQR1_L_LSB); ADC_SQR1(adc) = reg32_1; ADC_SQR2(adc) = reg32_2; diff --git a/lib/stm32/f1/gpio.c b/lib/stm32/f1/gpio.c index d6f4a7ab..76cbd5b4 100644 --- a/lib/stm32/f1/gpio.c +++ b/lib/stm32/f1/gpio.c @@ -39,7 +39,7 @@ Example 1: Push-pull digital output actions on ports C2 and C9 @code gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ, - GPIO_CNF_OUTPUT_PUSHPULL, GPIO2 | GPIO9); + GPIO_CNF_OUTPUT_PUSHPULL, GPIO2 | GPIO9); gpio_set(GPIOC, GPIO2 | GPIO9); gpio_clear(GPIOC, GPIO2); gpio_toggle(GPIOC, GPIO2 | GPIO9); diff --git a/lib/stm32/f4/pwr.c b/lib/stm32/f4/pwr.c index b44ab5a6..07acada0 100644 --- a/lib/stm32/f4/pwr.c +++ b/lib/stm32/f4/pwr.c @@ -40,7 +40,7 @@ void pwr_set_vos_scale(vos_scale_t scale) { if (scale == SCALE1) { PWR_CR |= PWR_CR_VOS; - } else if (scale == SCALE2) { + } else if (scale == SCALE2) { PWR_CR &= PWR_CR_VOS; } } diff --git a/lib/usb/usb_f103.c b/lib/usb/usb_f103.c index 97191035..3dae7024 100644 --- a/lib/usb/usb_f103.c +++ b/lib/usb/usb_f103.c @@ -37,7 +37,7 @@ static uint8_t stm32f103_ep_stall_get(usbd_device *usbd_dev, uint8_t addr); static void stm32f103_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak); static uint16_t stm32f103_ep_write_packet(usbd_device *usbd_dev, uint8_t addr, - const void *buf, uint16_t len); + const void *buf, uint16_t len); static uint16_t stm32f103_ep_read_packet(usbd_device *usbd_dev, uint8_t addr, void *buf, uint16_t len); static void stm32f103_poll(usbd_device *usbd_dev); @@ -191,12 +191,14 @@ static uint8_t stm32f103_ep_stall_get(usbd_device *dev, uint8_t addr) (void)dev; if (addr & 0x80) { if ((*USB_EP_REG(addr & 0x7F) & USB_EP_TX_STAT) == - USB_EP_TX_STAT_STALL) + USB_EP_TX_STAT_STALL) { return 1; + } } else { if ((*USB_EP_REG(addr) & USB_EP_RX_STAT) == - USB_EP_RX_STAT_STALL) + USB_EP_RX_STAT_STALL) { return 1; + } } return 0; } @@ -213,9 +215,9 @@ static void stm32f103_ep_nak_set(usbd_device *dev, uint8_t addr, uint8_t nak) if (nak) { USB_SET_EP_RX_STAT(addr, USB_EP_RX_STAT_NAK); - } - else + } else { USB_SET_EP_RX_STAT(addr, USB_EP_RX_STAT_VALID); + } } /** @@ -308,10 +310,11 @@ static void stm32f103_poll(usbd_device *dev) uint8_t ep = istr & USB_ISTR_EP_ID; uint8_t type = (istr & USB_ISTR_DIR) ? 1 : 0; - if (type) /* OUT or SETUP transaction */ + if (type) { /* OUT or SETUP transaction */ type += (*USB_EP_REG(ep) & USB_EP_SETUP) ? 1 : 0; - else /* IN transaction */ + } else { /* IN transaction */ USB_CLR_EP_TX_CTR(ep); + } if (dev->user_callback_ctr[ep][type]) { dev->user_callback_ctr[ep][type] (dev, ep);