From 0d395e893a78b181265d11fe9494703730d7c2b9 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 19 Oct 2015 13:24:03 +0200 Subject: [PATCH] Aerocore: Fix formatting --- src/drivers/boards/aerocore/aerocore_init.c | 12 +++++++++--- src/drivers/boards/aerocore/aerocore_led.c | 14 ++++++++++---- src/drivers/boards/aerocore/aerocore_spi.c | 4 ++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/drivers/boards/aerocore/aerocore_init.c b/src/drivers/boards/aerocore/aerocore_init.c index 3bdb0d4238..83bc2f4234 100644 --- a/src/drivers/boards/aerocore/aerocore_init.c +++ b/src/drivers/boards/aerocore/aerocore_init.c @@ -117,12 +117,12 @@ __END_DECLS static GRAN_HANDLE dma_allocator; -/* - * The DMA heap size constrains the total number of things that can be +/* + * The DMA heap size constrains the total number of things that can be * ready to do DMA at a time. * * For example, FAT DMA depends on one sector-sized buffer per filesystem plus - * one sector-sized buffer per file. + * one sector-sized buffer per file. * * We use a fundamental alignment / granule size of 64B; this is sufficient * to guarantee alignment for the largest STM32 DMA burst (16 beats x 32bits). @@ -137,8 +137,10 @@ dma_alloc_init(void) sizeof(g_dma_heap), 7, /* 128B granule - must be > alignment (XXX bug?) */ 6); /* 64B alignment */ + if (dma_allocator == NULL) { message("[boot] DMA allocator setup FAILED"); + } else { g_dma_perf = perf_alloc(PC_COUNT, "DMA allocations"); } @@ -262,11 +264,13 @@ __EXPORT int nsh_archinitialize(void) /* Configure Sensors on SPI bus #3 */ spi3 = up_spiinitialize(3); + if (!spi3) { message("[boot] FAILED to initialize SPI port 3\n"); up_ledon(LED_AMBER); return -ENODEV; } + /* Default: 1MHz, 8 bits, Mode 3 */ SPI_SETFREQUENCY(spi3, 10000000); SPI_SETBITS(spi3, 8); @@ -279,11 +283,13 @@ __EXPORT int nsh_archinitialize(void) /* Configure FRAM on SPI bus #4 */ spi4 = up_spiinitialize(4); + if (!spi4) { message("[boot] FAILED to initialize SPI port 4\n"); up_ledon(LED_AMBER); return -ENODEV; } + /* Default: ~10MHz, 8 bits, Mode 3 */ SPI_SETFREQUENCY(spi4, 10 * 1000 * 1000); SPI_SETBITS(spi4, 8); diff --git a/src/drivers/boards/aerocore/aerocore_led.c b/src/drivers/boards/aerocore/aerocore_led.c index 22b3a2c240..89c6367419 100644 --- a/src/drivers/boards/aerocore/aerocore_led.c +++ b/src/drivers/boards/aerocore/aerocore_led.c @@ -103,17 +103,23 @@ __EXPORT void led_toggle(int led) { switch (led) { case 0: - if (stm32_gpioread(GPIO_LED0)) + if (stm32_gpioread(GPIO_LED0)) { stm32_gpiowrite(GPIO_LED0, false); - else + + } else { stm32_gpiowrite(GPIO_LED0, true); + } + break; case 1: - if (stm32_gpioread(GPIO_LED1)) + if (stm32_gpioread(GPIO_LED1)) { stm32_gpiowrite(GPIO_LED1, false); - else + + } else { stm32_gpiowrite(GPIO_LED1, true); + } + break; default: diff --git a/src/drivers/boards/aerocore/aerocore_spi.c b/src/drivers/boards/aerocore/aerocore_spi.c index 1ce3f35f88..28103c843e 100644 --- a/src/drivers/boards/aerocore/aerocore_spi.c +++ b/src/drivers/boards/aerocore/aerocore_spi.c @@ -136,8 +136,8 @@ __EXPORT void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, switch (devid) { case PX4_SPIDEV_GYRO: - /* Making sure the other peripherals are not selected */ - stm32_gpiowrite(GPIO_SPI_CS_GYRO, !selected); + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI_CS_GYRO, !selected); stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1); stm32_gpiowrite(GPIO_SPI_CS_BARO, 1); break;