You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/10/01 17:54:16 UTC
[1/2] incubator-mynewt-core git commit: coding style cleanup
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop 3fabc8a1f -> 5fce0086c
coding style cleanup
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/30f4ba08
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/30f4ba08
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/30f4ba08
Branch: refs/heads/develop
Commit: 30f4ba08a8aba10c6cf8d748cd21ed6326c41ae9
Parents: 3fabc8a
Author: Sterling Hughes <st...@apache.org>
Authored: Sat Oct 1 10:53:13 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Sat Oct 1 10:53:13 2016 -0700
----------------------------------------------------------------------
hw/drivers/adc/adc_stm32f4/src/adc_stm32f4.c | 25 +++++++----------------
1 file changed, 7 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/30f4ba08/hw/drivers/adc/adc_stm32f4/src/adc_stm32f4.c
----------------------------------------------------------------------
diff --git a/hw/drivers/adc/adc_stm32f4/src/adc_stm32f4.c b/hw/drivers/adc/adc_stm32f4/src/adc_stm32f4.c
index fba9dd2..5ef60bd 100644
--- a/hw/drivers/adc/adc_stm32f4/src/adc_stm32f4.c
+++ b/hw/drivers/adc/adc_stm32f4/src/adc_stm32f4.c
@@ -55,7 +55,8 @@ struct stm32f4_adc_stats {
static struct stm32f4_adc_stats stm32f4_adc_stats;
static void
-stm32f4_adc_clk_enable(ADC_HandleTypeDef *hadc) {
+stm32f4_adc_clk_enable(ADC_HandleTypeDef *hadc)
+{
uintptr_t adc_addr = (uintptr_t)hadc->Instance;
switch (adc_addr) {
@@ -74,7 +75,8 @@ stm32f4_adc_clk_enable(ADC_HandleTypeDef *hadc) {
}
static void
-stm32f4_adc_clk_disable(ADC_HandleTypeDef *hadc) {
+stm32f4_adc_clk_disable(ADC_HandleTypeDef *hadc)
+{
uintptr_t adc_addr = (uintptr_t)hadc->Instance;
switch (adc_addr) {
@@ -93,7 +95,8 @@ stm32f4_adc_clk_disable(ADC_HandleTypeDef *hadc) {
}
static int
-stm32f4_resolve_adc_gpio(ADC_HandleTypeDef *adc, uint8_t cnum, GPIO_InitTypeDef *gpio)
+stm32f4_resolve_adc_gpio(ADC_HandleTypeDef *adc, uint8_t cnum,
+ GPIO_InitTypeDef *gpio)
{
uintptr_t adc_addr = (uintptr_t)adc->Instance;
uint32_t pin;
@@ -414,7 +417,7 @@ stm32f4_adc_uninit(struct adc_dev *dev)
goto err;
}
- if(hal_gpio_deinit_stm(gpio_td.Pin, &gpio_td)) {
+ if (hal_gpio_deinit_stm(gpio_td.Pin, &gpio_td)) {
goto err;
}
@@ -545,12 +548,6 @@ stm32f4_adc_configure_channel(struct adc_dev *dev, uint8_t cnum,
hal_gpio_init_stm(gpio_td.Pin, &gpio_td);
-#if 0
- if (HAL_ADC_Start_IT(hadc) != HAL_OK) {
- goto err;
- }
-#endif
-
return (OS_OK);
err:
return (rc);
@@ -683,14 +680,6 @@ stm32f4_adc_size_buffer(struct adc_dev *dev, int chans, int samples)
return (sizeof(uint32_t) * chans * samples);
}
-#if 0
-void ADC_IRQHandler(void)
-{
- HAL_ADC_IRQHandler(adc_handle);
-}
-#endif
-
-
/**
* Callback to initialize an adc_dev structure from the os device
* initialization callback. This sets up a stm32f4_adc_device(), so
[2/2] incubator-mynewt-core git commit: remove HAL adc and pwm for
native, and make SPI and I2C list static const to save RAM
Posted by st...@apache.org.
remove HAL adc and pwm for native, and make SPI and I2C list static const to save RAM
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/5fce0086
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5fce0086
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5fce0086
Branch: refs/heads/develop
Commit: 5fce0086c195605048ca94b5222f284db49134d5
Parents: 30f4ba0
Author: Sterling Hughes <st...@apache.org>
Authored: Sat Oct 1 10:54:04 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Sat Oct 1 10:54:04 2016 -0700
----------------------------------------------------------------------
hw/bsp/native/src/hal_bsp.c | 2 --
hw/mcu/native/include/mcu/hal_dac.h | 36 --------------------
hw/mcu/native/include/mcu/hal_pwm.h | 52 -----------------------------
hw/mcu/nordic/nrf51xxx/src/hal_spi.c | 20 +++++------
hw/mcu/nordic/nrf52xxx/src/hal_i2c.c | 20 +++++------
hw/mcu/nordic/nrf52xxx/src/hal_spi.c | 20 +++++------
hw/mcu/nordic/nrf52xxx/src/hal_timer.c | 4 +--
hw/mcu/stm/stm32f4xx/src/hal_i2c.c | 20 +++++------
hw/mcu/stm/stm32f4xx/src/hal_spi.c | 20 +++++------
9 files changed, 52 insertions(+), 142 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fce0086/hw/bsp/native/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/native/src/hal_bsp.c b/hw/bsp/native/src/hal_bsp.c
index cabca3d..f8756cc 100644
--- a/hw/bsp/native/src/hal_bsp.c
+++ b/hw/bsp/native/src/hal_bsp.c
@@ -27,8 +27,6 @@
#include "mcu/mcu_hal.h"
#include <bsp/bsp.h>
#include <bsp/bsp_sysid.h>
-#include <mcu/hal_pwm.h>
-#include <mcu/hal_dac.h>
const struct hal_flash *
bsp_flash_dev(uint8_t id)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fce0086/hw/mcu/native/include/mcu/hal_dac.h
----------------------------------------------------------------------
diff --git a/hw/mcu/native/include/mcu/hal_dac.h b/hw/mcu/native/include/mcu/hal_dac.h
deleted file mode 100644
index 0fb1a47..0000000
--- a/hw/mcu/native/include/mcu/hal_dac.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _NATIVE_HAL_DAC_H
-#define _NATIVE_HAL_DAC_H
-
-enum native_dac_channel
-{
- NATIVE_MCU_DAC0 = 0,
- NATIVE_MCU_DAC1,
- NATIVE_MCU_DAC2,
- NATIVE_MCU_DAC3,
-};
-
-/* to create a native dac driver */
-struct hal_dac *
-native_dac_create (enum native_dac_channel);
-
-#endif /* _NATIVE_HAL_PWM_H */
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fce0086/hw/mcu/native/include/mcu/hal_pwm.h
----------------------------------------------------------------------
diff --git a/hw/mcu/native/include/mcu/hal_pwm.h b/hw/mcu/native/include/mcu/hal_pwm.h
deleted file mode 100644
index 8ba23cc..0000000
--- a/hw/mcu/native/include/mcu/hal_pwm.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _NATIVE_HAL_PWM_H
-#define _NATIVE_HAL_PWM_H
-
-enum native_pwm_channel
-{
- NATIVE_MCU_PWM0 = 0,
- NATIVE_MCU_PWM1,
- NATIVE_MCU_PWM2,
- NATIVE_MCU_PWM3,
- NATIVE_MCU_PWM4,
- NATIVE_MCU_PWM5,
- NATIVE_MCU_PWM6,
- NATIVE_MCU_PWM7,
- NATIVE_MCU_PWM_MAX
-};
-
-/* to create a pwm driver */
-struct hal_pwm *
-native_pwm_create (enum native_pwm_channel);
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _NATIVE_HAL_PWM_H */
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fce0086/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_spi.c b/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
index cfa4a6d..baf652a 100644
--- a/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
@@ -86,7 +86,7 @@ struct nrf51_hal_spi nrf51_hal_spi0;
struct nrf51_hal_spi nrf51_hal_spi1;
#endif
-struct nrf51_hal_spi *nrf51_hal_spis[NRF51_HAL_SPI_MAX] = {
+static const struct nrf51_hal_spi *nrf51_hal_spis[NRF51_HAL_SPI_MAX] = {
#if SPI0_ENABLED
&nrf51_hal_spi0,
#else
@@ -109,15 +109,15 @@ nrf_drv_spi_t inst_spi1_m = NRF_DRV_SPI_INSTANCE(1);
nrf_drv_spis_t inst_spi1_s = NRF_DRV_SPIS_INSTANCE(1);
#endif
-#define NRF51_HAL_SPI_RESOLVE(__n, __v) \
- if ((__n) >= NRF51_HAL_SPI_MAX) { \
- rc = EINVAL; \
- goto err; \
- } \
- (__v) = nrf51_hal_spis[(__n)]; \
- if ((__v) == NULL) { \
- rc = EINVAL; \
- goto err; \
+#define NRF51_HAL_SPI_RESOLVE(__n, __v) \
+ if ((__n) >= NRF51_HAL_SPI_MAX) { \
+ rc = EINVAL; \
+ goto err; \
+ } \
+ (__v) = (struct nrf51_hal_spi *) nrf51_hal_spis[(__n)]; \
+ if ((__v) == NULL) { \
+ rc = EINVAL; \
+ goto err; \
}
#if (SPI0_ENABLED || SPI1_ENABLED)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fce0086/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c b/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
index e42d376..8648b4d 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
@@ -42,7 +42,7 @@ struct nrf52_hal_i2c hal_twi_i2c0;
struct nrf52_hal_i2c hal_twi_i2c1;
#endif
-struct nrf52_hal_i2c *nrf52_hal_i2cs[NRF52_HAL_I2C_MAX] = {
+static const struct nrf52_hal_i2c *nrf52_hal_i2cs[NRF52_HAL_I2C_MAX] = {
#if TWI0_ENABLED
&hal_twi_i2c0,
#else
@@ -55,15 +55,15 @@ struct nrf52_hal_i2c *nrf52_hal_i2cs[NRF52_HAL_I2C_MAX] = {
#endif
};
-#define NRF52_HAL_I2C_RESOLVE(__n, __v) \
- if ((__n) >= NRF52_HAL_I2C_MAX) { \
- rc = EINVAL; \
- goto err; \
- } \
- (__v) = nrf52_hal_i2cs[(__n)]; \
- if ((__v) == NULL) { \
- rc = EINVAL; \
- goto err; \
+#define NRF52_HAL_I2C_RESOLVE(__n, __v) \
+ if ((__n) >= NRF52_HAL_I2C_MAX) { \
+ rc = EINVAL; \
+ goto err; \
+ } \
+ (__v) = (struct nrf52_hal_i2c *) nrf52_hal_i2cs[(__n)]; \
+ if ((__v) == NULL) { \
+ rc = EINVAL; \
+ goto err; \
}
int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fce0086/hw/mcu/nordic/nrf52xxx/src/hal_spi.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_spi.c b/hw/mcu/nordic/nrf52xxx/src/hal_spi.c
index f2b0b1d..195b175 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_spi.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_spi.c
@@ -90,7 +90,7 @@ struct nrf52_hal_spi nrf52_hal_spi0;
struct nrf52_hal_spi nrf52_hal_spi1;
#endif
-struct nrf52_hal_spi *nrf52_hal_spis[NRF52_HAL_SPI_MAX] = {
+static const struct nrf52_hal_spi *nrf52_hal_spis[NRF52_HAL_SPI_MAX] = {
#if SPI0_ENABLED || SPIS0_ENABLED
&nrf52_hal_spi0,
#else
@@ -116,15 +116,15 @@ nrf_drv_spis_t inst_spi0_s = NRF_DRV_SPIS_INSTANCE(0);
nrf_drv_spis_t inst_spi1_s = NRF_DRV_SPIS_INSTANCE(1);
#endif
-#define NRF52_HAL_SPI_RESOLVE(__n, __v) \
- if ((__n) >= NRF52_HAL_SPI_MAX) { \
- rc = EINVAL; \
- goto err; \
- } \
- (__v) = nrf52_hal_spis[(__n)]; \
- if ((__v) == NULL) { \
- rc = EINVAL; \
- goto err; \
+#define NRF52_HAL_SPI_RESOLVE(__n, __v) \
+ if ((__n) >= NRF52_HAL_SPI_MAX) { \
+ rc = EINVAL; \
+ goto err; \
+ } \
+ (__v) = (struct nrf52_hal_spi *) nrf52_hal_spis[(__n)]; \
+ if ((__v) == NULL) { \
+ rc = EINVAL; \
+ goto err; \
}
#if (SPI0_ENABLED || SPI1_ENABLED)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fce0086/hw/mcu/nordic/nrf52xxx/src/hal_timer.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_timer.c b/hw/mcu/nordic/nrf52xxx/src/hal_timer.c
index 8581142..6d43409 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_timer.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_timer.c
@@ -68,7 +68,7 @@ struct nrf52_hal_timer nrf52_hal_timer3;
struct nrf52_hal_timer nrf52_hal_timer4;
#endif
-struct nrf52_hal_timer *nrf52_hal_timers[NRF52_HAL_TIMER_MAX] = {
+static const struct nrf52_hal_timer *nrf52_hal_timers[NRF52_HAL_TIMER_MAX] = {
#if MYNEWT_VAL(TIMER_0)
&nrf52_hal_timer0,
#else
@@ -102,7 +102,7 @@ struct nrf52_hal_timer *nrf52_hal_timers[NRF52_HAL_TIMER_MAX] = {
rc = EINVAL; \
goto err; \
} \
- (__v) = nrf52_hal_timers[(__n)]; \
+ (__v) = (struct nrf52_hal_timer *) nrf52_hal_timers[(__n)]; \
if ((__v) == NULL) { \
rc = EINVAL; \
goto err; \
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fce0086/hw/mcu/stm/stm32f4xx/src/hal_i2c.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_i2c.c b/hw/mcu/stm/stm32f4xx/src/hal_i2c.c
index be74c2b..b11244b 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_i2c.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_i2c.c
@@ -58,7 +58,7 @@ struct stm32f4_hal_i2c hal_i2c3;
#define __HAL_RCC_I2C3_CLK_ENABLE()
#endif
-struct stm32f4_hal_i2c *stm32f4_hal_i2cs[STM32_HAL_I2C_MAX] = {
+static const struct stm32f4_hal_i2c *stm32f4_hal_i2cs[STM32_HAL_I2C_MAX] = {
#ifdef I2C1
&hal_i2c1,
#else
@@ -76,15 +76,15 @@ struct stm32f4_hal_i2c *stm32f4_hal_i2cs[STM32_HAL_I2C_MAX] = {
#endif
};
-#define STM32_HAL_I2C_RESOLVE(__n, __v) \
- if ((__n) >= STM32_HAL_I2C_MAX) { \
- rc = EINVAL; \
- goto err; \
- } \
- (__v) = stm32f4_hal_i2cs[(__n)]; \
- if ((__v) == NULL) { \
- rc = EINVAL; \
- goto err; \
+#define STM32_HAL_I2C_RESOLVE(__n, __v) \
+ if ((__n) >= STM32_HAL_I2C_MAX) { \
+ rc = EINVAL; \
+ goto err; \
+ } \
+ (__v) = (struct stm32f4_hal_i2c *) stm32f4_hal_i2cs[(__n)]; \
+ if ((__v) == NULL) { \
+ rc = EINVAL; \
+ goto err; \
}
int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fce0086/hw/mcu/stm/stm32f4xx/src/hal_spi.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_spi.c b/hw/mcu/stm/stm32f4xx/src/hal_spi.c
index 197cf2c..e581034 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_spi.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_spi.c
@@ -73,7 +73,7 @@ struct stm32f4_hal_spi stm32f4_hal_spi6;
#define __HAL_RCC_SPI6_CLK_ENABLE()
#endif
-struct stm32f4_hal_spi *stm32f4_hal_spis[STM32F4_HAL_SPI_MAX] = {
+static const struct stm32f4_hal_spi *stm32f4_hal_spis[STM32F4_HAL_SPI_MAX] = {
#ifdef SPI1
&stm32f4_hal_spi1,
#else
@@ -106,15 +106,15 @@ struct stm32f4_hal_spi *stm32f4_hal_spis[STM32F4_HAL_SPI_MAX] = {
#endif
};
-#define STM32F4_HAL_SPI_RESOLVE(__n, __v) \
- if ((__n) >= STM32F4_HAL_SPI_MAX) { \
- rc = EINVAL; \
- goto err; \
- } \
- (__v) = stm32f4_hal_spis[(__n)]; \
- if ((__v) == NULL) { \
- rc = EINVAL; \
- goto err; \
+#define STM32F4_HAL_SPI_RESOLVE(__n, __v) \
+ if ((__n) >= STM32F4_HAL_SPI_MAX) { \
+ rc = EINVAL; \
+ goto err; \
+ } \
+ (__v) = (struct stm32f4_hal_spi *) stm32f4_hal_spis[(__n)]; \
+ if ((__v) == NULL) { \
+ rc = EINVAL; \
+ goto err; \
}
int