diff --git a/libraries/USBDevice/USBDevice/USBDevice.cpp b/libraries/USBDevice/USBDevice/USBDevice.cpp index 53659164a7..0f08932a80 100644 --- a/libraries/USBDevice/USBDevice/USBDevice.cpp +++ b/libraries/USBDevice/USBDevice/USBDevice.cpp @@ -718,6 +718,11 @@ void USBDevice::disconnect(void) { /* Disconnect device */ USBHAL::disconnect(); + + /* Set initial device state */ + device.state = POWERED; + device.configuration = 0; + device.suspended = false; } CONTROL_TRANSFER * USBDevice::getTransferPtr(void) diff --git a/libraries/mbed/api/error.h b/libraries/mbed/api/error.h index c62f22b602..3a403586dc 100644 --- a/libraries/mbed/api/error.h +++ b/libraries/mbed/api/error.h @@ -53,8 +53,6 @@ * #endcode */ -#include "toolchain.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/libraries/mbed/api/mbed_assert.h b/libraries/mbed/api/mbed_assert.h new file mode 100644 index 0000000000..1bcfb092ba --- /dev/null +++ b/libraries/mbed/api/mbed_assert.h @@ -0,0 +1,50 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 MBED_ASSERT_H +#define MBED_ASSERT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** Internal mbed assert function which is invoked when MBED_ASSERT macro failes. + * This function is active only if NDEBUG is not defined prior to including this + * assert header file. + * In case of MBED_ASSERT failing condition, the assertation message is printed + * to stderr and mbed_die() is called. + * @param expr Expresion to be checked. + * @param file File where assertation failed. + * @param line Failing assertation line number. + */ +void mbed_assert_internal(const char *expr, const char *file, int line); + +#ifdef __cplusplus +} +#endif + +#ifdef NDEBUG +#define MBED_ASSERT(expr) ((void)0) + +#else +#define MBED_ASSERT(expr) \ +do { \ + if (!(expr)) { \ + mbed_assert_internal(#expr, __FILE__, __LINE__); \ + } \ +} while (0) +#endif + +#endif diff --git a/libraries/mbed/common/assert.c b/libraries/mbed/common/assert.c new file mode 100644 index 0000000000..51394707b0 --- /dev/null +++ b/libraries/mbed/common/assert.c @@ -0,0 +1,32 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ +#include "mbed_assert.h" +#include "device.h" + +#if DEVICE_STDIO_MESSAGES +#include +#endif + +#include +#include "mbed_interface.h" + +void mbed_assert_internal(const char *expr, const char *file, int line) +{ +#if DEVICE_STDIO_MESSAGES + fprintf(stderr, "mbed assertation failed: %s, file: %s, line %d \n", expr, file, line); +#endif + mbed_die(); +} diff --git a/libraries/mbed/common/board.c b/libraries/mbed/common/board.c index a9e749b811..9103236456 100644 --- a/libraries/mbed/common/board.c +++ b/libraries/mbed/common/board.c @@ -16,8 +16,8 @@ #include "gpio_api.h" #include "wait_api.h" #include "toolchain.h" +#include "mbed_interface.h" -WEAK void mbed_die(void); WEAK void mbed_die(void) { #ifndef NRF51_H __disable_irq(); // dont allow interrupts to disturb the flash pattern diff --git a/libraries/mbed/common/error.c b/libraries/mbed/common/error.c index 7c6a556c03..b5947cfa79 100644 --- a/libraries/mbed/common/error.c +++ b/libraries/mbed/common/error.c @@ -17,11 +17,11 @@ #include #include "device.h" #include "toolchain.h" +#include "error.h" #if DEVICE_STDIO_MESSAGES #include #endif -WEAK void error(const char* format, ...); WEAK void error(const char* format, ...) { #if DEVICE_STDIO_MESSAGES va_list arg; diff --git a/libraries/mbed/common/mbed_interface.c b/libraries/mbed/common/mbed_interface.c index 0055843e55..9230c2d663 100644 --- a/libraries/mbed/common/mbed_interface.c +++ b/libraries/mbed/common/mbed_interface.c @@ -38,7 +38,6 @@ int mbed_interface_reset(void) { } } -WEAK int mbed_interface_uid(char *uid); WEAK int mbed_interface_uid(char *uid) { if (mbed_interface_connected()) { return semihost_uid(uid); // Returns 0 if successful, -1 on failure @@ -77,13 +76,11 @@ void mbed_reset(void) { mbed_interface_reset(); } -WEAK int mbed_uid(char *uid); WEAK int mbed_uid(char *uid) { return mbed_interface_uid(uid); } #endif -WEAK void mbed_mac_address(char *mac); WEAK void mbed_mac_address(char *mac) { #if DEVICE_SEMIHOST char uid[DEVICE_ID_LENGTH + 1]; diff --git a/libraries/mbed/common/pinmap_common.c b/libraries/mbed/common/pinmap_common.c index 10b981e784..837cd44ef3 100644 --- a/libraries/mbed/common/pinmap_common.c +++ b/libraries/mbed/common/pinmap_common.c @@ -17,7 +17,8 @@ #include "error.h" void pinmap_pinout(PinName pin, const PinMap *map) { - if (pin == NC) return; + if (pin == NC) + return; while (map->pin != NC) { if (map->pin == pin) { @@ -33,11 +34,14 @@ void pinmap_pinout(PinName pin, const PinMap *map) { uint32_t pinmap_merge(uint32_t a, uint32_t b) { // both are the same (inc both NC) - if (a == b) return a; + if (a == b) + return a; // one (or both) is not connected - if (a == (uint32_t)NC) return b; - if (b == (uint32_t)NC) return a; + if (a == (uint32_t)NC) + return b; + if (b == (uint32_t)NC) + return a; // mis-match error case error("pinmap mis-match"); diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld index f6839ccde3..5bf14b145e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld +++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld @@ -7,7 +7,7 @@ MEMORY VECTORS (rx) : ORIGIN = 0x00000000, LENGTH = 0x00000400 FLASH_PROTECTION (rx) : ORIGIN = 0x00000400, LENGTH = 0x00000010 FLASH (rx) : ORIGIN = 0x00000410, LENGTH = 0x00100000 - 0x00000410 - RAM (rwx) : ORIGIN = 0x1FFF0400, LENGTH = 0x00040000 - 0x00000400 + RAM (rwx) : ORIGIN = 0x1FFF0198, LENGTH = 0x00040000 - 0x00000198 } /* Linker script to place sections and symbol values. Should be used together diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.s b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.s index 20021433c4..5978e7c444 100644 --- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.s +++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.s @@ -49,7 +49,7 @@ #ifdef __STACK_SIZE .equ Stack_Size, __STACK_SIZE #else - .equ Stack_Size, 0x400 + .equ Stack_Size, 0xC00 #endif .globl __StackTop .globl __StackLimit @@ -64,7 +64,7 @@ __StackTop: #ifdef __HEAP_SIZE .equ Heap_Size, __HEAP_SIZE #else - .equ Heap_Size, 0x80 + .equ Heap_Size, 0x400 #endif .globl __HeapBase .globl __HeapLimit @@ -199,6 +199,18 @@ Reset_Handler: * __data_start__/__data_end__: RAM address range that data should be * copied to. Both must be aligned to 4 bytes boundary. */ +disable_watchdog: + /* unlock */ + ldr r1, =0x4005200e + ldr r0, =0xc520 + strh r0, [r1] + ldr r0, =0xd928 + strh r0, [r1] + /* disable */ + ldr r1, =0x40052000 + ldr r0, =0x01d2 + strh r0, [r1] + ldr r1, =__etext ldr r2, =__data_start__ ldr r3, =__data_end__ diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/cmsis_nvic.h b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/cmsis_nvic.h index c985b02170..64fa27221e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/cmsis_nvic.h +++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/cmsis_nvic.h @@ -7,7 +7,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#define NVIC_NUM_VECTORS (16 + 85) // CORE + MCU Peripherals +#define NVIC_NUM_VECTORS (16 + 86) // CORE + MCU Peripherals #define NVIC_USER_IRQ_OFFSET 16 #include "cmsis.h" diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s index 973e0fb050..d9887d3884 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s @@ -1,9 +1,9 @@ ;******************** (C) COPYRIGHT 2014 STMicroelectronics ******************** ;* File Name : startup_stm32f401xe.s ;* Author : MCD Application Team -;* Version : V2.0.0 -;* Date : 18-February-2014 -;* Description : STM32F401xe devices vector table for MDK-ARM toolchain. +;* Version : V2.1.0RC2 +;* Date : 14-May-2014 +;* Description : STM32F401xe devices vector table for MDK-ARM_MICRO toolchain. ;* This module performs: ;* - Set the initial SP ;* - Set the initial PC == Reset_Handler diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/startup_stm32f401xe.s b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/startup_stm32f401xe.s index 24e135371f..b065e7b128 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/startup_stm32f401xe.s +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/startup_stm32f401xe.s @@ -1,9 +1,9 @@ ;******************** (C) COPYRIGHT 2014 STMicroelectronics ******************** ;* File Name : startup_stm32f401xe.s ;* Author : MCD Application Team -;* Version : V2.0.0 -;* Date : 18-February-2014 -;* Description : STM32F401xe devices vector table for MDK-ARM toolchain. +;* Version : V2.1.0RC2 +;* Date : 14-May-2014 +;* Description : STM32F401xe devices vector table for MDK-ARM_STD toolchain. ;* This module performs: ;* - Set the initial SP ;* - Set the initial PC == Reset_Handler diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/hal_tick.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/hal_tick.c new file mode 100644 index 0000000000..95b6bfe9b4 --- /dev/null +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/hal_tick.c @@ -0,0 +1,120 @@ +/** + ****************************************************************************** + * @file hal_tick.c + * @author MCD Application Team + * @brief Initialization of HAL tick + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +#include "hal_tick.h" + +TIM_HandleTypeDef TimMasterHandle; +uint32_t PreviousVal = 0; + +void us_ticker_irq_handler(void); + +void timer_irq_handler(void) { + // Channel 1 for mbed timeout + if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) { + __HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1); + us_ticker_irq_handler(); + } + + // Channel 2 for HAL tick + if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) { + __HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2); + uint32_t val = __HAL_TIM_GetCounter(&TimMasterHandle); + if ((val - PreviousVal) >= HAL_TICK_DELAY) { + // Increment HAL variable + HAL_IncTick(); + // Prepare next interrupt + __HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_2, val + HAL_TICK_DELAY); + PreviousVal = val; +#if 0 // For DEBUG only + HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_6); +#endif + } + } +} + +// Reconfigure the HAL tick using a standard timer instead of systick. +HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) { + // Enable timer clock + TIM_MST_RCC; + + // Reset timer + TIM_MST_RESET_ON; + TIM_MST_RESET_OFF; + + // Configure time base + TimMasterHandle.Instance = TIM_MST; + TimMasterHandle.Init.Period = 0xFFFFFFFF; + TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick + TimMasterHandle.Init.ClockDivision = 0; + TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP; + TimMasterHandle.Init.RepetitionCounter = 0; + HAL_TIM_OC_Init(&TimMasterHandle); + + NVIC_SetVector(TIM_MST_IRQ, (uint32_t)timer_irq_handler); + NVIC_EnableIRQ(TIM_MST_IRQ); + + // Channel 1 for mbed timeout + HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_1); + + // Channel 2 for HAL tick + HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_2); + PreviousVal = __HAL_TIM_GetCounter(&TimMasterHandle); + __HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_2, PreviousVal + HAL_TICK_DELAY); + __HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2); + +#if 0 // For DEBUG only + __GPIOB_CLK_ENABLE(); + GPIO_InitTypeDef GPIO_InitStruct; + GPIO_InitStruct.Pin = GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FAST; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); +#endif + + return HAL_OK; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/hal_tick.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/hal_tick.h new file mode 100644 index 0000000000..2e6f01b8a6 --- /dev/null +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/hal_tick.h @@ -0,0 +1,60 @@ +/** + ****************************************************************************** + * @file hal_tick.h + * @author MCD Application Team + * @brief Initialization of HAL tick + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2014 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +#ifndef __HAL_TICK_H +#define __HAL_TICK_H + +#ifdef __cplusplus + extern "C" { +#endif + +#include "stm32f4xx.h" +#include "cmsis_nvic.h" + +#define TIM_MST TIM5 +#define TIM_MST_IRQ TIM5_IRQn +#define TIM_MST_RCC __TIM5_CLK_ENABLE() + +#define TIM_MST_RESET_ON __TIM5_FORCE_RESET() +#define TIM_MST_RESET_OFF __TIM5_RELEASE_RESET() + +#define HAL_TICK_DELAY (1000) // 1 ms + +#ifdef __cplusplus +} +#endif + +#endif // __HAL_TICK_H + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f401xe.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f401xe.h index d49f3ef086..62e7fb3bb5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f401xe.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f401xe.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f401xe.h * @author MCD Application Team - * @version V2.0.0 - * @date 18-February-2014 + * @version V2.1.0RC2 + * @date 14-May-2014 * @brief CMSIS STM32F401xExx Device Peripheral Access Layer Header File. * * This file contains: @@ -537,20 +537,6 @@ typedef struct __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; - -/** - * @brief RNG - */ - -typedef struct -{ - __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ - __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ - __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ -} RNG_TypeDef; - - - /** * @brief __USB_OTG_Core_register */ @@ -678,15 +664,15 @@ USB_OTG_HostChannelTypeDef; */ #define FLASH_BASE ((uint32_t)0x08000000) /*!< FLASH(up to 1 MB) base address in the alias region */ #define CCMDATARAM_BASE ((uint32_t)0x10000000) /*!< CCM(core coupled memory) data RAM(64 KB) base address in the alias region */ -#define SRAM1_BASE ((uint32_t)0x20000000) /*!< SRAM1(96 KB) base address in the alias region */ -//#define SRAM2_BASE ((uint32_t)0x2001C000) /*!< SRAM2(16 KB) base address in the alias region */ -//#define SRAM3_BASE ((uint32_t)0x20020000) /*!< SRAM3(64 KB) base address in the alias region */ +#define SRAM1_BASE ((uint32_t)0x20000000) /*!< SRAM1(112 KB) base address in the alias region */ +#define SRAM2_BASE ((uint32_t)0x2001C000) /*!< SRAM2(16 KB) base address in the alias region */ +#define SRAM3_BASE ((uint32_t)0x20020000) /*!< SRAM3(64 KB) base address in the alias region */ #define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */ #define BKPSRAM_BASE ((uint32_t)0x40024000) /*!< Backup SRAM(4 KB) base address in the alias region */ #define CCMDATARAM_BB_BASE ((uint32_t)0x12000000) /*!< CCM(core coupled memory) data RAM(64 KB) base address in the bit-band region */ -#define SRAM1_BB_BASE ((uint32_t)0x22000000) /*!< SRAM1(96 KB) base address in the bit-band region */ -//#define SRAM2_BB_BASE ((uint32_t)0x2201C000) /*!< SRAM2(16 KB) base address in the bit-band region */ -//#define SRAM3_BB_BASE ((uint32_t)0x22020000) /*!< SRAM3(64 KB) base address in the bit-band region */ +#define SRAM1_BB_BASE ((uint32_t)0x22000000) /*!< SRAM1(112 KB) base address in the bit-band region */ +#define SRAM2_BB_BASE ((uint32_t)0x2201C000) /*!< SRAM2(16 KB) base address in the bit-band region */ +#define SRAM3_BB_BASE ((uint32_t)0x22020000) /*!< SRAM3(64 KB) base address in the bit-band region */ #define PERIPH_BB_BASE ((uint32_t)0x42000000) /*!< Peripheral base address in the bit-band region */ #define BKPSRAM_BB_BASE ((uint32_t)0x42024000) /*!< Backup SRAM(4 KB) base address in the bit-band region */ @@ -763,9 +749,6 @@ USB_OTG_HostChannelTypeDef; #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8) -/*!< AHB2 peripherals */ -#define RNG_BASE (AHB2PERIPH_BASE + 0x60800) - /* Debug MCU registers base address */ #define DBGMCU_BASE ((uint32_t )0xE0042000) @@ -847,8 +830,7 @@ USB_OTG_HostChannelTypeDef; #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) -#define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) -#define RNG ((RNG_TypeDef *) RNG_BASE) +#define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) @@ -1971,6 +1953,24 @@ USB_OTG_HostChannelTypeDef; #define GPIO_BSRR_BR_14 ((uint32_t)0x40000000) #define GPIO_BSRR_BR_15 ((uint32_t)0x80000000) +/****************** Bit definition for GPIO_LCKR register ********************/ +#define GPIO_LCKR_LCK0 ((uint32_t)0x00000001) +#define GPIO_LCKR_LCK1 ((uint32_t)0x00000002) +#define GPIO_LCKR_LCK2 ((uint32_t)0x00000004) +#define GPIO_LCKR_LCK3 ((uint32_t)0x00000008) +#define GPIO_LCKR_LCK4 ((uint32_t)0x00000010) +#define GPIO_LCKR_LCK5 ((uint32_t)0x00000020) +#define GPIO_LCKR_LCK6 ((uint32_t)0x00000040) +#define GPIO_LCKR_LCK7 ((uint32_t)0x00000080) +#define GPIO_LCKR_LCK8 ((uint32_t)0x00000100) +#define GPIO_LCKR_LCK9 ((uint32_t)0x00000200) +#define GPIO_LCKR_LCK10 ((uint32_t)0x00000400) +#define GPIO_LCKR_LCK11 ((uint32_t)0x00000800) +#define GPIO_LCKR_LCK12 ((uint32_t)0x00001000) +#define GPIO_LCKR_LCK13 ((uint32_t)0x00002000) +#define GPIO_LCKR_LCK14 ((uint32_t)0x00004000) +#define GPIO_LCKR_LCK15 ((uint32_t)0x00008000) +#define GPIO_LCKR_LCKK ((uint32_t)0x00010000) /******************************************************************************/ /* */ @@ -2121,7 +2121,10 @@ USB_OTG_HostChannelTypeDef; #define PWR_CR_DBP ((uint32_t)0x00000100) /*!< Disable Backup Domain write protection */ #define PWR_CR_FPDS ((uint32_t)0x00000200) /*!< Flash power down in Stop mode */ -#define PWR_CR_VOS ((uint32_t)0x0000C000) /*!< VOS[1:0] bits (Regulator voltage scaling output selection) */ +#define PWR_CR_LPLVDS ((uint32_t)0x00000400) /*!< Low Power Regulator Low Voltage in Deep Sleep mode */ +#define PWR_CR_MRLVDS ((uint32_t)0x00000800) /*!< Main Regulator Low Voltage in Deep Sleep mode */ +#define PWR_CR_ADCDC1 ((uint32_t)0x00002000) /*!< Refer to AN4073 on how to use this bit */ +#define PWR_CR_VOS ((uint32_t)0x0000C000) /*!< VOS[1:0] bits (Regulator voltage scaling output selection) */ #define PWR_CR_VOS_0 ((uint32_t)0x00004000) /*!< Bit 0 */ #define PWR_CR_VOS_1 ((uint32_t)0x00008000) /*!< Bit 1 */ @@ -2335,7 +2338,6 @@ USB_OTG_HostChannelTypeDef; #define RCC_AHB1RSTR_DMA2RST ((uint32_t)0x00400000) /******************** Bit definition for RCC_AHB2RSTR register **************/ -#define RCC_AHB2RSTR_RNGRST ((uint32_t)0x00000040) #define RCC_AHB2RSTR_OTGFSRST ((uint32_t)0x00000080) /******************** Bit definition for RCC_AHB3RSTR register **************/ @@ -2384,7 +2386,6 @@ USB_OTG_HostChannelTypeDef; #define RCC_AHB1ENR_DMA2EN ((uint32_t)0x00400000) /******************** Bit definition for RCC_AHB2ENR register ***************/ -#define RCC_AHB2ENR_RNGEN ((uint32_t)0x00000040) #define RCC_AHB2ENR_OTGFSEN ((uint32_t)0x00000080) /******************** Bit definition for RCC_AHB3ENR register ***************/ @@ -2433,7 +2434,6 @@ USB_OTG_HostChannelTypeDef; #define RCC_AHB1LPENR_DMA2LPEN ((uint32_t)0x00400000) /******************** Bit definition for RCC_AHB2LPENR register *************/ -#define RCC_AHB2LPENR_RNGLPEN ((uint32_t)0x00000040) #define RCC_AHB2LPENR_OTGFSLPEN ((uint32_t)0x00000080) /******************** Bit definition for RCC_AHB3LPENR register *************/ @@ -2513,22 +2513,6 @@ USB_OTG_HostChannelTypeDef; #define RCC_PLLI2SCFGR_PLLI2SR_1 ((uint32_t)0x20000000) #define RCC_PLLI2SCFGR_PLLI2SR_2 ((uint32_t)0x40000000) -/******************************************************************************/ -/* */ -/* RNG */ -/* */ -/******************************************************************************/ -/******************** Bits definition for RNG_CR register *******************/ -#define RNG_CR_RNGEN ((uint32_t)0x00000004) -#define RNG_CR_IE ((uint32_t)0x00000008) - -/******************** Bits definition for RNG_SR register *******************/ -#define RNG_SR_DRDY ((uint32_t)0x00000001) -#define RNG_SR_CECS ((uint32_t)0x00000002) -#define RNG_SR_SECS ((uint32_t)0x00000004) -#define RNG_SR_CEIS ((uint32_t)0x00000020) -#define RNG_SR_SEIS ((uint32_t)0x00000040) - /******************************************************************************/ /* */ /* Real-Time Clock (RTC) */ @@ -3166,10 +3150,7 @@ USB_OTG_HostChannelTypeDef; #define SYSCFG_MEMRMP_MEM_MODE_2 ((uint32_t)0x00000004) /****************** Bit definition for SYSCFG_PMC register ******************/ -#define SYSCFG_PMC_ADCxDC2 ((uint32_t)0x00070000) /*!< Refer to AN4073 on how to use this bit */ #define SYSCFG_PMC_ADC1DC2 ((uint32_t)0x00010000) /*!< Refer to AN4073 on how to use this bit */ -#define SYSCFG_PMC_ADC2DC2 ((uint32_t)0x00020000) /*!< Refer to AN4073 on how to use this bit */ -#define SYSCFG_PMC_ADC3DC2 ((uint32_t)0x00040000) /*!< Refer to AN4073 on how to use this bit */ /***************** Bit definition for SYSCFG_EXTICR1 register ***************/ #define SYSCFG_EXTICR1_EXTI0 ((uint32_t)0x000F) /*!CTRL &= ~SysTick_CTRL_TICKINT_Msk; +} + +/** + * @brief Resume Tick increment. + * @note In the default implementation , SysTick timer is the source of time base. It is + * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() + * is called, the the SysTick interrupt will be enabled and so Tick increment + * is resumed. + * @note This function is declared as __weak to be overwritten in case of other + * implementations in user file. + * @param None + * @retval None + */ +__weak void HAL_ResumeTick(void) +{ + /* Enable SysTick Interrupt */ + SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; +} + /** * @brief Returns the HAL revision * @param None @@ -320,7 +403,7 @@ uint32_t HAL_GetDEVID(void) } /** - * @brief Enable the Debug Module during SLEEP mode + * @brief Enable the Debug Module during SLEEP mode * @param None * @retval None */ @@ -330,7 +413,7 @@ void HAL_EnableDBGSleepMode(void) } /** - * @brief Disable the Debug Module during SLEEP mode + * @brief Disable the Debug Module during SLEEP mode * @param None * @retval None */ @@ -340,7 +423,7 @@ void HAL_DisableDBGSleepMode(void) } /** - * @brief Enable the Debug Module during STOP mode + * @brief Enable the Debug Module during STOP mode * @param None * @retval None */ @@ -350,7 +433,7 @@ void HAL_EnableDBGStopMode(void) } /** - * @brief Disable the Debug Module during STOP mode + * @brief Disable the Debug Module during STOP mode * @param None * @retval None */ @@ -360,7 +443,7 @@ void HAL_DisableDBGStopMode(void) } /** - * @brief Enable the Debug Module during STANDBY mode + * @brief Enable the Debug Module during STANDBY mode * @param None * @retval None */ @@ -370,7 +453,7 @@ void HAL_EnableDBGStandbyMode(void) } /** - * @brief Disable the Debug Module during STANDBY mode + * @brief Disable the Debug Module during STANDBY mode * @param None * @retval None */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.h index 48c87474ba..8a2439756b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief This file contains all the functions prototypes for the HAL * module driver. ****************************************************************************** @@ -152,11 +152,14 @@ HAL_StatusTypeDef HAL_Init(void); HAL_StatusTypeDef HAL_DeInit(void); void HAL_MspInit(void); void HAL_MspDeInit(void); +HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority); /* Peripheral Control functions ************************************************/ -void HAL_IncTick(void); -void HAL_Delay(__IO uint32_t Delay); +void HAL_IncTick(void); +void HAL_Delay(__IO uint32_t Delay); uint32_t HAL_GetTick(void); +void HAL_SuspendTick(void); +void HAL_ResumeTick(void); uint32_t HAL_GetHalVersion(void); uint32_t HAL_GetREVID(void); uint32_t HAL_GetDEVID(void); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.c index bd48131ceb..59c82e5f96 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_adc.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief This file provides firmware functions to manage the following * functionalities of the Analog to Digital Convertor (ADC) peripheral: * + Initialization and de-initialization functions @@ -63,7 +63,7 @@ (#) Configure the ADC regular channels group features, use HAL_ADC_Init() and HAL_ADC_ConfigChannel() functions. - (#) Three mode of operations are available within this driver : + (#) Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -89,7 +89,7 @@ ============================== [..] (+) Start the ADC peripheral using HAL_ADC_Start_DMA(), at this stage the user specify the length - of data to be transfered at each end of conversion + of data to be transferred at each end of conversion (+) At The end of data transfer by HAL_ADC_ConvCpltCallback() function is executed and user can add his own code by customization of function pointer HAL_ADC_ConvCpltCallback (+) In case of transfer Error, HAL_ADC_ErrorCallback() function is executed and user can @@ -410,7 +410,7 @@ HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc) * * @param hadc: pointer to a ADC_HandleTypeDef structure that contains * the configuration information for the specified ADC. - * last transfer and End of conversion selection). + * * @retval HAL status. */ HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc) @@ -780,7 +780,7 @@ void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc) * the configuration information for the specified ADC. * @param pData: The destination Buffer address. * @param Length: The length of data to be transferred from ADC peripheral to memory. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length) { @@ -846,7 +846,7 @@ HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, ui * @brief Disables ADC DMA (Single-ADC mode) and disables ADC peripheral * @param hadc: pointer to a ADC_HandleTypeDef structure that contains * the configuration information for the specified ADC. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc) { @@ -1221,7 +1221,8 @@ static void ADC_Init(ADC_HandleTypeDef* hadc) /** * @brief DMA transfer complete callback. - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void ADC_DMAConvCplt(DMA_HandleTypeDef *hdma) @@ -1245,7 +1246,8 @@ static void ADC_DMAConvCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA half transfer complete callback. - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void ADC_DMAHalfConvCplt(DMA_HandleTypeDef *hdma) @@ -1257,7 +1259,8 @@ static void ADC_DMAHalfConvCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA error callback - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void ADC_DMAError(DMA_HandleTypeDef *hdma) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.h index 0e1ef89937..35485afd8b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_adc.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of ADC HAL extension module. ****************************************************************************** * @attention @@ -139,9 +139,9 @@ typedef struct */ typedef struct { - uint32_t Channel; /*!< The ADC channel to configure + uint32_t Channel; /*!< The ADC channel to configure. This parameter can be a value of @ref ADC_channels */ - uint32_t Rank; /*!< The rank in the regular group sequencer + uint32_t Rank; /*!< The rank in the regular group sequencer. This parameter must be a number between Min_Data = 1 and Max_Data = 16 */ uint32_t SamplingTime; /*!< The sample time value to be set for the selected channel. This parameter can be a value of @ref ADC_sampling_times */ @@ -154,14 +154,14 @@ typedef struct typedef struct { uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode. - This parameter can be a value of @ref ADC_analog_watchdog_selection. */ + This parameter can be a value of @ref ADC_analog_watchdog_selection */ uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value. This parameter must be a 12-bit value. */ uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value. This parameter must be a 12-bit value. */ uint32_t Channel; /*!< Configures ADC channel for the analog watchdog. This parameter has an effect only if watchdog mode is configured on single channel - This parameter can be a value of @ref ADC_channels. */ + This parameter can be a value of @ref ADC_channels */ uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured is interrupt mode or in polling mode. This parameter can be set to ENABLE or DISABLE */ @@ -202,46 +202,6 @@ typedef struct * @} */ -/** @defgroup ADC_delay_between_2_sampling_phases - * @{ - */ -#define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000) -#define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0) -#define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1) -#define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) -#define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2) -#define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0)) -#define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1)) -#define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) -#define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3) -#define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0)) -#define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1)) -#define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) -#define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2)) -#define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0)) -#define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1)) -#define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY) - -#define IS_ADC_SAMPLING_DELAY(DELAY) (((DELAY) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \ - ((DELAY) == ADC_TWOSAMPLINGDELAY_20CYCLES)) -/** - * @} - */ - /** @defgroup ADC_Resolution * @{ */ @@ -538,6 +498,13 @@ typedef struct */ /* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset ADC handle state + * @param __HANDLE__: ADC handle + * @retval None + */ +#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET) + /** * @brief Enable the ADC peripheral. * @param __HANDLE__: ADC handle diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.c index d00e35ab75..d3b6a87271 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_adc_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief This file provides firmware functions to manage the following * functionalities of the ADC extension peripheral: * + Extended features functions @@ -24,22 +24,21 @@ (+++) Enable the ADC IRQ handler using HAL_NVIC_EnableIRQ() (+++) In ADC IRQ handler, call HAL_ADC_IRQHandler() (##) In case of using DMA to control data transfer (e.g. HAL_ADC_Start_DMA()) - (++) Enable the DMAx interface clock using __DMAx_CLK_ENABLE() - (++) Configure and enable two DMA streams stream for managing data + (+++) Enable the DMAx interface clock using __DMAx_CLK_ENABLE() + (+++) Configure and enable two DMA streams stream for managing data transfer from peripheral to memory (output stream) - (++) Associate the initilalized DMA handle to the CRYP DMA handle + (+++) Associate the initilalized DMA handle to the ADC DMA handle using __HAL_LINKDMA() - (++) Configure the priority and enable the NVIC for the transfer complete + (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the two DMA Streams. The output stream should have higher - priority than the input stream. - + priority than the input stream. (#) Configure the ADC Prescaler, conversion resolution and data alignment using the HAL_ADC_Init() function. (#) Configure the ADC Injected channels group features, use HAL_ADC_Init() and HAL_ADC_ConfigChannel() functions. - (#) Three mode of operations are available within this driver : + (#) Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -66,7 +65,7 @@ ============================== [..] (+) Start the ADC peripheral using HAL_ADCEx_InjectedStart_DMA(), at this stage the user specify the length - of data to be transfered at each end of conversion + of data to be transferred at each end of conversion (+) At The end of data transfer ba HAL_ADCEx_InjectedConvCpltCallback() function is executed and user can add his own code by customization of function pointer HAL_ADCEx_InjectedConvCpltCallback (+) In case of transfer Error, HAL_ADCEx_InjectedErrorCallback() function is executed and user can @@ -79,7 +78,7 @@ (+) Select the Multi mode ADC regular channels features (dual or triple mode) and configure the DMA mode using HAL_ADCEx_MultiModeConfigChannel() functions. (+) Start the ADC peripheral using HAL_ADCEx_MultiModeStart_DMA(), at this stage the user specify the length - of data to be transfered at each end of conversion + of data to be transferred at each end of conversion (+) Read the ADCs converted values using the HAL_ADCEx_MultiModeGetValue() function. @@ -409,10 +408,10 @@ HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc) * the configuration information for the specified ADC. * @param InjectedRank: the ADC injected rank. * This parameter can be one of the following values: - * @arg ADC_InjectedChannel_1: Injected Channel1 selected - * @arg ADC_InjectedChannel_2: Injected Channel2 selected - * @arg ADC_InjectedChannel_3: Injected Channel3 selected - * @arg ADC_InjectedChannel_4: Injected Channel4 selected + * @arg ADC_INJECTED_RANK_1: Injected Channel1 selected + * @arg ADC_INJECTED_RANK_2: Injected Channel2 selected + * @arg ADC_INJECTED_RANK_3: Injected Channel3 selected + * @arg ADC_INJECTED_RANK_4: Injected Channel4 selected * @retval None */ uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank) @@ -463,7 +462,7 @@ uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRa * the configuration information for the specified ADC. * @param pData: Pointer to buffer in which transferred from ADC peripheral to memory will be stored. * @param Length: The length of data to be transferred from ADC peripheral to memory. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length) { @@ -538,7 +537,7 @@ HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t * @brief Disables ADC DMA (multi-ADC mode) and disables ADC peripheral * @param hadc: pointer to a ADC_HandleTypeDef structure that contains * the configuration information for the specified ADC. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef* hadc) { @@ -774,7 +773,8 @@ HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_ /** * @brief DMA transfer complete callback. - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma) @@ -798,7 +798,8 @@ static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA half transfer complete callback. - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma) @@ -810,7 +811,8 @@ static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA error callback - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void ADC_MultiModeDMAError(DMA_HandleTypeDef *hdma) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.h index 3e94ac2b9b..7988d3d1a4 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_adc.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of ADC HAL module. ****************************************************************************** * @attention @@ -61,8 +61,8 @@ */ typedef struct { - uint32_t InjectedChannel; /*!< Configure the ADC injected channel - This parameter can be a value of @ref ADC_channels. */ + uint32_t InjectedChannel; /*!< Configure the ADC injected channel. + This parameter can be a value of @ref ADC_channels */ uint32_t InjectedRank; /*!< The rank in the injected group sequencer This parameter must be a number between Min_Data = 1 and Max_Data = 4. */ uint32_t InjectedSamplingTime; /*!< The sample time value to be set for the selected channel. @@ -77,9 +77,9 @@ typedef struct uint32_t InjectedDiscontinuousConvMode; /*!< Specifies whether the conversion is performed in Discontinuous mode or not for injected channels. This parameter can be set to ENABLE or DISABLE. */ uint32_t ExternalTrigInjecConvEdge; /*!< Select the external trigger edge and enable the trigger of an injected channels. - This parameter can be a value of @ref ADC_External_trigger_Source_Injected. */ + This parameter can be a value of @ref ADCEx_External_trigger_edge_Injected */ uint32_t ExternalTrigInjecConv; /*!< Select the external event used to trigger the start of conversion of a injected channels. - This parameter can be a value of @ref ADC_External_trigger_Source_Injected */ + This parameter can be a value of @ref ADCEx_External_trigger_Source_Injected */ }ADC_InjectionConfTypeDef; /** @@ -88,11 +88,11 @@ typedef struct typedef struct { uint32_t Mode; /*!< Configures the ADC to operate in independent or multi mode. - This parameter can be a value of @ref ADC_Common_mode */ + This parameter can be a value of @ref ADCEx_Common_mode */ uint32_t DMAAccessMode; /*!< Configures the Direct memory access mode for multi ADC mode. - This parameter can be a value of @ref ADC_Direct_memory_access_mode_for_multi_mode */ + This parameter can be a value of @ref ADCEx_Direct_memory_access_mode_for_multi_mode */ uint32_t TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases. - This parameter can be a value of @ref ADC_delay_between_2_sampling_phases */ + This parameter can be a value of @ref ADCEx_delay_between_2_sampling_phases */ }ADC_MultiModeTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -152,6 +152,46 @@ typedef struct * @} */ + /** @defgroup ADCEx_delay_between_2_sampling_phases + * @{ + */ +#define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000) +#define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0) +#define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1) +#define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) +#define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2) +#define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0)) +#define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1)) +#define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) +#define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3) +#define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0)) +#define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1)) +#define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) +#define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2)) +#define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0)) +#define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1)) +#define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY) + +#define IS_ADC_SAMPLING_DELAY(DELAY) (((DELAY) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \ + ((DELAY) == ADC_TWOSAMPLINGDELAY_20CYCLES)) +/** + * @} + */ + /** @defgroup ADCEx_External_trigger_edge_Injected * @{ */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.c index dd123b6e9b..19c8071f9f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_can.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief This file provides firmware functions to manage the following * functionalities of the Controller Area Network (CAN) peripheral: * + Initialization and de-initialization functions @@ -771,10 +771,9 @@ HAL_StatusTypeDef HAL_CAN_Transmit_IT(CAN_HandleTypeDef* hcan) * @brief Receives a correct CAN frame. * @param hcan: pointer to a CAN_HandleTypeDef structure that contains * the configuration information for the specified CAN. - * @param FIFONumber: FIFO Number value - * @param Timeout: Specify Timeout value + * @param FIFONumber: FIFO Number value + * @param Timeout: Specify Timeout value * @retval HAL status - * @retval None */ HAL_StatusTypeDef HAL_CAN_Receive(CAN_HandleTypeDef* hcan, uint8_t FIFONumber, uint32_t Timeout) { @@ -881,7 +880,6 @@ HAL_StatusTypeDef HAL_CAN_Receive(CAN_HandleTypeDef* hcan, uint8_t FIFONumber, u * the configuration information for the specified CAN. * @param FIFONumber: Specify the FIFO number * @retval HAL status - * @retval None */ HAL_StatusTypeDef HAL_CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber) { @@ -1229,7 +1227,7 @@ __weak void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan) ##### Peripheral State and Error functions ##### ============================================================================== [..] - This subsection provides functions allowing to + This subsection provides functions allowing to : (+) Check the CAN state. (+) Check CAN Errors detected during interrupt process diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.h index 930f632d3f..5101eebea2 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_can.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of CAN HAL module. ****************************************************************************** * @attention @@ -152,7 +152,7 @@ typedef struct uint32_t FilterActivation; /*!< Enable or disable the filter. This parameter can be set to ENABLE or DISABLE. */ - uint32_t BankNumber; /*!< Select the start slave bank filter + uint32_t BankNumber; /*!< Select the start slave bank filter. This parameter must be a number between Min_Data = 0 and Max_Data = 28 */ }CAN_FilterConfTypeDef; @@ -579,6 +579,12 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset CAN handle state + * @param __HANDLE__: specifies the CAN Handle. + * @retval None + */ +#define __HAL_CAN_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CAN_STATE_RESET) + /** * @brief Enable the specified CAN interrupts. * @param __HANDLE__: CAN handle diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_conf.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_conf.h index e91593d200..e937395652 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_conf.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_conf.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_conf_template.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief HAL configuration template file. * This file should be copied to the application folder and renamed * to stm32f4xx_hal_conf.h. @@ -76,7 +76,7 @@ #define HAL_LTDC_MODULE_ENABLED #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED -#define HAL_RNG_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED #define HAL_RTC_MODULE_ENABLED #define HAL_SAI_MODULE_ENABLED #define HAL_SD_MODULE_ENABLED @@ -99,7 +99,7 @@ * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External crystal in Hz */ + #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) @@ -140,9 +140,9 @@ * @brief This is the HAL system configuration section */ #define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)3) /*!< tick interrupt priority */ -#define USE_RTOS 0 -#define PREFETCH_ENABLE 1 +#define TICK_INT_PRIORITY ((uint32_t)0x0F) /*!< tick interrupt priority */ +#define USE_RTOS 0 +#define PREFETCH_ENABLE 1 #define INSTRUCTION_CACHE_ENABLE 1 #define DATA_CACHE_ENABLE 1 diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.c index 57e07b6288..854d0b42d3 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cortex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief CORTEX HAL module driver. * This file provides firmware functions to manage the following * functionalities of the CORTEX: @@ -16,40 +16,18 @@ ============================================================================== [..] - *** How to configure Interrupts using Cortex HAL driver *** + *** How to configure Interrupts using CORTEX HAL driver *** =========================================================== [..] - This section provide functions allowing to configure the NVIC interrupts (IRQ). + This section provides functions allowing to configure the NVIC interrupts (IRQ). The Cortex-M4 exceptions are managed by CMSIS functions. (#) Configure the NVIC Priority Grouping using HAL_NVIC_SetPriorityGrouping() function according to the following table. - - The table below gives the allowed values of the pre-emption priority and subpriority according - to the Priority Grouping configuration performed by HAL_NVIC_SetPriorityGrouping() function. - ========================================================================================================================== - NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description - ========================================================================================================================== - NVIC_PRIORITYGROUP_0 | 0 | 0-15 | 0 bits for pre-emption priority - | | | 4 bits for subpriority - -------------------------------------------------------------------------------------------------------------------------- - NVIC_PRIORITYGROUP_1 | 0-1 | 0-7 | 1 bits for pre-emption priority - | | | 3 bits for subpriority - -------------------------------------------------------------------------------------------------------------------------- - NVIC_PRIORITYGROUP_2 | 0-3 | 0-3 | 2 bits for pre-emption priority - | | | 2 bits for subpriority - -------------------------------------------------------------------------------------------------------------------------- - NVIC_PRIORITYGROUP_3 | 0-7 | 0-1 | 3 bits for pre-emption priority - | | | 1 bits for subpriority - -------------------------------------------------------------------------------------------------------------------------- - NVIC_PRIORITYGROUP_4 | 0-15 | 0 | 4 bits for pre-emption priority - | | | 0 bits for subpriority - ========================================================================================================================== - (#) Configure the priority of the selected IRQ Channels using HAL_NVIC_SetPriority() - - (#) Enable the selected IRQ Channels using HAL_NVIC_EnableIRQ() + (#) Configure the priority of the selected IRQ Channels using HAL_NVIC_SetPriority(). + (#) Enable the selected IRQ Channels using HAL_NVIC_EnableIRQ(). + (#) please refer to programing manual for details in how to configure priority. - -@- When the NVIC_PRIORITYGROUP_0 is selected, IRQ pre-emption is no more possible. The pending IRQ priority will be managed only by the sub priority. @@ -59,12 +37,12 @@ (+@) Lowest hardware priority (IRQ number) [..] - *** How to configure Systick using Cortex HAL driver *** + *** How to configure Systick using CORTEX HAL driver *** ======================================================== [..] - Setup SysTick Timer for 1 msec interrupts. + Setup SysTick Timer for time base. - (+) The HAL_SYSTICK_Config()function calls the SysTick_Config() function which + (+) The HAL_SYSTICK_Config() function calls the SysTick_Config() function which is a CMSIS function that: (++) Configures the SysTick Reload register with value passed as function parameter. (++) Configures the SysTick IRQ priority to the lowest value (0x0F). @@ -153,7 +131,7 @@ ##### Initialization and de-initialization functions ##### ============================================================================== [..] - This section provide the Cortex HAL driver functions allowing to configure Interrupts + This section provides the CORTEX HAL driver functions allowing to configure Interrupts Systick functionalities @endverbatim @@ -191,8 +169,8 @@ void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup) /** * @brief Sets the priority of an interrupt. - * @param IRQn: External interrupt number - * This parameter can be an enumerator of @ref IRQn_Type enumeration + * @param IRQn: External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration * (For the complete STM32 Devices IRQ Channels list, please refer to stm32f4xx.h file) * @param PreemptPriority: The pre-emption priority for the IRQn channel. * This parameter can be a value between 0 and 15 @@ -219,8 +197,8 @@ void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t Sub * @brief Enables a device specific interrupt in the NVIC interrupt controller. * @note To configure interrupts priority correctly, the NVIC_PriorityGroupConfig() * function should be called before. - * @param IRQn External interrupt number - * This parameter can be an enumerator of @ref IRQn_Type enumeration + * @param IRQn External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration * (For the complete STM32 Devices IRQ Channels list, please refer to stm32f4xx.h file) * @retval None */ @@ -232,8 +210,8 @@ void HAL_NVIC_EnableIRQ(IRQn_Type IRQn) /** * @brief Disables a device specific interrupt in the NVIC interrupt controller. - * @param IRQn External interrupt number - * This parameter can be an enumerator of @ref IRQn_Type enumeration + * @param IRQn External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration * (For the complete STM32 Devices IRQ Channels list, please refer to stm32f4xx.h file) * @retval None */ @@ -298,8 +276,8 @@ uint32_t HAL_NVIC_GetPriorityGrouping(void) /** * @brief Gets the priority of an interrupt. - * @param IRQn: External interrupt number - * This parameter can be an enumerator of @ref IRQn_Type enumeration + * @param IRQn: External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration * (For the complete STM32 Devices IRQ Channels list, please refer to stm32f4xx.h file) * @param PriorityGroup: the priority grouping bits length. * This parameter can be one of the following values: @@ -341,8 +319,8 @@ void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn) /** * @brief Gets Pending Interrupt (reads the pending register in the NVIC * and returns the pending bit for the specified interrupt). - * @param IRQn External interrupt number - * This parameter can be an enumerator of @ref IRQn_Type enumeration + * @param IRQn External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration * (For the complete STM32 Devices IRQ Channels list, please refer to stm32f4xx.h file) * @retval status: - 0 Interrupt status is not pending. * - 1 Interrupt status is pending. @@ -355,8 +333,8 @@ uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn) /** * @brief Clears the pending bit of an external interrupt. - * @param IRQn External interrupt number - * This parameter can be an enumerator of @ref IRQn_Type enumeration + * @param IRQn External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration * (For the complete STM32 Devices IRQ Channels list, please refer to stm32f4xx.h file) * @retval None */ @@ -369,7 +347,7 @@ void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn) /** * @brief Gets active interrupt ( reads the active register in NVIC and returns the active bit). * @param IRQn External interrupt number - * This parameter can be an enumerator of @ref IRQn_Type enumeration + * This parameter can be an enumerator of IRQn_Type enumeration * (For the complete STM32 Devices IRQ Channels list, please refer to stm32f4xx.h file) * @retval status: - 0 Interrupt status is not pending. * - 1 Interrupt status is pending. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.h index b964bbaea9..17ac2ab2fb 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cortex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of CORTEX HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.c index 59ca9fedc5..03e899d2bc 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_crc.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief CRC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Cyclic Redundancy Check (CRC) peripheral: @@ -105,7 +105,8 @@ /** * @brief Initializes the CRC according to the specified * parameters in the CRC_InitTypeDef and creates the associated handle. - * @param hcrc: CRC handle + * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains + * the configuration information for CRC * @retval HAL status */ HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc) @@ -137,7 +138,8 @@ HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc) /** * @brief DeInitializes the CRC peripheral. - * @param hcrc: CRC handle + * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains + * the configuration information for CRC * @retval HAL status */ HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc) @@ -169,7 +171,8 @@ HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc) /** * @brief Initializes the CRC MSP. - * @param hcrc: CRC handle + * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains + * the configuration information for CRC * @retval None */ __weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc) @@ -181,7 +184,8 @@ __weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc) /** * @brief DeInitializes the CRC MSP. - * @param hcrc: CRC handle + * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains + * the configuration information for CRC * @retval None */ __weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc) @@ -215,7 +219,8 @@ __weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc) /** * @brief Computes the 32-bit CRC of 32-bit data buffer using combination * of the previous CRC value and the new one. - * @param hcrc: CRC handle + * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains + * the configuration information for CRC * @param pBuffer: pointer to the buffer containing the data to be computed * @param BufferLength: length of the buffer to be computed * @retval 32-bit CRC @@ -249,7 +254,8 @@ uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_ /** * @brief Computes the 32-bit CRC of 32-bit data buffer independently * of the previous CRC value. - * @param hcrc: CRC handle + * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains + * the configuration information for CRC * @param pBuffer: Pointer to the buffer containing the data to be computed * @param BufferLength: Length of the buffer to be computed * @retval 32-bit CRC @@ -304,7 +310,8 @@ uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t /** * @brief Returns the CRC state. - * @param hcrc: CRC handle + * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains + * the configuration information for CRC * @retval HAL state */ HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.h index 8e97e702f5..eb8fb765d8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_crc.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of CRC HAL module. ****************************************************************************** * @attention @@ -85,6 +85,12 @@ typedef struct /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset CRC handle state + * @param __HANDLE__: CRC handle + * @retval None + */ +#define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET) + /** * @brief Resets CRC Data Register. * @param __HANDLE__: CRC handle diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.c index ab93244467..a67cbb401f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cryp.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief CRYP HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Cryptography (CRYP) peripheral: @@ -29,18 +29,15 @@ (+++) Enable the CRYP IRQ handler using HAL_NVIC_EnableIRQ() (+++) In CRYP IRQ handler, call HAL_CRYP_IRQHandler() (##) In case of using DMA to control data transfer (e.g. HAL_CRYP_AESECB_Encrypt_DMA()) - (++) Enable the DMAx interface clock using - (+++) __DMAx_CLK_ENABLE() - (++) Configure and enable two DMA streams one for managing data transfer from + (+++) Enable the DMAx interface clock using __DMAx_CLK_ENABLE() + (+++) Configure and enable two DMA streams one for managing data transfer from memory to peripheral (input stream) and another stream for managing data transfer from peripheral to memory (output stream) - (++) Associate the initilalized DMA handle to the CRYP DMA handle + (+++) Associate the initilalized DMA handle to the CRYP DMA handle using __HAL_LINKDMA() - (++) Configure the priority and enable the NVIC for the transfer complete + (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the two DMA Streams. The output stream should have higher - priority than the input stream. - (+++) HAL_NVIC_SetPriority() - (+++) HAL_NVIC_EnableIRQ() + priority than the input stream HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ() (#)Initialize the CRYP HAL using HAL_CRYP_Init(). This function configures mainly: (##) The data type: 1-bit, 8-bit, 16-bit and 32-bit @@ -51,13 +48,13 @@ (#)Three processing (encryption/decryption) functions are available: (##) Polling mode: encryption and decryption APIs are blocking functions - i.e. they process the data and wait till the processing is finished + i.e. they process the data and wait till the processing is finished, e.g. HAL_CRYP_AESCBC_Encrypt() (##) Interrupt mode: encryption and decryption APIs are not blocking functions - i.e. they process the data under interrupt + i.e. they process the data under interrupt, e.g. HAL_CRYP_AESCBC_Encrypt_IT() (##) DMA mode: encryption and decryption APIs are not blocking functions - i.e. the data transfer is ensured by DMA + i.e. the data transfer is ensured by DMA, e.g. HAL_CRYP_AESCBC_Encrypt_DMA() (#)When the processing function is called at first time after HAL_CRYP_Init() @@ -161,7 +158,8 @@ static void CRYP_SetDESCBCMode(CRYP_HandleTypeDef *hcryp, uint32_t Direction); /** * @brief Initializes the CRYP according to the specified * parameters in the CRYP_InitTypeDef and creates the associated handle. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval HAL status */ HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp) @@ -204,7 +202,8 @@ HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp) /** * @brief DeInitializes the CRYP peripheral. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval HAL status */ HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp) @@ -243,7 +242,8 @@ HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp) /** * @brief Initializes the CRYP MSP. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval None */ __weak void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp) @@ -255,7 +255,8 @@ __weak void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp) /** * @brief DeInitializes CRYP MSP. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval None */ __weak void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp) @@ -291,7 +292,8 @@ __weak void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp) /** * @brief Initializes the CRYP peripheral in AES ECB encryption mode * then encrypt pPlainData. The cypher data are available in pCypherData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16. * @param pCypherData: Pointer to the cyphertext buffer @@ -344,7 +346,8 @@ HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pP /** * @brief Initializes the CRYP peripheral in AES CBC encryption mode * then encrypt pPlainData. The cypher data are available in pCypherData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16. * @param pCypherData: Pointer to the cyphertext buffer @@ -400,7 +403,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pP /** * @brief Initializes the CRYP peripheral in AES CTR encryption mode * then encrypt pPlainData. The cypher data are available in pCypherData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16. * @param pCypherData: Pointer to the cyphertext buffer @@ -458,7 +462,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pP /** * @brief Initializes the CRYP peripheral in AES ECB decryption mode * then decrypted pCypherData. The cypher data are available in pPlainData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16. * @param pPlainData: Pointer to the plaintext buffer @@ -545,7 +550,8 @@ HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pC /** * @brief Initializes the CRYP peripheral in AES ECB decryption mode * then decrypted pCypherData. The cypher data are available in pPlainData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16. * @param pPlainData: Pointer to the plaintext buffer @@ -633,7 +639,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pC /** * @brief Initializes the CRYP peripheral in AES CTR decryption mode * then decrypted pCypherData. The cypher data are available in pPlainData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16. * @param pPlainData: Pointer to the plaintext buffer @@ -688,7 +695,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pC /** * @brief Initializes the CRYP peripheral in AES ECB encryption mode using Interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 bytes * @param pCypherData: Pointer to the cyphertext buffer @@ -788,7 +796,8 @@ HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES CBC encryption mode using Interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 bytes * @param pCypherData: Pointer to the cyphertext buffer @@ -890,7 +899,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES CTR encryption mode using Interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 bytes * @param pCypherData: Pointer to the cyphertext buffer @@ -993,7 +1003,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES ECB decryption mode using Interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16. * @param pPlainData: Pointer to the plaintext buffer @@ -1121,7 +1132,8 @@ HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES CBC decryption mode using IT. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pPlainData: Pointer to the plaintext buffer @@ -1257,7 +1269,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES CTR decryption mode using Interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pPlainData: Pointer to the plaintext buffer @@ -1361,7 +1374,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES ECB encryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 bytes * @param pCypherData: Pointer to the cyphertext buffer @@ -1415,7 +1429,8 @@ HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES CBC encryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16. * @param pCypherData: Pointer to the cyphertext buffer @@ -1472,7 +1487,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES CTR encryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16. * @param pCypherData: Pointer to the cyphertext buffer @@ -1530,7 +1546,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES ECB decryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 bytes * @param pPlainData: Pointer to the plaintext buffer @@ -1613,7 +1630,8 @@ HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES CBC encryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 bytes * @param pPlainData: Pointer to the plaintext buffer @@ -1699,7 +1717,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in AES CTR decryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pPlainData: Pointer to the plaintext buffer @@ -1768,10 +1787,10 @@ HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t ============================================================================== [..] This section provides functions allowing to: (+) Encrypt plaintext using DES using ECB or CBC chaining modes - (+) Decrypt cyphertext using using ECB or CBC chaining modes + (+) Decrypt cyphertext using ECB or CBC chaining modes [..] Three processing functions are available: - (+) polling mode - (+) interrupt mode + (+) Polling mode + (+) Interrupt mode (+) DMA mode @endverbatim @@ -1780,7 +1799,8 @@ HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in DES ECB encryption mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -1819,7 +1839,8 @@ HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pP /** * @brief Initializes the CRYP peripheral in DES ECB decryption mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -1858,7 +1879,8 @@ HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pP /** * @brief Initializes the CRYP peripheral in DES CBC encryption mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -1897,7 +1919,8 @@ HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pP /** * @brief Initializes the CRYP peripheral in DES ECB decryption mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -1936,7 +1959,8 @@ HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pP /** * @brief Initializes the CRYP peripheral in DES ECB encryption mode using IT. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2020,7 +2044,8 @@ HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in DES CBC encryption mode using interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2105,7 +2130,8 @@ HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in DES ECB decryption mode using IT. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2189,7 +2215,8 @@ HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in DES ECB decryption mode using interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2273,7 +2300,8 @@ HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in DES ECB encryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2315,7 +2343,8 @@ HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in DES CBC encryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2357,7 +2386,8 @@ HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in DES ECB decryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2399,7 +2429,8 @@ HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in DES ECB decryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2451,11 +2482,11 @@ HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t ##### TDES processing functions ##### ============================================================================== [..] This section provides functions allowing to: - (+) Encrypt plaintext using TDES using ECB or CBC chaining modes - (+) Decrypt cyphertext using TDES using ECB or CBC chaining modes + (+) Encrypt plaintext using TDES based on ECB or CBC chaining modes + (+) Decrypt cyphertext using TDES based on ECB or CBC chaining modes [..] Three processing functions are available: - (+) polling mode - (+) interrupt mode + (+) Polling mode + (+) Interrupt mode (+) DMA mode @endverbatim @@ -2465,7 +2496,8 @@ HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in TDES ECB encryption mode * then encrypt pPlainData. The cypher data are available in pCypherData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2505,7 +2537,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *p /** * @brief Initializes the CRYP peripheral in TDES ECB decryption mode * then decrypted pCypherData. The cypher data are available in pPlainData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2545,7 +2578,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *p /** * @brief Initializes the CRYP peripheral in TDES CBC encryption mode * then encrypt pPlainData. The cypher data are available in pCypherData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2585,7 +2619,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *p /** * @brief Initializes the CRYP peripheral in TDES CBC decryption mode * then decrypted pCypherData. The cypher data are available in pPlainData - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pPlainData: Pointer to the plaintext buffer @@ -2624,7 +2659,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *p /** * @brief Initializes the CRYP peripheral in TDES ECB encryption mode using interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2708,7 +2744,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in TDES CBC encryption mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2791,7 +2828,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in TDES ECB decryption mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2874,7 +2912,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in TDES CBC decryption mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pPlainData: Pointer to the plaintext buffer @@ -2957,7 +2996,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /** * @brief Initializes the CRYP peripheral in TDES ECB encryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -2999,7 +3039,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_ /** * @brief Initializes the CRYP peripheral in TDES CBC encryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -3041,7 +3082,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_ /** * @brief Initializes the CRYP peripheral in TDES ECB decryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pCypherData: Pointer to the cyphertext buffer @@ -3083,7 +3125,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_ /** * @brief Initializes the CRYP peripheral in TDES CBC decryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 8 * @param pPlainData: Pointer to the plaintext buffer @@ -3145,7 +3188,8 @@ HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_ /** * @brief Input FIFO transfer completed callbacks. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval None */ __weak void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp) @@ -3157,7 +3201,8 @@ __weak void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp) /** * @brief Output FIFO transfer completed callbacks. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval None */ __weak void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp) @@ -3169,7 +3214,8 @@ __weak void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp) /** * @brief CRYP error callbacks. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval None */ __weak void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp) @@ -3198,7 +3244,8 @@ __weak void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp) /** * @brief This function handles CRYP interrupt request. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval None */ void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp) @@ -3286,7 +3333,8 @@ void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp) /** * @brief Returns the CRYP state. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval HAL state */ HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp) @@ -3352,7 +3400,8 @@ static void CRYP_DMAError(DMA_HandleTypeDef *hdma) /** * @brief Writes the Key in Key registers. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Key: Pointer to Key buffer * @param KeySize: Size of Key * @retval None @@ -3410,7 +3459,8 @@ static void CRYP_SetKey(CRYP_HandleTypeDef *hcryp, uint8_t *Key, uint32_t KeySiz /** * @brief Writes the InitVector/InitCounter in IV registers. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param InitVector: Pointer to InitVector/InitCounter buffer * @param IVSize: Size of the InitVector/InitCounter * @retval None @@ -3448,7 +3498,8 @@ static void CRYP_SetInitVector(CRYP_HandleTypeDef *hcryp, uint8_t *InitVector, u /** * @brief Process Data: Writes Input data in polling mode and read the output data - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Input: Pointer to the Input buffer * @param Ilength: Length of the Input buffer, must be a multiple of 16. * @param Output: Pointer to the returned buffer @@ -3510,7 +3561,8 @@ static HAL_StatusTypeDef CRYP_ProcessData(CRYP_HandleTypeDef *hcryp, uint8_t* In /** * @brief Process Data: Write Input data in polling mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Input: Pointer to the Input buffer * @param Ilength: Length of the Input buffer, must be a multiple of 8 * @param Output: Pointer to the returned buffer @@ -3565,7 +3617,8 @@ static HAL_StatusTypeDef CRYP_ProcessData2Words(CRYP_HandleTypeDef *hcryp, uint8 /** * @brief Set the DMA configuration and start the DMA transfer - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param inputaddr: address of the Input buffer * @param Size: Size of the Input buffer, must be a multiple of 16. * @param outputaddr: address of the Output buffer @@ -3602,7 +3655,8 @@ static void CRYP_SetDMAConfig(CRYP_HandleTypeDef *hcryp, uint32_t inputaddr, uin /** * @brief Sets the CRYP peripheral in DES ECB mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Direction: Encryption or decryption * @retval None */ @@ -3628,7 +3682,8 @@ static void CRYP_SetDESECBMode(CRYP_HandleTypeDef *hcryp, uint32_t Direction) /** * @brief Sets the CRYP peripheral in DES CBC mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Direction: Encryption or decryption * @retval None */ @@ -3657,7 +3712,8 @@ static void CRYP_SetDESCBCMode(CRYP_HandleTypeDef *hcryp, uint32_t Direction) /** * @brief Sets the CRYP peripheral in TDES ECB mode. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Direction: Encryption or decryption * @retval None */ @@ -3682,7 +3738,8 @@ static void CRYP_SetTDESECBMode(CRYP_HandleTypeDef *hcryp, uint32_t Direction) /** * @brief Sets the CRYP peripheral in TDES CBC mode - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Direction: Encryption or decryption * @retval None */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h index fddff61ed8..43049f2bad 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cryp.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of CRYP HAL module. ****************************************************************************** * @attention @@ -53,59 +53,57 @@ /** @addtogroup CRYP * @{ - */ + */ -/* Exported types ------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ /** - * @brief CRYP Configuration Structure definition + * @brief CRYP Configuration Structure definition */ typedef struct -{ +{ uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. This parameter can be a value of @ref CRYP_Data_Type */ - + uint32_t KeySize; /*!< Used only in AES mode only : 128, 192 or 256 bit key length. This parameter can be a value of @ref CRYP_Key_Size */ - + uint8_t* pKey; /*!< The key used for encryption/decryption */ - + uint8_t* pInitVect; /*!< The initialization vector used also as initialization counter in CTR mode */ - + uint8_t IVSize; /*!< The size of initialization vector. This parameter (called nonce size in CCM) is used only in AES-128/192/256 encryption/decryption CCM mode */ - + uint8_t TagSize; /*!< The size of returned authentication TAG. This parameter is used only in AES-128/192/256 encryption/decryption CCM mode */ - + uint8_t* Header; /*!< The header used in GCM and CCM modes */ - + uint16_t HeaderSize; /*!< The size of header buffer in bytes */ - + uint8_t* pScratch; /*!< Scratch buffer used to append the header. It's size must be equal to header size + 21 bytes. This parameter is used only in AES-128/192/256 encryption/decryption CCM mode */ - }CRYP_InitTypeDef; /** - * @brief HAL CRYP State structures definition - */ + * @brief HAL CRYP State structures definition + */ typedef enum { HAL_CRYP_STATE_RESET = 0x00, /*!< CRYP not yet initialized or disabled */ HAL_CRYP_STATE_READY = 0x01, /*!< CRYP initialized and ready for use */ HAL_CRYP_STATE_BUSY = 0x02, /*!< CRYP internal processing is ongoing */ HAL_CRYP_STATE_TIMEOUT = 0x03, /*!< CRYP timeout state */ - HAL_CRYP_STATE_ERROR = 0x04 /*!< CRYP error state */ - + HAL_CRYP_STATE_ERROR = 0x04 /*!< CRYP error state */ }HAL_CRYP_STATETypeDef; /** - * @brief HAL CRYP phase structures definition - */ + * @brief HAL CRYP phase structures definition + */ typedef enum { HAL_CRYP_PHASE_READY = 0x01, /*!< CRYP peripheral is ready for initialization. */ @@ -115,32 +113,31 @@ typedef enum }HAL_PhaseTypeDef; /** - * @brief CRYP handle Structure definition + * @brief CRYP handle Structure definition */ typedef struct -{ +{ CRYP_InitTypeDef Init; /*!< CRYP required parameters */ - + uint8_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ - + uint8_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ - + __IO uint16_t CrypInCount; /*!< Counter of inputed data */ - + __IO uint16_t CrypOutCount; /*!< Counter of outputed data */ - + HAL_StatusTypeDef Status; /*!< CRYP peripheral status */ - + HAL_PhaseTypeDef Phase; /*!< CRYP peripheral phase */ - + DMA_HandleTypeDef *hdmain; /*!< CRYP In DMA handle parameters */ - + DMA_HandleTypeDef *hdmaout; /*!< CRYP Out DMA handle parameters */ - + HAL_LockTypeDef Lock; /*!< CRYP locking object */ - + __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */ - }CRYP_HandleTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -151,7 +148,7 @@ typedef struct /** @defgroup CRYP_Key_Size * @{ - */ + */ #define CRYP_KEYSIZE_128B ((uint32_t)0x00000000) #define CRYP_KEYSIZE_192B CRYP_CR_KEYSIZE_0 #define CRYP_KEYSIZE_256B CRYP_CR_KEYSIZE_1 @@ -210,7 +207,6 @@ typedef struct * @} */ - /** @defgroup CRYP_Flags * @{ */ @@ -229,7 +225,7 @@ typedef struct interrupt status */ /** * @} - */ + */ /** * @} @@ -237,6 +233,12 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset CRYP handle state + * @param __HANDLE__: specifies the CRYP handle. + * @retval None + */ +#define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRYP_STATE_RESET) + /** * @brief Enable/Disable the CRYP peripheral. * @param None @@ -253,13 +255,12 @@ typedef struct #define __HAL_CRYP_FIFO_FLUSH() (CRYP->CR |= CRYP_CR_FFLUSH) /** - * @brief Set the algorithm mode: AES-ECB, AES-CBC, AES-CTR, DES-ECB, DES-CBC,... + * @brief Set the algorithm mode: AES-ECB, AES-CBC, AES-CTR, DES-ECB, DES-CBC, * @param MODE: The algorithm mode. * @retval None */ #define __HAL_CRYP_SET_MODE(MODE) CRYP->CR |= (uint32_t)(MODE) - /** @brief Check whether the specified CRYP flag is set or not. * @param __FLAG__: specifies the flag to check. * This parameter can be one of the following values: @@ -304,7 +305,7 @@ typedef struct #include "stm32f4xx_hal_cryp_ex.h" /* Exported functions --------------------------------------------------------*/ -/* Initialization/de-initialization functions **********************************/ +/* Initialization/de-initialization functions ********************************/ HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp); HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp); @@ -368,10 +369,10 @@ HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_ HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); -/* Processing functions ********************************************************/ +/* Processing functions ******************************************************/ void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); -/* Peripheral State functions **************************************************/ +/* Peripheral State functions ************************************************/ HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); /* MSP functions *************************************************************/ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.c index 8887047525..3c95906aa5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cryp_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Extended CRYP HAL module driver * This file provides firmware functions to manage the following * functionalities of CRYP extension peripheral: @@ -153,7 +153,8 @@ static void CRYPEx_GCMCCM_SetDMAConfig(CRYP_HandleTypeDef *hcryp, uint32_t input /** * @brief Initializes the CRYP peripheral in AES CCM encryption mode then * encrypt pPlainData. The cypher data are available in pCypherData. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pCypherData: Pointer to the cyphertext buffer @@ -407,7 +408,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t * /** * @brief Initializes the CRYP peripheral in AES GCM encryption mode then * encrypt pPlainData. The cypher data are available in pCypherData. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pCypherData: Pointer to the cyphertext buffer @@ -504,7 +506,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t * /** * @brief Initializes the CRYP peripheral in AES GCM decryption mode then * decrypted pCypherData. The cypher data are available in pPlainData. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the cyphertext buffer, must be a multiple of 16 * @param pPlainData: Pointer to the plaintext buffer @@ -596,7 +599,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t * /** * @brief Computes the authentication TAG. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Size: Total length of the plain/cyphertext buffer * @param AuthTag: Pointer to the authentication buffer * @param Timeout: Timeout duration @@ -704,7 +708,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Finish(CRYP_HandleTypeDef *hcryp, uint16_t S /** * @brief Computes the authentication TAG for AES CCM mode. * @note This API is called after HAL_AES_CCM_Encrypt()/HAL_AES_CCM_Decrypt() - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param AuthTag: Pointer to the authentication buffer * @param Timeout: Timeout duration * @retval HAL status @@ -795,7 +800,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Finish(CRYP_HandleTypeDef *hcryp, uint8_t *A /** * @brief Initializes the CRYP peripheral in AES CCM decryption mode then * decrypted pCypherData. The cypher data are available in pPlainData. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pCypherData: Pointer to the cyphertext buffer @@ -1046,7 +1052,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t * /** * @brief Initializes the CRYP peripheral in AES GCM encryption mode using IT. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pCypherData: Pointer to the cyphertext buffer @@ -1196,7 +1203,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_ /** * @brief Initializes the CRYP peripheral in AES CCM encryption mode using interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pCypherData: Pointer to the cyphertext buffer @@ -1494,7 +1502,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_ /** * @brief Initializes the CRYP peripheral in AES GCM decryption mode using IT. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the cyphertext buffer, must be a multiple of 16 * @param pPlainData: Pointer to the plaintext buffer @@ -1641,7 +1650,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_ /** * @brief Initializes the CRYP peripheral in AES CCM decryption mode using interrupt * then decrypted pCypherData. The cypher data are available in pPlainData. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pPlainData: Pointer to the plaintext buffer @@ -1930,7 +1940,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_ /** * @brief Initializes the CRYP peripheral in AES GCM encryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pCypherData: Pointer to the cyphertext buffer @@ -2026,7 +2037,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8 /** * @brief Initializes the CRYP peripheral in AES CCM encryption mode using interrupt. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pPlainData: Pointer to the plaintext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pCypherData: Pointer to the cyphertext buffer @@ -2279,7 +2291,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8 /** * @brief Initializes the CRYP peripheral in AES GCM decryption mode using DMA. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer. * @param Size: Length of the cyphertext buffer, must be a multiple of 16 * @param pPlainData: Pointer to the plaintext buffer @@ -2368,7 +2381,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8 /** * @brief Initializes the CRYP peripheral in AES CCM decryption mode using DMA * then decrypted pCypherData. The cypher data are available in pPlainData. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param pCypherData: Pointer to the cyphertext buffer * @param Size: Length of the plaintext buffer, must be a multiple of 16 * @param pPlainData: Pointer to the plaintext buffer @@ -2621,7 +2635,8 @@ HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8 /** * @brief This function handles CRYP interrupt request. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @retval None */ void HAL_CRYPEx_GCMCCM_IRQHandler(CRYP_HandleTypeDef *hcryp) @@ -2707,7 +2722,8 @@ static void CRYPEx_GCMCCM_DMAError(DMA_HandleTypeDef *hdma) /** * @brief Writes the Key in Key registers. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Key: Pointer to Key buffer * @param KeySize: Size of Key * @retval None @@ -2765,7 +2781,8 @@ static void CRYPEx_GCMCCM_SetKey(CRYP_HandleTypeDef *hcryp, uint8_t *Key, uint32 /** * @brief Writes the InitVector/InitCounter in IV registers. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param InitVector: Pointer to InitVector/InitCounter buffer * @param IVSize: Size of the InitVector/InitCounter * @retval None @@ -2803,7 +2820,8 @@ static void CRYPEx_GCMCCM_SetInitVector(CRYP_HandleTypeDef *hcryp, uint8_t *Init /** * @brief Process Data: Writes Input data in polling mode and read the Output data. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Input: Pointer to the Input buffer. * @param Ilength: Length of the Input buffer, must be a multiple of 16 * @param Output: Pointer to the returned buffer @@ -2865,7 +2883,8 @@ static HAL_StatusTypeDef CRYPEx_GCMCCM_ProcessData(CRYP_HandleTypeDef *hcryp, ui /** * @brief Sets the header phase - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param Input: Pointer to the Input buffer. * @param Ilength: Length of the Input buffer, must be a multiple of 16 * @param Timeout: Timeout value @@ -2947,7 +2966,8 @@ static HAL_StatusTypeDef CRYPEx_GCMCCM_SetHeaderPhase(CRYP_HandleTypeDef *hcryp, /** * @brief Sets the DMA configuration and start the DMA transfert. - * @param hcryp: CRYP handle + * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains + * the configuration information for CRYP module * @param inputaddr: Address of the Input buffer * @param Size: Size of the Input buffer, must be a multiple of 16 * @param outputaddr: Address of the Output buffer diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.h index 7ac7f78df6..4c1cfcd6fc 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cryp_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of CRYP HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.c index 598e1e0934..49ac58c1ef 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dac.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief DAC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Digital to Analog Converter (DAC) peripheral: @@ -116,7 +116,7 @@ ============================== [..] (+) Start the DAC peripheral using HAL_DAC_Start_DMA(), at this stage the user specify the length - of data to be transfered at each end of conversion + of data to be transferred at each end of conversion (+) At The end of data transfer HAL_DAC_ConvCpltCallbackCh1()or HAL_DAC_ConvCpltCallbackCh2() function is executed and user can add his own code by customization of function pointer HAL_DAC_ConvCpltCallbackCh1 or HAL_DAC_ConvCpltCallbackCh2 @@ -430,9 +430,9 @@ HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel) * @param Length: The length of data to be transferred from memory to DAC peripheral * @param Alignment: Specifies the data alignment for DAC channel. * This parameter can be one of the following values: - * @arg DAC_Align_8b_R: 8bit right data alignment selected - * @arg DAC_Align_12b_L: 12bit left data alignment selected - * @arg DAC_Align_12b_R: 12bit right data alignment selected + * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected + * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected + * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected * @retval HAL status */ HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment) @@ -448,27 +448,18 @@ HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, u /* Change DAC state */ hdac->State = HAL_DAC_STATE_BUSY; - - /* Set the DMA transfer complete callback for channel1 */ - hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1; - - /* Set the DMA half transfer complete callback for channel1 */ - hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1; - - /* Set the DMA error callback for channel1 */ - hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1; - - /* Set the DMA transfer complete callback for channel2 */ - hdac->DMA_Handle2->XferCpltCallback = DAC_DMAConvCpltCh2; - - /* Set the DMA half transfer complete callback for channel2 */ - hdac->DMA_Handle2->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh2; - - /* Set the DMA error callback for channel2 */ - hdac->DMA_Handle2->XferErrorCallback = DAC_DMAErrorCh2; - + if(Channel == DAC_CHANNEL_1) { + /* Set the DMA transfer complete callback for channel1 */ + hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1; + + /* Set the DMA half transfer complete callback for channel1 */ + hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1; + + /* Set the DMA error callback for channel1 */ + hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1; + /* Enable the selected DAC channel1 DMA request */ hdac->Instance->CR |= DAC_CR_DMAEN1; @@ -493,9 +484,18 @@ HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, u } else { + /* Set the DMA transfer complete callback for channel2 */ + hdac->DMA_Handle2->XferCpltCallback = DAC_DMAConvCpltCh2; + + /* Set the DMA half transfer complete callback for channel2 */ + hdac->DMA_Handle2->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh2; + + /* Set the DMA error callback for channel2 */ + hdac->DMA_Handle2->XferErrorCallback = DAC_DMAErrorCh2; + /* Enable the selected DAC channel2 DMA request */ hdac->Instance->CR |= DAC_CR_DMAEN2; - + /* Case of use of channel 2 */ switch(Alignment) { @@ -556,20 +556,42 @@ HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, u */ HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel) { + HAL_StatusTypeDef status = HAL_OK; + /* Check the parameters */ assert_param(IS_DAC_CHANNEL(Channel)); /* Disable the selected DAC channel DMA request */ - hdac->Instance->CR &= ~(DAC_CR_DMAEN1 << Channel); + hdac->Instance->CR &= ~(DAC_CR_DMAEN1 << Channel); /* Disable the Peripharal */ __HAL_DAC_DISABLE(hdac, Channel); - /* Change DAC state */ - hdac->State = HAL_DAC_STATE_READY; - + /* Disable the DMA Channel */ + /* Channel1 is used */ + if(Channel == DAC_CHANNEL_1) + { + status = HAL_DMA_Abort(hdac->DMA_Handle1); + } + else /* Channel2 is used for */ + { + status = HAL_DMA_Abort(hdac->DMA_Handle2); + } + + /* Check if DMA Channel effectively disabled */ + if(status == HAL_ERROR) + { + /* Update ADC state machine to error */ + hdac->State = HAL_DAC_STATE_ERROR; + } + else + { + /* Change DAC state */ + hdac->State = HAL_DAC_STATE_READY; + } + /* Return function status */ - return HAL_OK; + return status; } /** @@ -732,7 +754,6 @@ HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConf /* Check the DAC parameters */ assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger)); assert_param(IS_DAC_OUTPUT_BUFFER_STATE(sConfig->DAC_OutputBuffer)); - assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger)); assert_param(IS_DAC_CHANNEL(Channel)); /* Process locked */ @@ -776,9 +797,9 @@ HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConf * @arg DAC_CHANNEL_2: DAC Channel2 selected * @param Alignment: Specifies the data alignment. * This parameter can be one of the following values: - * @arg DAC_Align_8b_R: 8bit right data alignment selected - * @arg DAC_Align_12b_L: 12bit left data alignment selected - * @arg DAC_Align_12b_R: 12bit right data alignment selected + * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected + * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected + * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected * @param Data: Data to be loaded in the selected data holding register. * @retval HAL status */ @@ -858,7 +879,8 @@ uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac) /** * @brief DMA conversion complete callback. - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma) @@ -872,7 +894,8 @@ static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma) /** * @brief DMA half transfer complete callback. - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma) @@ -884,7 +907,8 @@ static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma) /** * @brief DMA error callback - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.h index 863ef3fbf4..7077fea924 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dac.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of DAC HAL module. ****************************************************************************** * @attention @@ -59,8 +59,8 @@ /* Exported types ------------------------------------------------------------*/ /** - * @brief HAL State structures definition - */ + * @brief HAL State structures definition + */ typedef enum { HAL_DAC_STATE_RESET = 0x00, /*!< DAC not yet initialized or disabled */ @@ -68,39 +68,37 @@ typedef enum HAL_DAC_STATE_BUSY = 0x02, /*!< DAC internal processing is ongoing */ HAL_DAC_STATE_TIMEOUT = 0x03, /*!< DAC timeout state */ HAL_DAC_STATE_ERROR = 0x04 /*!< DAC error state */ - }HAL_DAC_StateTypeDef; /** - * @brief DAC handle Structure definition - */ + * @brief DAC handle Structure definition + */ typedef struct { DAC_TypeDef *Instance; /*!< Register base address */ - + __IO HAL_DAC_StateTypeDef State; /*!< DAC communication state */ HAL_LockTypeDef Lock; /*!< DAC locking object */ - + DMA_HandleTypeDef *DMA_Handle1; /*!< Pointer DMA handler for channel 1 */ - - DMA_HandleTypeDef *DMA_Handle2; /*!< Pointer DMA handler for channel 2 */ - + + DMA_HandleTypeDef *DMA_Handle2; /*!< Pointer DMA handler for channel 2 */ + __IO uint32_t ErrorCode; /*!< DAC Error code */ - + }DAC_HandleTypeDef; /** - * @brief DAC Configuration regular Channel structure definition - */ + * @brief DAC Configuration regular Channel structure definition + */ typedef struct { uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel. This parameter can be a value of @ref DAC_trigger_selection */ - + uint32_t DAC_OutputBuffer; /*!< Specifies whether the DAC channel output buffer is enabled or disabled. This parameter can be a value of @ref DAC_output_buffer */ - }DAC_ChannelConfTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -111,12 +109,12 @@ typedef struct #define HAL_DAC_ERROR_NONE 0x00 /*!< No error */ #define HAL_DAC_ERROR_DMAUNDERRUNCH1 0x01 /*!< DAC channel1 DAM underrun error */ #define HAL_DAC_ERROR_DMAUNDERRUNCH2 0x02 /*!< DAC channel2 DAM underrun error */ -#define HAL_DAC_ERROR_DMA 0x04 /*!< DMA error */ +#define HAL_DAC_ERROR_DMA 0x04 /*!< DMA error */ /** * @} */ - -/** @defgroup DAC_trigger_selection + +/** @defgroup DAC_trigger_selection * @{ */ @@ -186,7 +184,7 @@ typedef struct /** @defgroup DAC_data * @{ */ -#define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) +#define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) /** * @} */ @@ -195,7 +193,7 @@ typedef struct * @{ */ #define DAC_FLAG_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1) -#define DAC_FLAG_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2) +#define DAC_FLAG_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2) #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR1) || \ ((FLAG) == DAC_FLAG_DMAUDR2)) @@ -207,67 +205,104 @@ typedef struct * @{ */ #define DAC_IT_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1) -#define DAC_IT_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2) +#define DAC_IT_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2) #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR1) || \ ((IT) == DAC_IT_DMAUDR2)) - /** * @} */ /* Exported macro ------------------------------------------------------------*/ -/* Enable the DAC peripheral */ + +/** @brief Reset DAC handle state + * @param __HANDLE__: specifies the DAC handle. + * @retval None + */ +#define __HAL_DAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DAC_STATE_RESET) + +/** @brief Enable the DAC channel + * @param __HANDLE__: specifies the DAC handle. + * @param __DAC_Channel__: specifies the DAC channel + * @retval None + */ #define __HAL_DAC_ENABLE(__HANDLE__, __DAC_Channel__) \ ((__HANDLE__)->Instance->CR |= (DAC_CR_EN1 << (__DAC_Channel__))) -/* Disable the DAC peripheral */ +/** @brief Disable the DAC channel + * @param __HANDLE__: specifies the DAC handle + * @param __DAC_Channel__: specifies the DAC channel. + * @retval None + */ #define __HAL_DAC_DISABLE(__HANDLE__, __DAC_Channel__) \ ((__HANDLE__)->Instance->CR &= ~(DAC_CR_EN1 << (__DAC_Channel__))) - -/* Set DHR12R1 alignment */ + +/** @brief Set DHR12R1 alignment + * @param __ALIGNEMENT__: specifies the DAC alignement + * @retval None + */ #define __HAL_DHR12R1_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000008) + (__ALIGNEMENT__)) -/* Set DHR12R2 alignment */ +/** @brief Set DHR12R2 alignment + * @param __ALIGNEMENT__: specifies the DAC alignement + * @retval None + */ #define __HAL_DHR12R2_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000014) + (__ALIGNEMENT__)) -/* Set DHR12RD alignment */ +/** @brief Set DHR12RD alignment + * @param __ALIGNEMENT__: specifies the DAC alignement + * @retval None + */ #define __HAL_DHR12RD_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000020) + (__ALIGNEMENT__)) -/* Enable the DAC interrupt */ +/** @brief Enable the DAC interrupt + * @param __HANDLE__: specifies the DAC handle + * @param __INTERRUPT__: specifies the DAC interrupt. + * @retval None + */ #define __HAL_DAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__)) -/* Disable the DAC interrupt */ +/** @brief Disable the DAC interrupt + * @param __HANDLE__: specifies the DAC handle + * @param __INTERRUPT__: specifies the DAC interrupt. + * @retval None + */ #define __HAL_DAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__)) -/* Get the selected DAC's flag status */ +/** @brief Get the selected DAC's flag status. + * @param __HANDLE__: specifies the DAC handle. + * @retval None + */ #define __HAL_DAC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) -/* Clear the DAC's flag */ -#define __HAL_DAC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) |= (__FLAG__)) +/** @brief Clear the DAC's flag. + * @param __HANDLE__: specifies the DAC handle. + * @retval None + */ +#define __HAL_DAC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) |= (__FLAG__)) /* Include DAC HAL Extension module */ -#include "stm32f4xx_hal_dac_ex.h" +#include "stm32f4xx_hal_dac_ex.h" -/* Exported functions --------------------------------------------------------*/ -/* Initialization/de-initialization functions ***********************************/ +/* Exported functions --------------------------------------------------------*/ +/* Initialization/de-initialization functions *********************************/ HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac); HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac); void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac); void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac); -/* I/O operation functions ******************************************************/ +/* I/O operation functions ****************************************************/ HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel); HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel); HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment); HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel); uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel); -/* Peripheral Control functions *************************************************/ +/* Peripheral Control functions ***********************************************/ HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel); HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data); -/* Peripheral State functions ***************************************************/ +/* Peripheral State functions *************************************************/ HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac); void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac); uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.c index 1ddea46698..6d08d60bb7 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dac_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief DAC HAL module driver. * This file provides firmware functions to manage the following * functionalities of DAC extension peripheral: @@ -123,8 +123,7 @@ uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac) * the configuration information for the specified DAC. * @param Channel: The selected DAC channel. * This parameter can be one of the following values: - * @arg DAC_CHANNEL_1: DAC Channel1 selected - * @arg DAC_CHANNEL_2: DAC Channel2 selected + * DAC_CHANNEL_1 / DAC_CHANNEL_2 * @param Amplitude: Select max triangle amplitude. * This parameter can be one of the following values: * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1 @@ -172,8 +171,7 @@ HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32 * the configuration information for the specified DAC. * @param Channel: The selected DAC channel. * This parameter can be one of the following values: - * @arg DAC_CHANNEL_1: DAC Channel1 selected - * @arg DAC_CHANNEL_2: DAC Channel2 selected + * DAC_CHANNEL_1 / DAC_CHANNEL_2 * @param Amplitude: Unmask DAC channel LFSR for noise wave generation. * This parameter can be one of the following values: * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation @@ -221,9 +219,9 @@ HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t * the configuration information for the specified DAC. * @param Alignment: Specifies the data alignment for dual channel DAC. * This parameter can be one of the following values: - * @arg DAC_Align_8b_R: 8bit right data alignment selected - * @arg DAC_Align_12b_L: 12bit left data alignment selected - * @arg DAC_Align_12b_R: 12bit right data alignment selected + * DAC_ALIGN_8B_R: 8bit right data alignment selected + * DAC_ALIGN_12B_L: 12bit left data alignment selected + * DAC_ALIGN_12B_R: 12bit right data alignment selected * @param Data1: Data for DAC Channel2 to be loaded in the selected data holding register. * @param Data2: Data for DAC Channel1 to be loaded in the selected data holding register. * @note In dual mode, a unique register access is required to write in both @@ -317,7 +315,8 @@ __weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac) /** * @brief DMA conversion complete callback. - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma) @@ -331,7 +330,8 @@ void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma) /** * @brief DMA half transfer complete callback. - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma) @@ -343,7 +343,8 @@ void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma) /** * @brief DMA error callback - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.h index 6b3617c06e..522ab1acee 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dac.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of DAC HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.c index f21e7f7c98..5702e99ccb 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dcmi.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief DCMI HAL module driver * This file provides firmware functions to manage the following * functionalities of the Digital Camera Interface (DCMI) peripheral: @@ -39,9 +39,9 @@ window from the received image using HAL_DCMI_ConfigCrop() and HAL_DCMI_EnableCROP() functions - (#) The capture can be stopped using the following HAL_DCMI_Stop() function. + (#) The capture can be stopped using HAL_DCMI_Stop() function. - (#) To control DCMI state you can use the following function : HAL_DCMI_GetState() + (#) To control DCMI state you can use the function HAL_DCMI_GetState(). *** DCMI HAL driver macros list *** ============================================= @@ -217,7 +217,7 @@ HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi) * values. * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains * the configuration information for DCMI. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi) @@ -290,7 +290,7 @@ __weak void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi) * @param DCMI_Mode: DCMI capture mode snapshot or continuous grab. * @param pData: The destination memory Buffer address (LCD Frame buffer). * @param Length: The length of capture to be transferred. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length) { @@ -363,6 +363,7 @@ HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mo * @brief Disable DCMI DMA request and Disable DCMI capture * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains * the configuration information for DCMI. + * @retval HAL status */ HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi) { @@ -417,7 +418,7 @@ HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi) * @brief Handles DCMI interrupt request. * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains * the configuration information for the DCMI. - * @retval HAL status + * @retval None */ void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi) { @@ -593,7 +594,7 @@ __weak void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) =============================================================================== [..] This section provides functions allowing to: (+) Configure the CROP feature. - (+) ENABLE/DISABLE the CROP feature. + (+) Enable/Disable the CROP feature. @endverbatim * @{ @@ -640,7 +641,7 @@ HAL_StatusTypeDef HAL_DCMI_ConfigCROP(DCMI_HandleTypeDef *hdcmi, uint32_t X0, ui * @brief Disable the Crop feature. * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains * the configuration information for DCMI. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_DCMI_DisableCROP(DCMI_HandleTypeDef *hdcmi) { @@ -666,7 +667,7 @@ HAL_StatusTypeDef HAL_DCMI_DisableCROP(DCMI_HandleTypeDef *hdcmi) * @brief Enable the Crop feature. * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains * the configuration information for DCMI. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_DCMI_EnableCROP(DCMI_HandleTypeDef *hdcmi) { @@ -736,7 +737,8 @@ uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi) /** * @brief DMA conversion complete callback. - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma) @@ -789,7 +791,8 @@ static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA error callback - * @param hdma: pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void DCMI_DMAError(DMA_HandleTypeDef *hdma) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.h index 11b07c1d04..b9da51d3fd 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dcmi.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of DCMI HAL module. ****************************************************************************** * @attention @@ -59,17 +59,16 @@ /* Exported types ------------------------------------------------------------*/ /** - * @brief DCMI Error source - */ + * @brief DCMI Error source + */ typedef enum { DCMI_ERROR_SYNC = 1, /*!< Synchronisation error */ DCMI_OVERRUN = 2, /*!< DCMI Overrun */ - -}DCMI_ErrorTypeDef; +}DCMI_ErrorTypeDef; /** - * @brief DCMI Embedded Synchronisation CODE Init structure definition + * @brief DCMI Embedded Synchronisation CODE Init structure definition */ typedef struct { @@ -77,11 +76,10 @@ typedef struct uint8_t LineStartCode; /*!< Specifies the code of the line start delimiter. */ uint8_t LineEndCode; /*!< Specifies the code of the line end delimiter. */ uint8_t FrameEndCode; /*!< Specifies the code of the frame end delimiter. */ - }DCMI_CodesInitTypeDef; /** - * @brief DCMI Init structure definition + * @brief DCMI Init structure definition */ typedef struct { @@ -102,17 +100,16 @@ typedef struct uint32_t ExtendedDataMode; /*!< Specifies the data width: 8-bit, 10-bit, 12-bit or 14-bit. This parameter can be a value of @ref DCMI_Extended_Data_Mode */ - + DCMI_CodesInitTypeDef SyncroCode; /*!< Specifies the code of the frame start delimiter. */ - + uint32_t JPEGMode; /*!< Enable or Disable the JPEG mode. - This parameter can be a value of @ref DCMI_MODE_JPEG */ - + This parameter can be a value of @ref DCMI_MODE_JPEG */ + }DCMI_InitTypeDef; - /** - * @brief HAL DCMI State structures definition + * @brief HAL DCMI State structures definition */ typedef enum { @@ -121,35 +118,34 @@ typedef enum HAL_DCMI_STATE_BUSY = 0x02, /*!< DCMI internal processing is ongoing */ HAL_DCMI_STATE_TIMEOUT = 0x03, /*!< DCMI timeout state */ HAL_DCMI_STATE_ERROR = 0x04 /*!< DCMI error state */ - }HAL_DCMI_StateTypeDef; /** - * @brief DCMI handle Structure definition - */ + * @brief DCMI handle Structure definition + */ typedef struct -{ +{ DCMI_TypeDef *Instance; /*!< DCMI Register base address */ - - DCMI_InitTypeDef Init; /*!< DCMI parameters */ - - HAL_LockTypeDef Lock; /*!< DCMI locking object */ - - __IO HAL_DCMI_StateTypeDef State; /*!< DCMI state */ - - __IO uint32_t XferCount; /*!< DMA transfer counter */ - - __IO uint32_t XferSize; /*!< DMA transfer size */ - - uint32_t XferTransferNumber; /*!< DMA transfer number */ - uint32_t pBuffPtr; /*!< Pointer to DMA output buffer */ - + DCMI_InitTypeDef Init; /*!< DCMI parameters */ + + HAL_LockTypeDef Lock; /*!< DCMI locking object */ + + __IO HAL_DCMI_StateTypeDef State; /*!< DCMI state */ + + __IO uint32_t XferCount; /*!< DMA transfer counter */ + + __IO uint32_t XferSize; /*!< DMA transfer size */ + + uint32_t XferTransferNumber; /*!< DMA transfer number */ + + uint32_t pBuffPtr; /*!< Pointer to DMA output buffer */ + DMA_HandleTypeDef *DMA_Handle; /*!< Pointer to the DMA handler */ - __IO uint32_t ErrorCode; /*!< DCMI Error code */ - -}DCMI_HandleTypeDef; + __IO uint32_t ErrorCode; /*!< DCMI Error code */ + +}DCMI_HandleTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -162,13 +158,13 @@ typedef struct */ #define HAL_DCMI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ #define HAL_DCMI_ERROR_OVF ((uint32_t)0x00000001) /*!< Overflow error */ -#define HAL_DCMI_ERROR_SYNC ((uint32_t)0x00000002) /*!< Synchronization error */ +#define HAL_DCMI_ERROR_SYNC ((uint32_t)0x00000002) /*!< Synchronization error */ #define HAL_DCMI_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */ /** * @} - */ + */ -/** @defgroup DCMI_Capture_Mode +/** @defgroup DCMI_Capture_Mode * @{ */ #define DCMI_MODE_CONTINUOUS ((uint32_t)0x00000000) /*!< The received data are transferred continuously @@ -180,8 +176,7 @@ typedef struct ((MODE) == DCMI_MODE_SNAPSHOT)) /** * @} - */ - + */ /** @defgroup DCMI_Synchronization_Mode * @{ @@ -190,17 +185,16 @@ typedef struct is synchronized with the HSYNC/VSYNC signals */ #define DCMI_SYNCHRO_EMBEDDED ((uint32_t)DCMI_CR_ESS) /*!< Embedded synchronization data capture is synchronized with synchronization codes embedded in the data flow */ - + #define IS_DCMI_SYNCHRO(MODE)(((MODE) == DCMI_SYNCHRO_HARDWARE) || \ ((MODE) == DCMI_SYNCHRO_EMBEDDED)) /** * @} - */ + */ - -/** @defgroup DCMI_PIXCK_Polarity +/** @defgroup DCMI_PIXCK_Polarity * @{ - */ + */ #define DCMI_PCKPOLARITY_FALLING ((uint32_t)0x00000000) /*!< Pixel clock active on Falling edge */ #define DCMI_PCKPOLARITY_RISING ((uint32_t)DCMI_CR_PCKPOL) /*!< Pixel clock active on Rising edge */ @@ -208,12 +202,11 @@ typedef struct ((POLARITY) == DCMI_PCKPOLARITY_RISING)) /** * @} - */ + */ - -/** @defgroup DCMI_VSYNC_Polarity +/** @defgroup DCMI_VSYNC_Polarity * @{ - */ + */ #define DCMI_VSPOLARITY_LOW ((uint32_t)0x00000000) /*!< Vertical synchronization active Low */ #define DCMI_VSPOLARITY_HIGH ((uint32_t)DCMI_CR_VSPOL) /*!< Vertical synchronization active High */ @@ -221,10 +214,9 @@ typedef struct ((POLARITY) == DCMI_VSPOLARITY_HIGH)) /** * @} - */ + */ - -/** @defgroup DCMI_HSYNC_Polarity +/** @defgroup DCMI_HSYNC_Polarity * @{ */ #define DCMI_HSPOLARITY_LOW ((uint32_t)0x00000000) /*!< Horizontal synchronization active Low */ @@ -234,11 +226,11 @@ typedef struct ((POLARITY) == DCMI_HSPOLARITY_HIGH)) /** * @} - */ + */ /** @defgroup DCMI_MODE_JPEG * @{ - */ + */ #define DCMI_JPEG_DISABLE ((uint32_t)0x00000000) /*!< Mode JPEG Disabled */ #define DCMI_JPEG_ENABLE ((uint32_t)DCMI_CR_JPEG) /*!< Mode JPEG Enabled */ @@ -246,11 +238,11 @@ typedef struct ((JPEG_MODE) == DCMI_JPEG_ENABLE)) /** * @} - */ + */ /** @defgroup DCMI_Capture_Rate * @{ - */ + */ #define DCMI_CR_ALL_FRAME ((uint32_t)0x00000000) /*!< All frames are captured */ #define DCMI_CR_ALTERNATE_2_FRAME ((uint32_t)DCMI_CR_FCRC_0) /*!< Every alternate frame captured */ #define DCMI_CR_ALTERNATE_4_FRAME ((uint32_t)DCMI_CR_FCRC_1) /*!< One frame in 4 frames captured */ @@ -260,12 +252,11 @@ typedef struct ((RATE) == DCMI_CR_ALTERNATE_4_FRAME)) /** * @} - */ - + */ /** @defgroup DCMI_Extended_Data_Mode * @{ - */ + */ #define DCMI_EXTEND_DATA_8B ((uint32_t)0x00000000) /*!< Interface captures 8-bit data on every pixel clock */ #define DCMI_EXTEND_DATA_10B ((uint32_t)DCMI_CR_EDM_0) /*!< Interface captures 10-bit data on every pixel clock */ #define DCMI_EXTEND_DATA_12B ((uint32_t)DCMI_CR_EDM_1) /*!< Interface captures 12-bit data on every pixel clock */ @@ -277,11 +268,11 @@ typedef struct ((DATA) == DCMI_EXTEND_DATA_14B)) /** * @} - */ + */ /** @defgroup DCMI_Window_Coordinate * @{ - */ + */ #define DCMI_WINDOW_COORDINATE ((uint32_t)0x3FFF) /*!< Window coordinate */ #define IS_DCMI_WINDOW_COORDINATE(COORDINATE) ((COORDINATE) <= DCMI_WINDOW_COORDINATE) @@ -297,11 +288,11 @@ typedef struct #define IS_DCMI_WINDOW_HEIGHT(HEIGHT) ((HEIGHT) <= DCMI_WINDOW_HEIGHT) /** * @} - */ + */ -/** @defgroup DCMI_interrupt_sources +/** @defgroup DCMI_interrupt_sources * @{ - */ + */ #define DCMI_IT_FRAME ((uint32_t)DCMI_IER_FRAME_IE) #define DCMI_IT_OVF ((uint32_t)DCMI_IER_OVF_IE) #define DCMI_IT_ERR ((uint32_t)DCMI_IER_ERR_IE) @@ -317,13 +308,14 @@ typedef struct ((IT) == DCMI_IT_LINE)) /** * @} - */ + */ -/** @defgroup DCMI_Flags +/** @defgroup DCMI_Flags * @{ - */ + */ + /** - * @brief DCMI SR register + * @brief DCMI SR register */ #define DCMI_FLAG_HSYNC ((uint32_t)0x2001) #define DCMI_FLAG_VSYNC ((uint32_t)0x2002) @@ -368,6 +360,13 @@ typedef struct */ /* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset DCMI handle state + * @param __HANDLE__: specifies the DCMI handle. + * @retval None + */ +#define __HAL_DCMI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DCMI_STATE_RESET) + /** * @brief Enable the DCMI. * @param __HANDLE__: DCMI handle @@ -455,15 +454,15 @@ typedef struct */ #define __HAL_DCMI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MISR & (__INTERRUPT__)) -/* Exported functions --------------------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ -/* Initialization and de-initialization functions *******************************/ +/* Initialization and de-initialization functions *****************************/ HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi); HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi); void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi); void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi); -/* IO operation functions *******************************************************/ +/* IO operation functions *****************************************************/ HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length); HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi); void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi); @@ -472,12 +471,12 @@ void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi); void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi); void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi); -/* Peripheral Control functions *************************************************/ +/* Peripheral Control functions ***********************************************/ HAL_StatusTypeDef HAL_DCMI_ConfigCROP(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize); HAL_StatusTypeDef HAL_DCMI_EnableCROP(DCMI_HandleTypeDef *hdcmi); HAL_StatusTypeDef HAL_DCMI_DisableCROP(DCMI_HandleTypeDef *hdcmi); -/* Peripheral State functions ***************************************************/ +/* Peripheral State functions *************************************************/ HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi); uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_def.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_def.h index 78b560aab1..739c4b34b0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_def.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_def.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_def.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief This file contains HAL common defines, enumeration, macros and * structures definitions. ****************************************************************************** @@ -79,10 +79,10 @@ typedef enum #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) -#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ +#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ do{ \ - (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ - (__DMA_HANDLE_).Parent = (__HANDLE__); \ + (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ + (__DMA_HANDLE__).Parent = (__HANDLE__); \ } while(0) #if (USE_RTOS == 1) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.c index 40e1bbc244..32ed25c510 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief DMA HAL module driver. * * This file provides firmware functions to manage the following @@ -47,7 +47,7 @@ (+) At the end of data transfer HAL_DMA_IRQHandler() function is executed and user can add his own function by customization of function pointer XferCpltCallback and XferErrorCallback (i.e a member of DMA handle structure). - + [..] (#) Use HAL_DMA_GetState() function to return the DMA state and HAL_DMA_GetError() in case of error detection. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.h index d248e4c4e4..dca4059fd8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of DMA HAL module. ****************************************************************************** * @attention @@ -54,36 +54,36 @@ * @{ */ -/* Exported types ------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ /** - * @brief DMA Configuration Structure definition + * @brief DMA Configuration Structure definition */ typedef struct { uint32_t Channel; /*!< Specifies the channel used for the specified stream. This parameter can be a value of @ref DMA_Channel_selection */ - + uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral, from memory to memory or from peripheral to memory. This parameter can be a value of @ref DMA_Data_transfer_direction */ uint32_t PeriphInc; /*!< Specifies whether the Peripheral address register should be incremented or not. - This parameter can be a value of @ref DMA_Peripheral_incremented_mode */ - + This parameter can be a value of @ref DMA_Peripheral_incremented_mode */ + uint32_t MemInc; /*!< Specifies whether the memory address register should be incremented or not. This parameter can be a value of @ref DMA_Memory_incremented_mode */ - + uint32_t PeriphDataAlignment; /*!< Specifies the Peripheral data width. - This parameter can be a value of @ref DMA_Peripheral_data_size */ + This parameter can be a value of @ref DMA_Peripheral_data_size */ uint32_t MemDataAlignment; /*!< Specifies the Memory data width. This parameter can be a value of @ref DMA_Memory_data_size */ - + uint32_t Mode; /*!< Specifies the operation mode of the DMAy Streamx. This parameter can be a value of @ref DMA_mode @note The circular buffer mode cannot be used if the memory-to-memory - data transfer is configured on the selected Stream */ + data transfer is configured on the selected Stream */ uint32_t Priority; /*!< Specifies the software priority for the DMAy Streamx. This parameter can be a value of @ref DMA_Priority_level */ @@ -92,80 +92,75 @@ typedef struct This parameter can be a value of @ref DMA_FIFO_direct_mode @note The Direct mode (FIFO mode disabled) cannot be used if the memory-to-memory data transfer is configured on the selected stream */ - + uint32_t FIFOThreshold; /*!< Specifies the FIFO threshold level. This parameter can be a value of @ref DMA_FIFO_threshold_level */ - + uint32_t MemBurst; /*!< Specifies the Burst transfer configuration for the memory transfers. It specifies the amount of data to be transferred in a single non interruptable - transaction. + transaction. This parameter can be a value of @ref DMA_Memory_burst @note The burst mode is possible only if the address Increment mode is enabled. */ - + uint32_t PeriphBurst; /*!< Specifies the Burst transfer configuration for the peripheral transfers. It specifies the amount of data to be transferred in a single non interruptable transaction. This parameter can be a value of @ref DMA_Peripheral_burst @note The burst mode is possible only if the address Increment mode is enabled. */ - }DMA_InitTypeDef; /** - * @brief HAL DMA State structures definition - */ + * @brief HAL DMA State structures definition + */ typedef enum { - HAL_DMA_STATE_RESET = 0x00, /*!< DMA not yet initialized or disabled */ + HAL_DMA_STATE_RESET = 0x00, /*!< DMA not yet initialized or disabled */ HAL_DMA_STATE_READY = 0x01, /*!< DMA initialized and ready for use */ HAL_DMA_STATE_READY_MEM0 = 0x11, /*!< DMA Mem0 process success */ - HAL_DMA_STATE_READY_MEM1 = 0x21, /*!< DMA Mem1 process success */ + HAL_DMA_STATE_READY_MEM1 = 0x21, /*!< DMA Mem1 process success */ HAL_DMA_STATE_READY_HALF_MEM0 = 0x31, /*!< DMA Mem0 Half process success */ - HAL_DMA_STATE_READY_HALF_MEM1 = 0x41, /*!< DMA Mem1 Half process success */ + HAL_DMA_STATE_READY_HALF_MEM1 = 0x41, /*!< DMA Mem1 Half process success */ HAL_DMA_STATE_BUSY = 0x02, /*!< DMA process is ongoing */ HAL_DMA_STATE_BUSY_MEM0 = 0x12, /*!< DMA Mem0 process is ongoing */ - HAL_DMA_STATE_BUSY_MEM1 = 0x22, /*!< DMA Mem1 process is ongoing */ - HAL_DMA_STATE_TIMEOUT = 0x03, /*!< DMA timeout state */ + HAL_DMA_STATE_BUSY_MEM1 = 0x22, /*!< DMA Mem1 process is ongoing */ + HAL_DMA_STATE_TIMEOUT = 0x03, /*!< DMA timeout state */ HAL_DMA_STATE_ERROR = 0x04, /*!< DMA error state */ - }HAL_DMA_StateTypeDef; /** - * @brief HAL DMA Error Code structure definition - */ + * @brief HAL DMA Error Code structure definition + */ typedef enum { HAL_DMA_FULL_TRANSFER = 0x00, /*!< Full transfer */ HAL_DMA_HALF_TRANSFER = 0x01, /*!< Half Transfer */ - }HAL_DMA_LevelCompleteTypeDef; - /** - * @brief DMA handle Structure definition - */ + * @brief DMA handle Structure definition + */ typedef struct __DMA_HandleTypeDef -{ +{ DMA_Stream_TypeDef *Instance; /*!< Register base address */ - + DMA_InitTypeDef Init; /*!< DMA communication parameters */ - + HAL_LockTypeDef Lock; /*!< DMA locking object */ - + __IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */ - + void *Parent; /*!< Parent object state */ - + void (* XferCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete callback */ - + void (* XferHalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback */ - + void (* XferM1CpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete Memory1 callback */ - + void (* XferErrorCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer error callback */ __IO uint32_t ErrorCode; /*!< DMA Error code */ - -}DMA_HandleTypeDef; +}DMA_HandleTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -178,7 +173,7 @@ typedef struct __DMA_HandleTypeDef */ #define HAL_DMA_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ #define HAL_DMA_ERROR_TE ((uint32_t)0x00000001) /*!< Transfer error */ -#define HAL_DMA_ERROR_FE ((uint32_t)0x00000002) /*!< FIFO error */ +#define HAL_DMA_ERROR_FE ((uint32_t)0x00000002) /*!< FIFO error */ #define HAL_DMA_ERROR_DME ((uint32_t)0x00000004) /*!< Direct Mode error */ #define HAL_DMA_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */ /** @@ -418,6 +413,13 @@ typedef struct __DMA_HandleTypeDef */ /* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset DMA handle state + * @param __HANDLE__: specifies the DMA handle. + * @retval None + */ +#define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET) + /** * @brief Return the current DMA Stream FIFO filled level. * @param __HANDLE__: DMA handle diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c index f0901020ba..124d302135 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma2d.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief DMA2D HAL module driver. * This file provides firmware functions to manage the following * functionalities of the DMA2D peripheral: @@ -71,15 +71,15 @@ *** DMA2D HAL driver macros list *** ============================================= [..] - Below the list of most used macros in DMA2D HAL driver. + Below the list of most used macros in DMA2D HAL driver : (+) __HAL_DMA2D_ENABLE: Enable the DMA2D peripheral. (+) __HAL_DMA2D_DISABLE: Disable the DMA2D peripheral. (+) __HAL_DMA2D_GET_FLAG: Get the DMA2D pending flags. - (+) __HAL_DMA2D_CLEAR_FLAG: Clears the DMA2D pending flags. - (+) __HAL_DMA2D_ENABLE_IT: Enables the specified DMA2D interrupts. - (+) __HAL_DMA2D_DISABLE_IT: Disables the specified DMA2D interrupts. - (+) __HAL_DMA2D_GET_IT_SOURCE: Checks whether the specified DMA2D interrupt has occurred or not. + (+) __HAL_DMA2D_CLEAR_FLAG: Clear the DMA2D pending flags. + (+) __HAL_DMA2D_ENABLE_IT: Enable the specified DMA2D interrupts. + (+) __HAL_DMA2D_DISABLE_IT: Disable the specified DMA2D interrupts. + (+) __HAL_DMA2D_GET_IT_SOURCE: Check whether the specified DMA2D interrupt has occurred or not. [..] (@) You can refer to the DMA2D HAL driver header file for more useful macros @@ -320,8 +320,8 @@ __weak void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d) (+) Abort DMA2D transfer. (+) Suspend DMA2D transfer. (+) Continue DMA2D transfer. - (+) polling for transfer complete. - (+) handles DMA2D interrupt request. + (+) Poll for transfer complete. + (+) handle DMA2D interrupt request. @endverbatim * @{ @@ -827,8 +827,9 @@ void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d) /** * @brief Configure the DMA2D Layer according to the specified * parameters in the DMA2D_InitTypeDef and create the associated handle. - * @param hdma2d: DMA2D handle - * @param LayerIdx: DMA2D Layer index + * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains + * the configuration information for the DMA2D. + * @param LayerIdx: DMA2D Layer index. * This parameter can be one of the following values: * 0(background) / 1(foreground) * @retval HAL status @@ -931,7 +932,7 @@ HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t La * the configuration information for the DMA2D. * @param CLUTCfg: pointer to a DMA2D_CLUTCfgTypeDef structure that contains * the configuration information for the color look up table. - * @param LayerIdx: DMA2D Layer index + * @param LayerIdx: DMA2D Layer index. * This parameter can be one of the following values: * 0(background) / 1(foreground) * @retval HAL status @@ -1013,7 +1014,7 @@ HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCf * @brief Enable the DMA2D CLUT Transfer. * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains * the configuration information for the DMA2D. - * @param LayerIdx: DMA2D Layer index + * @param LayerIdx: DMA2D Layer index. * This parameter can be one of the following values: * 0(background) / 1(foreground) * @retval HAL status @@ -1041,7 +1042,7 @@ HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t Lay * @brief Disable the DMA2D CLUT Transfer. * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains * the configuration information for the DMA2D. - * @param LayerIdx: DMA2D Layer index + * @param LayerIdx: DMA2D Layer index. * This parameter can be one of the following values: * 0(background) / 1(foreground) * @retval HAL status @@ -1070,7 +1071,7 @@ HAL_StatusTypeDef HAL_DMA2D_DisableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t La * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains * the configuration information for the DMA2D. * @param Line: Line Watermark configuration. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line) @@ -1108,7 +1109,7 @@ HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32 ##### Peripheral State and Errors functions ##### =============================================================================== [..] - This subsection provides functions allowing to + This subsection provides functions allowing to : (+) Check the DMA2D state (+) Get error code diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.h index 40db8e70b0..37a40d1fff 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma2d.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of DMA2D HAL module. ****************************************************************************** * @attention @@ -58,121 +58,116 @@ /* Exported types ------------------------------------------------------------*/ #define MAX_DMA2D_LAYER 2 - + /** - * @brief DMA2D color Structure definition + * @brief DMA2D color Structure definition */ typedef struct { uint32_t Blue; /*!< Configures the blue value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ - uint32_t Green; /*!< Configures the green value. + uint32_t Green; /*!< Configures the green value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ - - uint32_t Red; /*!< Configures the red value. + + uint32_t Red; /*!< Configures the red value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ } DMA2D_ColorTypeDef; /** - * @brief DMA2D CLUT Structure definition + * @brief DMA2D CLUT Structure definition */ typedef struct { - uint32_t *pCLUT; /*!< Configures the DMA2D CLUT memory address. */ + uint32_t *pCLUT; /*!< Configures the DMA2D CLUT memory address.*/ - uint32_t CLUTColorMode; /*!< configures the DMA2D CLUT color mode. + uint32_t CLUTColorMode; /*!< configures the DMA2D CLUT color mode. This parameter can be one value of @ref DMA2D_CLUT_CM */ - + uint32_t Size; /*!< configures the DMA2D CLUT size. - This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ + This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.*/ } DMA2D_CLUTCfgTypeDef; /** - * @brief DMA2D Init structure definition + * @brief DMA2D Init structure definition */ typedef struct { uint32_t Mode; /*!< configures the DMA2D transfer mode. This parameter can be one value of @ref DMA2D_Mode */ - + uint32_t ColorMode; /*!< configures the color format of the output image. This parameter can be one value of @ref DMA2D_Color_Mode */ uint32_t OutputOffset; /*!< Specifies the Offset value. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF. */ - } DMA2D_InitTypeDef; /** - * @brief DMA2D Layer structure definition + * @brief DMA2D Layer structure definition */ typedef struct { - - uint32_t InputOffset; /*!< configures the DMA2D foreground offset. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF. */ uint32_t InputColorMode; /*!< configures the DMA2D foreground color mode . This parameter can be one value of @ref DMA2D_Input_Color_Mode */ - + uint32_t AlphaMode; /*!< configures the DMA2D foreground alpha mode. This parameter can be one value of @ref DMA2D_ALPHA_MODE */ - uint32_t InputAlpha; /*!< Specifies the DMA2D foreground alpha value + uint32_t InputAlpha; /*!< Specifies the DMA2D foreground alpha value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ - + } DMA2D_LayerCfgTypeDef; /** - * @brief HAL DMA2D State structures definition - */ + * @brief HAL DMA2D State structures definition + */ typedef enum { HAL_DMA2D_STATE_RESET = 0x00, /*!< DMA2D not yet initialized or disabled */ HAL_DMA2D_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ - HAL_DMA2D_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ - HAL_DMA2D_STATE_TIMEOUT = 0x03, /*!< Timeout state */ + HAL_DMA2D_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ + HAL_DMA2D_STATE_TIMEOUT = 0x03, /*!< Timeout state */ HAL_DMA2D_STATE_ERROR = 0x04, /*!< DMA2D state error */ HAL_DMA2D_STATE_SUSPEND = 0x05 /*!< DMA2D process is suspended */ - }HAL_DMA2D_StateTypeDef; /** - * @brief DMA2D handle Structure definition - */ + * @brief DMA2D handle Structure definition + */ typedef struct __DMA2D_HandleTypeDef -{ +{ DMA2D_TypeDef *Instance; /*!< DMA2D Register base address */ - + DMA2D_InitTypeDef Init; /*!< DMA2D communication parameters */ - + void (* XferCpltCallback)(struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D transfer complete callback */ - + void (* XferErrorCallback)(struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D transfer error callback */ - + DMA2D_LayerCfgTypeDef LayerCfg[MAX_DMA2D_LAYER]; /*!< DMA2D Layers parameters */ - + HAL_LockTypeDef Lock; /*!< DMA2D Lock */ - + __IO HAL_DMA2D_StateTypeDef State; /*!< DMA2D transfer state */ - + __IO uint32_t ErrorCode; /*!< DMA2D Error code */ - -} DMA2D_HandleTypeDef; +} DMA2D_HandleTypeDef; /* Exported constants --------------------------------------------------------*/ /** @defgroup DMA2D_Exported_Constants * @{ - */ + */ /** @defgroup DMA2D_Layer * @{ */ -#define IS_DMA2D_LAYER(LAYER) ((LAYER) <= MAX_DMA2D_LAYER) +#define IS_DMA2D_LAYER(LAYER) ((LAYER) <= MAX_DMA2D_LAYER) /** * @} */ @@ -182,12 +177,12 @@ typedef struct __DMA2D_HandleTypeDef */ #define HAL_DMA2D_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ #define HAL_DMA2D_ERROR_TE ((uint32_t)0x00000001) /*!< Transfer error */ -#define HAL_DMA2D_ERROR_CE ((uint32_t)0x00000002) /*!< Configuration error */ +#define HAL_DMA2D_ERROR_CE ((uint32_t)0x00000002) /*!< Configuration error */ #define HAL_DMA2D_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */ /** * @} */ - + /** @defgroup DMA2D_Mode * @{ */ @@ -200,7 +195,7 @@ typedef struct __DMA2D_HandleTypeDef ((MODE) == DMA2D_M2M_BLEND) || ((MODE) == DMA2D_R2M)) /** * @} - */ + */ /** @defgroup DMA2D_Color_Mode * @{ @@ -242,7 +237,7 @@ typedef struct __DMA2D_HandleTypeDef * @} */ -/** @defgroup DMA2D_OFFSET +/** @defgroup DMA2D_Offset * @{ */ #define DMA2D_OFFSET DMA2D_FGOR_LO /*!< Line Offset */ @@ -303,7 +298,7 @@ typedef struct __DMA2D_HandleTypeDef * @} */ -/** @defgroup DMA2D_CLUT_SIZE +/** @defgroup DMA2D_Size_Clut * @{ */ #define DMA2D_CLUT_SIZE (DMA2D_FGPFCCR_CS >> 8) /*!< DMA2D C-LUT size */ @@ -321,8 +316,8 @@ typedef struct __DMA2D_HandleTypeDef #define IS_DMA2D_LineWatermark(LineWatermark) ((LineWatermark) <= LINE_WATERMARK) /** * @} - */ - + */ + /** @defgroup DMA2D_Interrupts * @{ */ @@ -339,7 +334,7 @@ typedef struct __DMA2D_HandleTypeDef /** * @} */ - + /** @defgroup DMA2D_Flag * @{ */ @@ -361,6 +356,13 @@ typedef struct __DMA2D_HandleTypeDef * @} */ /* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset DMA2D handle state + * @param __HANDLE__: specifies the DMA2D handle. + * @retval None + */ +#define __HAL_DMA2D_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA2D_STATE_RESET) + /** * @brief Enable the DMA2D. * @param __HANDLE__: DMA2D handle diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.c index 91a775171d..572c2050f3 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief DMA Extension HAL module driver * This file provides firmware functions to manage the following * functionalities of the DMA Extension peripheral: @@ -21,7 +21,7 @@ -@- In Memory-to-Memory transfer mode, Multi (Double) Buffer mode is not allowed. -@- When Multi (Double) Buffer mode is enabled the, transfer is circular by default. -@- In Multi (Double) buffer mode, it is possible to update the base address for - the AHB memory port on-the-fly (DMA_SxM0AR or DMA_SxM1AR) when the stream is enabled. + the AHB memory port on the fly (DMA_SxM0AR or DMA_SxM1AR) when the stream is enabled. @endverbatim ****************************************************************************** @@ -217,8 +217,8 @@ HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_ * @param Address: The new address * @param memory: the memory to be changed, This parameter can be one of * the following values: - * @arg MEMORY0 - * @arg MEMORY1 + * MEMORY0 / + * MEMORY1 * @note The MEMORY0 address can be changed only when the current transfer use * MEMORY1 and the MEMORY1 address can be changed only when the current * transfer use MEMORY0. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.h index fdaafea401..0383733c45 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of DMA HAL extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.c index eaf2b155e3..0d90393b9a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_eth.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief ETH HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Ethernet (ETH) peripheral: @@ -152,7 +152,8 @@ static void ETH_FlushTransmitFIFO(ETH_HandleTypeDef *heth); /** * @brief Initializes the Ethernet MAC and DMA according to default * parameters. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval HAL status */ HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth) @@ -389,7 +390,8 @@ HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth) /** * @brief De-Initializes the ETH peripheral. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval HAL status */ HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth) @@ -412,7 +414,8 @@ HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth) /** * @brief Initializes the DMA Tx descriptors in chain mode. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @param DMATxDescTab: Pointer to the first Tx desc list * @param TxBuff: Pointer to the first TxBuffer list * @param TxBuffCount: Number of the used Tx desc in the list @@ -478,7 +481,8 @@ HAL_StatusTypeDef HAL_ETH_DMATxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADesc /** * @brief Initializes the DMA Rx descriptors in chain mode. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @param DMARxDescTab: Pointer to the first Rx desc list * @param RxBuff: Pointer to the first RxBuffer list * @param RxBuffCount: Number of the used Rx desc in the list @@ -547,7 +551,8 @@ HAL_StatusTypeDef HAL_ETH_DMARxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADesc /** * @brief Initializes the ETH MSP. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ __weak void HAL_ETH_MspInit(ETH_HandleTypeDef *heth) @@ -559,7 +564,8 @@ __weak void HAL_ETH_MspInit(ETH_HandleTypeDef *heth) /** * @brief DeInitializes ETH MSP. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ __weak void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth) @@ -588,7 +594,7 @@ __weak void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth) HAL_ETH_GetReceivedFrame_IT(); (+) Read from an External PHY register HAL_ETH_ReadPHYRegister(); - (+) Writo to an External PHY register + (+) Write to an External PHY register HAL_ETH_WritePHYRegister(); @endverbatim @@ -598,7 +604,8 @@ __weak void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth) /** * @brief Sends an Ethernet frame. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @param FrameLength: Amount of data to be sent * @retval HAL status */ @@ -711,7 +718,8 @@ HAL_StatusTypeDef HAL_ETH_TransmitFrame(ETH_HandleTypeDef *heth, uint32_t FrameL /** * @brief Checks for received frames. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval HAL status */ HAL_StatusTypeDef HAL_ETH_GetReceivedFrame(ETH_HandleTypeDef *heth) @@ -789,7 +797,8 @@ HAL_StatusTypeDef HAL_ETH_GetReceivedFrame(ETH_HandleTypeDef *heth) /** * @brief Gets the Received frame in interrupt mode. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval HAL status */ HAL_StatusTypeDef HAL_ETH_GetReceivedFrame_IT(ETH_HandleTypeDef *heth) @@ -873,7 +882,8 @@ HAL_StatusTypeDef HAL_ETH_GetReceivedFrame_IT(ETH_HandleTypeDef *heth) /** * @brief This function handles ETH interrupt request. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval HAL status */ void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth) @@ -932,7 +942,8 @@ void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth) /** * @brief Tx Transfer completed callbacks. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ __weak void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth) @@ -944,7 +955,8 @@ __weak void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth) /** * @brief Rx Transfer completed callbacks. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ __weak void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth) @@ -956,7 +968,8 @@ __weak void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth) /** * @brief Ethernet transfer error callbacks - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ __weak void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth) @@ -968,15 +981,15 @@ __weak void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth) /** * @brief Reads a PHY register - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @param PHYReg: PHY register address, is the index of one of the 32 PHY register. * This parameter can be one of the following values: - * @arg PHY_BCR: Transceiver Basic Control Register - * @arg PHY_BSR: Transceiver Basic Status Register - * @arg More PHY register could be read depending on the used PHY + * PHY_BCR: Transceiver Basic Control Register, + * PHY_BSR: Transceiver Basic Status Register. + * More PHY register could be read depending on the used PHY * @param RegValue: PHY register value - * @retval HAL_TIMEOUT: in case of timeout - * MACMIIDR register value: Data read from the selected PHY register (correct read ) + * @retval HAL status */ HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t *RegValue) { @@ -1037,11 +1050,12 @@ HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYR /** * @brief Writes to a PHY register. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @param PHYReg: PHY register address, is the index of one of the 32 PHY register. * This parameter can be one of the following values: - * @arg PHY_BCR: Transceiver Control Register - * @arg More PHY register could be written depending on the used PHY + * PHY_BCR: Transceiver Control Register. + * More PHY register could be written depending on the used PHY * @param RegValue: the value to write * @retval HAL status */ @@ -1129,7 +1143,8 @@ HAL_StatusTypeDef HAL_ETH_WritePHYRegister(ETH_HandleTypeDef *heth, uint16_t PHY /** * @brief Enables Ethernet MAC and DMA reception/transmission - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval HAL status */ HAL_StatusTypeDef HAL_ETH_Start(ETH_HandleTypeDef *heth) @@ -1167,7 +1182,8 @@ HAL_StatusTypeDef HAL_ETH_Start(ETH_HandleTypeDef *heth) /** * @brief Stop Ethernet MAC and DMA reception/transmission - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval HAL status */ HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth) @@ -1205,7 +1221,8 @@ HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth) /** * @brief Set ETH MAC Configuration. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @param macconf: MAC Configuration structure * @retval HAL status */ @@ -1371,7 +1388,8 @@ HAL_StatusTypeDef HAL_ETH_ConfigMAC(ETH_HandleTypeDef *heth, ETH_MACInitTypeDef /** * @brief Sets ETH DMA Configuration. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @param dmaconf: DMA Configuration structure * @retval HAL status */ @@ -1478,7 +1496,8 @@ HAL_StatusTypeDef HAL_ETH_ConfigDMA(ETH_HandleTypeDef *heth, ETH_DMAInitTypeDef /** * @brief Return the ETH HAL state - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval HAL state */ HAL_ETH_StateTypeDef HAL_ETH_GetState(ETH_HandleTypeDef *heth) @@ -1493,7 +1512,8 @@ HAL_ETH_StateTypeDef HAL_ETH_GetState(ETH_HandleTypeDef *heth) /** * @brief Configures Ethernet MAC and DMA with default parameters. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @param err: Ethernet Init error * @retval HAL status */ @@ -1749,7 +1769,8 @@ static void ETH_MACDMAConfig(ETH_HandleTypeDef *heth, uint32_t err) /** * @brief Configures the selected MAC address. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @param MacAddr: The MAC address to configure * This parameter can be one of the following values: * @arg ETH_MAC_Address0: MAC Address0 @@ -1779,7 +1800,8 @@ static void ETH_MACAddressConfig(ETH_HandleTypeDef *heth, uint32_t MacAddr, uint /** * @brief Enables the MAC transmission. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ static void ETH_MACTransmissionEnable(ETH_HandleTypeDef *heth) @@ -1798,7 +1820,8 @@ static void ETH_MACTransmissionEnable(ETH_HandleTypeDef *heth) /** * @brief Disables the MAC transmission. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ static void ETH_MACTransmissionDisable(ETH_HandleTypeDef *heth) @@ -1817,7 +1840,8 @@ static void ETH_MACTransmissionDisable(ETH_HandleTypeDef *heth) /** * @brief Enables the MAC reception. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ static void ETH_MACReceptionEnable(ETH_HandleTypeDef *heth) @@ -1836,7 +1860,8 @@ static void ETH_MACReceptionEnable(ETH_HandleTypeDef *heth) /** * @brief Disables the MAC reception. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ static void ETH_MACReceptionDisable(ETH_HandleTypeDef *heth) @@ -1855,7 +1880,8 @@ static void ETH_MACReceptionDisable(ETH_HandleTypeDef *heth) /** * @brief Enables the DMA transmission. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ static void ETH_DMATransmissionEnable(ETH_HandleTypeDef *heth) @@ -1866,7 +1892,8 @@ static void ETH_DMATransmissionEnable(ETH_HandleTypeDef *heth) /** * @brief Disables the DMA transmission. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ static void ETH_DMATransmissionDisable(ETH_HandleTypeDef *heth) @@ -1877,7 +1904,8 @@ static void ETH_DMATransmissionDisable(ETH_HandleTypeDef *heth) /** * @brief Enables the DMA reception. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ static void ETH_DMAReceptionEnable(ETH_HandleTypeDef *heth) @@ -1888,7 +1916,8 @@ static void ETH_DMAReceptionEnable(ETH_HandleTypeDef *heth) /** * @brief Disables the DMA reception. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ static void ETH_DMAReceptionDisable(ETH_HandleTypeDef *heth) @@ -1899,7 +1928,8 @@ static void ETH_DMAReceptionDisable(ETH_HandleTypeDef *heth) /** * @brief Clears the ETHERNET transmit FIFO. - * @param heth: ETH handle + * @param heth: pointer to a ETH_HandleTypeDef structure that contains + * the configuration information for ETHERNET module * @retval None */ static void ETH_FlushTransmitFIFO(ETH_HandleTypeDef *heth) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.h index 1fa014d081..2952c63771 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_eth.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of ETH HAL module. ****************************************************************************** * @attention @@ -85,24 +85,24 @@ typedef struct and the mode (half/full-duplex). This parameter can be a value of @ref ETH_AutoNegotiation */ - uint32_t Speed; /*!< Sets the Ethernet speed: 10/100 Mbps + uint32_t Speed; /*!< Sets the Ethernet speed: 10/100 Mbps. This parameter can be a value of @ref ETH_Speed */ uint32_t DuplexMode; /*!< Selects the MAC duplex mode: Half-Duplex or Full-Duplex mode This parameter can be a value of @ref ETH_Duplex_Mode */ - uint16_t PhyAddress; /*!< Ethernet PHY address + uint16_t PhyAddress; /*!< Ethernet PHY address. This parameter must be a number between Min_Data = 0 and Max_Data = 32 */ uint8_t *MACAddr; /*!< MAC Address of used Hardware: must be pointer on an array of 6 bytes */ - uint32_t RxMode; /*!< Selects the Ethernet Rx mode: Polling mode, Interrupt mode + uint32_t RxMode; /*!< Selects the Ethernet Rx mode: Polling mode, Interrupt mode. This parameter can be a value of @ref ETH_Rx_Mode */ - uint32_t ChecksumMode; /*!< Selects if the checksum is check by hardware or by software + uint32_t ChecksumMode; /*!< Selects if the checksum is check by hardware or by software. This parameter can be a value of @ref ETH_Checksum_Mode */ - uint32_t MediaInterface ; /*!< Selects the media-independent interface or the reduced media-independent interface + uint32_t MediaInterface ; /*!< Selects the media-independent interface or the reduced media-independent interface. This parameter can be a value of @ref ETH_Media_Interface */ } ETH_InitTypeDef; @@ -124,78 +124,78 @@ typedef struct When disabled, the MAC can send up to 16384 bytes. This parameter can be a value of @ref ETH_Jabber */ - uint32_t InterFrameGap; /*!< Selects the minimum IFG between frames during transmission + uint32_t InterFrameGap; /*!< Selects the minimum IFG between frames during transmission. This parameter can be a value of @ref ETH_Inter_Frame_Gap */ - uint32_t CarrierSense; /*!< Selects or not the Carrier Sense + uint32_t CarrierSense; /*!< Selects or not the Carrier Sense. This parameter can be a value of @ref ETH_Carrier_Sense */ - uint32_t ReceiveOwn; /*!< Selects or not the ReceiveOwn + uint32_t ReceiveOwn; /*!< Selects or not the ReceiveOwn, ReceiveOwn allows the reception of frames when the TX_EN signal is asserted - in Half-Duplex mode + in Half-Duplex mode. This parameter can be a value of @ref ETH_Receive_Own */ - uint32_t LoopbackMode; /*!< Selects or not the internal MAC MII Loopback mode + uint32_t LoopbackMode; /*!< Selects or not the internal MAC MII Loopback mode. This parameter can be a value of @ref ETH_Loop_Back_Mode */ uint32_t ChecksumOffload; /*!< Selects or not the IPv4 checksum checking for received frame payloads' TCP/UDP/ICMP headers. This parameter can be a value of @ref ETH_Checksum_Offload */ uint32_t RetryTransmission; /*!< Selects or not the MAC attempt retries transmission, based on the settings of BL, - when a collision occurs (Half-Duplex mode) + when a collision occurs (Half-Duplex mode). This parameter can be a value of @ref ETH_Retry_Transmission */ - uint32_t AutomaticPadCRCStrip; /*!< Selects or not the Automatic MAC Pad/CRC Stripping + uint32_t AutomaticPadCRCStrip; /*!< Selects or not the Automatic MAC Pad/CRC Stripping. This parameter can be a value of @ref ETH_Automatic_Pad_CRC_Strip */ - uint32_t BackOffLimit; /*!< Selects the BackOff limit value + uint32_t BackOffLimit; /*!< Selects the BackOff limit value. This parameter can be a value of @ref ETH_Back_Off_Limit */ - uint32_t DeferralCheck; /*!< Selects or not the deferral check function (Half-Duplex mode) + uint32_t DeferralCheck; /*!< Selects or not the deferral check function (Half-Duplex mode). This parameter can be a value of @ref ETH_Deferral_Check */ - uint32_t ReceiveAll; /*!< Selects or not all frames reception by the MAC (No filtering) + uint32_t ReceiveAll; /*!< Selects or not all frames reception by the MAC (No filtering). This parameter can be a value of @ref ETH_Receive_All */ - uint32_t SourceAddrFilter; /*!< Selects the Source Address Filter mode + uint32_t SourceAddrFilter; /*!< Selects the Source Address Filter mode. This parameter can be a value of @ref ETH_Source_Addr_Filter */ uint32_t PassControlFrames; /*!< Sets the forwarding mode of the control frames (including unicast and multicast PAUSE frames) This parameter can be a value of @ref ETH_Pass_Control_Frames */ - uint32_t BroadcastFramesReception; /*!< Selects or not the reception of Broadcast Frames + uint32_t BroadcastFramesReception; /*!< Selects or not the reception of Broadcast Frames. This parameter can be a value of @ref ETH_Broadcast_Frames_Reception */ - uint32_t DestinationAddrFilter; /*!< Sets the destination filter mode for both unicast and multicast frames + uint32_t DestinationAddrFilter; /*!< Sets the destination filter mode for both unicast and multicast frames. This parameter can be a value of @ref ETH_Destination_Addr_Filter */ uint32_t PromiscuousMode; /*!< Selects or not the Promiscuous Mode This parameter can be a value of @ref ETH_Promiscuous_Mode */ - uint32_t MulticastFramesFilter; /*!< Selects the Multicast Frames filter mode: None/HashTableFilter/PerfectFilter/PerfectHashTableFilter + uint32_t MulticastFramesFilter; /*!< Selects the Multicast Frames filter mode: None/HashTableFilter/PerfectFilter/PerfectHashTableFilter. This parameter can be a value of @ref ETH_Multicast_Frames_Filter */ - uint32_t UnicastFramesFilter; /*!< Selects the Unicast Frames filter mode: HashTableFilter/PerfectFilter/PerfectHashTableFilter + uint32_t UnicastFramesFilter; /*!< Selects the Unicast Frames filter mode: HashTableFilter/PerfectFilter/PerfectHashTableFilter. This parameter can be a value of @ref ETH_Unicast_Frames_Filter */ - uint32_t HashTableHigh; /*!< This field holds the higher 32 bits of Hash table + uint32_t HashTableHigh; /*!< This field holds the higher 32 bits of Hash table. This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFFFFFF */ - uint32_t HashTableLow; /*!< This field holds the lower 32 bits of Hash table + uint32_t HashTableLow; /*!< This field holds the lower 32 bits of Hash table. This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFFFFFF */ - uint32_t PauseTime; /*!< This field holds the value to be used in the Pause Time field in the transmit control frame + uint32_t PauseTime; /*!< This field holds the value to be used in the Pause Time field in the transmit control frame. This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFF */ - uint32_t ZeroQuantaPause; /*!< Selects or not the automatic generation of Zero-Quanta Pause Control frames + uint32_t ZeroQuantaPause; /*!< Selects or not the automatic generation of Zero-Quanta Pause Control frames. This parameter can be a value of @ref ETH_Zero_Quanta_Pause */ uint32_t PauseLowThreshold; /*!< This field configures the threshold of the PAUSE to be checked for - automatic retransmission of PAUSE Frame + automatic retransmission of PAUSE Frame. This parameter can be a value of @ref ETH_Pause_Low_Threshold */ uint32_t UnicastPauseFrameDetect; /*!< Selects or not the MAC detection of the Pause frames (with MAC Address0 - unicast address and unique multicast address) + unicast address and unique multicast address). This parameter can be a value of @ref ETH_Unicast_Pause_Frame_Detect */ uint32_t ReceiveFlowControl; /*!< Enables or disables the MAC to decode the received Pause frame and @@ -207,7 +207,7 @@ typedef struct This parameter can be a value of @ref ETH_Transmit_Flow_Control */ uint32_t VLANTagComparison; /*!< Selects the 12-bit VLAN identifier or the complete 16-bit VLAN tag for - comparison and filtering + comparison and filtering. This parameter can be a value of @ref ETH_VLAN_Tag_Comparison */ uint32_t VLANTagIdentifier; /*!< Holds the VLAN tag identifier for receive frames */ @@ -221,54 +221,54 @@ typedef struct typedef struct { - uint32_t DropTCPIPChecksumErrorFrame; /*!< Selects or not the Dropping of TCP/IP Checksum Error Frames + uint32_t DropTCPIPChecksumErrorFrame; /*!< Selects or not the Dropping of TCP/IP Checksum Error Frames. This parameter can be a value of @ref ETH_Drop_TCP_IP_Checksum_Error_Frame */ - uint32_t ReceiveStoreForward; /*!< Enables or disables the Receive store and forward mode + uint32_t ReceiveStoreForward; /*!< Enables or disables the Receive store and forward mode. This parameter can be a value of @ref ETH_Receive_Store_Forward */ - uint32_t FlushReceivedFrame; /*!< Enables or disables the flushing of received frames + uint32_t FlushReceivedFrame; /*!< Enables or disables the flushing of received frames. This parameter can be a value of @ref ETH_Flush_Received_Frame */ - uint32_t TransmitStoreForward; /*!< Enables or disables Transmit store and forward mode + uint32_t TransmitStoreForward; /*!< Enables or disables Transmit store and forward mode. This parameter can be a value of @ref ETH_Transmit_Store_Forward */ - uint32_t TransmitThresholdControl; /*!< Selects or not the Transmit Threshold Control + uint32_t TransmitThresholdControl; /*!< Selects or not the Transmit Threshold Control. This parameter can be a value of @ref ETH_Transmit_Threshold_Control */ - uint32_t ForwardErrorFrames; /*!< Selects or not the forward to the DMA of erroneous frames + uint32_t ForwardErrorFrames; /*!< Selects or not the forward to the DMA of erroneous frames. This parameter can be a value of @ref ETH_Forward_Error_Frames */ uint32_t ForwardUndersizedGoodFrames; /*!< Enables or disables the Rx FIFO to forward Undersized frames (frames with no Error and length less than 64 bytes) including pad-bytes and CRC) This parameter can be a value of @ref ETH_Forward_Undersized_Good_Frames */ - uint32_t ReceiveThresholdControl; /*!< Selects the threshold level of the Receive FIFO + uint32_t ReceiveThresholdControl; /*!< Selects the threshold level of the Receive FIFO. This parameter can be a value of @ref ETH_Receive_Threshold_Control */ uint32_t SecondFrameOperate; /*!< Selects or not the Operate on second frame mode, which allows the DMA to process a second frame of Transmit data even before obtaining the status for the first frame. This parameter can be a value of @ref ETH_Second_Frame_Operate */ - uint32_t AddressAlignedBeats; /*!< Enables or disables the Address Aligned Beats + uint32_t AddressAlignedBeats; /*!< Enables or disables the Address Aligned Beats. This parameter can be a value of @ref ETH_Address_Aligned_Beats */ - uint32_t FixedBurst; /*!< Enables or disables the AHB Master interface fixed burst transfers + uint32_t FixedBurst; /*!< Enables or disables the AHB Master interface fixed burst transfers. This parameter can be a value of @ref ETH_Fixed_Burst */ - uint32_t RxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Rx DMA transaction + uint32_t RxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Rx DMA transaction. This parameter can be a value of @ref ETH_Rx_DMA_Burst_Length */ - uint32_t TxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Tx DMA transaction + uint32_t TxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Tx DMA transaction. This parameter can be a value of @ref ETH_Tx_DMA_Burst_Length */ - uint32_t EnhancedDescriptorFormat; /*!< Enables the enhanced descriptor format + uint32_t EnhancedDescriptorFormat; /*!< Enables the enhanced descriptor format. This parameter can be a value of @ref ETH_DMA_Enhanced_descriptor_format */ uint32_t DescriptorSkipLength; /*!< Specifies the number of word to skip between two unchained descriptors (Ring mode) This parameter must be a number between Min_Data = 0 and Max_Data = 32 */ - uint32_t DMAArbitration; /*!< Selects the DMA Tx/Rx arbitration + uint32_t DMAArbitration; /*!< Selects the DMA Tx/Rx arbitration. This parameter can be a value of @ref ETH_DMA_Arbitration */ } ETH_DMAInitTypeDef; @@ -1290,9 +1290,9 @@ typedef struct ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_64BEAT) || \ ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_128BEAT)) -/** - * @brief ETH_DMA_Enhanced_descriptor_format - */ +/** @defgroup ETH_DMA_Enhanced_descriptor_format + * @{ + */ #define ETH_DMAENHANCEDDESCRIPTOR_ENABLE ((uint32_t)0x00000080) #define ETH_DMAENHANCEDDESCRIPTOR_DISABLE ((uint32_t)0x00000000) @@ -1700,6 +1700,12 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset ETH handle state + * @param __HANDLE__: specifies the ETH handle. + * @retval None + */ +#define __HAL_ETH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ETH_STATE_RESET) + /** * @brief Checks whether the specified ETHERNET DMA Tx Desc flag is set or not. * @param __HANDLE__: ETH Handle diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.c index 624fea035d..b8ac0f5bc4 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_flash.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief FLASH HAL module driver. * This file provides firmware functions to manage the following * functionalities of the internal FLASH memory: @@ -212,7 +212,7 @@ HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint * @param Address: specifies the address to be programmed. * @param Data: specifies the data to be programmed * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data) { @@ -387,11 +387,11 @@ void HAL_FLASH_IRQHandler(void) /** * @brief FLASH end of operation interrupt callback * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure - * - Mass Erase: Bank number which has been requested to erase - * - Sectors Erase: Sector which has been erased + * Mass Erase: Bank number which has been requested to erase + * Sectors Erase: Sector which has been erased * (if 0xFFFFFFFF, it means that all the selected sectors have been erased) - * - Program: Address which was selected for data program - * @retval none + * Program: Address which was selected for data program + * @retval None */ __weak void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue) { @@ -403,10 +403,10 @@ __weak void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue) /** * @brief FLASH operation error interrupt callback * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure - * - Mass Erase: Bank number which has been requested to erase - * - Sectors Erase: Sector number which returned an error - * - Program: Address which was selected for data program - * @retval none + * Mass Erase: Bank number which has been requested to erase + * Sectors Erase: Sector number which returned an error + * Program: Address which was selected for data program + * @retval None */ __weak void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue) { @@ -437,7 +437,7 @@ __weak void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue) /** * @brief Unlock the FLASH control register access * @param None - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASH_Unlock(void) { @@ -458,7 +458,7 @@ HAL_StatusTypeDef HAL_FLASH_Unlock(void) /** * @brief Locks the FLASH control register access * @param None - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASH_Lock(void) { @@ -472,7 +472,7 @@ HAL_StatusTypeDef HAL_FLASH_Lock(void) /** * @brief Unlock the FLASH Option Control Registers access. * @param None - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void) { @@ -493,7 +493,7 @@ HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void) /** * @brief Lock the FLASH Option Control Registers access. * @param None - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASH_OB_Lock(void) { @@ -506,7 +506,7 @@ HAL_StatusTypeDef HAL_FLASH_OB_Lock(void) /** * @brief Launch the option byte loading. * @param None - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASH_OB_Launch(void) { @@ -529,7 +529,7 @@ HAL_StatusTypeDef HAL_FLASH_OB_Launch(void) ##### Peripheral Errors functions ##### =============================================================================== [..] - This subsection permit to get in run-time Errors of the FLASH peripheral. + This subsection permits to get in run-time Errors of the FLASH peripheral. @endverbatim * @{ @@ -558,7 +558,7 @@ FLASH_ErrorTypeDef HAL_FLASH_GetError(void) /** * @brief Wait for a FLASH operation to complete. * @param Timeout: maximum flash operationtimeout - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout) { diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.h index a8533c9b20..65fb6da997 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_flash.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of FLASH HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.c index 5f4b2b6f29..ae66e94c45 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_flash_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Extended FLASH HAL module driver. * This file provides firmware functions to manage the following * functionalities of the FLASH extension peripheral: @@ -30,7 +30,7 @@ (++) Lock and Unlock the FLASH interface using HAL_FLASH_Unlock() and HAL_FLASH_Lock() functions (++) Erase function: Erase sector, erase all sectors - (++) There is two mode of erase : + (++) There are two modes of erase : (+++) Polling Mode using HAL_FLASHEx_Erase() (+++) Interrupt Mode using HAL_FLASHEx_Erase_IT() @@ -154,7 +154,7 @@ extern HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); * contains the configuration information on faulty sector in case of error * (0xFFFFFFFF means that all the sectors have been correctly erased) * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError) { @@ -224,7 +224,7 @@ HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t * @param pEraseInit: pointer to an FLASH_EraseInitTypeDef structure that * contains the configuration information for the erasing. * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit) { @@ -277,7 +277,7 @@ HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit) * @param pOBInit: pointer to an FLASH_OBInitStruct structure that * contains the configuration information for the programming. * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit) { @@ -361,7 +361,7 @@ void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit) * @param pAdvOBInit: pointer to an FLASH_AdvOBProgramInitTypeDef structure that * contains the configuration information for the programming. * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASHEx_AdvOBProgram (FLASH_AdvOBProgramInitTypeDef *pAdvOBInit) { @@ -440,7 +440,7 @@ void HAL_FLASHEx_AdvOBGetConfig(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit) * @note This function can be used only for STM32F427xx/STM32F429xx/STM32F437xx/STM32F439xx/STM32F401xx devices. * * @param None - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void) { @@ -466,7 +466,7 @@ HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void) * @note This function can be used only for STM32F427xx/STM32F429xx/STM32F437xx/STM32F439xx/STM32F401xx devices. * * @param None - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ HAL_StatusTypeDef HAL_FLASHEx_OB_DeSelectPCROP(void) { @@ -522,7 +522,7 @@ uint16_t HAL_FLASHEx_OB_GetBank2WRP(void) * @arg FLASH_BANK_2: Bank2 to be erased * @arg FLASH_BANK_BOTH: Bank1 and Bank2 to be erased * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static void FLASH_MassErase(uint8_t VoltageRange, uint32_t Banks) { @@ -801,7 +801,7 @@ static HAL_StatusTypeDef FLASH_OB_BootConfig(uint8_t BootConfig) * @arg FLASH_BANK_2: WRP on all sectors of bank2 * @arg FLASH_BANK_BOTH: WRP on all sectors of bank1 & bank2 * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static HAL_StatusTypeDef FLASH_OB_EnablePCROP(uint32_t SectorBank1, uint32_t SectorBank2, uint32_t Banks) { @@ -865,7 +865,7 @@ static HAL_StatusTypeDef FLASH_OB_EnablePCROP(uint32_t SectorBank1, uint32_t Sec * @arg FLASH_BANK_2: WRP on all sectors of bank2 * @arg FLASH_BANK_BOTH: WRP on all sectors of bank1 & bank2 * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static HAL_StatusTypeDef FLASH_OB_DisablePCROP(uint32_t SectorBank1, uint32_t SectorBank2, uint32_t Banks) { @@ -1014,7 +1014,7 @@ void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange) * This parameter can be one of the following values: * @arg FLASH_BANK_1: WRP on all sectors of bank1 * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static HAL_StatusTypeDef FLASH_OB_EnableWRP(uint32_t WRPSector, uint32_t Banks) { @@ -1050,7 +1050,7 @@ static HAL_StatusTypeDef FLASH_OB_EnableWRP(uint32_t WRPSector, uint32_t Banks) * This parameter can be one of the following values: * @arg FLASH_BANK_1: WRP on all sectors of bank1 * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static HAL_StatusTypeDef FLASH_OB_DisableWRP(uint32_t WRPSector, uint32_t Banks) { @@ -1080,7 +1080,7 @@ static HAL_StatusTypeDef FLASH_OB_DisableWRP(uint32_t WRPSector, uint32_t Banks) * This parameter can be one of the following values: * @arg OB_PCROP: A value between OB_PCROP_Sector0 and OB_PCROP_Sector5 * @arg OB_PCROP_Sector_All - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static HAL_StatusTypeDef FLASH_OB_EnablePCROP(uint32_t Sector) { @@ -1108,7 +1108,7 @@ static HAL_StatusTypeDef FLASH_OB_EnablePCROP(uint32_t Sector) * This parameter can be one of the following values: * @arg OB_PCROP: A value between OB_PCROP_Sector0 and OB_PCROP_Sector5 * @arg OB_PCROP_Sector_All - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static HAL_StatusTypeDef FLASH_OB_DisablePCROP(uint32_t Sector) { @@ -1140,7 +1140,7 @@ static HAL_StatusTypeDef FLASH_OB_DisablePCROP(uint32_t Sector) * * @note WARNING: When enabling OB_RDP level 2 it's no more possible to go back to level 1 or 0 * - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static HAL_StatusTypeDef FLASH_OB_RDP_LevelConfig(uint8_t Level) { @@ -1174,7 +1174,7 @@ static HAL_StatusTypeDef FLASH_OB_RDP_LevelConfig(uint8_t Level) * This parameter can be one of the following values: * @arg OB_STDBY_NO_RST: No reset generated when entering in STANDBY * @arg OB_STDBY_RST: Reset generated when entering in STANDBY - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static HAL_StatusTypeDef FLASH_OB_UserConfig(uint8_t Iwdg, uint8_t Stop, uint8_t Stdby) { @@ -1210,7 +1210,7 @@ static HAL_StatusTypeDef FLASH_OB_UserConfig(uint8_t Iwdg, uint8_t Stop, uint8_t * @arg OB_BOR_LEVEL2: Supply voltage ranges from 2.4 to 2.7 V * @arg OB_BOR_LEVEL1: Supply voltage ranges from 2.1 to 2.4 V * @arg OB_BOR_OFF: Supply voltage ranges from 1.62 to 2.1 V - * @retval HAL_StatusTypeDef HAL Status + * @retval HAL Status */ static HAL_StatusTypeDef FLASH_OB_BOR_LevelConfig(uint8_t Level) { diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.h index 70659377cb..1df2a89359 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_flash_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of FLASH HAL Extension module. ****************************************************************************** * @attention @@ -61,19 +61,19 @@ */ typedef struct { - uint32_t TypeErase; /*!< TypeErase: Mass erase or sector Erase. + uint32_t TypeErase; /*!< Mass erase or sector Erase. This parameter can be a value of @ref FLASHEx_Type_Erase */ - uint32_t Banks; /*!< Banks: Select banks to erase when Mass erase is enabled + uint32_t Banks; /*!< Select banks to erase when Mass erase is enabled. This parameter must be a value of @ref FLASHEx_Banks */ - uint32_t Sector; /*!< Sector: Initial FLASH sector to erase when Mass erase is disabled + uint32_t Sector; /*!< Initial FLASH sector to erase when Mass erase is disabled This parameter must be a value of @ref FLASHEx_Sectors */ - uint32_t NbSectors; /*!< NbSectors: Number of sectors to be erased. + uint32_t NbSectors; /*!< Number of sectors to be erased. This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/ - uint32_t VoltageRange;/*!< VoltageRange: The device voltage range which defines the erase parallelism + uint32_t VoltageRange;/*!< The device voltage range which defines the erase parallelism This parameter must be a value of @ref FLASHEx_Voltage_Range */ } FLASH_EraseInitTypeDef; @@ -83,26 +83,25 @@ typedef struct */ typedef struct { - uint32_t OptionType; /*!< OptionType: Option byte to be configured. + uint32_t OptionType; /*!< Option byte to be configured. This parameter can be a value of @ref FLASHEx_Option_Type */ - uint32_t WRPState; /*!< WRPState: Write protection activation or deactivation. + uint32_t WRPState; /*!< Write protection activation or deactivation. This parameter can be a value of @ref FLASHEx_WRP_State */ - uint32_t WRPSector; /*!< WRPSector: specifies the sector(s) to be write protected + uint32_t WRPSector; /*!< Specifies the sector(s) to be write protected. The value of this parameter depend on device used within the same series */ - uint32_t Banks; /*!< Banks: Select banks for WRP activation/deactivation of all sectors + uint32_t Banks; /*!< Select banks for WRP activation/deactivation of all sectors. This parameter must be a value of @ref FLASHEx_Banks */ - uint32_t RDPLevel; /*!< RDPLevel: Set the read protection level.. + uint32_t RDPLevel; /*!< Set the read protection level. This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */ - uint32_t BORLevel; /*!< BORLevel: Set the BOR Level. + uint32_t BORLevel; /*!< Set the BOR Level. This parameter can be a value of @ref FLASHEx_BOR_Reset_Level */ - uint8_t USERConfig; /*!< USERConfig: Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. - This parameter can be a combination of @ref FLASHEx_Option_Bytes_IWatchdog, @ref FLASHEx_Option_Bytes_nRST_STOP and @ref FLASHEx_Option_Bytes_nRST_STDBY*/ + uint8_t USERConfig; /*!< Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. */ } FLASH_OBProgramInitTypeDef; @@ -112,27 +111,27 @@ typedef struct #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F401xC) || defined(STM32F401xE) typedef struct { - uint32_t OptionType; /*!< OptionType: Option byte to be configured for extension . + uint32_t OptionType; /*!< Option byte to be configured for extension. This parameter can be a value of @ref FLASHEx_Advanced_Option_Type */ - uint32_t PCROPState; /*!< PCROPState: PCROP activation or deactivation. + uint32_t PCROPState; /*!< PCROP activation or deactivation. This parameter can be a value of @ref FLASHEx_PCROP_State */ #if defined (STM32F401xC) || defined (STM32F401xE) - uint16_t Sectors; /*!< Sectors: specifies the sector(s) set for PCROP + uint16_t Sectors; /*!< specifies the sector(s) set for PCROP. This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ #endif /* STM32F401xC || STM32F401xE */ #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) - uint32_t Banks; /*!< Banks: Select banks for PCROP activation/deactivation of all sectors + uint32_t Banks; /*!< Select banks for PCROP activation/deactivation of all sectors. This parameter must be a value of @ref FLASHEx_Banks */ - uint16_t SectorsBank1; /*!< SectorsBank1: specifies the sector(s) set for PCROP for Bank1 + uint16_t SectorsBank1; /*!< Specifies the sector(s) set for PCROP for Bank1. This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ - uint16_t SectorsBank2; /*!< SectorsBank2: specifies the sector(s) set for PCROP for Bank2 + uint16_t SectorsBank2; /*!< Specifies the sector(s) set for PCROP for Bank2. This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ - uint8_t BootConfig; /*!< BootConfig: specifies Option bytes for boot config + uint8_t BootConfig; /*!< Specifies Option bytes for boot config. This parameter can be a value of @ref FLASHEx_Dual_Boot */ #endif /*STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.c index 65080d7d4e..12440951f1 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.c @@ -2,18 +2,18 @@ ****************************************************************************** * @file stm32f4xx_hal_gpio.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief GPIO HAL module driver. * This file provides firmware functions to manage the following * functionalities of the General Purpose Input/Output (GPIO) peripheral: * + Initialization and de-initialization functions * + IO operation functions - * + * @verbatim ============================================================================== ##### GPIO Peripheral features ##### - ============================================================================== + ============================================================================== [..] (+) Each port bit of the general-purpose I/O (GPIO) ports can be individually configured by software in several modes: @@ -22,7 +22,7 @@ (++) Output mode (++) Alternate function mode (++) External interrupt/event lines - + (+) During and just after reset, the alternate functions and external interrupt lines are not active and the I/O ports are configured in input floating mode. @@ -31,27 +31,27 @@ (+) In Output or Alternate mode, each IO can be configured on open-drain or push-pull type and the IO speed can be selected depending on the VDD value. - + (+) The microcontroller IO pins are connected to onboard peripherals/modules through a multiplexer that allows only one peripheral alternate function (AF) connected to an IO pin at a time. In this way, there can be no conflict between peripherals sharing the same IO pin. - + (+) All ports have external interrupt/event capability. To use external interrupt lines, the port must be configured in input mode. All available GPIO pins are connected to the 16 external interrupt/event lines from EXTI0 to EXTI15. - + (+) The external interrupt/event controller consists of up to 23 edge detectors (16 lines are connected to GPIO) for generating event/interrupt requests (each input line can be independently configured to select the type (interrupt or event) and the corresponding trigger event (rising or falling or both). Each line can also be masked independently. - + ##### How to use this driver ##### ============================================================================== - [..] + [..] (#) Enable the GPIO AHB clock using the following function: __GPIOx_CLK_ENABLE(). - + (#) Configure the GPIO pin(s) using HAL_GPIO_Init(). (++) Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure (++) Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef @@ -65,7 +65,7 @@ (++) In case of external interrupt/event selection the "Mode" member from GPIO_InitTypeDef structure select the type (interrupt or event) and the corresponding trigger event (rising or falling or both). - + (#) In case of external interrupt/event mode selection, configure NVIC IRQ priority mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using HAL_NVIC_EnableIRQ(). @@ -213,14 +213,17 @@ void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init) /* Check the Alternate function parameter */ assert_param(IS_GPIO_AF(GPIO_Init->Alternate)); /* Configure Alternate function mapped with the current IO */ - temp = ((uint32_t)(GPIO_Init->Alternate) << (((uint32_t)position & (uint32_t)0x07) * 4)) ; - GPIOx->AFR[position >> 3] &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ; - GPIOx->AFR[position >> 3] |= temp; + temp = GPIOx->AFR[position >> 3]; + temp &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ; + temp |= ((uint32_t)(GPIO_Init->Alternate) << (((uint32_t)position & (uint32_t)0x07) * 4)); + GPIOx->AFR[position >> 3] = temp; } /* Configure IO Direction mode (Input, Output, Alternate or Analog) */ - GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (position * 2)); - GPIOx->MODER |= ((GPIO_Init->Mode & GPIO_MODE) << (position * 2)); + temp = GPIOx->MODER; + temp &= ~(GPIO_MODER_MODER0 << (position * 2)); + temp |= ((GPIO_Init->Mode & GPIO_MODE) << (position * 2)); + GPIOx->MODER = temp; /* In case of Output or Alternate function mode selection */ if((GPIO_Init->Mode == GPIO_MODE_OUTPUT_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_PP) || @@ -229,18 +232,23 @@ void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init) /* Check the Speed parameter */ assert_param(IS_GPIO_SPEED(GPIO_Init->Speed)); /* Configure the IO Speed */ - GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (position * 2)); - GPIOx->OSPEEDR |= (GPIO_Init->Speed << (position * 2)); + temp = GPIOx->OSPEEDR; + temp &= ~(GPIO_OSPEEDER_OSPEEDR0 << (position * 2)); + temp |= (GPIO_Init->Speed << (position * 2)); + GPIOx->OSPEEDR = temp; /* Configure the IO Output Type */ - GPIOx->OTYPER &= ~(GPIO_OTYPER_OT_0 << position) ; - GPIOx->OTYPER |= (((GPIO_Init->Mode & GPIO_OUTPUT_TYPE) >> 4) << position); + temp = GPIOx->OTYPER; + temp &= ~(GPIO_OTYPER_OT_0 << position) ; + temp |= (((GPIO_Init->Mode & GPIO_OUTPUT_TYPE) >> 4) << position); + GPIOx->OTYPER = temp; } /* Activate the Pull-up or Pull down resistor for the current IO */ - GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << (position * 2)); - GPIOx->PUPDR |= ((GPIO_Init->Pull) << (position * 2)); - + temp = GPIOx->PUPDR; + temp &= ~(GPIO_PUPDR_PUPDR0 << (position * 2)); + temp |= ((GPIO_Init->Pull) << (position * 2)); + GPIOx->PUPDR = temp; /*--------------------- EXTI Mode Configuration ------------------------*/ /* Configure the External Interrupt or event for the current IO */ @@ -249,35 +257,44 @@ void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init) /* Enable SYSCFG Clock */ __SYSCFG_CLK_ENABLE(); - temp = ((uint32_t)0x0F) << (4 * (position & 0x03)); - SYSCFG->EXTICR[position >> 2] &= ~temp; - SYSCFG->EXTICR[position >> 2] |= ((uint32_t)(__HAL_GET_GPIO_SOURCE(GPIOx)) << (4 * (position & 0x03))); - - /* Clear EXTI line configuration */ - EXTI->IMR &= ~((uint32_t)iocurrent); - EXTI->EMR &= ~((uint32_t)iocurrent); + temp = SYSCFG->EXTICR[position >> 2]; + temp &= ~(((uint32_t)0x0F) << (4 * (position & 0x03))); + temp |= ((uint32_t)(__HAL_GET_GPIO_SOURCE(GPIOx)) << (4 * (position & 0x03))); + SYSCFG->EXTICR[position >> 2] = temp; + /* Clear EXTI line configuration */ + temp = EXTI->IMR; + temp &= ~((uint32_t)iocurrent); if((GPIO_Init->Mode & GPIO_MODE_IT) == GPIO_MODE_IT) { - EXTI->IMR |= iocurrent; + temp |= iocurrent; } + EXTI->IMR = temp; + + temp = EXTI->EMR; + temp &= ~((uint32_t)iocurrent); if((GPIO_Init->Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT) { - EXTI->EMR |= iocurrent; + temp |= iocurrent; } + EXTI->EMR = temp; /* Clear Rising Falling edge configuration */ - EXTI->RTSR &= ~((uint32_t)iocurrent); - EXTI->FTSR &= ~((uint32_t)iocurrent); - + temp = EXTI->RTSR; + temp &= ~((uint32_t)iocurrent); if((GPIO_Init->Mode & RISING_EDGE) == RISING_EDGE) { - EXTI->RTSR |= iocurrent; + temp |= iocurrent; } + EXTI->RTSR = temp; + + temp = EXTI->FTSR; + temp &= ~((uint32_t)iocurrent); if((GPIO_Init->Mode & FALLING_EDGE) == FALLING_EDGE) { - EXTI->FTSR |= iocurrent; + temp |= iocurrent; } + EXTI->FTSR = temp; } } } @@ -324,7 +341,6 @@ void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin) /* Deactivate the Pull-up oand Pull-down resistor for the current IO */ GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << (position * 2)); - /*------------------------- EXTI Mode Configuration --------------------*/ /* Configure the External Interrupt or event for the current IO */ tmp = ((uint32_t)0x0F) << (4 * (position & 0x03)); @@ -396,8 +412,8 @@ GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) * This parameter can be one of GPIO_PIN_x where x can be (0..15). * @param PinState: specifies the value to be written to the selected bit. * This parameter can be one of the GPIO_PinState enum values: - * @arg GPIO_BIT_RESET: to clear the port pin - * @arg GPIO_BIT_SET: to set the port pin + * @arg GPIO_PIN_RESET: to clear the port pin + * @arg GPIO_PIN_SET: to set the port pin * @retval None */ void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState) @@ -431,6 +447,45 @@ void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) GPIOx->ODR ^= GPIO_Pin; } +/** + * @brief Locks GPIO Pins configuration registers. + * @note The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR, + * GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH. + * @note The configuration of the locked GPIO pins can no longer be modified + * until the next reset. + * @param GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F4 family + * @param GPIO_Pin: specifies the port bit to be locked. + * This parameter can be any combination of GPIO_PIN_x where x can be (0..15). + * @retval None + */ +HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) +{ + __IO uint32_t tmp = GPIO_LCKR_LCKK; + + /* Check the parameters */ + assert_param(IS_GPIO_PIN(GPIO_Pin)); + + /* Apply lock key write sequence */ + tmp |= GPIO_Pin; + /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */ + GPIOx->LCKR = tmp; + /* Reset LCKx bit(s): LCKK='0' + LCK[15-0] */ + GPIOx->LCKR = GPIO_Pin; + /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */ + GPIOx->LCKR = tmp; + /* Read LCKK bit*/ + tmp = GPIOx->LCKR; + + if(GPIOx->LCKR & GPIO_LCKR_LCKK) + { + return HAL_OK; + } + else + { + return HAL_ERROR; + } +} + /** * @brief This function handles EXTI interrupt request. * @param GPIO_Pin: Specifies the pins connected EXTI line diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.h index ff0dd3c619..7513307c93 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_gpio.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of GPIO HAL module. ****************************************************************************** * @attention @@ -73,7 +73,7 @@ typedef struct uint32_t Speed; /*!< Specifies the speed for the selected pins. This parameter can be a value of @ref GPIO_speed_define */ - uint32_t Alternate; /*!< Peripheral to be connected to the selected pins + uint32_t Alternate; /*!< Peripheral to be connected to the selected pins. This parameter can be a value of @ref GPIO_Alternat_function_selection */ }GPIO_InitTypeDef; @@ -177,7 +177,6 @@ typedef enum /** * @} */ - /** @defgroup GPIO_speed_define * @brief GPIO Output Maximum frequency * @{ @@ -216,7 +215,7 @@ typedef enum /** * @brief Checks whether the specified EXTI line flag is set or not. * @param __EXTI_LINE__: specifies the EXTI line flag to check. - * This parameter can be EXTI_Linex where x can be(0..15) + * This parameter can be GPIO_PIN_x where x can be(0..15) * @retval The new state of __EXTI_LINE__ (SET or RESET). */ #define __HAL_GPIO_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__)) @@ -224,7 +223,7 @@ typedef enum /** * @brief Clears the EXTI's line pending flags. * @param __EXTI_LINE__: specifies the EXTI lines flags to clear. - * This parameter can be any combination of EXTI_Linex where x can be (0..15) + * This parameter can be any combination of GPIO_PIN_x where x can be (0..15) * @retval None */ #define __HAL_GPIO_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__)) @@ -232,7 +231,7 @@ typedef enum /** * @brief Checks whether the specified EXTI line is asserted or not. * @param __EXTI_LINE__: specifies the EXTI line to check. - * This parameter can be EXTI_Linex where x can be(0..15) + * This parameter can be GPIO_PIN_x where x can be(0..15) * @retval The new state of __EXTI_LINE__ (SET or RESET). */ #define __HAL_GPIO_EXTI_GET_IT(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__)) @@ -240,7 +239,7 @@ typedef enum /** * @brief Clears the EXTI's line pending bits. * @param __EXTI_LINE__: specifies the EXTI lines to clear. - * This parameter can be any combination of EXTI_Linex where x can be (0..15) + * This parameter can be any combination of GPIO_PIN_x where x can be (0..15) * @retval None */ #define __HAL_GPIO_EXTI_CLEAR_IT(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__)) @@ -255,10 +254,11 @@ void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin); /* IO operation functions *******************************************************/ GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); -void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState); -void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); -void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin); -void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin); +void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState); +void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); +HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); +void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin); +void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin); /** * @} diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio_ex.h index b52791f938..5878cf77b6 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_gpio_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of GPIO HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.c index 95d64784f0..7ee3eb7d0a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hash.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief HASH HAL module driver. * This file provides firmware functions to manage the following * functionalities of the HASH peripheral: @@ -148,7 +148,8 @@ static void HASH_WriteData(uint8_t *pInBuffer, uint32_t Size); /** * @brief Initializes the HASH according to the specified parameters in the HASH_HandleTypeDef and creates the associated handle. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval HAL status */ HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash) @@ -192,7 +193,8 @@ HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash) /** * @brief DeInitializes the HASH peripheral. * @note This API must be called before starting a new processing. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval HAL status */ HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash) @@ -229,7 +231,8 @@ HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash) /** * @brief Initializes the HASH MSP. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval None */ __weak void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash) @@ -241,7 +244,8 @@ __weak void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash) /** * @brief DeInitializes HASH MSP. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval None */ __weak void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash) @@ -253,7 +257,8 @@ __weak void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash) /** * @brief Input data transfer complete callback. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval None */ __weak void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash) @@ -265,7 +270,8 @@ __weak void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash) /** * @brief Data transfer Error callback. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval None */ __weak void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash) @@ -278,7 +284,8 @@ __weak void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash) /** * @brief Digest computation complete callback. It is used only with interrupt. * @note This callback is not relevant with DMA. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval None */ __weak void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash) @@ -311,9 +318,9 @@ __weak void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash) /** * @brief Initializes the HASH peripheral in MD5 mode then processes pInBuffer. The digest is available in pOutBuffer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). - * @param pOutBuffer: Pointer to the Output buffer (hashed buffer). * @param Size: Length of the input buffer in bytes. * If the Size is multiple of 64 bytes, appending the input buffer is possible. * If the Size is not multiple of 64 bytes, the padding is managed by hardware @@ -388,7 +395,8 @@ HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuff /** * @brief Initializes the HASH peripheral in MD5 mode then writes the pInBuffer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is multiple of 64 bytes, appending the input buffer is possible. @@ -434,9 +442,9 @@ HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pI /** * @brief Initializes the HASH peripheral in SHA1 mode then processes pInBuffer. The digest is available in pOutBuffer. - * @param hhash: HASH handle - * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). - * @param pOutBuffer: Pointer to the Output buffer (hashed buffer). + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module + * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. @@ -510,7 +518,8 @@ HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuf /** * @brief Initializes the HASH peripheral in SHA1 mode then processes pInBuffer. The digest is available in pOutBuffer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -575,8 +584,8 @@ HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *p /** * @brief Initializes the HASH peripheral in MD5 mode then processes pInBuffer. * The digest is available in pOutBuffer. - * @param hhash: HASH handle - * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pOutBuffer: Pointer to the Output buffer (hashed buffer). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -727,9 +736,9 @@ HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInB /** * @brief Initializes the HASH peripheral in SHA1 mode then processes pInBuffer. * The digest is available in pOutBuffer. - * @param hhash: HASH handle - * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). - * @param pOutBuffer: Pointer to the Output buffer (hashed buffer). + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module + * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. @@ -880,7 +889,8 @@ HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pIn /** * @brief This function handles HASH interrupt request. - * @param hhash: hash handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval None */ void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash) @@ -923,11 +933,11 @@ void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash) /** * @brief Initializes the HASH peripheral in MD5 mode then enables DMA to control data transfer. Use HAL_HASH_MD5_Finish() to get the digest. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. - * @param pOutBuffer: Pointer to the computed digest. Its size must be 16 bytes. * @retval HAL status */ HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) @@ -974,7 +984,8 @@ HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pIn /** * @brief Returns the computed digest in MD5 mode - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pOutBuffer: Pointer to the computed digest. Its size must be 16 bytes. * @param Timeout: Timeout value * @retval HAL status @@ -1026,11 +1037,11 @@ HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBu /** * @brief Initializes the HASH peripheral in SHA1 mode then enables DMA to control data transfer. Use HAL_HASH_SHA1_Finish() to get the digest. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. - * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. * @retval HAL status */ HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) @@ -1078,7 +1089,8 @@ HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pI /** * @brief Returns the computed digest in SHA1 mode. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. * @param Timeout: Timeout value * @retval HAL status @@ -1150,7 +1162,8 @@ HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutB /** * @brief Initializes the HASH peripheral in HMAC MD5 mode * then processes pInBuffer. The digest is available in pOutBuffer - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -1294,7 +1307,8 @@ HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuff /** * @brief Initializes the HASH peripheral in HMAC SHA1 mode * then processes pInBuffer. The digest is available in pOutBuffer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -1460,7 +1474,8 @@ HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuf /** * @brief Initializes the HASH peripheral in HMAC MD5 mode * then enables DMA to control data transfer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -1526,7 +1541,8 @@ HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pIn /** * @brief Initializes the HASH peripheral in HMAC SHA1 mode * then enables DMA to control data transfer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -1609,7 +1625,8 @@ HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pI /** * @brief return the HASH state - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval HAL state */ HAL_HASH_STATETypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h index e49d1e0dc0..85f3240437 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hash.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of HASH HAL module. ****************************************************************************** * @attention @@ -33,7 +33,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** - */ + */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_HASH_H @@ -56,72 +56,68 @@ * @{ */ -/* Exported types ------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ /** - * @brief HASH Configuration Structure definition + * @brief HASH Configuration Structure definition */ typedef struct -{ +{ uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. This parameter can be a value of @ref HASH_Data_Type */ - + uint32_t KeySize; /*!< The key size is used only in HMAC operation */ - + uint8_t* pKey; /*!< The key is used only in HMAC operation */ - }HASH_InitTypeDef; /** - * @brief HAL State structures definition + * @brief HAL State structures definition */ typedef enum { HAL_HASH_STATE_RESET = 0x00, /*!< HASH not yet initialized or disabled */ - HAL_HASH_STATE_READY = 0x01, /*!< HASH initialized and ready for use */ - HAL_HASH_STATE_BUSY = 0x02, /*!< HASH internal process is ongoing */ + HAL_HASH_STATE_READY = 0x01, /*!< HASH initialized and ready for use */ + HAL_HASH_STATE_BUSY = 0x02, /*!< HASH internal process is ongoing */ HAL_HASH_STATE_TIMEOUT = 0x03, /*!< HASH timeout state */ HAL_HASH_STATE_ERROR = 0x04 /*!< HASH error state */ - }HAL_HASH_STATETypeDef; /** - * @brief HAL phase structures definition - */ + * @brief HAL phase structures definition + */ typedef enum { HAL_HASH_PHASE_READY = 0x01, /*!< HASH peripheral is ready for initialization */ HAL_HASH_PHASE_PROCESS = 0x02, /*!< HASH peripheral is in processing phase */ - }HAL_HASHPhaseTypeDef; /** - * @brief HASH Handle Structure definition - */ + * @brief HASH Handle Structure definition + */ typedef struct -{ +{ HASH_InitTypeDef Init; /*!< HASH required parameters */ - + uint8_t *pHashInBuffPtr; /*!< Pointer to input buffer */ - + uint8_t *pHashOutBuffPtr; /*!< Pointer to input buffer */ - + __IO uint32_t HashBuffSize; /*!< Size of buffer to be processed */ - + __IO uint32_t HashInCount; /*!< Counter of inputed data */ - + __IO uint32_t HashITCounter; /*!< Counter of issued interrupts */ - + HAL_StatusTypeDef Status; /*!< HASH peripheral status */ - + HAL_HASHPhaseTypeDef Phase; /*!< HASH peripheral phase */ - + DMA_HandleTypeDef *hdmain; /*!< HASH In DMA handle parameters */ - + HAL_LockTypeDef Lock; /*!< HASH locking object */ - + __IO HAL_HASH_STATETypeDef State; /*!< HASH peripheral state */ - } HASH_HandleTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -130,9 +126,9 @@ typedef struct * @{ */ -/** @defgroup HASH_Algo_Selection +/** @defgroup HASH_Algo_Selection * @{ - */ + */ #define HASH_AlgoSelection_SHA1 ((uint32_t)0x0000) /*!< HASH function is SHA1 */ #define HASH_AlgoSelection_SHA224 HASH_CR_ALGO_1 /*!< HASH function is SHA224 */ #define HASH_AlgoSelection_SHA256 HASH_CR_ALGO /*!< HASH function is SHA256 */ @@ -146,7 +142,7 @@ typedef struct * @} */ -/** @defgroup HASH_Algorithm_Mode +/** @defgroup HASH_Algorithm_Mode * @{ */ #define HASH_AlgoMode_HASH ((uint32_t)0x00000000) /*!< Algorithm is HASH */ @@ -158,9 +154,9 @@ typedef struct * @} */ -/** @defgroup HASH_Data_Type +/** @defgroup HASH_Data_Type * @{ - */ + */ #define HASH_DATATYPE_32B ((uint32_t)0x0000) /*!< 32-bit data. No swapping */ #define HASH_DATATYPE_16B HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */ #define HASH_DATATYPE_8B HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */ @@ -174,7 +170,7 @@ typedef struct * @} */ -/** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode +/** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode * @{ */ #define HASH_HMACKeyType_ShortKey ((uint32_t)0x00000000) /*!< HMAC Key is <= 64 bytes */ @@ -186,9 +182,9 @@ typedef struct * @} */ -/** @defgroup HASH_flags_definition +/** @defgroup HASH_flags_definition * @{ - */ + */ #define HASH_FLAG_DINIS HASH_SR_DINIS /*!< 16 locations are free in the DIN : A new block can be entered into the input buffer */ #define HASH_FLAG_DCIS HASH_SR_DCIS /*!< Digest calculation complete */ #define HASH_FLAG_DMAS HASH_SR_DMAS /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing */ @@ -196,9 +192,9 @@ typedef struct #define HASH_FLAG_DINNE HASH_CR_DINNE /*!< DIN not empty : The input buffer contains at least one word of data */ /** * @} - */ + */ -/** @defgroup HASH_interrupts_definition +/** @defgroup HASH_interrupts_definition * @{ */ #define HASH_IT_DINI HASH_IMR_DINIM /*!< A new block can be entered into the input buffer (DIN) */ @@ -213,6 +209,12 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset HASH handle state + * @param __HANDLE__: specifies the HASH handle. + * @retval None + */ +#define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET) + /** @brief Check whether the specified HASH flag is set or not. * @param __FLAG__: specifies the flag to check. * This parameter can be one of the following values: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.c index 4a64c23606..358a459882 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hash_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief HASH HAL Extension module driver. * This file provides firmware functions to manage the following * functionalities of HASH peripheral: @@ -143,9 +143,9 @@ static void HASHEx_DMAError(DMA_HandleTypeDef *hdma); /** * @brief Initializes the HASH peripheral in SHA224 mode * then processes pInBuffer. The digest is available in pOutBuffer - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). - * @param pOutBuffer: Pointer to the output buffer (hashed buffer). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. * @param pOutBuffer: Pointer to the computed digest. Its size must be 28 bytes. @@ -219,9 +219,9 @@ HAL_StatusTypeDef HAL_HASHEx_SHA224_Start(HASH_HandleTypeDef *hhash, uint8_t *pI /** * @brief Initializes the HASH peripheral in SHA256 mode then processes pInBuffer. The digest is available in pOutBuffer. - * @param hhash: HASH handle - * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). - * @param pOutBuffer: Pointer to the output buffer (hashed buffer). + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module + * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. * @param pOutBuffer: Pointer to the computed digest. Its size must be 32 bytes. @@ -296,7 +296,8 @@ HAL_StatusTypeDef HAL_HASHEx_SHA256_Start(HASH_HandleTypeDef *hhash, uint8_t *pI /** * @brief Initializes the HASH peripheral in SHA224 mode * then processes pInBuffer. The digest is available in pOutBuffer - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -341,7 +342,8 @@ HAL_StatusTypeDef HAL_HASHEx_SHA224_Accumulate(HASH_HandleTypeDef *hhash, uint8_ /** * @brief Initializes the HASH peripheral in SHA256 mode then processes pInBuffer. The digest is available in pOutBuffer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -406,9 +408,9 @@ HAL_StatusTypeDef HAL_HASHEx_SHA256_Accumulate(HASH_HandleTypeDef *hhash, uint8_ /** * @brief Initializes the HASH peripheral in HMAC SHA224 mode * then processes pInBuffer. The digest is available in pOutBuffer. - * @param hhash: HASH handle - * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). - * @param pOutBuffer: Pointer to the output buffer (hashed buffer). + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module + * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. @@ -549,9 +551,9 @@ HAL_StatusTypeDef HAL_HMACEx_SHA224_Start(HASH_HandleTypeDef *hhash, uint8_t *pI /** * @brief Initializes the HASH peripheral in HMAC SHA256 mode * then processes pInBuffer. The digest is available in pOutBuffer - * @param hhash: HASH handle - * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). - * @param pOutBuffer: Pointer to the output buffer (hashed buffer). + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module + * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. @@ -715,7 +717,8 @@ HAL_StatusTypeDef HAL_HMACEx_SHA256_Start(HASH_HandleTypeDef *hhash, uint8_t *pI /** * @brief Initializes the HASH peripheral in SHA224 mode then processes pInBuffer. * The digest is available in pOutBuffer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -858,7 +861,8 @@ HAL_StatusTypeDef HAL_HASHEx_SHA224_Start_IT(HASH_HandleTypeDef *hhash, uint8_t /** * @brief Initializes the HASH peripheral in SHA256 mode then processes pInBuffer. * The digest is available in pOutBuffer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -1000,7 +1004,8 @@ HAL_StatusTypeDef HAL_HASHEx_SHA256_Start_IT(HASH_HandleTypeDef *hhash, uint8_t /** * @brief This function handles HASH interrupt request. - * @param hhash: hash handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @retval None */ void HAL_HASHEx_IRQHandler(HASH_HandleTypeDef *hhash) @@ -1045,11 +1050,11 @@ void HAL_HASHEx_IRQHandler(HASH_HandleTypeDef *hhash) /** * @brief Initializes the HASH peripheral in SHA224 mode then enables DMA to control data transfer. Use HAL_HASH_SHA224_Finish() to get the digest. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. - * @param pOutBuffer: Pointer to the computed digest. Its size must be 28 bytes. * @retval HAL status */ HAL_StatusTypeDef HAL_HASHEx_SHA224_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) @@ -1096,8 +1101,10 @@ HAL_StatusTypeDef HAL_HASHEx_SHA224_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t /** * @brief Returns the computed digest in SHA224 - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pOutBuffer: Pointer to the computed digest. Its size must be 28 bytes. + * @param Timeout: Timeout value * @retval HAL status */ HAL_StatusTypeDef HAL_HASHEx_SHA224_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout) @@ -1147,11 +1154,11 @@ HAL_StatusTypeDef HAL_HASHEx_SHA224_Finish(HASH_HandleTypeDef *hhash, uint8_t* p /** * @brief Initializes the HASH peripheral in SHA256 mode then enables DMA to control data transfer. Use HAL_HASH_SHA256_Finish() to get the digest. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. - * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. * @retval HAL status */ HAL_StatusTypeDef HAL_HASHEx_SHA256_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) @@ -1198,8 +1205,10 @@ HAL_StatusTypeDef HAL_HASHEx_SHA256_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t /** * @brief Returns the computed digest in SHA256. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pOutBuffer: Pointer to the computed digest. Its size must be 32 bytes. + * @param Timeout: Timeout value * @retval HAL status */ HAL_StatusTypeDef HAL_HASHEx_SHA256_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout) @@ -1269,7 +1278,8 @@ HAL_StatusTypeDef HAL_HASHEx_SHA256_Finish(HASH_HandleTypeDef *hhash, uint8_t* p /** * @brief Initializes the HASH peripheral in HMAC SHA224 mode * then enables DMA to control data transfer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. @@ -1335,7 +1345,8 @@ HAL_StatusTypeDef HAL_HMACEx_SHA224_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t /** * @brief Initializes the HASH peripheral in HMAC SHA256 mode * then enables DMA to control data transfer. - * @param hhash: HASH handle + * @param hhash: pointer to a HASH_HandleTypeDef structure that contains + * the configuration information for HASH module * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). * @param Size: Length of the input buffer in bytes. * If the Size is not multiple of 64 bytes, the padding is managed by hardware. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.h index 34385971bb..026a3715ea 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hash_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of HASH HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c index 8ea7000070..c3cc496572 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hcd.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief HCD HAL module driver. * This file provides firmware functions to manage the following * functionalities of the USB Peripheral Controller: @@ -25,9 +25,9 @@ (#)Call HAL_HCD_Init() API to initialize the HCD peripheral (Core, Host core, ...) (#)Initialize the HCD low level resources through the HAL_HCD_MspInit() API: - (##) Enable the HCD/USB Low Level interface clock using - (+++) __OTGFS-OTG_CLK_ENABLE()/__OTGHS-OTG_CLK_ENABLE(); - (+++) __OTGHSULPI_CLK_ENABLE(); (For High Speed Mode) + (##) Enable the HCD/USB Low Level interface clock using the following macros + (+++) __OTGFS-OTG_CLK_ENABLE() or __OTGHS-OTG_CLK_ENABLE() + (+++) __OTGHSULPI_CLK_ENABLE() For High Speed Mode (##) Initialize the related GPIO clocks (##) Configure HCD pin-out @@ -113,8 +113,8 @@ static void HCD_Port_IRQHandler(HCD_HandleTypeDef *hhcd); /** * @brief Initialize the host driver - * @param hhcd : HCD handle - * @retval HAL state + * @param hhcd: HCD handle + * @retval HAL status */ HAL_StatusTypeDef HAL_HCD_Init(HCD_HandleTypeDef *hhcd) { @@ -151,27 +151,27 @@ HAL_StatusTypeDef HAL_HCD_Init(HCD_HandleTypeDef *hhcd) /** * @brief Initialize a host channel - * @param hhcd : HCD handle - * @param ch_num : Channel number + * @param hhcd: HCD handle + * @param ch_num: Channel number. * This parameter can be a value from 1 to 15 - * @param epnum : Endpoint number + * @param epnum: Endpoint number. * This parameter can be a value from 1 to 15 * @param dev_address : Current device address * This parameter can be a value from 0 to 255 - * @param speed : Current device speed - * This parameter can be one of the these values: - * @arg HCD_SPEED_HIGH: High speed mode - * @arg HCD_SPEED_FULL: Full speed mode - * @arg HCD_SPEED_LOW: Low speed mode - * @param ep_type : Endpoint Type - * This parameter can be one of the these values: - * @arg EP_TYPE_CTRL: Control type - * @arg EP_TYPE_ISOC: Isochrounous type - * @arg EP_TYPE_BULK: Bulk type - * @arg EP_TYPE_INTR: Interrupt type - * @param mps : Max Packet Size + * @param speed: Current device speed. + * This parameter can be one of these values: + * HCD_SPEED_HIGH: High speed mode, + * HCD_SPEED_FULL: Full speed mode, + * HCD_SPEED_LOW: Low speed mode + * @param ep_type: Endpoint Type. + * This parameter can be one of these values: + * EP_TYPE_CTRL: Control type, + * EP_TYPE_ISOC: Isochrounous type, + * EP_TYPE_BULK: Bulk type, + * EP_TYPE_INTR: Interrupt type + * @param mps: Max Packet Size. * This parameter can be a value from 0 to32K - * @retval HAL state + * @retval HAL status */ HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd, uint8_t ch_num, @@ -209,10 +209,10 @@ HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd, /** * @brief Halt a host channel - * @param hhcd : HCD handle - * @param ch_num : Channel number + * @param hhcd: HCD handle + * @param ch_num: Channel number. * This parameter can be a value from 1 to 15 - * @retval HAL state + * @retval HAL status */ HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd, uint8_t ch_num) @@ -227,8 +227,8 @@ HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd, } /** * @brief DeInitialize the host driver - * @param hhcd : HCD handle - * @retval HAL state + * @param hhcd: HCD handle + * @retval HAL status */ HAL_StatusTypeDef HAL_HCD_DeInit(HCD_HandleTypeDef *hhcd) { @@ -294,30 +294,27 @@ __weak void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhhcd) /** * @brief Submit a new URB for processing - * @param hhcd : HCD handle - * @param ch_num : Channel number + * @param hhcd: HCD handle + * @param ch_num: Channel number. * This parameter can be a value from 1 to 15 - * @param direction : Channel number - * This parameter can be one of the these values: - * 0 : Output - * 1 : Input - * @param ep_type : Endpoint Type - * This parameter can be one of the these values: - * @arg EP_TYPE_CTRL: Control type - * @arg EP_TYPE_ISOC: Isochrounous type - * @arg EP_TYPE_BULK: Bulk type - * @arg EP_TYPE_INTR: Interrupt type - * @param token : Endpoint Type - * This parameter can be one of the these values: - * @arg 0: HC_PID_SETUP - * @arg 1: HC_PID_DATA1 - * @param pbuff : pointer to URB data - * @param length : Length of URB data - * @param do_ping : activate do ping protocol (for high speed only) - * This parameter can be one of the these values: - * 0 : do ping inactive - * 1 : do ping active - * @retval HAL state + * @param direction: Channel number. + * This parameter can be one of these values: + * 0 : Output / 1 : Input + * @param ep_type: Endpoint Type. + * This parameter can be one of these values: + * EP_TYPE_CTRL: Control type/ + * EP_TYPE_ISOC: Isochrounous type/ + * EP_TYPE_BULK: Bulk type/ + * EP_TYPE_INTR: Interrupt type/ + * @param token: Endpoint Type. + * This parameter can be one of these values: + * 0: HC_PID_SETUP / 1: HC_PID_DATA1 + * @param pbuff: pointer to URB data + * @param length: Length of URB data + * @param do_ping: activate do ping protocol (for high speed only). + * This parameter can be one of these values: + * 0 : do ping inactive / 1 : do ping active + * @retval HAL status */ HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd, uint8_t ch_num, @@ -442,7 +439,7 @@ HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd, /** * @brief This function handles HCD interrupt request. * @param hhcd: HCD handle - * @retval none + * @retval None */ void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd) { @@ -583,16 +580,16 @@ __weak void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) /** * @brief Notify URB state change callback. * @param hhcd: HCD handle - * @param chnum : Channel number + * @param chnum: Channel number. * This parameter can be a value from 1 to 15 * @param urb_state: - * This parameter can be one of the these values: - * @arg URB_IDLE - * @arg URB_DONE - * @arg URB_NOTREADY - * @arg URB_NYET - * @arg URB_ERROR - * @arg URB_STALL + * This parameter can be one of these values: + * URB_IDLE/ + * URB_DONE/ + * URB_NOTREADY/ + * URB_NYET/ + * URB_ERROR/ + * URB_STALL/ * @retval None */ __weak void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) @@ -623,8 +620,8 @@ __weak void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t /** * @brief Start the host driver - * @param hhcd : HCD handle - * @retval HAL state + * @param hhcd: HCD handle + * @retval HAL status */ HAL_StatusTypeDef HAL_HCD_Start(HCD_HandleTypeDef *hhcd) { @@ -637,8 +634,8 @@ HAL_StatusTypeDef HAL_HCD_Start(HCD_HandleTypeDef *hhcd) /** * @brief Stop the host driver - * @param hhcd : HCD handle - * @retval HAL state + * @param hhcd: HCD handle + * @retval HAL status */ HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd) @@ -651,8 +648,8 @@ HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd) /** * @brief Reset the host port - * @param hhcd : HCD handle - * @retval HAL state + * @param hhcd: HCD handle + * @retval HAL status */ HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd) { @@ -671,7 +668,7 @@ HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd) ##### Peripheral State functions ##### =============================================================================== [..] - This subsection permit to get in run-time the status of the peripheral + This subsection permits to get in run-time the status of the peripheral and the data flow. @endverbatim @@ -680,7 +677,7 @@ HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd) /** * @brief Return the HCD state - * @param hhcd : HCD handle + * @param hhcd: HCD handle * @retval HAL state */ HCD_StateTypeDef HAL_HCD_GetState(HCD_HandleTypeDef *hhcd) @@ -690,17 +687,17 @@ HCD_StateTypeDef HAL_HCD_GetState(HCD_HandleTypeDef *hhcd) /** * @brief Return URB state for a channel - * @param hhcd : HCD handle - * @param chnum : Channel number + * @param hhcd: HCD handle + * @param chnum: Channel number. * This parameter can be a value from 1 to 15 - * @retval URB state - * This parameter can be one of the these values: - * @arg URB_IDLE - * @arg URB_DONE - * @arg URB_NOTREADY - * @arg URB_NYET - * @arg URB_ERROR - * @arg URB_STALL + * @retval URB state. + * This parameter can be one of these values: + * URB_IDLE/ + * URB_DONE/ + * URB_NOTREADY/ + * URB_NYET/ + * URB_ERROR/ + * URB_STALL */ HCD_URBStateTypeDef HAL_HCD_HC_GetURBState(HCD_HandleTypeDef *hhcd, uint8_t chnum) { @@ -710,8 +707,8 @@ HCD_URBStateTypeDef HAL_HCD_HC_GetURBState(HCD_HandleTypeDef *hhcd, uint8_t chnu /** * @brief Return the last host transfer size - * @param hhcd : HCD handle - * @param chnum : Channel number + * @param hhcd: HCD handle + * @param chnum: Channel number. * This parameter can be a value from 1 to 15 * @retval last transfer size in byte */ @@ -722,20 +719,20 @@ uint32_t HAL_HCD_HC_GetXferCount(HCD_HandleTypeDef *hhcd, uint8_t chnum) /** * @brief Return the Host Channel state - * @param hhcd : HCD handle - * @param chnum : Channel number + * @param hhcd: HCD handle + * @param chnum: Channel number. * This parameter can be a value from 1 to 15 * @retval Host channel state * This parameter can be one of the these values: - * @arg HC_IDLE - * @arg HC_XFRC - * @arg HC_HALTED - * @arg HC_NYET - * @arg HC_NAK - * @arg HC_STALL - * @arg HC_XACTERR - * @arg HC_BBLERR - * @arg HC_DATATGLERR + * HC_IDLE/ + * HC_XFRC/ + * HC_HALTED/ + * HC_NYET/ + * HC_NAK/ + * HC_STALL/ + * HC_XACTERR/ + * HC_BBLERR/ + * HC_DATATGLERR/ */ HCD_HCStateTypeDef HAL_HCD_HC_GetState(HCD_HandleTypeDef *hhcd, uint8_t chnum) { @@ -744,8 +741,8 @@ HCD_HCStateTypeDef HAL_HCD_HC_GetState(HCD_HandleTypeDef *hhcd, uint8_t chnum) /** * @brief Return the current Host frame number - * @param hhcd : HCD handle - * @retval current Host frame number + * @param hhcd: HCD handle + * @retval Current Host frame number */ uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef *hhcd) { @@ -754,7 +751,7 @@ uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef *hhcd) /** * @brief Return the Host enumeration speed - * @param hhcd : HCD handle + * @param hhcd: HCD handle * @retval Enumeration speed */ uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd) @@ -769,7 +766,7 @@ uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd) /** * @brief This function handles Host Channel IN interrupt requests. * @param hhcd: HCD handle - * @param chnum : Channel number + * @param chnum: Channel number. * This parameter can be a value from 1 to 15 * @retval none */ @@ -908,7 +905,7 @@ static void HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) /** * @brief This function handles Host Channel OUT interrupt requests. * @param hhcd: HCD handle - * @param chnum : Channel number + * @param chnum: Channel number. * This parameter can be a value from 1 to 15 * @retval none */ @@ -1100,7 +1097,7 @@ static void HCD_RXQLVL_IRQHandler (HCD_HandleTypeDef *hhcd) /** * @brief This function handles Host Port interrupt requests. * @param hhcd: HCD handle - * @retval none + * @retval None */ static void HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd) { diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.h index a4de060027..65cce1b2a5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hcd.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of HCD HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.c index 80d92c51e4..fcddc9c6d6 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2c.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief I2C HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Inter Integrated Circuit (I2C) peripheral: @@ -36,18 +36,18 @@ (+++) Configure the DMA handle parameters (+++) Configure the DMA Tx or Rx Stream (+++) Associate the initilalized DMA handle to the hi2c DMA Tx or Rx handle - (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx or Rx Stream + (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on + the DMA Tx or Rx Stream (#) Configure the Communication Speed, Duty cycle, Addressing mode, Own Address1, Dual Addressing mode, Own Address2, General call and Nostretch mode in the hi2c Init structure. - (#) Initialize the I2C registers by calling the HAL_I2C_Init() API: - (+++) These API's configures also the low level Hardware GPIO, CLOCK, CORTEX...etc) - by calling the customed HAL_I2C_MspInit(&hi2c) API. + (#) Initialize the I2C registers by calling the HAL_I2C_Init(), configures also the low level Hardware + (GPIO, CLOCK, NVIC...etc) by calling the customed HAL_I2C_MspInit(&hi2c) API. (#) To check if target device is ready for communication, use the function HAL_I2C_IsDeviceReady() - (#) For I2C IO and IO MEM operations, three mode of operations are available within this driver : + (#) For I2C IO and IO MEM operations, three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -141,9 +141,9 @@ (+) __HAL_I2C_ENABLE: Enable the I2C peripheral (+) __HAL_I2C_DISABLE: Disable the I2C peripheral (+) __HAL_I2C_GET_FLAG : Checks whether the specified I2C flag is set or not - (+) __HAL_I2C_CLEAR_FLAG : Clears the specified I2C pending flag - (+) __HAL_I2C_ENABLE_IT: Enables the specified I2C interrupt - (+) __HAL_I2C_DISABLE_IT: Disables the specified I2C interrupt + (+) __HAL_I2C_CLEAR_FLAG : Clear the specified I2C pending flag + (+) __HAL_I2C_ENABLE_IT: Enable the specified I2C interrupt + (+) __HAL_I2C_DISABLE_IT: Disable the specified I2C interrupt [..] (@) You can refer to the I2C HAL driver header file for more useful macros @@ -270,8 +270,8 @@ static HAL_StatusTypeDef I2C_Slave_AF(I2C_HandleTypeDef *hi2c); /** * @brief Initializes the I2C according to the specified parameters * in the I2C_InitTypeDef and create the associated handle. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c) @@ -348,8 +348,8 @@ HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c) /** * @brief DeInitializes the I2C peripheral. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c) @@ -383,8 +383,8 @@ HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c) /** * @brief I2C MSP Init. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval None */ __weak void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c) @@ -396,8 +396,8 @@ HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c) /** * @brief I2C MSP DeInit - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval None */ __weak void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c) @@ -422,7 +422,7 @@ HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c) This subsection provides a set of functions allowing to manage the I2C data transfers. - (#) There is two mode of transfer: + (#) There are two modes of transfer: (++) Blocking mode : The communication is performed in the polling mode. The status of all data processing is returned by the same function after finishing transfer. @@ -457,7 +457,7 @@ HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c) (++) HAL_I2C_Mem_Write_DMA() (++) HAL_I2C_Mem_Read_DMA() - (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: + (#) A set of Transfer Complete Callbacks are provided in non Blocking mode: (++) HAL_I2C_MemTxCpltCallback() (++) HAL_I2C_MemRxCpltCallback() (++) HAL_I2C_MasterTxCpltCallback() @@ -472,8 +472,8 @@ HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c) /** * @brief Transmits in master mode an amount of data in blocking mode. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent @@ -570,8 +570,8 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevA /** * @brief Receives in master mode an amount of data in blocking mode. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent @@ -762,8 +762,8 @@ HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAd /** * @brief Transmits in slave mode an amount of data in blocking mode. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @param Timeout: Timeout duration @@ -867,8 +867,8 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData /** * @brief Receive in slave mode an amount of data in blocking mode - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @param Timeout: Timeout duration @@ -959,8 +959,8 @@ HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, /** * @brief Transmit in master mode an amount of data in no-blocking mode with Interrupt - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent @@ -1030,8 +1030,8 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t D /** * @brief Receive in master mode an amount of data in no-blocking mode with Interrupt - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent @@ -1129,8 +1129,8 @@ HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t De /** * @brief Transmit in slave mode an amount of data in no-blocking mode with Interrupt - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -1182,8 +1182,8 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pD /** * @brief Receive in slave mode an amount of data in no-blocking mode with Interrupt - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -1235,8 +1235,8 @@ HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pDa /** * @brief Transmit in master mode an amount of data in no-blocking mode with DMA - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent @@ -1311,8 +1311,8 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t /** * @brief Receive in master mode an amount of data in no-blocking mode with DMA - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent @@ -1398,8 +1398,8 @@ HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t D /** * @brief Transmit in slave mode an amount of data in no-blocking mode with DMA - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -1483,8 +1483,8 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *p /** * @brief Receive in slave mode an amount of data in no-blocking mode with DMA - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -1549,8 +1549,8 @@ HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pD } /** * @brief Write an amount of data in blocking mode to a specific memory address - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param MemAddress: Internal memory address * @param MemAddSize: Size of internal memory address @@ -1649,8 +1649,8 @@ HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress /** * @brief Read an amount of data in blocking mode from a specific memory address - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param MemAddress: Internal memory address * @param MemAddSize: Size of internal memory address @@ -1842,8 +1842,8 @@ HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, } /** * @brief Write an amount of data in no-blocking mode with Interrupt to a specific memory address - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param MemAddress: Internal memory address * @param MemAddSize: Size of internal memory address @@ -1915,8 +1915,8 @@ HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddr /** * @brief Read an amount of data in no-blocking mode with Interrupt from a specific memory address - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param MemAddress: Internal memory address * @param MemAddSize: Size of internal memory address @@ -2018,8 +2018,8 @@ HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddre } /** * @brief Write an amount of data in no-blocking mode with DMA to a specific memory address - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param MemAddress: Internal memory address * @param MemAddSize: Size of internal memory address @@ -2096,8 +2096,8 @@ HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAdd /** * @brief Reads an amount of data in no-blocking mode with DMA from a specific memory address. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param MemAddress: Internal memory address * @param MemAddSize: Size of internal memory address @@ -2189,8 +2189,8 @@ HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddr /** * @brief Checks if target device is ready for communication. * @note This function is used with Memory devices - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param Trials: Number of trials * @param Timeout: Timeout duration @@ -2299,8 +2299,8 @@ HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAdd /** * @brief This function handles I2C event interrupt request. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c) @@ -2404,8 +2404,8 @@ void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c) /** * @brief This function handles I2C error interrupt request. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c) @@ -2474,8 +2474,8 @@ void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c) /** * @brief Master Tx Transfer completed callbacks. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval None */ __weak void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c) @@ -2487,8 +2487,8 @@ void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c) /** * @brief Master Rx Transfer completed callbacks. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval None */ __weak void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) @@ -2499,8 +2499,8 @@ __weak void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) } /** @brief Slave Tx Transfer completed callbacks. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval None */ __weak void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c) @@ -2512,8 +2512,8 @@ __weak void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) /** * @brief Slave Rx Transfer completed callbacks. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval None */ __weak void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c) @@ -2525,8 +2525,8 @@ __weak void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c) /** * @brief Memory Tx Transfer completed callbacks. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval None */ __weak void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c) @@ -2538,8 +2538,8 @@ __weak void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c) /** * @brief Memory Rx Transfer completed callbacks. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval None */ __weak void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) @@ -2551,8 +2551,8 @@ __weak void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) /** * @brief I2C error callbacks. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval None */ __weak void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c) @@ -2574,7 +2574,7 @@ __weak void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) ##### Peripheral State and Errors functions ##### =============================================================================== [..] - This subsection permit to get in run-time the status of the peripheral + This subsection permits to get in run-time the status of the peripheral and the data flow. @endverbatim @@ -2583,7 +2583,8 @@ __weak void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) /** * @brief Returns the I2C state. - * @param hi2c : I2C handle + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL state */ HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c) @@ -2608,8 +2609,8 @@ uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c) /** * @brief Handle TXE flag for Master - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_MasterTransmit_TXE(I2C_HandleTypeDef *hi2c) @@ -2635,8 +2636,8 @@ static HAL_StatusTypeDef I2C_MasterTransmit_TXE(I2C_HandleTypeDef *hi2c) /** * @brief Handle BTF flag for Master transmitter - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_MasterTransmit_BTF(I2C_HandleTypeDef *hi2c) @@ -2691,8 +2692,8 @@ static HAL_StatusTypeDef I2C_MasterTransmit_BTF(I2C_HandleTypeDef *hi2c) /** * @brief Handle RXNE flag for Master - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_MasterReceive_RXNE(I2C_HandleTypeDef *hi2c) @@ -2759,8 +2760,8 @@ static HAL_StatusTypeDef I2C_MasterReceive_RXNE(I2C_HandleTypeDef *hi2c) /** * @brief Handle BTF flag for Master receiver - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_MasterReceive_BTF(I2C_HandleTypeDef *hi2c) @@ -2835,8 +2836,8 @@ static HAL_StatusTypeDef I2C_MasterReceive_BTF(I2C_HandleTypeDef *hi2c) /** * @brief Handle TXE flag for Slave - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_SlaveTransmit_TXE(I2C_HandleTypeDef *hi2c) @@ -2858,8 +2859,8 @@ static HAL_StatusTypeDef I2C_SlaveTransmit_TXE(I2C_HandleTypeDef *hi2c) /** * @brief Handle BTF flag for Slave transmitter - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_SlaveTransmit_BTF(I2C_HandleTypeDef *hi2c) @@ -2881,8 +2882,8 @@ static HAL_StatusTypeDef I2C_SlaveTransmit_BTF(I2C_HandleTypeDef *hi2c) /** * @brief Handle RXNE flag for Slave - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_SlaveReceive_RXNE(I2C_HandleTypeDef *hi2c) @@ -2904,8 +2905,8 @@ static HAL_StatusTypeDef I2C_SlaveReceive_RXNE(I2C_HandleTypeDef *hi2c) /** * @brief Handle BTF flag for Slave receiver - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_SlaveReceive_BTF(I2C_HandleTypeDef *hi2c) @@ -2927,8 +2928,8 @@ static HAL_StatusTypeDef I2C_SlaveReceive_BTF(I2C_HandleTypeDef *hi2c) /** * @brief Handle ADD flag for Slave - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_Slave_ADDR(I2C_HandleTypeDef *hi2c) @@ -2946,8 +2947,8 @@ static HAL_StatusTypeDef I2C_Slave_ADDR(I2C_HandleTypeDef *hi2c) /** * @brief Handle STOPF flag for Slave - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_Slave_STOPF(I2C_HandleTypeDef *hi2c) @@ -2981,8 +2982,8 @@ static HAL_StatusTypeDef I2C_Slave_STOPF(I2C_HandleTypeDef *hi2c) } /** - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @retval HAL status */ static HAL_StatusTypeDef I2C_Slave_AF(I2C_HandleTypeDef *hi2c) @@ -3016,8 +3017,8 @@ static HAL_StatusTypeDef I2C_Slave_AF(I2C_HandleTypeDef *hi2c) } /** - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @retval HAL status */ @@ -3077,8 +3078,8 @@ static HAL_StatusTypeDef I2C_MasterRequestWrite(I2C_HandleTypeDef *hi2c, uint16_ /** * @brief Master sends target device address for read request. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @retval HAL status */ @@ -3169,8 +3170,8 @@ static HAL_StatusTypeDef I2C_MasterRequestRead(I2C_HandleTypeDef *hi2c, uint16_t /** * @brief Master sends target device address followed by internal memory address for write request. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param MemAddress: Internal memory address * @param MemAddSize: Size of internal memory address @@ -3239,8 +3240,8 @@ static HAL_StatusTypeDef I2C_RequestMemoryWrite(I2C_HandleTypeDef *hi2c, uint16_ /** * @brief Master sends target device address followed by internal memory address for read request. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param DevAddress: Target device address * @param MemAddress: Internal memory address * @param MemAddSize: Size of internal memory address @@ -3622,8 +3623,8 @@ static void I2C_DMAError(DMA_HandleTypeDef *hdma) /** * @brief This function handles I2C Communication Timeout. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param Flag: specifies the I2C flag to check. * @param Status: The new Flag status (SET or RESET). * @param Timeout: Timeout duration @@ -3679,8 +3680,8 @@ static HAL_StatusTypeDef I2C_WaitOnFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uin /** * @brief This function handles I2C Communication Timeout for Master addressing phase. - * @param hi2c : Pointer to a I2C_HandleTypeDef structure that contains - * the configuration information for the specified I2C. + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains + * the configuration information for I2C module * @param Flag: specifies the I2C flag to check. * @param Timeout: Timeout duration * @retval HAL status diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.h index af574dc3bd..a3daf7c489 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2c.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of I2C HAL module. ****************************************************************************** * @attention @@ -80,7 +80,7 @@ typedef struct This parameter can be a 7-bit address. */ uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected. - This parameter can be a value of @ref I2C_general_call_addressing_mode. */ + This parameter can be a value of @ref I2C_general_call_addressing_mode */ uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected. This parameter can be a value of @ref I2C_nostretch_mode */ @@ -268,6 +268,13 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset I2C handle state + * @param __HANDLE__: specifies the I2C Handle. + * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. + * @retval None + */ +#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET) + /** @brief Enable or disable the specified I2C interrupts. * @param __HANDLE__: specifies the I2C Handle. * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.c index e6a750461c..f532287e1a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2c_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief I2C Extension HAL module driver. * This file provides firmware functions to manage the following * functionalities of I2C extension peripheral: @@ -14,8 +14,8 @@ ##### I2C peripheral extension features ##### ============================================================================== - [..] Comparing to other previous devices, the I2C interface for STM32F427X and - STM32F429X devices contains the following additional features + [..] Comparing to other previous devices, the I2C interface for STM32F427xx/437xx/ + 429xx/439xx devices contains the following additional features : (+) Possibility to disable or enable Analog Noise Filter (+) Use of a configured Digital Noise Filter @@ -100,9 +100,9 @@ /** * @brief Configures I2C Analog noise filter. - * @param hi2c : pointer to a I2C_HandleTypeDef structure that contains + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains * the configuration information for the specified I2Cx peripheral. - * @param AnalogFilter : new state of the Analog filter. + * @param AnalogFilter: new state of the Analog filter. * @retval HAL status */ HAL_StatusTypeDef HAL_I2CEx_AnalogFilter_Config(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter) @@ -139,9 +139,9 @@ HAL_StatusTypeDef HAL_I2CEx_AnalogFilter_Config(I2C_HandleTypeDef *hi2c, uint32_ /** * @brief Configures I2C Digital noise filter. - * @param hi2c : pointer to a I2C_HandleTypeDef structure that contains + * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains * the configuration information for the specified I2Cx peripheral. - * @param DigitalFilter : Coefficient of digital noise filter between 0x00 and 0x0F. + * @param DigitalFilter: Coefficient of digital noise filter between 0x00 and 0x0F. * @retval HAL status */ HAL_StatusTypeDef HAL_I2CEx_DigitalFilter_Config(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.h index 58c75b42f4..152e1b44ea 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2c_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of I2C HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.c index 1e7b41fc77..d13540b121 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2s.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief I2S HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Integrated Interchip Sound (I2S) peripheral: @@ -31,7 +31,7 @@ and HAL_I2S_Receive_DMA() APIs: (+++) Declare a DMA handle structure for the Tx/Rx stream. (+++) Enable the DMAx interface clock. - (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters. + (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters. (+++) Configure the DMA Tx/Rx Stream. (+++) Associate the initilalized DMA handle to the I2S DMA Tx/Rx handle. (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the @@ -48,7 +48,7 @@ (+@) External clock source is configured after setting correctly the define constant EXTERNAL_CLOCK_VALUE in the stm32f4xx_hal_conf.h file. - (#) Three mode of operations are available within this driver : + (#) Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -56,7 +56,7 @@ (+) Send an amount of data in blocking mode using HAL_I2S_Transmit() (+) Receive an amount of data in blocking mode using HAL_I2S_Receive() - *** Interrupt mode IO operation *** + *** Interrupt mode IO operation *** =================================== [..] (+) Send an amount of data in non blocking mode using HAL_I2S_Transmit_IT() @@ -68,11 +68,11 @@ (+) At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback (+) At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can - add his own code by customization of function pointer HAL_I2S_RxCpltCallback + add his own code by customization of function pointer HAL_I2S_RxCpltCallback (+) In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2S_ErrorCallback - *** DMA mode IO operation *** + *** DMA mode IO operation *** ============================== [..] (+) Send an amount of data in non blocking mode (DMA) using HAL_I2S_Transmit_DMA() @@ -84,25 +84,25 @@ (+) At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback (+) At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can - add his own code by customization of function pointer HAL_I2S_RxCpltCallback + add his own code by customization of function pointer HAL_I2S_RxCpltCallback (+) In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2S_ErrorCallback - (+) Pause the DMA Transfer using HAL_I2S_DMAPause() - (+) Resume the DMA Transfer using HAL_I2S_DMAResume() - (+) Stop the DMA Transfer using HAL_I2S_DMAStop() - + (+) Pause the DMA Transfer using HAL_I2S_DMAPause() + (+) Resume the DMA Transfer using HAL_I2S_DMAResume() + (+) Stop the DMA Transfer using HAL_I2S_DMAStop() + *** I2S HAL driver macros list *** - ============================================= + ============================================= [..] Below the list of most used macros in USART HAL driver. (+) __HAL_I2S_ENABLE: Enable the specified SPI peripheral (in I2S mode) - (+) __HAL_I2S_DISABLE: Disable the specified SPI peripheral (in I2S mode) + (+) __HAL_I2S_DISABLE: Disable the specified SPI peripheral (in I2S mode) (+) __HAL_I2S_ENABLE_IT : Enable the specified I2S interrupts (+) __HAL_I2S_DISABLE_IT : Disable the specified I2S interrupts (+) __HAL_I2S_GET_FLAG: Check whether the specified I2S flag is set or not - - [..] + + [..] (@) You can refer to the I2S HAL driver header file for more useful macros @endverbatim @@ -195,7 +195,8 @@ static HAL_StatusTypeDef I2S_Receive_IT(I2S_HandleTypeDef *hi2s); /** * @brief Initializes the I2S according to the specified parameters * in the I2S_InitTypeDef and create the associated handle. - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval HAL status */ HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s) @@ -375,7 +376,8 @@ HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s) /** * @brief DeInitializes the I2S peripheral - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval HAL status */ HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) @@ -390,7 +392,8 @@ HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) /* DeInit the low level hardware: GPIO, CLOCK, NVIC... */ HAL_I2S_MspDeInit(hi2s); - + + hi2s->ErrorCode = HAL_I2S_ERROR_NONE; hi2s->State = HAL_I2S_STATE_RESET; /* Release Lock */ @@ -401,7 +404,8 @@ HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) /** * @brief I2S MSP Init - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval None */ __weak void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s) @@ -413,7 +417,8 @@ HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) /** * @brief I2S MSP DeInit - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval None */ __weak void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s) @@ -438,7 +443,7 @@ HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) This subsection provides a set of functions allowing to manage the I2S data transfers. - (#) There is two mode of transfer: + (#) There are two modes of transfer: (++) Blocking mode : The communication is performed in the polling mode. The status of all data processing is returned by the same function after finishing transfer. @@ -460,7 +465,7 @@ HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) (++) HAL_I2S_Transmit_DMA() (++) HAL_I2S_Receive_DMA() - (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: + (#) A set of Transfer Complete Callbacks are provided in non Blocking mode: (++) HAL_I2S_TxCpltCallback() (++) HAL_I2S_RxCpltCallback() (++) HAL_I2S_ErrorCallback() @@ -471,7 +476,8 @@ HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) /** * @brief Transmit an amount of data in blocking mode - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param pData: a 16-bit pointer to data buffer. * @param Size: number of data sample to be sent: * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S @@ -550,7 +556,8 @@ HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uin /** * @brief Receive an amount of data in blocking mode - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param pData: a 16-bit pointer to data buffer. * @param Size: number of data sample to be sent: * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S @@ -635,7 +642,8 @@ HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint /** * @brief Transmit an amount of data in non-blocking mode with Interrupt - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param pData: a 16-bit pointer to data buffer. * @param Size: number of data sample to be sent: * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S @@ -700,7 +708,8 @@ HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, /** * @brief Receive an amount of data in non-blocking mode with Interrupt - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param pData: a 16-bit pointer to the Receive data buffer. * @param Size: number of data sample to be sent: * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S @@ -767,7 +776,8 @@ HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, u /** * @brief Transmit an amount of data in non-blocking mode with DMA - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param pData: a 16-bit pointer to the Transmit data buffer. * @param Size: number of data sample to be sent: * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S @@ -851,7 +861,8 @@ HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, /** * @brief Receive an amount of data in non-blocking mode with DMA - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param pData: a 16-bit pointer to the Receive data buffer. * @param Size: number of data sample to be sent: * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S @@ -942,8 +953,9 @@ HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, /** * @brief Pauses the audio stream playing from the Media. - * @param hi2s: I2S handle - * @retval None + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module + * @retval HAL status */ HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s) { @@ -986,8 +998,9 @@ HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s) /** * @brief Resumes the audio stream playing from the Media. - * @param hi2s: I2S handle - * @retval None + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module + * @retval HAL status */ HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s) { @@ -1037,8 +1050,9 @@ HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s) /** * @brief Resumes the audio stream playing from the Media. - * @param hi2s: I2S handle - * @retval None + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module + * @retval HAL status */ HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s) { @@ -1086,8 +1100,9 @@ HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s) /** * @brief This function handles I2S interrupt request. - * @param hi2s: I2S handle - * @retval HAL status + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module + * @retval None */ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) { @@ -1106,7 +1121,7 @@ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) tmp1 = __HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_OVR); tmp2 = __HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_ERR); - /* I2S Overrun error interrupt occured ---------------------------------*/ + /* I2S Overrun error interrupt occurred ---------------------------------*/ if((tmp1 != RESET) && (tmp2 != RESET)) { __HAL_I2S_CLEAR_OVRFLAG(hi2s); @@ -1126,7 +1141,7 @@ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) tmp1 = __HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_UDR); tmp2 = __HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_ERR); - /* I2S Underrun error interrupt occured --------------------------------*/ + /* I2S Underrun error interrupt occurred --------------------------------*/ if((tmp1 != RESET) && (tmp2 != RESET)) { __HAL_I2S_CLEAR_UDRFLAG(hi2s); @@ -1158,7 +1173,7 @@ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) tmp1 = I2SxEXT(hi2s->Instance)->SR & SPI_SR_OVR; tmp2 = I2SxEXT(hi2s->Instance)->CR2 & I2S_IT_ERR; - /* I2Sext Overrun error interrupt occured ------------------------------*/ + /* I2Sext Overrun error interrupt occurred ------------------------------*/ if((tmp1 == SPI_SR_OVR) && (tmp2 == I2S_IT_ERR)) { /* Clear I2Sext OVR Flag */ @@ -1184,7 +1199,7 @@ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) tmp1 = __HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_UDR); tmp2 = __HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_ERR); - /* I2S Underrun error interrupt occured --------------------------------*/ + /* I2S Underrun error interrupt occurred --------------------------------*/ if((tmp1 != RESET) && (tmp2 != RESET)) { __HAL_I2S_CLEAR_UDRFLAG(hi2s); @@ -1211,7 +1226,7 @@ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) tmp1 = __HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_OVR); tmp2 = __HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_ERR); - /* I2S Overrun error interrupt occured ---------------------------------*/ + /* I2S Overrun error interrupt occurred ---------------------------------*/ if((tmp1 != RESET) && (tmp2 != RESET)) { __HAL_I2S_CLEAR_OVRFLAG(hi2s); @@ -1235,7 +1250,7 @@ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) tmp1 = I2SxEXT(hi2s->Instance)->SR & SPI_SR_UDR; tmp2 = I2SxEXT(hi2s->Instance)->CR2 & I2S_IT_ERR; - /* I2Sext Underrun error interrupt occured -----------------------------*/ + /* I2Sext Underrun error interrupt occurred -----------------------------*/ if((tmp1 == SPI_SR_UDR) && (tmp2 == I2S_IT_ERR)) { /* Clear I2Sext UDR Flag */ @@ -1256,7 +1271,8 @@ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) /** * @brief Tx Transfer Half completed callbacks - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval None */ __weak void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s) @@ -1268,7 +1284,8 @@ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) /** * @brief Tx Transfer completed callbacks - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval None */ __weak void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s) @@ -1280,7 +1297,8 @@ void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) /** * @brief Rx Transfer half completed callbacks - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval None */ __weak void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s) @@ -1292,7 +1310,8 @@ __weak void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s) /** * @brief Rx Transfer completed callbacks - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval None */ __weak void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) @@ -1304,7 +1323,8 @@ __weak void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) /** * @brief I2S error callbacks - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval None */ __weak void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) @@ -1326,7 +1346,7 @@ __weak void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) ##### Peripheral State and Errors functions ##### =============================================================================== [..] - This subsection permit to get in run-time the status of the peripheral + This subsection permits to get in run-time the status of the peripheral and the data flow. @endverbatim @@ -1335,7 +1355,8 @@ __weak void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) /** * @brief Return the I2S state - * @param hi2s : I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval HAL state */ HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s) @@ -1345,7 +1366,8 @@ HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s) /** * @brief Return the I2S error code - * @param hi2s : I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval I2S Error Code */ HAL_I2S_ErrorTypeDef HAL_I2S_GetError(I2S_HandleTypeDef *hi2s) @@ -1359,7 +1381,8 @@ HAL_I2S_ErrorTypeDef HAL_I2S_GetError(I2S_HandleTypeDef *hi2s) /** * @brief DMA I2S transmit process complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void I2S_DMATxCplt(DMA_HandleTypeDef *hdma) @@ -1396,7 +1419,8 @@ void I2S_DMATxCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA I2S transmit process half complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma) @@ -1408,7 +1432,8 @@ void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA I2S receive process complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void I2S_DMARxCplt(DMA_HandleTypeDef *hdma) @@ -1444,7 +1469,8 @@ void I2S_DMARxCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA I2S receive process half complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma) @@ -1456,7 +1482,8 @@ void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA I2S communication error callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void I2S_DMAError(DMA_HandleTypeDef *hdma) @@ -1474,7 +1501,8 @@ void I2S_DMAError(DMA_HandleTypeDef *hdma) /** * @brief Transmit an amount of data in non-blocking mode with Interrupt - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval HAL status */ static HAL_StatusTypeDef I2S_Transmit_IT(I2S_HandleTypeDef *hi2s) @@ -1517,7 +1545,8 @@ static HAL_StatusTypeDef I2S_Transmit_IT(I2S_HandleTypeDef *hi2s) /** * @brief Receive an amount of data in non-blocking mode with Interrupt - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval HAL status */ static HAL_StatusTypeDef I2S_Receive_IT(I2S_HandleTypeDef *hi2s) @@ -1568,7 +1597,8 @@ static HAL_StatusTypeDef I2S_Receive_IT(I2S_HandleTypeDef *hi2s) /** * @brief This function handles I2S Communication Timeout. - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param Flag: Flag checked * @param State: Value of the flag expected * @param Timeout: Duration of the timeout diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.h index 8ab5057378..778ee5e2ba 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2s.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of I2S HAL module. ****************************************************************************** * @attention @@ -187,17 +187,25 @@ typedef struct /** @defgroup I2S_Standard * @{ */ -#define I2S_STANDARD_PHILLIPS ((uint32_t)0x00000000) +#define I2S_STANDARD_PHILIPS ((uint32_t)0x00000000) #define I2S_STANDARD_MSB ((uint32_t)0x00000010) #define I2S_STANDARD_LSB ((uint32_t)0x00000020) #define I2S_STANDARD_PCM_SHORT ((uint32_t)0x00000030) #define I2S_STANDARD_PCM_LONG ((uint32_t)0x000000B0) -#define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_STANDARD_PHILLIPS) || \ +#define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_STANDARD_PHILIPS) || \ ((STANDARD) == I2S_STANDARD_MSB) || \ ((STANDARD) == I2S_STANDARD_LSB) || \ ((STANDARD) == I2S_STANDARD_PCM_SHORT) || \ ((STANDARD) == I2S_STANDARD_PCM_LONG)) +/** @defgroup I2S_Legacy + * @{ + */ +#define I2S_STANDARD_PHILLIPS I2S_STANDARD_PHILIPS +/** + * @} + */ + /** * @} */ @@ -307,6 +315,13 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset I2S handle state + * @param __HANDLE__: specifies the I2S Handle. + * @retval None + */ +#define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET) + /** @brief Enable or disable the specified SPI peripheral (in I2S mode). * @param __HANDLE__: specifies the I2S Handle. * @retval None diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.c index eb247258ca..74a3355cf1 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2s_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief I2S HAL module driver. * This file provides firmware functions to manage the following * functionalities of I2S extension peripheral: @@ -16,21 +16,21 @@ [..] (#) In I2S full duplex mode, each SPI peripheral is able to manage sending and receiving data simultaneously using two data lines. Each SPI peripheral has an extended block - called I2Sxext ie. I2S2ext for SPI2 and I2S3ext for SPI3). + called I2Sxext (i.e I2S2ext for SPI2 and I2S3ext for SPI3). (#) The extension block is not a full SPI IP, it is used only as I2S slave to implement full duplex mode. The extension block uses the same clock sources as its master. (#) Both I2Sx and I2Sx_ext can be configured as transmitters or receivers. - -@- Only I2Sx can deliver SCK and WS to I2Sx_ext in full duplex mode, where + [..] + (@) Only I2Sx can deliver SCK and WS to I2Sx_ext in full duplex mode, where I2Sx can be I2S2 or I2S3. - =============================================================================== ##### How to use this driver ##### =============================================================================== [..] - Three mode of operations are available within this driver : + Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -137,7 +137,7 @@ This subsection provides a set of functions allowing to manage the I2S data transfers. - (#) There is two mode of transfer: + (#) There are two modes of transfer: (++) Blocking mode : The communication is performed in the polling mode. The status of all data processing is returned by the same function after finishing transfer. @@ -156,7 +156,7 @@ (#) No-Blocking mode functions with DMA are : (++) HAL_I2S_TransmitReceive_DMA() - (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: + (#) A set of Transfer Complete Callbacks are provided in non Blocking mode: (++) HAL_I2S_TxCpltCallback() (++) HAL_I2S_RxCpltCallback() (++) HAL_I2S_ErrorCallback() @@ -167,7 +167,8 @@ /** * @brief Full-Duplex Transmit/Receive data in blocking mode. - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param pTxData: a 16-bit pointer to the Transmit data buffer. * @param pRxData: a 16-bit pointer to the Receive data buffer. * @param Size: number of data sample to be sent: @@ -338,7 +339,8 @@ HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *p /** * @brief Full-Duplex Transmit/Receive data in non-blocking mode using Interrupt - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param pTxData: a 16-bit pointer to the Transmit data buffer. * @param pRxData: a 16-bit pointer to the Receive data buffer. * @param Size: number of data sample to be sent: @@ -346,7 +348,6 @@ HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *p * configuration phase, the Size parameter means the number of 16-bit data length * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected * the Size parameter means the number of 16-bit data length. - * @param Timeout: Timeout duration * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization * between Master and Slave(example: audio streaming). * @retval HAL status @@ -464,7 +465,8 @@ HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t /** * @brief Full-Duplex Transmit/Receive data in non-blocking mode using DMA - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @param pTxData: a 16-bit pointer to the Transmit data buffer. * @param pRxData: a 16-bit pointer to the Receive data buffer. * @param Size: number of data sample to be sent: @@ -472,7 +474,6 @@ HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t * configuration phase, the Size parameter means the number of 16-bit data length * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected * the Size parameter means the number of 16-bit data length. - * @param Timeout: Timeout duration * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization * between Master and Slave(example: audio streaming). * @retval HAL status @@ -621,7 +622,8 @@ HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_ /** * @brief Full-Duplex Transmit/Receive data in non-blocking mode using Interrupt - * @param hi2s: I2S handle + * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains + * the configuration information for I2S module * @retval HAL status */ HAL_StatusTypeDef I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.h index c6f39bf8a7..95fbd55b6f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2s_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of I2S HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.c index bc0b38481e..5c103eddbf 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.c @@ -2,24 +2,24 @@ ****************************************************************************** * @file stm32f4xx_hal_irda.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief IRDA HAL module driver. * This file provides firmware functions to manage the following * functionalities of the IrDA SIR ENDEC block (IrDA): - * + Initialization and de-initialization functions - * + IO operation functions - * + Peripheral State and Errors functions - * - @verbatim + * + Initialization and de-initialization methods + * + IO operation methods + * + Peripheral Control methods + * + @verbatim ============================================================================== ##### How to use this driver ##### ============================================================================== [..] - The IRDA HAL driver can be used as follow: + The IRDA HAL driver can be used as follows: (#) Declare a IRDA_HandleTypeDef handle structure. - (#) Initialize the IRDA low level resources by implement the HAL_IRDA_MspInit() API: + (#) Initialize the IRDA low level resources by implementing the HAL_IRDA_MspInit() API: (##) Enable the USARTx interface clock. (##) IRDA pins configuration: (+++) Enable the clock for the IRDA GPIOs. @@ -47,7 +47,7 @@ RXNE interrupt and Error Interrupts) will be managed using the macros __HAL_IRDA_ENABLE_IT() and __HAL_IRDA_DISABLE_IT() inside the transmit and receive process. - (#) Three mode of operations are available within this driver : + (#) Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -175,18 +175,7 @@ static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, (++) Parity: If the parity is enabled, then the MSB bit of the data written in the data register is transmitted but is changed by the parity bit. Depending on the frame length defined by the M bit (8-bits or 9-bits), - the possible IRDA frame formats are as listed in the following table: - +-------------------------------------------------------------+ - | M bit | PCE bit | IRDA frame | - |---------------------|---------------------------------------| - | 0 | 0 | | SB | 8 bit data | STB | | - |---------|-----------|---------------------------------------| - | 0 | 1 | | SB | 7 bit data | PB | STB | | - |---------|-----------|---------------------------------------| - | 1 | 0 | | SB | 9 bit data | STB | | - |---------|-----------|---------------------------------------| - | 1 | 1 | | SB | 8 bit data | PB | STB | | - +-------------------------------------------------------------+ + please refer to Reference manual for possible IRDA frame formats. (++) Prescaler: A pulse of width less than two and greater than one PSC period(s) may or may not be rejected. The receiver set up time should be managed by software. The IrDA physical layer specification specifies a minimum of 10 ms delay between transmission and @@ -204,7 +193,8 @@ static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, /** * @brief Initializes the IRDA mode according to the specified * parameters in the IRDA_InitTypeDef and create the associated handle. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval HAL status */ HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda) @@ -261,7 +251,8 @@ HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda) /** * @brief DeInitializes the IRDA peripheral - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval HAL status */ HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda) @@ -292,7 +283,8 @@ HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda) /** * @brief IRDA MSP Init. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval None */ __weak void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda) @@ -304,7 +296,8 @@ HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda) /** * @brief IRDA MSP DeInit. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval None */ __weak void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda) @@ -333,33 +326,33 @@ HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda) While receiving data, transmission should be avoided as the data to be transmitted could be corrupted. - (#) There are two mode of transfer: + (#) There are two modes of transfer: (++) Blocking mode: The communication is performed in polling mode. The HAL status of all data processing is returned by the same function after finishing transfer. (++) No-Blocking mode: The communication is performed using Interrupts - or DMA, These API's return the HAL status. + or DMA, These APIs return the HAL status. The end of the data processing will be indicated through the dedicated IRDA IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. The HAL_IRDA_TxCpltCallback(), HAL_IRDA_RxCpltCallback() user callbacks will be executed respectivelly at the end of the transmit or Receive process - The HAL_IRDA_ErrorCallback()user callback will be executed when a communication error is detected + The HAL_IRDA_ErrorCallback() user callback will be executed when a communication error is detected (#) Blocking mode API's are : (++) HAL_IRDA_Transmit() (++) HAL_IRDA_Receive() - (#) Non-Blocking mode API's with Interrupt are : + (#) Non Blocking mode APIs with Interrupt are : (++) HAL_IRDA_Transmit_IT() (++) HAL_IRDA_Receive_IT() (++) HAL_IRDA_IRQHandler() - (#) No-Blocking mode functions with DMA are : + (#) Non Blocking mode functions with DMA are : (++) HAL_IRDA_Transmit_DMA() (++) HAL_IRDA_Receive_DMA() - (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: + (#) A set of Transfer Complete Callbacks are provided in non Blocking mode: (++) HAL_IRDA_TxCpltCallback() (++) HAL_IRDA_RxCpltCallback() (++) HAL_IRDA_ErrorCallback() @@ -370,7 +363,8 @@ HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda) /** * @brief Sends an amount of data in blocking mode. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @param Timeout: Specify timeout value @@ -461,7 +455,8 @@ HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, u /** * @brief Receive an amount of data in blocking mode. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be received * @param Timeout: Specify timeout value @@ -554,7 +549,8 @@ HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, ui /** * @brief Send an amount of data in non blocking mode. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -608,7 +604,8 @@ HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData /** * @brief Receives an amount of data in non blocking mode. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be received * @retval HAL status @@ -663,7 +660,8 @@ HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, /** * @brief Sends an amount of data in non blocking mode. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -725,7 +723,8 @@ HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pDat /** * @brief Receives an amount of data in non blocking mode. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be received * @note When the IRDA parity is enabled (PCE = 1) the data received contain the parity bit. @@ -786,7 +785,8 @@ HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData /** * @brief This function handles IRDA interrupt request. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval None */ void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda) @@ -795,7 +795,7 @@ void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda) tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_PE); tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_PE); - /* IRDA parity error interrupt occured -------------------------------------*/ + /* IRDA parity error interrupt occurred -------------------------------------*/ if((tmp1 != RESET) && (tmp2 != RESET)) { __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_FLAG_PE); @@ -804,7 +804,7 @@ void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda) tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_FE); tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR); - /* IRDA frame error interrupt occured --------------------------------------*/ + /* IRDA frame error interrupt occurred --------------------------------------*/ if((tmp1 != RESET) && (tmp2 != RESET)) { __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_FLAG_FE); @@ -813,7 +813,7 @@ void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda) tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_NE); tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR); - /* IRDA noise error interrupt occured --------------------------------------*/ + /* IRDA noise error interrupt occurred --------------------------------------*/ if((tmp1 != RESET) && (tmp2 != RESET)) { __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_FLAG_NE); @@ -822,7 +822,7 @@ void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda) tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_ORE); tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR); - /* IRDA Over-Run interrupt occured -----------------------------------------*/ + /* IRDA Over-Run interrupt occurred -----------------------------------------*/ if((tmp1 != RESET) && (tmp2 != RESET)) { __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_FLAG_ORE); @@ -858,7 +858,8 @@ void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda) /** * @brief Tx Transfer complete callbacks. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval None */ __weak void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda) @@ -870,7 +871,8 @@ void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda) /** * @brief Rx Transfer complete callbacks. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval None */ __weak void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda) @@ -882,7 +884,8 @@ __weak void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda) /** * @brief IRDA error callbacks. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval None */ __weak void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda) @@ -905,9 +908,9 @@ __weak void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda) ============================================================================== [..] This subsection provides a set of functions allowing to return the State of IrDA - communication process, return Peripheral Errors occured during communication process + communication process and also return Peripheral Errors occurred during communication process (+) HAL_IRDA_GetState() API can be helpful to check in run-time the state of the IrDA peripheral. - (+) HAL_IRDA_GetError() check in run-time errors that could be occured durung communication. + (+) HAL_IRDA_GetError() check in run-time errors that could be occurred during communication. @endverbatim * @{ @@ -915,7 +918,8 @@ __weak void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda) /** * @brief Returns the IRDA state. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval HAL state */ HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda) @@ -949,10 +953,14 @@ static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma) hirda->TxXferCount = 0; + /* Disable the DMA transfer for transmit request by setting the DMAT bit + in the IRDA CR3 register */ + hirda->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_DMAT); + /* Wait for IRDA TC Flag */ if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TC, RESET, IRDA_TIMEOUT_VALUE) != HAL_OK) { - /* Timeout Occured */ + /* Timeout occurred */ hirda->State = HAL_IRDA_STATE_TIMEOUT; HAL_IRDA_ErrorCallback(hirda); } @@ -982,7 +990,11 @@ static void IRDA_DMAReceiveCplt(DMA_HandleTypeDef *hdma) IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; hirda->RxXferCount = 0; - + + /* Disable the DMA transfer for the receiver request by setting the DMAR bit + in the IRDA CR3 register */ + hirda->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_DMAR); + if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX) { hirda->State = HAL_IRDA_STATE_BUSY_TX; @@ -1014,7 +1026,8 @@ static void IRDA_DMAError(DMA_HandleTypeDef *hdma) /** * @brief This function handles IRDA Communication Timeout. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @param Flag: specifies the IRDA flag to check. * @param Status: The new Flag status (SET or RESET). * @param Timeout: Timeout duration @@ -1082,7 +1095,8 @@ static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, /** * @brief Send an amount of data in non blocking mode. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval HAL status */ static HAL_StatusTypeDef IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda) @@ -1093,9 +1107,6 @@ static HAL_StatusTypeDef IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda) tmp1 = hirda->State; if((tmp1 == HAL_IRDA_STATE_BUSY_TX) || (tmp1 == HAL_IRDA_STATE_BUSY_TX_RX)) { - /* Process Locked */ - __HAL_LOCK(hirda); - if(hirda->Init.WordLength == IRDA_WORDLENGTH_9B) { tmp = (uint16_t*) hirda->pTxBuffPtr; @@ -1133,17 +1144,12 @@ static HAL_StatusTypeDef IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda) hirda->State = HAL_IRDA_STATE_READY; } - /* Call the Process Unlocked before calling the Tx call back API to give the possibiity to - start again the Transmission under the Tx call back API */ - __HAL_UNLOCK(hirda); - + HAL_IRDA_TxCpltCallback(hirda); return HAL_OK; } - /* Process Unlocked */ - __HAL_UNLOCK(hirda); - + return HAL_OK; } else @@ -1154,7 +1160,8 @@ static HAL_StatusTypeDef IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda) /** * @brief Receives an amount of data in non blocking mode. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval HAL status */ static HAL_StatusTypeDef IRDA_Receive_IT(IRDA_HandleTypeDef *hirda) @@ -1165,9 +1172,6 @@ static HAL_StatusTypeDef IRDA_Receive_IT(IRDA_HandleTypeDef *hirda) tmp1 = hirda->State; if((tmp1 == HAL_IRDA_STATE_BUSY_RX) || (tmp1 == HAL_IRDA_STATE_BUSY_TX_RX)) { - /* Process Locked */ - __HAL_LOCK(hirda); - if(hirda->Init.WordLength == IRDA_WORDLENGTH_9B) { tmp = (uint16_t*) hirda->pRxBuffPtr; @@ -1215,18 +1219,10 @@ static HAL_StatusTypeDef IRDA_Receive_IT(IRDA_HandleTypeDef *hirda) hirda->State = HAL_IRDA_STATE_READY; } - /* Call the Process Unlocked before calling the Rx call back API to give the possibiity to - start again the receiption under the Rx call back API */ - __HAL_UNLOCK(hirda); - HAL_IRDA_RxCpltCallback(hirda); return HAL_OK; } - - /* Process Unlocked */ - __HAL_UNLOCK(hirda); - return HAL_OK; } else @@ -1237,7 +1233,8 @@ static HAL_StatusTypeDef IRDA_Receive_IT(IRDA_HandleTypeDef *hirda) /** * @brief Configures the IRDA peripheral. - * @param hirda: IRDA handle + * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains + * the configuration information for the specified IRDA module. * @retval None */ static void IRDA_SetConfig(IRDA_HandleTypeDef *hirda) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.h index e15ad994cf..a04957d9e7 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_irda.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of IRDA HAL module. ****************************************************************************** * @attention @@ -233,22 +233,33 @@ typedef struct #define IRDA_IT_TC ((uint32_t)0x10000040) #define IRDA_IT_RXNE ((uint32_t)0x10000020) #define IRDA_IT_IDLE ((uint32_t)0x10000010) - + #define IRDA_IT_LBD ((uint32_t)0x20000040) -#define IRDA_IT_CTS ((uint32_t)0x30000400) +#define IRDA_IT_CTS ((uint32_t)0x30000400) #define IRDA_IT_ERR ((uint32_t)0x30000001) /** * @} */ - + /** * @} */ /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset IRDA handle state + * @param __HANDLE__: specifies the IRDA Handle. + * @retval None + */ +#define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IRDA_STATE_RESET) + +/** @brief Flushs the IRDA DR register + * @param __HANDLE__: specifies the IRDA Handle. + */ +#define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) + /** @brief Checks whether the specified IRDA flag is set or not. * @param __HANDLE__: specifies the USART Handle. * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.c index 391f3a2d44..ac22eb5f8a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_iwdg.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief IWDG HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Independent Watchdog (IWDG) peripheral: @@ -142,7 +142,8 @@ /** * @brief Initializes the IWDG according to the specified * parameters in the IWDG_InitTypeDef and creates the associated handle. - * @param hiwdg: IWDG handle + * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains + * the configuration information for the specified IWDG module. * @retval HAL status */ HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg) @@ -206,7 +207,8 @@ HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg) /** * @brief Initializes the IWDG MSP. - * @param hiwdg: IWDG handle + * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains + * the configuration information for the specified IWDG module. * @retval None */ __weak void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg) @@ -237,7 +239,8 @@ __weak void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg) /** * @brief Starts the IWDG. - * @param hiwdg: IWDG handle + * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains + * the configuration information for the specified IWDG module. * @retval HAL status */ HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg) @@ -266,7 +269,8 @@ HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg) /** * @brief Refreshes the IWDG. - * @param hiwdg: IWDG handle + * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains + * the configuration information for the specified IWDG module. * @retval HAL status */ HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg) @@ -314,7 +318,8 @@ HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg) /** * @brief Returns the IWDG state. - * @param hiwdg: IWDG handle + * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains + * the configuration information for the specified IWDG module. * @retval HAL state */ HAL_IWDG_StateTypeDef HAL_IWDG_GetState(IWDG_HandleTypeDef *hiwdg) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h index a8e0479f54..53e6889630 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_iwdg.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of IWDG HAL module. ****************************************************************************** * @attention @@ -167,6 +167,12 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset IWDG handle state + * @param __HANDLE__: IWDG handle + * @retval None + */ +#define __HAL_IWDG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IWDG_STATE_RESET) + /** * @brief Enables the IWDG peripheral. * @param __HANDLE__: IWDG handle diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.c index d264a8b243..4c256b3099 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_ltdc.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief LTDC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the LTDC peripheral: @@ -17,12 +17,12 @@ ##### How to use this driver ##### ============================================================================== [..] - (#) Program the required configuration through following parameters: + (#) Program the required configuration through the following parameters: the LTDC timing, the horizontal and vertical polarity, the pixel clock polarity, Data Enable polarity and the LTDC background color value using HAL_LTDC_Init() function - (#) Program the required configuration through following parameters: + (#) Program the required configuration through the following parameters: the pixel format, the blending factors, input alpha value, the window size and the image size using HAL_LTDC_ConfigLayer() function for foreground or/and background layer. @@ -38,7 +38,7 @@ (#) Optionally, configure LineInterrupt using HAL_LTDC_ProgramLineInterrupt() function - (#) If needed, Reconfigure and change the pixel format value, the alpha value + (#) If needed, reconfigure and change the pixel format value, the alpha value value, the window size, the window position and the layer start address for foreground or/and background layer using respectively the following functions: HAL_LTDC_SetPixelFormat(), HAL_LTDC_SetAlpha(), HAL_LTDC_SetWindowSize(), @@ -57,10 +57,10 @@ (+) __HAL_LTDC_LAYER_DISABLE: Disable the LTDC Layer. (+) __HAL_LTDC_RELOAD_CONFIG: Reload Layer Configuration. (+) __HAL_LTDC_GET_FLAG: Get the LTDC pending flags. - (+) __HAL_LTDC_CLEAR_FLAG: Clears the LTDC pending flags. - (+) __HAL_LTDC_ENABLE_IT: Enables the specified LTDC interrupts. - (+) __HAL_LTDC_DISABLE_IT: Disables the specified LTDC interrupts. - (+) __HAL_LTDC_GET_IT_SOURCE: Checks whether the specified LTDC interrupt has occurred or not. + (+) __HAL_LTDC_CLEAR_FLAG: Clear the LTDC pending flags. + (+) __HAL_LTDC_ENABLE_IT: Enable the specified LTDC interrupts. + (+) __HAL_LTDC_DISABLE_IT: Disable the specified LTDC interrupts. + (+) __HAL_LTDC_GET_IT_SOURCE: Check whether the specified LTDC interrupt has occurred or not. [..] (@) You can refer to the LTDC HAL driver header file for more useful macros @@ -421,9 +421,9 @@ __weak void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc) (+) Enable / Disable the C-LUT. (+) Update the layer position. (+) Update the layer size. - (+) update pixel format on the fly the. - (+) update transparency on the fly the. - (+) update address on the fly. + (+) Update pixel format on the fly. + (+) Update transparency on the fly. + (+) Update address on the fly. @endverbatim * @{ @@ -436,7 +436,7 @@ __weak void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc) * the configuration information for the LTDC. * @param pLayerCfg: pointer to a LTDC_LayerCfgTypeDef structure that contains * the configuration information for the Layer. - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 * @retval HAL status @@ -485,10 +485,10 @@ HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgT * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. * @param RGBValue: the color key value - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx) { @@ -523,10 +523,10 @@ HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t * the configuration information for the LTDC. * @param pCLUT: pointer to the color lookup table address. * @param CLUTSize: the color lookup table size. - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx) { @@ -566,10 +566,10 @@ HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT * @brief Enable the color keying. * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx) { @@ -601,10 +601,10 @@ HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t * @brief Disable the color keying. * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx) { @@ -636,10 +636,10 @@ HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_ * @brief Enable the color lookup table. * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx) { @@ -672,10 +672,10 @@ HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerI * @brief Disable the color lookup table. * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx) { @@ -708,7 +708,7 @@ HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t Layer * @brief Enables Dither. * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc) @@ -735,7 +735,7 @@ HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc) * @brief Disables Dither. * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc) @@ -764,10 +764,10 @@ HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc) * the configuration information for the LTDC. * @param XSize: LTDC Pixel per line * @param YSize: LTDC Line number - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx) { @@ -826,10 +826,10 @@ HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSi * the configuration information for the LTDC. * @param X0: LTDC window X offset * @param Y0: LTDC window Y offset - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx) { @@ -882,7 +882,7 @@ HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx) { @@ -924,10 +924,10 @@ HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pi * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. * @param Alpha: new alpha value. - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1 - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx) { @@ -971,7 +971,7 @@ HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, u * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: * 0 or 1. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx) { @@ -1012,7 +1012,7 @@ HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Addres * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. * @param Line: Line Interrupt Position. - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line) { @@ -1091,7 +1091,7 @@ uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc) * @param hltdc : Pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. * @param pLayerCfg: Pointer LTDC Layer Configuration strusture - * @param LayerIdx: LTDC Layer index + * @param LayerIdx: LTDC Layer index. * This parameter can be one of the following values: 0 or 1 * @retval None */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.h index 42fbfed67e..308bda2511 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_ltdc.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of LTDC HAL module. ****************************************************************************** * @attention @@ -59,9 +59,9 @@ /* Exported types ------------------------------------------------------------*/ #define MAX_LAYER 2 - + /** - * @brief LTDC color structure definition + * @brief LTDC color structure definition */ typedef struct { @@ -70,15 +70,15 @@ typedef struct uint8_t Green; /*!< Configures the green value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ - + uint8_t Red; /*!< Configures the red value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ - - uint8_t Reserved; /*!< Reserved 0xFF */ -} LTDC_ColorTypeDef; - + + uint8_t Reserved; /*!< Reserved 0xFF */ +} LTDC_ColorTypeDef; + /** - * @brief LTDC Init structure definition + * @brief LTDC Init structure definition */ typedef struct { @@ -95,7 +95,7 @@ typedef struct This parameter can be one of value of @ref LTDC_PC_POLARITY */ uint32_t HorizontalSync; /*!< configures the number of Horizontal synchronization width. - This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ + This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ uint32_t VerticalSync; /*!< configures the number of Vertical synchronization heigh. This parameter must be a number between Min_Data = 0x000 and Max_Data = 0x7FF. */ @@ -104,42 +104,41 @@ typedef struct This parameter must be a number between Min_Data = LTDC_HorizontalSync and Max_Data = 0xFFF. */ uint32_t AccumulatedVBP; /*!< configures the accumulated vertical back porch heigh. - This parameter must be a number between Min_Data = LTDC_VerticalSync and Max_Data = 0x7FF. */ - - uint32_t AccumulatedActiveW; /*!< configures the accumulated active width. This parameter - This parameter must be a number between Min_Data = LTDC_AccumulatedHBP and Max_Data = 0xFFF. */ + This parameter must be a number between Min_Data = LTDC_VerticalSync and Max_Data = 0x7FF. */ - uint32_t AccumulatedActiveH; /*!< configures the accumulated active heigh. This parameter + uint32_t AccumulatedActiveW; /*!< configures the accumulated active width. + This parameter must be a number between Min_Data = LTDC_AccumulatedHBP and Max_Data = 0xFFF. */ + + uint32_t AccumulatedActiveH; /*!< configures the accumulated active heigh. This parameter must be a number between Min_Data = LTDC_AccumulatedVBP and Max_Data = 0x7FF. */ - uint32_t TotalWidth; /*!< configures the total width. This parameter + uint32_t TotalWidth; /*!< configures the total width. This parameter must be a number between Min_Data = LTDC_AccumulatedActiveW and Max_Data = 0xFFF. */ - uint32_t TotalHeigh; /*!< configures the total heigh. This parameter + uint32_t TotalHeigh; /*!< configures the total heigh. This parameter must be a number between Min_Data = LTDC_AccumulatedActiveH and Max_Data = 0x7FF. */ - - LTDC_ColorTypeDef Backcolor; /*!< Configures the background color. */ + LTDC_ColorTypeDef Backcolor; /*!< Configures the background color. */ } LTDC_InitTypeDef; /** - * @brief LTDC Layer structure definition + * @brief LTDC Layer structure definition */ typedef struct { uint32_t WindowX0; /*!< Configures the Window Horizontal Start Position. This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ - + uint32_t WindowX1; /*!< Configures the Window Horizontal Stop Position. This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ - + uint32_t WindowY0; /*!< Configures the Window vertical Start Position. This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ uint32_t WindowY1; /*!< Configures the Window vertical Stop Position. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ - + uint32_t PixelFormat; /*!< Specifies the pixel format. This parameter can be one of value of @ref LTDC_Pixelformat */ @@ -154,60 +153,58 @@ typedef struct uint32_t BlendingFactor2; /*!< Select the blending factor 2. This parameter can be one of value of @ref LTDC_BlendingFactor2 */ - + uint32_t FBStartAdress; /*!< Configures the color frame buffer address */ uint32_t ImageWidth; /*!< Configures the color frame buffer line length. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x1FFF. */ - + uint32_t ImageHeight; /*!< Specifies the number of line in frame buffer. This parameter must be a number between Min_Data = 0x000 and Max_Data = 0x7FF. */ - + LTDC_ColorTypeDef Backcolor; /*!< Configures the layer background color. */ - } LTDC_LayerCfgTypeDef; /** - * @brief HAL LTDC State structures definition - */ + * @brief HAL LTDC State structures definition + */ typedef enum { - HAL_LTDC_STATE_RESET = 0x00, /*!< LTDC not yet initialized or disabled */ + HAL_LTDC_STATE_RESET = 0x00, /*!< LTDC not yet initialized or disabled */ HAL_LTDC_STATE_READY = 0x01, /*!< LTDC initialized and ready for use */ - HAL_LTDC_STATE_BUSY = 0x02, /*!< LTDC internal process is ongoing */ - HAL_LTDC_STATE_TIMEOUT = 0x03, /*!< LTDC Timeout state */ - HAL_LTDC_STATE_ERROR = 0x04 /*!< LTDC state error */ - + HAL_LTDC_STATE_BUSY = 0x02, /*!< LTDC internal process is ongoing */ + HAL_LTDC_STATE_TIMEOUT = 0x03, /*!< LTDC Timeout state */ + HAL_LTDC_STATE_ERROR = 0x04 /*!< LTDC state error */ }HAL_LTDC_StateTypeDef; /** - * @brief LTDC handle Structure definition - */ + * @brief LTDC handle Structure definition + */ typedef struct -{ +{ LTDC_TypeDef *Instance; /*!< LTDC Register base address */ - + LTDC_InitTypeDef Init; /*!< LTDC parameters */ - + LTDC_LayerCfgTypeDef LayerCfg[MAX_LAYER]; /*!< LTDC Layers parameters */ - - HAL_LockTypeDef Lock; /*!< LTDC Lock */ - + + HAL_LockTypeDef Lock; /*!< LTDC Lock */ + __IO HAL_LTDC_StateTypeDef State; /*!< LTDC state */ - __IO uint32_t ErrorCode; /*!< LTDC Error code */ - -} LTDC_HandleTypeDef; + __IO uint32_t ErrorCode; /*!< LTDC Error code */ + +} LTDC_HandleTypeDef; /* Exported constants --------------------------------------------------------*/ /** @defgroup LTDC_Exported_Constants * @{ */ - + /** @defgroup LTDC_Layer * @{ */ -#define IS_LTDC_LAYER(LAYER) ((LAYER) <= MAX_LAYER) +#define IS_LTDC_LAYER(LAYER) ((LAYER) <= MAX_LAYER) /** * @} */ @@ -331,7 +328,7 @@ typedef struct */ #define LTDC_PIXEL_FORMAT_ARGB8888 ((uint32_t)0x00000000) /*!< ARGB8888 LTDC pixel format */ #define LTDC_PIXEL_FORMAT_RGB888 ((uint32_t)0x00000001) /*!< RGB888 LTDC pixel format */ -#define LTDC_PIXEL_FORMAT_RGB565 ((uint32_t)0x00000002) /*!< RGB565 LTDC pixel format */ +#define LTDC_PIXEL_FORMAT_RGB565 ((uint32_t)0x00000002) /*!< RGB565 LTDC pixel format */ #define LTDC_PIXEL_FORMAT_ARGB1555 ((uint32_t)0x00000003) /*!< ARGB1555 LTDC pixel format */ #define LTDC_PIXEL_FORMAT_ARGB4444 ((uint32_t)0x00000004) /*!< ARGB4444 LTDC pixel format */ #define LTDC_PIXEL_FORMAT_L8 ((uint32_t)0x00000005) /*!< L8 LTDC pixel format */ @@ -388,7 +385,7 @@ typedef struct /** @defgroup LTDC_Interrupts * @{ - */ + */ #define LTDC_IT_LI LTDC_IER_LIE #define LTDC_IT_FU LTDC_IER_FUIE #define LTDC_IT_TE LTDC_IER_TERRIE @@ -411,13 +408,20 @@ typedef struct ((FLAG) == LTDC_FLAG_TERR) || ((FLAG) == LTDC_FLAG_RR)) /** * @} - */ + */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset LTDC handle state + * @param __HANDLE__: specifies the LTDC handle. + * @retval None + */ +#define __HAL_LTDC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LTDC_STATE_RESET) + /** * @brief Enable the LTDC. * @param __HANDLE__: LTDC handle @@ -443,7 +447,6 @@ typedef struct #define __HAL_LTDC_LAYER_ENABLE(__HANDLE__, __LAYER__) ((__HAL_LTDC_LAYER((__HANDLE__), (__LAYER__)))->CR |= (uint32_t)LTDC_LxCR_LEN) - /** * @brief Disable the LTDC Layer. * @param __HANDLE__: LTDC handle @@ -525,10 +528,10 @@ typedef struct * @retval The state of INTERRUPT (SET or RESET). */ #define __HAL_LTDC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->ISR & (__INTERRUPT__)) - -/* Exported functions --------------------------------------------------------*/ -/* Initialization and de-initialization functions *******************************/ +/* Exported functions --------------------------------------------------------*/ + +/* Initialization and de-initialization functions *****************************/ HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc); HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc); void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc); @@ -536,10 +539,10 @@ void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc); void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc); void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc); -/* IO operation functions *******************************************************/ +/* IO operation functions *****************************************************/ void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc); -/* Peripheral Control functions *************************************************/ +/* Peripheral Control functions ***********************************************/ HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx); HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx); HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx); @@ -556,7 +559,7 @@ HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc); HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc); -/* Peripheral State functions ***************************************************/ +/* Peripheral State functions *************************************************/ HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc); uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.c index c0ef40e29e..8ba6764907 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_nand.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief NAND HAL module driver. * This file provides a generic firmware to drive NAND memories mounted * as external device. @@ -125,7 +125,8 @@ /** * @brief Perform NAND memory Initialization sequence - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @param ComSpace_Timing: pointer to Common space timing structure * @param AttSpace_Timing: pointer to Attribute space timing structure * @retval HAL status @@ -164,7 +165,8 @@ HAL_StatusTypeDef HAL_NAND_Init(NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingT /** * @brief Perform NAND memory De-Initialization sequence - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval HAL status */ HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand) @@ -186,7 +188,8 @@ HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand) /** * @brief NAND MSP Init - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval None */ __weak void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand) @@ -198,7 +201,8 @@ __weak void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand) /** * @brief NAND MSP DeInit - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval None */ __weak void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand) @@ -211,7 +215,8 @@ __weak void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand) /** * @brief This function handles NAND device interrupt request. - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval HAL status */ void HAL_NAND_IRQHandler(NAND_HandleTypeDef *hnand) @@ -260,7 +265,8 @@ void HAL_NAND_IRQHandler(NAND_HandleTypeDef *hnand) /** * @brief NAND interrupt feature callback - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval None */ __weak void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand) @@ -291,7 +297,8 @@ __weak void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand) /** * @brief Read the NAND memory electronic signature - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @param pNAND_ID: NAND ID structure * @retval HAL status */ @@ -346,7 +353,8 @@ HAL_StatusTypeDef HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pN /** * @brief NAND memory reset - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval HAL status */ HAL_StatusTypeDef HAL_NAND_Reset(NAND_HandleTypeDef *hnand) @@ -392,7 +400,8 @@ HAL_StatusTypeDef HAL_NAND_Reset(NAND_HandleTypeDef *hnand) /** * @brief Read Page(s) from NAND memory block - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @param pAddress : pointer to NAND address structure * @param pBuffer : pointer to destination read buffer * @param NumPageToRead : number of pages to read from block @@ -479,7 +488,8 @@ HAL_StatusTypeDef HAL_NAND_Read_Page(NAND_HandleTypeDef *hnand, NAND_AddressType /** * @brief Write Page(s) to NAND memory block - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @param pAddress : pointer to NAND address structure * @param pBuffer : pointer to source buffer to write * @param NumPageToWrite : number of pages to write to block @@ -580,7 +590,8 @@ HAL_StatusTypeDef HAL_NAND_Write_Page(NAND_HandleTypeDef *hnand, NAND_AddressTyp /** * @brief Read Spare area(s) from NAND memory - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @param pAddress : pointer to NAND address structure * @param pBuffer: pointer to source buffer to write * @param NumSpareAreaToRead: Number of spare area to read @@ -666,7 +677,8 @@ HAL_StatusTypeDef HAL_NAND_Read_SpareArea(NAND_HandleTypeDef *hnand, NAND_Addres /** * @brief Write Spare area(s) to NAND memory - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @param pAddress : pointer to NAND address structure * @param pBuffer : pointer to source buffer to write * @param NumSpareAreaTowrite : number of spare areas to write to block @@ -767,7 +779,8 @@ HAL_StatusTypeDef HAL_NAND_Write_SpareArea(NAND_HandleTypeDef *hnand, NAND_Addre /** * @brief NAND memory Block erase - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @param pAddress : pointer to NAND address structure * @retval HAL status */ @@ -824,7 +837,8 @@ HAL_StatusTypeDef HAL_NAND_Erase_Block(NAND_HandleTypeDef *hnand, NAND_AddressTy /** * @brief NAND memory read status - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval NAND status */ uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand) @@ -864,7 +878,8 @@ uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand) /** * @brief Increment the NAND memory address - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @param pAddress: pointer to NAND adress structure * @retval The new status of the increment address operation. It can be: * - NAND_VALID_ADDRESS: When the new address is valid address @@ -921,7 +936,8 @@ uint32_t HAL_NAND_Address_Inc(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pA /** * @brief Enables dynamically NAND ECC feature. - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval HAL status */ HAL_StatusTypeDef HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand) @@ -947,7 +963,8 @@ HAL_StatusTypeDef HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand) /** * @brief Disables dynamically FMC_NAND ECC feature. - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval HAL status */ HAL_StatusTypeDef HAL_NAND_ECC_Disable(NAND_HandleTypeDef *hnand) @@ -972,7 +989,8 @@ HAL_StatusTypeDef HAL_NAND_ECC_Disable(NAND_HandleTypeDef *hnand) /** * @brief Disables dynamically NAND ECC feature. - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @param ECCval: pointer to ECC value * @param Timeout: maximum timeout to wait * @retval HAL status @@ -1012,7 +1030,7 @@ HAL_StatusTypeDef HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, ##### NAND State functions ##### ============================================================================== [..] - This subsection permit to get in run-time the status of the NAND controller + This subsection permits to get in run-time the status of the NAND controller and the data flow. @endverbatim @@ -1021,7 +1039,8 @@ HAL_StatusTypeDef HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, /** * @brief return the NAND state - * @param hnand: pointer to NAND handle + * @param hnand: pointer to a NAND_HandleTypeDef structure that contains + * the configuration information for NAND module. * @retval HAL state */ HAL_NAND_StateTypeDef HAL_NAND_GetState(NAND_HandleTypeDef *hnand) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.h index aa6458331c..0e3c428f91 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_nand.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of NAND HAL module. ****************************************************************************** * @attention @@ -33,7 +33,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** - */ + */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_NAND_H @@ -62,70 +62,67 @@ #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) -/* Exported typedef ----------------------------------------------------------*/ +/* Exported typedef ----------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /** - * @brief HAL NAND State structures definition - */ + * @brief HAL NAND State structures definition + */ typedef enum { HAL_NAND_STATE_RESET = 0x00, /*!< NAND not yet initialized or disabled */ HAL_NAND_STATE_READY = 0x01, /*!< NAND initialized and ready for use */ HAL_NAND_STATE_BUSY = 0x02, /*!< NAND internal process is ongoing */ HAL_NAND_STATE_ERROR = 0x03 /*!< NAND error state */ - }HAL_NAND_StateTypeDef; /** - * @brief NAND Memory electronic signature Structure definition + * @brief NAND Memory electronic signature Structure definition */ typedef struct { - /*State = HAL_NAND_STATE_RESET) + /** * @brief NAND memory address computation. - * @param __ADDRESS__: NAND memory address. + * @param __ADDRESS__: NAND memory address. * @param __HANDLE__ : NAND handle. * @retval NAND Raw address value */ @@ -180,7 +183,7 @@ typedef struct /** * @brief NAND memory address cycling. - * @param __ADDRESS__: NAND memory address. + * @param __ADDRESS__: NAND memory address. * @retval NAND address cycling value. */ #define ADDR_1st_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__)& 0xFF) /* 1st addressing cycle */ @@ -190,7 +193,7 @@ typedef struct /* Exported functions --------------------------------------------------------*/ -/* Initialization/de-initialization functions **********************************/ +/* Initialization/de-initialization functions ********************************/ HAL_StatusTypeDef HAL_NAND_Init(NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingTypeDef *ComSpace_Timing, FMC_NAND_PCC_TimingTypeDef *AttSpace_Timing); HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand); void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand); @@ -198,7 +201,7 @@ void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand); void HAL_NAND_IRQHandler(NAND_HandleTypeDef *hnand); void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand); -/* IO operation functions *****************************************************/ +/* IO operation functions ****************************************************/ HAL_StatusTypeDef HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID); HAL_StatusTypeDef HAL_NAND_Reset(NAND_HandleTypeDef *hnand); HAL_StatusTypeDef HAL_NAND_Read_Page(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumPageToRead); @@ -209,12 +212,12 @@ HAL_StatusTypeDef HAL_NAND_Erase_Block(NAND_HandleTypeDef *hnand, NAND_AddressT uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand); uint32_t HAL_NAND_Address_Inc(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress); -/* NAND Control functions ******************************************************/ +/* NAND Control functions ****************************************************/ HAL_StatusTypeDef HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand); HAL_StatusTypeDef HAL_NAND_ECC_Disable(NAND_HandleTypeDef *hnand); HAL_StatusTypeDef HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, uint32_t Timeout); -/* NAND State functions *********************************************************/ +/* NAND State functions *******************************************************/ HAL_NAND_StateTypeDef HAL_NAND_GetState(NAND_HandleTypeDef *hnand); uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.c index c1e85f7ac3..ddeebae396 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_nor.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief NOR HAL module driver. * This file provides a generic firmware to drive NOR memories mounted * as external device. @@ -126,7 +126,8 @@ /** * @brief Perform the NOR memory Initialization sequence - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param Timing: pointer to NOR control timing structure * @param ExtTiming: pointer to NOR extended mode timing structure * @retval HAL status @@ -165,7 +166,8 @@ HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDe /** * @brief Perform NOR memory De-Initialization sequence - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @retval HAL status */ HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor) @@ -187,7 +189,8 @@ HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor) /** * @brief NOR MSP Init - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @retval None */ __weak void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor) @@ -199,7 +202,8 @@ __weak void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor) /** * @brief NOR MSP DeInit - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @retval None */ __weak void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor) @@ -211,7 +215,8 @@ __weak void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor) /** * @brief NOR BSP Wait fro Ready/Busy signal - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param Timeout: Maximum timeout value * @retval None */ @@ -242,7 +247,8 @@ __weak void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout) /** * @brief Read NOR flash IDs - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param pNOR_ID : pointer to NOR ID structure * @retval HAL status */ @@ -282,7 +288,8 @@ HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_I /** * @brief Returns the NOR memory to Read mode. - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @retval HAL status */ HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor) @@ -309,7 +316,8 @@ HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor) /** * @brief Read data from NOR memory - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param pAddress: pointer to Device address * @param pData : pointer to read data * @retval HAL status @@ -347,7 +355,8 @@ HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint /** * @brief Program data to NOR memory - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param pAddress: Device address * @param pData : pointer to the data to write * @retval HAL status @@ -385,7 +394,8 @@ HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, u /** * @brief Reads a block of data from the FMC NOR memory. - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param uwAddress: NOR memory internal address to read from. * @param pData: pointer to the buffer that receives the data read from the * NOR memory. @@ -431,7 +441,8 @@ HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress /** * @brief Writes a half-word buffer to the FMC NOR memory. This function * must be used only with S29GL128P NOR memory. - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param uwAddress: NOR memory internal address from which the data * @param pData: pointer to source data buffer. * @param uwBufferSize: number of Half words to write. The maximum allowed @@ -493,7 +504,8 @@ HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddr /** * @brief Erase the specified block of the NOR memory - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param BlockAddress : Block to erase address * @param Address: Device address * @retval HAL status @@ -532,7 +544,8 @@ HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAdd /** * @brief Erase the entire NOR chip. - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param Address : Device address * @retval HAL status */ @@ -569,7 +582,8 @@ HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address) /** * @brief Read NOR flash CFI IDs - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param pNOR_CFI : pointer to NOR CFI IDs structure * @retval HAL status */ @@ -626,7 +640,8 @@ HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR /** * @brief Enables dynamically NOR write operation. - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @retval HAL status */ HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor) @@ -648,7 +663,8 @@ HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor) /** * @brief Disables dynamically NOR write operation. - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @retval HAL status */ HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor) @@ -683,7 +699,7 @@ HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor) ##### NOR State functions ##### ============================================================================== [..] - This subsection permit to get in run-time the status of the NOR controller + This subsection permits to get in run-time the status of the NOR controller and the data flow. @endverbatim @@ -692,7 +708,8 @@ HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor) /** * @brief return the NOR controller state - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @retval NOR controller state */ HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor) @@ -702,7 +719,8 @@ HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor) /** * @brief Returns the NOR operation status. - * @param hnor: pointer to NOR handle + * @param hnor: pointer to a NOR_HandleTypeDef structure that contains + * the configuration information for NOR module. * @param Address: Device address * @param Timeout: NOR progamming Timeout * @retval NOR_Status: The returned value can be: NOR_SUCCESS, NOR_ERROR diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.h index 5de2e4eb9c..c47b4c79b5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_nor.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of NOR HAL module. ****************************************************************************** * @attention @@ -62,7 +62,7 @@ #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) -/* Exported typedef ----------------------------------------------------------*/ +/* Exported typedef ----------------------------------------------------------*/ /** * @brief HAL SRAM State structures definition */ @@ -71,10 +71,9 @@ typedef enum HAL_NOR_STATE_RESET = 0x00, /*!< NOR not yet initialized or disabled */ HAL_NOR_STATE_READY = 0x01, /*!< NOR initialized and ready for use */ HAL_NOR_STATE_BUSY = 0x02, /*!< NOR internal processing is ongoing */ - HAL_NOR_STATE_ERROR = 0x03, /*!< NOR error state */ - HAL_NOR_STATE_PROTECTED = 0x04 /*!< NOR NORSRAM device write protected */ - -}HAL_NOR_StateTypeDef; + HAL_NOR_STATE_ERROR = 0x03, /*!< NOR error state */ + HAL_NOR_STATE_PROTECTED = 0x04 /*!< NOR NORSRAM device write protected */ +}HAL_NOR_StateTypeDef; /** * @brief FMC NOR Status typedef @@ -85,8 +84,7 @@ typedef enum NOR_ONGOING, NOR_ERROR, NOR_TIMEOUT - -}NOR_StatusTypedef; +}NOR_StatusTypedef; /** * @brief FMC NOR ID typedef @@ -94,19 +92,17 @@ typedef enum typedef struct { uint16_t Manufacturer_Code; /*!< Defines the device's manufacturer code used to identify the memory */ - - uint16_t Device_Code1; - - uint16_t Device_Code2; - - uint16_t Device_Code3; /*!< Defines the device's codes used to identify the memory. + + uint16_t Device_Code1; + + uint16_t Device_Code2; + + uint16_t Device_Code3; /*!< Defines the devices' codes used to identify the memory. These codes can be accessed by performing read operations with specific control signals and addresses set.They can also be accessed by issuing - an Auto Select command */ - + an Auto Select command */ }NOR_IDTypeDef; - /** * @brief FMC NOR CFI typedef */ @@ -115,32 +111,31 @@ typedef struct /*!< Defines the information stored in the memory's Common flash interface which contains a description of various electrical and timing parameters, density information and functions supported by the memory */ - - uint16_t CFI_1; - - uint16_t CFI_2; - - uint16_t CFI_3; - - uint16_t CFI_4; - + + uint16_t CFI_1; + + uint16_t CFI_2; + + uint16_t CFI_3; + + uint16_t CFI_4; }NOR_CFITypeDef; /** - * @brief NOR handle Structure definition + * @brief NOR handle Structure definition */ typedef struct { - FMC_NORSRAM_TypeDef *Instance; /*!< Register base address */ - + FMC_NORSRAM_TypeDef *Instance; /*!< Register base address */ + FMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */ - + FMC_NORSRAM_InitTypeDef Init; /*!< NOR device control configuration parameters */ - HAL_LockTypeDef Lock; /*!< NOR locking object */ - + HAL_LockTypeDef Lock; /*!< NOR locking object */ + __IO HAL_NOR_StateTypeDef State; /*!< NOR device access state */ - + }NOR_HandleTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -173,6 +168,13 @@ typedef struct */ /* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset NOR handle state + * @param __HANDLE__: specifies the NOR handle. + * @retval None + */ +#define __HAL_NOR_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NOR_STATE_RESET) + /** * @brief NOR memory address shifting. * @param __ADDRESS__: NOR memory address @@ -194,14 +196,14 @@ typedef struct /* Exported functions --------------------------------------------------------*/ -/* Initialization/de-initialization functions **********************************/ +/* Initialization/de-initialization functions ********************************/ HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming); HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor); void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor); void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor); void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout); -/* I/O operation functions *****************************************************/ +/* I/O operation functions ***************************************************/ HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID); HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor); HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData); @@ -214,11 +216,11 @@ HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAdd HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address); HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI); -/* NOR Control functions *******************************************************/ +/* NOR Control functions *****************************************************/ HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor); HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor); -/* NOR State functions **********************************************************/ +/* NOR State functions ********************************************************/ HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor); NOR_StatusTypedef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.c index 99fd7eef13..850107de9f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pccard.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief PCCARD HAL module driver. * This file provides a generic firmware to drive PCCARD memories mounted * as external device. @@ -116,7 +116,8 @@ /** * @brief Perform the PCCARD memory Initialization sequence - * @param hpccard : pointer to PCCARD handle + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. * @param ComSpaceTiming: Common space timing structure * @param AttSpaceTiming: Attribute space timing structure * @param IOSpaceTiming: IO space timing structure @@ -163,7 +164,8 @@ HAL_StatusTypeDef HAL_PCCARD_Init(PCCARD_HandleTypeDef *hpccard, FMC_NAND_PCC_Ti /** * @brief Perform the PCCARD memory De-initialization sequence - * @param hpccard : pointer to PCCARD handle + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. * @retval HAL status */ HAL_StatusTypeDef HAL_PCCARD_DeInit(PCCARD_HandleTypeDef *hpccard) @@ -185,7 +187,8 @@ HAL_StatusTypeDef HAL_PCCARD_DeInit(PCCARD_HandleTypeDef *hpccard) /** * @brief PCCARD MSP Init - * @param hpccard : pointer to PCCARD handle + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. * @retval None */ __weak void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard) @@ -197,7 +200,8 @@ __weak void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard) /** * @brief PCCARD MSP DeInit - * @param hpccard : pointer to PCCARD handle + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. * @retval None */ __weak void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard) @@ -227,8 +231,9 @@ __weak void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard) /** * @brief Read Compact Flash's ID. - * @param hpccard : pointer to PCCARD handle - * @param CF_ID: Compact flash ID structure. + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. + * @param CompactFlash_ID: Compact flash ID structure. * @param pStatus: pointer to compact flash status * @retval HAL status * @@ -289,10 +294,11 @@ HAL_StatusTypeDef HAL_CF_Read_ID(PCCARD_HandleTypeDef *hpccard, uint8_t CompactF /** * @brief Read sector from PCCARD memory - * @param hpccard : pointer to PCCARD handle - * @param pBuffer : pointer to destination read buffer - * @param SectorAddress : Sector address to read - * @param pStatus : pointer to CF status + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. + * @param pBuffer: pointer to destination read buffer + * @param SectorAddress: Sector address to read + * @param pStatus: pointer to CF status * @retval HAL status */ HAL_StatusTypeDef HAL_CF_Read_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress, uint8_t *pStatus) @@ -364,10 +370,11 @@ HAL_StatusTypeDef HAL_CF_Read_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pB /** * @brief Write sector to PCCARD memory - * @param hpccard : pointer to PCCARD handle - * @param pBuffer : pointer to source write buffer - * @param SectorAddress : Sector address to write - * @param pStatus : pointer to CF status + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. + * @param pBuffer: pointer to source write buffer + * @param SectorAddress: Sector address to write + * @param pStatus: pointer to CF status * @retval HAL status */ HAL_StatusTypeDef HAL_CF_Write_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress, uint8_t *pStatus) @@ -437,9 +444,10 @@ HAL_StatusTypeDef HAL_CF_Write_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *p /** * @brief Erase sector from PCCARD memory - * @param hpccard : pointer to PCCARD handle - * @param SectorAddress : Sector address to erase - * @param pStatus : pointer to CF status + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. + * @param SectorAddress: Sector address to erase + * @param pStatus: pointer to CF status * @retval HAL status */ HAL_StatusTypeDef HAL_CF_Erase_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t SectorAddress, uint8_t *pStatus) @@ -495,7 +503,8 @@ HAL_StatusTypeDef HAL_CF_Erase_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t S /** * @brief Reset the PCCARD memory - * @param hpccard : pointer to PCCARD handle + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. * @retval HAL status */ HAL_StatusTypeDef HAL_CF_Reset(PCCARD_HandleTypeDef *hpccard) @@ -533,7 +542,8 @@ HAL_StatusTypeDef HAL_CF_Reset(PCCARD_HandleTypeDef *hpccard) /** * @brief This function handles PCCARD device interrupt request. - * @param hpccard : pointer to PCCARD handle + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. * @retval HAL status */ void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef *hpccard) @@ -582,7 +592,8 @@ void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef *hpccard) /** * @brief PCCARD interrupt feature callback - * @param hpccard : pointer to PCCARD handle + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. * @retval None */ __weak void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard) @@ -604,7 +615,7 @@ __weak void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard) ##### PCCARD State functions ##### ============================================================================== [..] - This subsection permit to get in run-time the status of the PCCARD controller + This subsection permits to get in run-time the status of the PCCARD controller and the data flow. @endverbatim @@ -613,8 +624,9 @@ __weak void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard) /** * @brief return the PCCARD controller state - * @param hpccard : pointer to PCCARD handle - * @retval PCCARD controller state + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. + * @retval HAL state */ HAL_PCCARD_StateTypeDef HAL_PCCARD_GetState(PCCARD_HandleTypeDef *hpccard) { @@ -623,7 +635,8 @@ HAL_PCCARD_StateTypeDef HAL_PCCARD_GetState(PCCARD_HandleTypeDef *hpccard) /** * @brief Get the compact flash memory status - * @param hpccard: PCCARD handle + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. * @retval New status of the CF operation. This parameter can be: * - CompactFlash_TIMEOUT_ERROR: when the previous operation generate * a Timeout error @@ -659,7 +672,8 @@ CF_StatusTypedef HAL_CF_GetStatus(PCCARD_HandleTypeDef *hpccard) /** * @brief Reads the Compact Flash memory status using the Read status command - * @param hpccard : pointer to PCCARD handle + * @param hpccard: pointer to a PCCARD_HandleTypeDef structure that contains + * the configuration information for PCCARD module. * @retval The status of the Compact Flash memory. This parameter can be: * - CompactFlash_BUSY: when memory is busy * - CompactFlash_READY: when memory is ready for the next operation diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.h index 759393c05d..53d5b3a95b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pccard.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of PCCARD HAL module. ****************************************************************************** * @attention @@ -138,6 +138,13 @@ typedef struct /** * @} */ +/* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset PCCARD handle state + * @param __HANDLE__: specifies the PCCARD handle. + * @retval None + */ +#define __HAL_PCCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_PCCARD_STATE_RESET) /* Exported functions --------------------------------------------------------*/ /* Initialization/de-initialization functions **********************************/ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.c index 7a72f2f0ab..d1a53ac220 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pcd.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief PCD HAL module driver. * This file provides firmware functions to manage the following * functionalities of the USB Peripheral Controller: @@ -597,7 +597,7 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) } /** * @brief Setup stage callback - * @param hpcd: ppp handle + * @param hpcd: PCD handle * @retval None */ __weak void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) @@ -694,7 +694,7 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) /** * @brief Disconnection event callbacks - * @param hpcd: ppp handle + * @param hpcd: PCD handle * @retval None */ __weak void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) @@ -726,8 +726,6 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) /** * @brief Send an amount of data in blocking mode * @param hpcd: PCD handle - * @param pData: pointer to data buffer - * @param Size: amount of data to be sent * @retval HAL status */ HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd) @@ -741,8 +739,6 @@ HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd) /** * @brief Send an amount of data in blocking mode * @param hpcd: PCD handle - * @param pData: pointer to data buffer - * @param Size: amount of data to be sent * @retval HAL status */ HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd) @@ -1025,7 +1021,7 @@ HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) /** * @brief Update FIFO configuration * @param hpcd: PCD handle - * @retval status + * @retval HAL status */ HAL_StatusTypeDef HAL_PCD_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size) { @@ -1069,7 +1065,7 @@ HAL_StatusTypeDef HAL_PCD_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint1 /** * @brief Update FIFO configuration * @param hpcd: PCD handle - * @retval status + * @retval HAL status */ HAL_StatusTypeDef HAL_PCD_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size) { @@ -1083,7 +1079,7 @@ HAL_StatusTypeDef HAL_PCD_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size) /** * @brief HAL_PCD_ActiveRemoteWakeup : active remote wakeup signalling * @param hpcd: PCD handle - * @retval status + * @retval HAL status */ HAL_StatusTypeDef HAL_PCD_ActiveRemoteWakeup(PCD_HandleTypeDef *hpcd) { @@ -1100,7 +1096,7 @@ HAL_StatusTypeDef HAL_PCD_ActiveRemoteWakeup(PCD_HandleTypeDef *hpcd) /** * @brief HAL_PCD_DeActiveRemoteWakeup : de-active remote wakeup signalling * @param hpcd: PCD handle - * @retval status + * @retval HAL status */ HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup(PCD_HandleTypeDef *hpcd) { @@ -1122,7 +1118,7 @@ HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup(PCD_HandleTypeDef *hpcd) ##### Peripheral State functions ##### =============================================================================== [..] - This subsection permit to get in run-time the status of the peripheral + This subsection permits to get in run-time the status of the peripheral and the data flow. @endverbatim @@ -1131,7 +1127,7 @@ HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup(PCD_HandleTypeDef *hpcd) /** * @brief Return the PCD state - * @param hpcd : PCD handle + * @param hpcd: PCD handle * @retval HAL state */ PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd) @@ -1146,7 +1142,7 @@ PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd) * @brief DCD_WriteEmptyTxFifo * check FIFO for the next packet to be loaded * @param hpcd: PCD handle - * @retval status + * @retval HAL status */ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t epnum) { diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.h index 02c8973433..78a10a861d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pcd.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of PCD HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.c index 7577942add..04e9226a35 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pwr.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief PWR HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Power Controller (PWR) peripheral: @@ -276,6 +276,9 @@ void HAL_PWR_PVDConfig(PWR_PVDTypeDef *sConfigPVD) { __HAL_PVD_EXTI_ENABLE_IT(PWR_EXTI_LINE_PVD); } + /* Clear the edge trigger for the EXTI Line 16 (PVD) */ + EXTI->RTSR &= ~EXTI_RTSR_TR16; + EXTI->FTSR &= ~EXTI_FTSR_TR16; /* Configure the rising edge */ if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\ (sConfigPVD->Mode == PWR_MODE_IT_RISING)) @@ -312,7 +315,7 @@ void HAL_PWR_DisablePVD(void) /** * @brief Enables the WakeUp PINx functionality. - * @param WakeUpPinx: Specifies the Power Wake-Up pin to enable + * @param WakeUpPinx: Specifies the Power Wake-Up pin to enable. * This parameter can be one of the following values: * @arg PWR_WAKEUP_PIN1 * @retval None @@ -326,7 +329,7 @@ void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx) /** * @brief Disables the WakeUp PINx functionality. - * @param WakeUpPinx: Specifies the Power Wake-Up pin to disable + * @param WakeUpPinx: Specifies the Power Wake-Up pin to disable. * This parameter can be one of the following values: * @arg PWR_WAKEUP_PIN1 * @retval None @@ -363,10 +366,7 @@ void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry) /* Check the parameters */ assert_param(IS_PWR_REGULATOR(Regulator)); assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry)); - - /* Disable SysTick Timer */ - SysTick->CTRL &= 0xFE; - + /* Select SLEEP mode entry -------------------------------------------------*/ if(SLEEPEntry == PWR_SLEEPENTRY_WFI) { @@ -376,11 +376,10 @@ void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry) else { /* Request Wait For Event */ + __SEV(); + __WFE(); __WFE(); } - - /* Enable SysTick Timer */ - SysTick->CTRL |= 0x01; } /** @@ -490,8 +489,8 @@ void HAL_PWR_PVD_IRQHandler(void) /** * @brief PWR PVD interrupt callback - * @param none - * @retval none + * @param None + * @retval None */ __weak void HAL_PWR_PVDCallback(void) { diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.h index 350de24e4a..3986a5a77d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pwr.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of PWR HAL module. ****************************************************************************** * @attention @@ -60,7 +60,7 @@ */ typedef struct { - uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level + uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level. This parameter can be a value of @ref PWR_PVD_detection_level */ uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.c index 36556ce779..f261b6f73e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pwr_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Extended PWR HAL module driver. * This file provides firmware functions to manage the following * functionalities of PWR extension peripheral: @@ -172,7 +172,7 @@ HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg(void) /** * @brief Disables the Backup Regulator. * @param None - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg(void) { diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.h index 57362779e5..4bb9b300d5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pwr_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of PWR HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.c index a1e82d30fd..dd8f183e5c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rcc.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief RCC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Reset and Clock Control (RCC) peripheral: @@ -115,7 +115,7 @@ const uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, ##### Initialization and de-initialization functions ##### =============================================================================== [..] - This section provide functions allowing to configure the internal/external oscillators + This section provides functions allowing to configure the internal/external oscillators (HSE, HSI, LSE, LSI, PLL, CSS and MCO) and the System busses clocks (SYSCLK, AHB, APB1 and APB2). @@ -176,77 +176,17 @@ const uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, (#) For the STM32F405xx/07xx and STM32F415xx/17xx devices, the maximum frequency of the SYSCLK and HCLK is 168 MHz, PCLK2 84 MHz and PCLK1 42 MHz. Depending on the device voltage range, the maximum frequency should - be adapted accordingly: - +-------------------------------------------------------------------------------------+ - | Latency | HCLK clock frequency (MHz) | - | |---------------------------------------------------------------------| - | | voltage range | voltage range | voltage range | voltage range | - | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V | - |---------------|----------------|----------------|-----------------|-----------------| - |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 22 |0 < HCLK <= 20 | - |---------------|----------------|----------------|-----------------|-----------------| - |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |22 < HCLK <= 44 |20 < HCLK <= 40 | - |---------------|----------------|----------------|-----------------|-----------------| - |2WS(3CPU cycle)|60 < HCLK <= 90 |48 < HCLK <= 72 |44 < HCLK <= 66 |40 < HCLK <= 60 | - |---------------|----------------|----------------|-----------------|-----------------| - |3WS(4CPU cycle)|90 < HCLK <= 120|72 < HCLK <= 96 |66 < HCLK <= 88 |60 < HCLK <= 80 | - |---------------|----------------|----------------|-----------------|-----------------| - |4WS(5CPU cycle)|120< HCLK <= 150|96 < HCLK <= 120|88 < HCLK <= 110 |80 < HCLK <= 100 | - |---------------|----------------|----------------|-----------------|-----------------| - |5WS(6CPU cycle)|150< HCLK <= 168|120< HCLK <= 144|110 < HCLK <= 132|100 < HCLK <= 120| - |---------------|----------------|----------------|-----------------|-----------------| - |6WS(7CPU cycle)| NA |144< HCLK <= 168|132 < HCLK <= 154|120 < HCLK <= 140| - |---------------|----------------|----------------|-----------------|-----------------| - |7WS(8CPU cycle)| NA | NA |154 < HCLK <= 168|140 < HCLK <= 160| - +-------------------------------------------------------------------------------------+ + be adapted accordingly (refer to the product datasheets for more details). + (#) For the STM32F42xxx and STM32F43xxx devices, the maximum frequency of the SYSCLK and HCLK is 180 MHz, PCLK2 90 MHz and PCLK1 45 MHz. Depending on the device voltage range, the maximum frequency should - be adapted accordingly: - +-------------------------------------------------------------------------------------+ - | Latency | HCLK clock frequency (MHz) | - | |---------------------------------------------------------------------| - | | voltage range | voltage range | voltage range | voltage range | - | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V | - |---------------|----------------|----------------|-----------------|-----------------| - |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 22 |0 < HCLK <= 20 | - |---------------|----------------|----------------|-----------------|-----------------| - |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |22 < HCLK <= 44 |20 < HCLK <= 40 | - |---------------|----------------|----------------|-----------------|-----------------| - |2WS(3CPU cycle)|60 < HCLK <= 90 |48 < HCLK <= 72 |44 < HCLK <= 66 |40 < HCLK <= 60 | - |---------------|----------------|----------------|-----------------|-----------------| - |3WS(4CPU cycle)|90 < HCLK <= 120|72 < HCLK <= 96 |66 < HCLK <= 88 |60 < HCLK <= 80 | - |---------------|----------------|----------------|-----------------|-----------------| - |4WS(5CPU cycle)|120< HCLK <= 150|96 < HCLK <= 120|88 < HCLK <= 110 |80 < HCLK <= 100 | - |---------------|----------------|----------------|-----------------|-----------------| - |5WS(6CPU cycle)|150< HCLK <= 180|120< HCLK <= 144|110 < HCLK <= 132|100 < HCLK <= 120| - |---------------|----------------|----------------|-----------------|-----------------| - |6WS(7CPU cycle)| NA |144< HCLK <= 168|132 < HCLK <= 154|120 < HCLK <= 140| - |---------------|----------------|----------------|-----------------|-----------------| - |7WS(8CPU cycle)| NA |168< HCLK <= 180|154 < HCLK <= 176|140 < HCLK <= 160| - |-------------------------------------------------------------------------------------| - |8WS(9CPU cycle)| NA | NA |176 < HCLK <= 180|160 < HCLK <= 180| - +-------------------------------------------------------------------------------------+ + be adapted accordingly (refer to the product datasheets for more details). + (#) For the STM32F401xx, the maximum frequency of the SYSCLK and HCLK is 84 MHz, PCLK2 84 MHz and PCLK1 42 MHz. Depending on the device voltage range, the maximum frequency should - be adapted accordingly: - +-------------------------------------------------------------------------------------+ - | Latency | HCLK clock frequency (MHz) | - | |---------------------------------------------------------------------| - | | voltage range | voltage range | voltage range | voltage range | - | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V | - |---------------|----------------|----------------|-----------------|-----------------| - |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 22 |0 < HCLK <= 20 | - |---------------|----------------|----------------|-----------------|-----------------| - |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |22 < HCLK <= 44 |20 < HCLK <= 40 | - |---------------|----------------|----------------|-----------------|-----------------| - |2WS(3CPU cycle)|60 < HCLK <= 84 |48 < HCLK <= 72 |44 < HCLK <= 66 |40 < HCLK <= 60 | - |---------------|----------------|----------------|-----------------|-----------------| - |3WS(4CPU cycle)| NA |72 < HCLK <= 84 |66 < HCLK <= 84 |60 < HCLK <= 80 | - |---------------|----------------|----------------|-----------------|-----------------| - |4WS(5CPU cycle)| NA | NA | NA |80 < HCLK <= 84 | - +-------------------------------------------------------------------------------------+ + be adapted accordingly (refer to the product datasheets for more details). @endverbatim * @{ */ @@ -301,8 +241,7 @@ void HAL_RCC_DeInit(void) */ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) { - - uint32_t timeout = 0; + uint32_t tickstart = 0; /* Check the parameters */ assert_param(IS_RCC_OSCILLATORTYPE(RCC_OscInitStruct->OscillatorType)); @@ -324,16 +263,16 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) /* Reset HSEON and HSEBYP bits before configuring the HSE --------------*/ __HAL_RCC_HSE_CONFIG(RCC_HSE_OFF); - /* Get timeout */ - timeout = HAL_GetTick() + HSE_TIMEOUT_VALUE; + /* Get Start Tick*/ + tickstart = HAL_GetTick(); /* Wait till HSE is disabled */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } /* Set the new HSE configuration ---------------------------------------*/ @@ -342,30 +281,30 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) /* Check the HSE State */ if((RCC_OscInitStruct->HSEState) == RCC_HSE_ON) { - /* Get timeout */ - timeout = HAL_GetTick() + HSE_TIMEOUT_VALUE; + /* Get Start Tick*/ + tickstart = HAL_GetTick(); /* Wait till HSE is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } else { - /* Get timeout */ - timeout = HAL_GetTick() + HSE_TIMEOUT_VALUE; + /* Get Start Tick*/ + tickstart = HAL_GetTick(); /* Wait till HSE is bypassed or disabled */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } } @@ -393,16 +332,16 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) /* Enable the Internal High Speed oscillator (HSI). */ __HAL_RCC_HSI_ENABLE(); - /* Get timeout */ - timeout = HAL_GetTick() + HSI_TIMEOUT_VALUE; + /* Get Start Tick*/ + tickstart = HAL_GetTick(); /* Wait till HSI is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > HSI_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } /* Adjusts the Internal High Speed oscillator (HSI) calibration value.*/ @@ -413,16 +352,16 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) /* Disable the Internal High Speed oscillator (HSI). */ __HAL_RCC_HSI_DISABLE(); - /* Get timeout */ - timeout = HAL_GetTick() + HSI_TIMEOUT_VALUE; + /* Get Start Tick*/ + tickstart = HAL_GetTick(); /* Wait till HSI is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > HSI_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } } @@ -438,34 +377,34 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) { /* Enable the Internal Low Speed oscillator (LSI). */ __HAL_RCC_LSI_ENABLE(); - - /* Get timeout */ - timeout = HAL_GetTick() + LSI_TIMEOUT_VALUE; - + + /* Get Start Tick*/ + tickstart = HAL_GetTick(); + /* Wait till LSI is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > LSI_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } else { /* Disable the Internal Low Speed oscillator (LSI). */ __HAL_RCC_LSI_DISABLE(); - - /* Get timeout */ - timeout = HAL_GetTick() + LSI_TIMEOUT_VALUE; + + /* Get Start Tick*/ + tickstart = HAL_GetTick(); /* Wait till LSI is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) != RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > LSI_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } } @@ -482,29 +421,29 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) PWR->CR |= PWR_CR_DBP; /* Wait for Backup domain Write protection disable */ - timeout = HAL_GetTick() + DBP_TIMEOUT_VALUE; + tickstart = HAL_GetTick(); while((PWR->CR & PWR_CR_DBP) == RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > DBP_TIMEOUT_VALUE) { return HAL_TIMEOUT; } } - + /* Reset LSEON and LSEBYP bits before configuring the LSE ----------------*/ __HAL_RCC_LSE_CONFIG(RCC_LSE_OFF); - /* Get timeout */ - timeout = HAL_GetTick() + LSE_TIMEOUT_VALUE; - + /* Get Start Tick*/ + tickstart = HAL_GetTick(); + /* Wait till LSE is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) != RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > LSE_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } /* Set the new LSE configuration -----------------------------------------*/ @@ -512,30 +451,30 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) /* Check the LSE State */ if((RCC_OscInitStruct->LSEState) == RCC_LSE_ON) { - /* Get timeout */ - timeout = HAL_GetTick() + LSE_TIMEOUT_VALUE; + /* Get Start Tick*/ + tickstart = HAL_GetTick(); /* Wait till LSE is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > LSE_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } else { - /* Get timeout */ - timeout = HAL_GetTick() + LSE_TIMEOUT_VALUE; + /* Get Start Tick*/ + tickstart = HAL_GetTick(); /* Wait till LSE is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) != RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > LSE_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } } @@ -558,17 +497,17 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) /* Disable the main PLL. */ __HAL_RCC_PLL_DISABLE(); - - /* Get timeout */ - timeout = HAL_GetTick() + PLL_TIMEOUT_VALUE; - + + /* Get Start Tick*/ + tickstart = HAL_GetTick(); + /* Wait till PLL is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) != RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > PLL_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } /* Configure the main PLL clock source, multiplication and division factors. */ @@ -580,32 +519,33 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) /* Enable the main PLL. */ __HAL_RCC_PLL_ENABLE(); - /* Get timeout */ - timeout = HAL_GetTick() + PLL_TIMEOUT_VALUE; - + /* Get Start Tick*/ + tickstart = HAL_GetTick(); + /* Wait till PLL is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > PLL_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } else { /* Disable the main PLL. */ __HAL_RCC_PLL_DISABLE(); - /* Get timeout */ - timeout = HAL_GetTick() + PLL_TIMEOUT_VALUE; - + + /* Get Start Tick*/ + tickstart = HAL_GetTick(); + /* Wait till PLL is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) != RESET) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > PLL_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } } @@ -644,8 +584,7 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) */ HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency) { - - uint32_t timeout = 0; + uint32_t tickstart = 0; /* Check the parameters */ assert_param(IS_RCC_CLOCKTYPE(RCC_ClkInitStruct->ClockType)); @@ -668,6 +607,13 @@ HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, ui return HAL_ERROR; } + /*-------------------------- HCLK Configuration --------------------------*/ + if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK) + { + assert_param(IS_RCC_HCLK(RCC_ClkInitStruct->AHBCLKDivider)); + MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, RCC_ClkInitStruct->AHBCLKDivider); + } + /*------------------------- SYSCLK Configuration ---------------------------*/ if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_SYSCLK) == RCC_CLOCKTYPE_SYSCLK) { @@ -702,34 +648,34 @@ HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, ui } MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, RCC_ClkInitStruct->SYSCLKSource); - /* Get timeout */ - timeout = HAL_GetTick() + CLOCKSWITCH_TIMEOUT_VALUE; + /* Get Start Tick*/ + tickstart = HAL_GetTick(); if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE) { while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_CFGR_SWS_HSE) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK) { while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_CFGR_SWS_PLL) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } else { while(__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_CFGR_SWS_HSI) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE) { return HAL_TIMEOUT; } @@ -740,7 +686,14 @@ HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, ui /* Decreasing the CPU frequency */ else { - /*------------------------- SYSCLK Configuration ---------------------------*/ + /*-------------------------- HCLK Configuration --------------------------*/ + if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK) + { + assert_param(IS_RCC_HCLK(RCC_ClkInitStruct->AHBCLKDivider)); + MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, RCC_ClkInitStruct->AHBCLKDivider); + } + + /*------------------------- SYSCLK Configuration -------------------------*/ if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_SYSCLK) == RCC_CLOCKTYPE_SYSCLK) { assert_param(IS_RCC_SYSCLKSOURCE(RCC_ClkInitStruct->SYSCLKSource)); @@ -774,14 +727,14 @@ HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, ui } MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, RCC_ClkInitStruct->SYSCLKSource); - /* Get timeout */ - timeout = HAL_GetTick() + CLOCKSWITCH_TIMEOUT_VALUE; + /* Get Start Tick*/ + tickstart = HAL_GetTick(); if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE) { while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_CFGR_SWS_HSE) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE) { return HAL_TIMEOUT; } @@ -791,7 +744,7 @@ HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, ui { while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_CFGR_SWS_PLL) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE) { return HAL_TIMEOUT; } @@ -801,10 +754,10 @@ HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, ui { while(__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_CFGR_SWS_HSI) { - if(HAL_GetTick() >= timeout) + if((int32_t) (HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE) { return HAL_TIMEOUT; - } + } } } } @@ -819,14 +772,7 @@ HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, ui return HAL_ERROR; } } - - /*-------------------------- HCLK Configuration ----------------------------*/ - if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK) - { - assert_param(IS_RCC_HCLK(RCC_ClkInitStruct->AHBCLKDivider)); - MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, RCC_ClkInitStruct->AHBCLKDivider); - } - + /*-------------------------- PCLK1 Configuration ---------------------------*/ if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_PCLK1) == RCC_CLOCKTYPE_PCLK1) { @@ -841,16 +787,8 @@ HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, ui MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE2, ((RCC_ClkInitStruct->APB2CLKDivider) << 3)); } - /* Setup SysTick Timer for 1 msec interrupts. - ------------------------------------------ - The SysTick_Config() function is a CMSIS function which configure: - - The SysTick Reload register with value passed as function parameter. - - Configure the SysTick IRQ priority to the lowest value (0x0F). - - Reset the SysTick Counter register. - - Configure the SysTick Counter clock source to be Core Clock Source (HCLK). - - Enable the SysTick Interrupt. - - Start the SysTick Counter.*/ - SysTick_Config(HAL_RCC_GetHCLKFreq() / 1000); + /* Configure the source of time base considering new system clocks settings*/ + HAL_InitTick (TICK_INT_PRIORITY); return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.h index d86b5c7a15..9d79f49a11 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rcc.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of RCC HAL module. ****************************************************************************** * @attention @@ -67,16 +67,16 @@ typedef struct uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source. This parameter must be a value of @ref RCC_PLL_Clock_Source */ - uint32_t PLLM; /*!< PLLM: Division factor for PLL VCO input clock + uint32_t PLLM; /*!< PLLM: Division factor for PLL VCO input clock. This parameter must be a number between Min_Data = 0 and Max_Data = 63 */ - uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL VCO output clock + uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL VCO output clock. This parameter must be a number between Min_Data = 192 and Max_Data = 432 */ - uint32_t PLLP; /*!< PLLP: Division factor for main system clock (SYSCLK) - This parameter must be a value of @ref RCC_PLLP_Clock_Divider. */ + uint32_t PLLP; /*!< PLLP: Division factor for main system clock (SYSCLK). + This parameter must be a value of @ref RCC_PLLP_Clock_Divider */ - uint32_t PLLQ; /*!< PLLQ: Division factor for OTG FS, SDIO and RNG clocks + uint32_t PLLQ; /*!< PLLQ: Division factor for OTG FS, SDIO and RNG clocks. This parameter must be a number between Min_Data = 0 and Max_Data = 63 */ }RCC_PLLInitTypeDef; @@ -190,7 +190,7 @@ typedef struct #define DBP_TIMEOUT_VALUE ((uint32_t)100) -#define LSE_TIMEOUT_VALUE ((uint32_t)100) +#define LSE_TIMEOUT_VALUE ((uint32_t)500) /** * @} */ @@ -1042,11 +1042,6 @@ typedef struct */ #define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC)) -/** @defgroup RCC_Flags_Interrupts_Management - * @brief macros to manage the specified RCC Flags and interrupts. - * @{ - */ - /** @brief Enable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to enable * the selected interrupts). * @param __INTERRUPT__: specifies the RCC interrupt sources to be enabled. @@ -1126,9 +1121,6 @@ typedef struct */ #define RCC_FLAG_MASK ((uint8_t)0x1F) #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5) == 1)? RCC->CR :((((__FLAG__) >> 5) == 2) ? RCC->BDCR :((((__FLAG__) >> 5) == 3)? RCC->CSR :RCC->CIR))) & ((uint32_t)1 << ((__FLAG__) & RCC_FLAG_MASK)))!= 0)? 1 : 0) -/** - * @} - */ #define __RCC_PLLSRC() ((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> POSITION_VAL(RCC_PLLCFGR_PLLSRC)) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.c index c6808c35d0..53b5d22575 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rcc_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Extension RCC HAL module driver. * This file provides firmware functions to manage the following * functionalities RCC extension peripheral: @@ -316,8 +316,8 @@ HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClk /** * @brief Configures the RCC_OscInitStruct according to the internal * RCC configuration registers. - * @param RCC_OscInitStruct: pointer to an RCC_OscInitTypeDef structure that - * will be configured. + * @param PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that + * will be configured. * @retval None */ void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit) @@ -471,7 +471,7 @@ HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClk /** * @brief Configures the RCC_OscInitStruct according to the internal * RCC configuration registers. - * @param RCC_OscInitStruct: pointer to an RCC_OscInitTypeDef structure that + * @param PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that * will be configured. * @retval None */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.h index 2e06c34fda..200ed554a8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rcc_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of RCC HAL Extension module. ****************************************************************************** * @attention @@ -61,16 +61,16 @@ */ typedef struct { - uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock - This parameter must be a number between Min_Data = 192 and Max_Data = 432 + uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock. + This parameter must be a number between Min_Data = 192 and Max_Data = 432. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */ - uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock - This parameter must be a number between Min_Data = 2 and Max_Data = 7 + uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock. + This parameter must be a number between Min_Data = 2 and Max_Data = 7. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */ uint32_t PLLI2SQ; /*!< Specifies the division factor for SAI1 clock. - This parameter must be a number between Min_Data = 2 and Max_Data = 15 + This parameter must be a number between Min_Data = 2 and Max_Data = 15. This parameter will be used only when PLLI2S is selected as Clock Source SAI */ }RCC_PLLI2SInitTypeDef; @@ -80,15 +80,15 @@ typedef struct typedef struct { uint32_t PLLSAIN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock. - This parameter must be a number between Min_Data = 192 and Max_Data = 432 + This parameter must be a number between Min_Data = 192 and Max_Data = 432. This parameter will be used only when PLLSAI is selected as Clock Source SAI or LTDC */ uint32_t PLLSAIQ; /*!< Specifies the division factor for SAI1 clock. - This parameter must be a number between Min_Data = 2 and Max_Data = 15 + This parameter must be a number between Min_Data = 2 and Max_Data = 15. This parameter will be used only when PLLSAI is selected as Clock Source SAI or LTDC */ uint32_t PLLSAIR; /*!< specifies the division factor for LTDC clock - This parameter must be a number between Min_Data = 2 and Max_Data = 7 + This parameter must be a number between Min_Data = 2 and Max_Data = 7. This parameter will be used only when PLLSAI is selected as Clock Source LTDC */ }RCC_PLLSAIInitTypeDef; @@ -100,13 +100,13 @@ typedef struct uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */ - RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters + RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */ - RCC_PLLSAIInitTypeDef PLLSAI; /*!< PLL SAI structure parameters + RCC_PLLSAIInitTypeDef PLLSAI; /*!< PLL SAI structure parameters. This parameter will be used only when PLLI2S is selected as Clock Source SAI or LTDC */ - uint32_t PLLI2SDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock + uint32_t PLLI2SDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock. This parameter must be a number between Min_Data = 1 and Max_Data = 32 This parameter will be used only when PLLI2S is selected as Clock Source SAI */ @@ -117,10 +117,10 @@ typedef struct uint32_t PLLSAIDivR; /*!< Specifies the PLLSAI division factor for LTDC clock. This parameter must be one value of @ref RCCEx_PLLSAI_DIVR */ - uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection + uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection. This parameter can be a value of @ref RCC_RTC_Clock_Source */ - uint8_t TIMPresSelection; /*!< Specifies TIM Clock Prescalers Selection + uint8_t TIMPresSelection; /*!< Specifies TIM Clock Prescalers Selection. This parameter can be a value of @ref RCCEx_TIM_PRescaler_Selection */ }RCC_PeriphCLKInitTypeDef; @@ -132,12 +132,12 @@ typedef struct */ typedef struct { - uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock + uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock. This parameter must be a number between Min_Data = 192 and Max_Data = 432 This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */ - uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock - This parameter must be a number between Min_Data = 2 and Max_Data = 7 + uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock. + This parameter must be a number between Min_Data = 2 and Max_Data = 7. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */ }RCC_PLLI2SInitTypeDef; @@ -151,10 +151,10 @@ typedef struct uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */ - RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters + RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */ - uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection + uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection. This parameter can be a value of @ref RCC_RTC_Clock_Source */ }RCC_PeriphCLKInitTypeDef; diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.c index 7e40104426..d4d6fce1ba 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rng.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief RNG HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Random Number Generator (RNG) peripheral: @@ -102,7 +102,8 @@ /** * @brief Initializes the RNG according to the specified * parameters in the RNG_InitTypeDef and creates the associated handle. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval HAL status */ HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng) @@ -118,20 +119,23 @@ HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng) /* Init the low level hardware */ HAL_RNG_MspInit(hrng); } + /* Change RNG peripheral state */ + hrng->State = HAL_RNG_STATE_BUSY; /* Enable the RNG Peripheral */ __HAL_RNG_ENABLE(hrng); - + /* Initialize the RNG state */ hrng->State = HAL_RNG_STATE_READY; - + /* Return function status */ return HAL_OK; } /** * @brief DeInitializes the RNG peripheral. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval HAL status */ HAL_StatusTypeDef HAL_RNG_DeInit(RNG_HandleTypeDef *hrng) @@ -168,7 +172,8 @@ HAL_StatusTypeDef HAL_RNG_DeInit(RNG_HandleTypeDef *hrng) /** * @brief Initializes the RNG MSP. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval None */ __weak void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng) @@ -180,7 +185,8 @@ __weak void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng) /** * @brief DeInitializes the RNG MSP. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval None */ __weak void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng) @@ -215,7 +221,8 @@ __weak void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng) * @brief Returns a 32-bit random number. * @note Each time the random number data is read the RNG_FLAG_DRDY flag * is automatically cleared. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval 32-bit random number */ uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng) @@ -249,7 +256,8 @@ uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng) /** * @brief Returns a 32-bit random number with interrupt enabled. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval 32-bit random number */ uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng) @@ -286,13 +294,14 @@ uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng) * not have enough entropy. In this case, it is recommended to clear the * SEIS bit using __HAL_RNG_CLEAR_FLAG(), then disable and enable * the RNG peripheral to reinitialize and restart the RNG. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval None */ void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng) { - /* RNG clock error interrupt occured */ + /* RNG clock error interrupt occurred */ if(__HAL_RNG_GET_FLAG(hrng, RNG_IT_CEI) != RESET) { HAL_RNG_ErrorCallback(hrng); @@ -307,7 +316,7 @@ void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng) __HAL_UNLOCK(hrng); } - /* RNG seed error interrupt occured */ + /* RNG seed error interrupt occurred */ if(__HAL_RNG_GET_FLAG(hrng, RNG_IT_SEI) != RESET) { HAL_RNG_ErrorCallback(hrng); @@ -341,7 +350,8 @@ void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng) /** * @brief Data Ready callback in non-blocking mode. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval None */ @@ -354,7 +364,8 @@ __weak void HAL_RNG_ReadyCallback(RNG_HandleTypeDef* hrng) /** * @brief RNG error callbacks. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval None */ __weak void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng) @@ -385,7 +396,8 @@ __weak void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng) /** * @brief Returns the RNG state. - * @param hrng: RNG handle + * @param hrng: pointer to a RNG_HandleTypeDef structure that contains + * the configuration information for RNG. * @retval HAL state */ HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.h index 38bd68e241..876396a741 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rng.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of RNG HAL module. ****************************************************************************** * @attention @@ -121,6 +121,12 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset RNG handle state + * @param __HANDLE__: RNG Handle + * @retval None + */ +#define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET) + /** * @brief Enables the RNG peripheral. * @param __HANDLE__: RNG Handle diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.c index a28a883f7f..d968809906 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rtc.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief RTC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Real Time Clock (RTC) peripheral: @@ -24,7 +24,7 @@ the RTC when VDD is turned off, VBAT pin can be connected to an optional standby voltage supplied by a battery or by another source. - [..] To allow the RTC to operate even when the main digital supply (VDD) is turned + [..] To allow the RTC operating even when the main digital supply (VDD) is turned off, the VBAT pin powers the following blocks: (#) The RTC (#) The LSE oscillator @@ -32,13 +32,13 @@ (#) PC13 to PC15 I/Os, plus PI8 I/O (when available) [..] When the backup domain is supplied by VDD (analog switch connected to VDD), - the following functions are available: + the following pins are available: (#) PC14 and PC15 can be used as either GPIO or LSE pins (#) PC13 can be used as a GPIO or as the RTC_AF1 pin (#) PI8 can be used as a GPIO or as the RTC_AF2 pin [..] When the backup domain is supplied by VBAT (analog switch connected to VBAT - because VDD is not present), the following functions are available: + because VDD is not present), the following pins are available: (#) PC14 and PC15 can be used as LSE pins only (#) PC13 can be used as the RTC_AF1 pin (#) PI8 can be used as the RTC_AF2 pin @@ -47,7 +47,7 @@ ================================================================== [..] The backup domain reset sets all RTC registers and the RCC_BDCR register to their reset values. The BKPSRAM is not affected by this reset. The only - way of resetting the BKPSRAM is through the Flash interface by requesting + way to reset the BKPSRAM is through the Flash interface by requesting a protection level change from 1 to 0. [..] A backup domain reset is generated when one of the following events occurs: (#) Software reset, triggered by setting the BDRST bit in the @@ -101,7 +101,7 @@ or the RTC wakeup events. [..] The RTC provides a programmable time base for waking up from the Stop or Standby mode at regular intervals. - Wakeup from STOP and Standby modes is possible only when the RTC clock source + Wakeup from STOP and STANDBY modes is possible only when the RTC clock source is LSE or LSI. @endverbatim @@ -167,18 +167,18 @@ =============================================================================== ##### Initialization and de-initialization functions ##### =============================================================================== - [..] This section provide functions allowing to initialize and configure the + [..] This section provides functions allowing to initialize and configure the RTC Prescaler (Synchronous and Asynchronous), RTC Hour format, disable RTC registers Write protection, enter and exit the RTC initialization mode, RTC registers synchronization check and reference clock detection enable. (#) The RTC Prescaler is programmed to generate the RTC 1Hz time base. It is split into 2 programmable prescalers to minimize power consumption. - (++) A 7-bit asynchronous prescaler and A 13-bit synchronous prescaler. + (++) A 7-bit asynchronous prescaler and a 13-bit synchronous prescaler. (++) When both prescalers are used, it is recommended to configure the - asynchronous prescaler to a high value to minimize consumption. + asynchronous prescaler to a high value to minimize power consumption. (#) All RTC registers are Write protected. Writing to the RTC registers is enabled by writing a key into the Write Protection register, RTC_WPR. - (#) To Configure the RTC Calendar, user application should enter + (#) To configure the RTC Calendar, user application should enter initialization mode. In this mode, the calendar counter is stopped and its value can be updated. When the initialization sequence is complete, the calendar restarts counting after 4 RTCCLK cycles. @@ -196,7 +196,8 @@ /** * @brief Initializes the RTC peripheral - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc) @@ -267,7 +268,8 @@ HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc) /** * @brief DeInitializes the RTC peripheral - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @note This function doesn't reset the RTC Backup Data registers. * @retval HAL status */ @@ -366,7 +368,8 @@ HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc) /** * @brief Initializes the RTC MSP. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ __weak void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) @@ -378,7 +381,8 @@ __weak void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) /** * @brief DeInitializes the RTC MSP. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ __weak void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) @@ -400,7 +404,7 @@ __weak void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) ##### RTC Time and Date functions ##### =============================================================================== - [..] This section provide functions allowing to configure Time and Date features + [..] This section provides functions allowing to configure Time and Date features @endverbatim * @{ @@ -408,12 +412,13 @@ __weak void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) /** * @brief Sets RTC current time. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sTime: Pointer to Time structure * @param Format: Specifies the format of the entered parameters. * This parameter can be one of the following values: - * @arg Format_BIN: Binary data format - * @arg Format_BCD: BCD data format + * @arg FORMAT_BIN: Binary data format + * @arg FORMAT_BCD: BCD data format * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format) @@ -532,12 +537,13 @@ HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTim /** * @brief Gets RTC current time. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sTime: Pointer to Time structure * @param Format: Specifies the format of the entered parameters. * This parameter can be one of the following values: - * @arg Format_BIN: Binary data format - * @arg Format_BCD: BCD data format + * @arg FORMAT_BIN: Binary data format + * @arg FORMAT_BCD: BCD data format * @note Call HAL_RTC_GetDate() after HAL_RTC_GetTime() to unlock the values * in the higher-order calendar shadow registers. * @retval HAL status @@ -575,12 +581,13 @@ HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTim /** * @brief Sets RTC current date. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sDate: Pointer to date structure * @param Format: specifies the format of the entered parameters. * This parameter can be one of the following values: - * @arg Format_BIN: Binary data format - * @arg Format_BCD: BCD data format + * @arg FORMAT_BIN: Binary data format + * @arg FORMAT_BCD: BCD data format * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format) @@ -683,12 +690,13 @@ HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDat /** * @brief Gets RTC current date. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sDate: Pointer to Date structure * @param Format: Specifies the format of the entered parameters. * This parameter can be one of the following values: - * @arg Format_BIN : Binary data format - * @arg Format_BCD : BCD data format + * @arg FORMAT_BIN: Binary data format + * @arg FORMAT_BCD: BCD data format * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format) @@ -730,19 +738,20 @@ HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDat ##### RTC Alarm functions ##### =============================================================================== - [..] This section provide functions allowing to configure Alarm feature + [..] This section provides functions allowing to configure Alarm feature @endverbatim * @{ */ /** * @brief Sets the specified RTC Alarm. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sAlarm: Pointer to Alarm structure * @param Format: Specifies the format of the entered parameters. * This parameter can be one of the following values: - * @arg Format_BIN: Binary data format - * @arg Format_BCD: BCD data format + * @arg FORMAT_BIN: Binary data format + * @arg FORMAT_BCD: BCD data format * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format) @@ -918,12 +927,13 @@ HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sA /** * @brief Sets the specified RTC Alarm with Interrupt - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sAlarm: Pointer to Alarm structure * @param Format: Specifies the format of the entered parameters. * This parameter can be one of the following values: - * @arg Format_BIN: Binary data format - * @arg Format_BCD: BCD data format + * @arg FORMAT_BIN: Binary data format + * @arg FORMAT_BCD: BCD data format * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format) @@ -1104,11 +1114,12 @@ HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef /** * @brief Deactive the specified RTC Alarm - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param Alarm: Specifies the Alarm. * This parameter can be one of the following values: - * @arg ALARM_A : AlarmA - * @arg ALARM_B : AlarmB + * @arg RTC_ALARM_A: AlarmA + * @arg RTC_ALARM_B: AlarmB * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm) @@ -1193,16 +1204,17 @@ HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alar /** * @brief Gets the RTC Alarm value and masks. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sAlarm: Pointer to Date structure - * @param Alarm: Specifies the Alarm + * @param Alarm: Specifies the Alarm. * This parameter can be one of the following values: - * @arg ALARM_A: AlarmA - * @arg ALARM_B: AlarmB + * @arg RTC_ALARM_A: AlarmA + * @arg RTC_ALARM_B: AlarmB * @param Format: Specifies the format of the entered parameters. * This parameter can be one of the following values: - * @arg Format_BIN: Binary data format - * @arg Format_BCD: BCD data format + * @arg FORMAT_BIN: Binary data format + * @arg FORMAT_BCD: BCD data format * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format) @@ -1252,7 +1264,8 @@ HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sA /** * @brief This function handles Alarm interrupt request. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef* hrtc) @@ -1292,7 +1305,8 @@ void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef* hrtc) /** * @brief Alarm A callback. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ __weak void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc) @@ -1304,7 +1318,8 @@ __weak void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc) /** * @brief This function handles AlarmA Polling request. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param Timeout: Timeout duration * @retval HAL status */ @@ -1367,7 +1382,8 @@ HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t T * The software must then wait until it is set again before reading * the calendar, which means that the calendar registers have been * correctly copied into the RTC_TR and RTC_DR shadow registers. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc) @@ -1406,8 +1422,9 @@ HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc) * @{ */ /** - * @brief Returns the Alarm state. - * @param hrtc: RTC handle + * @brief Returns the RTC state. + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL state */ HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef* hrtc) @@ -1423,7 +1440,8 @@ HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef* hrtc) * @brief Enters the RTC Initialization mode. * @note The RTC Initialization mode is write protected, use the * __HAL_RTC_WRITEPROTECTION_DISABLE() before calling this function. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.h index 413f6860eb..1ae9172d20 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rtc.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of RTC HAL module. ****************************************************************************** * @attention @@ -98,7 +98,7 @@ typedef struct typedef struct { uint8_t Hours; /*!< Specifies the RTC Time Hour. - This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected + This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected. This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ uint8_t Minutes; /*!< Specifies the RTC Time Minutes. @@ -113,7 +113,7 @@ typedef struct uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. This parameter can be a value of @ref RTC_AM_PM_Definitions */ - uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment. + uint32_t DayLightSaving; /*!< Specifies DayLight Save Operation. This parameter can be a value of @ref RTC_DayLightSaving_Definitions */ uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BCK bit @@ -542,6 +542,12 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset RTC handle state + * @param __HANDLE__: specifies the RTC handle. + * @retval None + */ +#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) + /** * @brief Disable the write protection for RTC registers. * @param __HANDLE__: specifies the RTC handle. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.c index 4e68a5c235..39c3e7e77d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rtc_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief RTC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Real Time Clock (RTC) Extension peripheral: @@ -26,7 +26,7 @@ ================================ [..] (+) To configure the RTC Wakeup Clock source and Counter use the HAL_RTC_SetWakeUpTimer() - function. You can also configure the RTC Wakeup timer with interrupt mode + function. You can also configure the RTC Wakeup timer in interrupt mode using the HAL_RTC_SetWakeUpTimer_IT() function. (+) To read the RTC WakeUp Counter register, use the HAL_RTC_GetWakeUpTimer() function. @@ -34,7 +34,7 @@ *** TimeStamp configuration *** =============================== [..] - (+) Configure the RTC_AFx trigger and enables the RTC TimeStamp using the + (+) Configure the RTC_AFx trigger and enable the RTC TimeStamp using the HAL_RTC_SetTimeStamp() function. You can also configure the RTC TimeStamp with interrupt mode using the HAL_RTC_SetTimeStamp_IT() function. (+) To read the RTC TimeStamp Time and Date register, use the HAL_RTC_GetTimeStamp() @@ -47,10 +47,10 @@ *** Tamper configuration *** ============================ [..] - (+) Enable the RTC Tamper and Configure the Tamper filter count, trigger Edge + (+) Enable the RTC Tamper and configure the Tamper filter count, trigger Edge or Level according to the Tamper filter (if equal to 0 Edge else Level) value, sampling frequency, precharge or discharge and Pull-UP using the - HAL_RTC_SetTamper() function. You can configure RTC Tamper with interrupt + HAL_RTC_SetTamper() function. You can configure RTC Tamper in interrupt mode using HAL_RTC_SetTamper_IT() function. (+) The TAMPER1 alternate function can be mapped either to RTC_AF1 (PC13) or RTC_AF2 (PI8) depending on the value of TAMP1INSEL bit in @@ -130,7 +130,7 @@ ##### RTC TimeStamp and Tamper functions ##### =============================================================================== - [..] This section provide functions allowing to configure TimeStamp feature + [..] This section provides functions allowing to configure TimeStamp feature @endverbatim * @{ @@ -139,13 +139,14 @@ /** * @brief Sets TimeStamp. * @note This API must be called before enabling the TimeStamp feature. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param TimeStampEdge: Specifies the pin edge on which the TimeStamp is * activated. - * This parameter can be one of the following: - * @arg TimeStampEdge_Rising: the Time stamp event occurs on the + * This parameter can be one of the following values: + * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the * rising edge of the related pin. - * @arg TimeStampEdge_Falling: the Time stamp event occurs on the + * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the * falling edge of the related pin. * @param RTC_TimeStampPin: specifies the RTC TimeStamp Pin. * This parameter can be one of the following values: @@ -196,14 +197,15 @@ HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeS /** * @brief Sets TimeStamp with Interrupt. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @note This API must be called before enabling the TimeStamp feature. * @param TimeStampEdge: Specifies the pin edge on which the TimeStamp is * activated. - * This parameter can be one of the following: - * @arg TimeStampEdge_Rising: the Time stamp event occurs on the + * This parameter can be one of the following values: + * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the * rising edge of the related pin. - * @arg TimeStampEdge_Falling: the Time stamp event occurs on the + * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the * falling edge of the related pin. * @param RTC_TimeStampPin: Specifies the RTC TimeStamp Pin. * This parameter can be one of the following values: @@ -261,7 +263,8 @@ HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t Ti /** * @brief Deactivates TimeStamp. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc) @@ -298,13 +301,14 @@ HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc) /** * @brief Gets the RTC TimeStamp value. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sTimeStamp: Pointer to Time structure * @param sTimeStampDate: Pointer to Date structure * @param Format: specifies the format of the entered parameters. * This parameter can be one of the following values: - * @arg Format_BIN: Binary data format - * @arg Format_BCD: BCD data format + * FORMAT_BIN: Binary data format + * FORMAT_BCD: BCD data format * @retval HAL status */ HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef* sTimeStamp, RTC_DateTypeDef* sTimeStampDate, uint32_t Format) @@ -354,7 +358,8 @@ HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDe /** * @brief Sets Tamper * @note By calling this API we disable the tamper interrupt for all tampers. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sTamper: Pointer to Tamper Structure. * @retval HAL status */ @@ -403,7 +408,8 @@ HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef /** * @brief Sets Tamper with interrupt. * @note By calling this API we force the tamper interrupt for all tampers. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param sTamper: Pointer to RTC Tamper. * @retval HAL status */ @@ -427,11 +433,7 @@ HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperType hrtc->State = HAL_RTC_STATE_BUSY; /* Configure the tamper trigger */ - if((sTamper->Trigger == RTC_TAMPERTRIGGER_RISINGEDGE) || (sTamper->Trigger == RTC_TAMPERTRIGGER_LOWLEVEL)) - { - sTamper->Trigger = RTC_TAMPERTRIGGER_RISINGEDGE; - } - else + if(sTamper->Trigger != RTC_TAMPERTRIGGER_RISINGEDGE) { sTamper->Trigger = (uint32_t)(sTamper->Tamper << 1); } @@ -464,7 +466,8 @@ HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperType /** * @brief Deactivates Tamper. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param Tamper: Selected tamper pin. * This parameter can be RTC_Tamper_1 and/or RTC_TAMPER_2. * @retval HAL status @@ -491,7 +494,8 @@ HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t T /** * @brief This function handles TimeStamp interrupt request. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc) @@ -545,7 +549,8 @@ void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc) /** * @brief TimeStamp callback. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ __weak void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc) @@ -557,7 +562,8 @@ __weak void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc) /** * @brief Tamper 1 callback. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ __weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc) @@ -569,7 +575,8 @@ __weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc) /** * @brief Tamper 2 callback. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ __weak void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc) @@ -581,7 +588,8 @@ __weak void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc) /** * @brief This function handles TimeStamp polling request. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param Timeout: Timeout duration * @retval HAL status */ @@ -623,7 +631,8 @@ HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint3 /** * @brief This function handles Tamper1 Polling. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param Timeout: Timeout duration * @retval HAL status */ @@ -658,7 +667,8 @@ HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_ /** * @brief This function handles Tamper2 Polling. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param Timeout: Timeout duration * @retval HAL status */ @@ -703,7 +713,7 @@ HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_ ##### RTC Wake-up functions ##### =============================================================================== - [..] This section provide functions allowing to configure Wake-up feature + [..] This section provides functions allowing to configure Wake-up feature @endverbatim * @{ @@ -711,7 +721,8 @@ HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_ /** * @brief Sets wake up timer. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param WakeUpCounter: Wake up counter * @param WakeUpClock: Wake up clock * @retval HAL status @@ -778,9 +789,10 @@ HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t Wak /** * @brief Sets wake up timer with interrupt - * @param hrtc: RTC handle - * @param WakeUpCounter: wake up counter - * @param WakeUpClock: wake up clock + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. + * @param WakeUpCounter: Wake up counter + * @param WakeUpClock: Wake up clock * @retval HAL status */ HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock) @@ -853,7 +865,8 @@ HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t /** * @brief Deactivates wake up timer counter. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL status */ uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc) @@ -905,7 +918,8 @@ uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc) /** * @brief Gets wake up timer counter. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval Counter value */ uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc) @@ -916,7 +930,8 @@ uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc) /** * @brief This function handles Wake Up Timer interrupt request. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc) @@ -943,7 +958,8 @@ void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc) /** * @brief Wake Up Timer callback. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ __weak void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc) @@ -955,7 +971,8 @@ __weak void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc) /** * @brief This function handles Wake Up Timer Polling. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param Timeout: Timeout duration * @retval HAL status */ @@ -1002,18 +1019,18 @@ HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uin =============================================================================== [..] This subsection provides functions allowing to - (+) Writes a data in a specified RTC Backup data register + (+) Write a data in a specified RTC Backup data register (+) Read a data in a specified RTC Backup data register - (+) Sets the Coarse calibration parameters. - (+) Deactivates the Coarse calibration parameters - (+) Sets the Smooth calibration parameters. - (+) Configures the Synchronization Shift Control Settings. - (+) Configures the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). - (+) Deactivates the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). - (+) Enables the RTC reference clock detection. + (+) Set the Coarse calibration parameters. + (+) Deactivate the Coarse calibration parameters + (+) Set the Smooth calibration parameters. + (+) Configure the Synchronization Shift Control Settings. + (+) Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). + (+) Deactivate the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). + (+) Enable the RTC reference clock detection. (+) Disable the RTC reference clock detection. - (+) Enables the Bypass Shadow feature. - (+) Disables the Bypass Shadow feature. + (+) Enable the Bypass Shadow feature. + (+) Disable the Bypass Shadow feature. @endverbatim * @{ @@ -1021,7 +1038,8 @@ HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uin /** * @brief Writes a data in a specified RTC Backup data register. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param BackupRegister: RTC Backup data Register number. * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to * specify the register. @@ -1044,7 +1062,8 @@ void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint3 /** * @brief Reads data from the specified RTC Backup data Register. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param BackupRegister: RTC Backup data Register number. * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to * specify the register. @@ -1066,7 +1085,8 @@ uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister) /** * @brief Sets the Coarse calibration parameters. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param CalibSign: Specifies the sign of the coarse calibration value. * This parameter can be one of the following values : * @arg RTC_CALIBSIGN_POSITIVE: The value sign is positive @@ -1134,7 +1154,8 @@ HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef* hrtc, uint32_t Cal /** * @brief Deactivates the Coarse calibration parameters. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef* hrtc) @@ -1184,7 +1205,8 @@ HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef* hrtc) /** * @brief Sets the Smooth calibration parameters. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param SmoothCalibPeriod: Select the Smooth Calibration Period. * This parameter can be can be one of the following values : * @arg RTC_SMOOTHCALIB_PERIOD_32SEC: The smooth calibration periode is 32s. @@ -1198,7 +1220,7 @@ HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef* hrtc) * This parameter can be one any value from 0 to 0x000001FF. * @note To deactivate the smooth calibration, the field SmoothCalibPlusPulses * must be equal to SMOOTHCALIB_PLUSPULSES_RESET and the field - * SmouthCalibMinusPulsesValue mut be equal to 0. + * SmouthCalibMinusPulsesValue must be equal to 0. * @retval HAL status */ HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef* hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue) @@ -1260,7 +1282,8 @@ HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef* hrtc, uint32_t Smo /** * @brief Configures the Synchronization Shift Control Settings. * @note When REFCKON is set, firmware must not write to Shift control register. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param ShiftAdd1S: Select to add or not 1 second to the time calendar. * This parameter can be one of the following values : * @arg RTC_SHIFTADD1S_SET: Add one second to the clock calendar. @@ -1355,8 +1378,9 @@ HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef* hrtc, uint32_t Sh /** * @brief Configures the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). - * @param hrtc: RTC handle - * @param CalibOutput : Select the Calibration output Selection . + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. + * @param CalibOutput: Select the Calibration output Selection . * This parameter can be one of the following values: * @arg RTC_CALIBOUTPUT_512HZ: A signal has a regular waveform at 512Hz. * @arg RTC_CALIBOUTPUT_1HZ: A signal has a regular waveform at 1Hz. @@ -1397,7 +1421,8 @@ HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef* hrtc, uint32 /** * @brief Deactivates the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef* hrtc) @@ -1426,7 +1451,8 @@ HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef* hrtc) /** * @brief Enables the RTC reference clock detection. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef* hrtc) @@ -1475,7 +1501,8 @@ HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef* hrtc) /** * @brief Disable the RTC reference clock detection. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef* hrtc) @@ -1524,7 +1551,8 @@ HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef* hrtc) /** * @brief Enables the Bypass Shadow feature. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @note When the Bypass Shadow is enabled the calendar value are taken * directly from the Calendar counter. * @retval HAL status @@ -1556,7 +1584,8 @@ HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef* hrtc) /** * @brief Disables the Bypass Shadow feature. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @note When the Bypass Shadow is enabled the calendar value are taken * directly from the Calendar counter. * @retval HAL status @@ -1607,7 +1636,8 @@ HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef* hrtc) /** * @brief Alarm B callback. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @retval None */ __weak void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc) @@ -1619,7 +1649,8 @@ __weak void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc) /** * @brief This function handles AlarmB Polling request. - * @param hrtc: RTC handle + * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains + * the configuration information for RTC. * @param Timeout: Timeout duration * @retval HAL status */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.h index df35db3b44..d773bdc465 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rtc_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of RTC HAL Extension module. ****************************************************************************** * @attention @@ -335,7 +335,7 @@ typedef struct * @} */ -/** @defgroup RTC_Smooth_calib_period_Definitions +/** @defgroup RTCEx_Smooth_calib_period_Definitions * @{ */ #define RTC_SMOOTHCALIB_PERIOD_32SEC ((uint32_t)0x00000000) /*!< If RTCCLK = 32768 Hz, Smooth calibation diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.c index b2912e3c6f..dbd58c6937 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sai.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief SAI HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Serial Audio Interface (SAI) peripheral: @@ -18,10 +18,10 @@ ============================================================================== [..] - The SAI HAL driver can be used as follow: + The SAI HAL driver can be used as follows: (#) Declare a SAI_HandleTypeDef handle structure. - (#) Initialize the SAI low level resources by implement the HAL_SAI_MspInit() API: + (#) Initialize the SAI low level resources by implementing the HAL_SAI_MspInit() API: (##) Enable the SAI interface clock. (##) SAI pins configuration: (+++) Enable the clock for the SAI GPIOs. @@ -56,12 +56,12 @@ the define constant EXTERNAL_CLOCK_VALUE in the stm32f4xx_hal_conf.h file. [..] - (@) In master TX mode: enabling the audio block immediately generates the bit clock + (@) In master Tx mode: enabling the audio block immediately generates the bit clock for the external slaves even if there is no data in the FIFO, However FS signal generation is conditioned by the presence of data in the FIFO. [..] - (@) In master RX mode: enabling the audio block immediately generates the bit clock + (@) In master Rx mode: enabling the audio block immediately generates the bit clock and FS signal for the external slaves. [..] @@ -72,7 +72,7 @@ (+@) The number of slots should be even when SAI_FS_CHANNEL_IDENTIFICATION is selected. [..] - Three mode of operations are available within this driver : + Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -110,7 +110,7 @@ *** SAI HAL driver macros list *** ============================================= [..] - Below the list of most used macros in USART HAL driver. + Below the list of most used macros in USART HAL driver : (+) __HAL_SAI_ENABLE: Enable the SAI peripheral (+) __HAL_SAI_DISABLE: Disable the SAI peripheral @@ -199,7 +199,7 @@ static void SAI_DMAError(DMA_HandleTypeDef *hdma); [..] This subsection provides a set of functions allowing to initialize and de-initialize the SAIx peripheral: - (+) User must Implement HAL_SAI_MspInit() function in which he configures + (+) User must implement HAL_SAI_MspInit() function in which he configures all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ). (+) Call the function HAL_SAI_Init() to configure the selected device with @@ -223,7 +223,8 @@ static void SAI_DMAError(DMA_HandleTypeDef *hdma); /** * @brief Initializes the SAI according to the specified parameters * in the SAI_InitTypeDef and create the associated handle. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval HAL status */ HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai) @@ -453,7 +454,8 @@ HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai) /** * @brief DeInitializes the SAI peripheral. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval HAL status */ HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai) @@ -483,7 +485,8 @@ HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai) /** * @brief SAI MSP Init. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval None */ __weak void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai) @@ -495,7 +498,8 @@ __weak void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai) /** * @brief SAI MSP DeInit. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval None */ __weak void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai) @@ -520,7 +524,7 @@ __weak void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai) This subsection provides a set of functions allowing to manage the SAI data transfers. - (+) There is two mode of transfer: + (+) There are two modes of transfer: (++) Blocking mode : The communication is performed in the polling mode. The status of all data processing is returned by the same function after finishing transfer. @@ -535,17 +539,17 @@ __weak void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai) (++) HAL_SAI_Receive() (++) HAL_SAI_TransmitReceive() - (+) No-Blocking mode functions with Interrupt are : + (+) Non Blocking mode functions with Interrupt are : (++) HAL_SAI_Transmit_IT() (++) HAL_SAI_Receive_IT() (++) HAL_SAI_TransmitReceive_IT() - (+) No-Blocking mode functions with DMA are : + (+) Non Blocking mode functions with DMA are : (++) HAL_SAI_Transmit_DMA() (++) HAL_SAI_Receive_DMA() (++) HAL_SAI_TransmitReceive_DMA() - (+) A set of Transfer Complete Callbacks are provided in No_Blocking mode: + (+) A set of Transfer Complete Callbacks are provided in non Blocking mode: (++) HAL_SAI_TxCpltCallback() (++) HAL_SAI_RxCpltCallback() (++) HAL_SAI_ErrorCallback() @@ -556,7 +560,8 @@ __weak void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai) /** * @brief Transmits an amount of data in blocking mode. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @param Timeout: Timeout duration @@ -630,7 +635,8 @@ HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint16_t* pData, uin /** * @brief Receives an amount of data in blocking mode. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be received * @param Timeout: Timeout duration @@ -707,7 +713,8 @@ HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint16_t *pData, uint /** * @brief Transmits an amount of data in no-blocking mode with Interrupt. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -784,7 +791,8 @@ HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint16_t *pData, /** * @brief Receives an amount of data in no-blocking mode with Interrupt. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be received * @retval HAL status @@ -855,8 +863,9 @@ HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint16_t *pData, u /** * @brief Pauses the audio stream playing from the Media. - * @param hsai: SAI handle - * @retval None + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. + * @retval HAL status */ HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai) { @@ -875,8 +884,9 @@ HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai) /** * @brief Resumes the audio stream playing from the Media. - * @param hsai: SAI handle - * @retval None + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. + * @retval HAL status */ HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai) { @@ -901,9 +911,10 @@ HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai) } /** - * @brief Resumes the audio stream playing from the Media. - * @param hsai: SAI handle - * @retval None + * @brief Stops the audio stream playing from the Media. + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. + * @retval HAL status */ HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai) { @@ -936,7 +947,8 @@ HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai) } /** * @brief Transmits an amount of data in no-blocking mode with DMA. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -996,8 +1008,9 @@ HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint16_t *pData, } /** - * @brief Receive an amount of data in no-blocking mode with DMA. - * @param hsai: SAI handle + * @brief Receives an amount of data in no-blocking mode with DMA. + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be received * @retval HAL status @@ -1058,7 +1071,8 @@ HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint16_t *pData, /** * @brief This function handles SAI interrupt request. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval HAL status */ void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai) @@ -1120,7 +1134,8 @@ void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai) /** * @brief Tx Transfer completed callbacks. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval None */ __weak void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai) @@ -1132,7 +1147,8 @@ void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai) /** * @brief Tx Transfer Half completed callbacks - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval None */ __weak void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai) @@ -1144,7 +1160,8 @@ void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai) /** * @brief Rx Transfer completed callbacks. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval None */ __weak void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai) @@ -1156,7 +1173,8 @@ __weak void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai) /** * @brief Rx Transfer half completed callbacks - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval None */ __weak void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai) @@ -1168,7 +1186,8 @@ __weak void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai) /** * @brief SAI error callbacks. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval None */ __weak void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai) @@ -1191,7 +1210,7 @@ __weak void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai) ##### Peripheral State and Errors functions ##### =============================================================================== [..] - This subsection permit to get in run-time the status of the peripheral + This subsection permits to get in run-time the status of the peripheral and the data flow. @endverbatim @@ -1200,7 +1219,8 @@ __weak void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai) /** * @brief Returns the SAI state. - * @param hsai: SAI handle + * @param hsai: pointer to a SAI_HandleTypeDef structure that contains + * the configuration information for SAI module. * @retval HAL state */ HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai) @@ -1224,7 +1244,8 @@ uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai) /** * @brief DMA SAI transmit process complete callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SAI_DMATxCplt(DMA_HandleTypeDef *hdma) @@ -1265,7 +1286,8 @@ static void SAI_DMATxCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA SAI transmit process half complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SAI_DMATxHalfCplt(DMA_HandleTypeDef *hdma) @@ -1277,7 +1299,8 @@ static void SAI_DMATxHalfCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA SAI receive process complete callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SAI_DMARxCplt(DMA_HandleTypeDef *hdma) @@ -1296,7 +1319,8 @@ static void SAI_DMARxCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA SAI receive process half complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SAI_DMARxHalfCplt(DMA_HandleTypeDef *hdma) @@ -1307,7 +1331,8 @@ static void SAI_DMARxHalfCplt(DMA_HandleTypeDef *hdma) } /** * @brief DMA SAI communication error callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SAI_DMAError(DMA_HandleTypeDef *hdma) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.h index 876568a1a9..1e491ff16a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sai.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of SAI HAL module. ****************************************************************************** * @attention @@ -177,35 +177,34 @@ typedef enum typedef struct { SAI_Block_TypeDef *Instance; /*!< SAI Blockx registers base address */ - + SAI_InitTypeDef Init; /*!< SAI communication parameters */ - + SAI_FrameInitTypeDef FrameInit; /*!< SAI Frame configuration parameters */ - + SAI_SlotInitTypeDef SlotInit; /*!< SAI Slot configuration parameters */ - - uint16_t *pTxBuffPtr; /*!< Pointer to SAI Tx transfer Buffer */ - - uint16_t TxXferSize; /*!< SAI Tx transfer size */ - - uint16_t TxXferCount; /*!< SAI Tx transfer counter */ - - uint16_t *pRxBuffPtr; /*!< Pointer to SAI Rx transfer buffer */ - - uint16_t RxXferSize; /*!< SAI Rx transfer size */ - - uint16_t RxXferCount; /*!< SAI Rx transfer counter */ - - DMA_HandleTypeDef *hdmatx; /*!< SAI Tx DMA handle parameters */ - - DMA_HandleTypeDef *hdmarx; /*!< SAI Rx DMA handle parameters */ - HAL_LockTypeDef Lock; /*!< SAI locking object */ - - __IO HAL_SAI_StateTypeDef State; /*!< SAI communication state */ - - __IO uint32_t ErrorCode; /*!< SAI Error code */ + uint16_t *pTxBuffPtr; /*!< Pointer to SAI Tx transfer Buffer */ + uint16_t TxXferSize; /*!< SAI Tx transfer size */ + + uint16_t TxXferCount; /*!< SAI Tx transfer counter */ + + uint16_t *pRxBuffPtr; /*!< Pointer to SAI Rx transfer buffer */ + + uint16_t RxXferSize; /*!< SAI Rx transfer size */ + + uint16_t RxXferCount; /*!< SAI Rx transfer counter */ + + DMA_HandleTypeDef *hdmatx; /*!< SAI Tx DMA handle parameters */ + + DMA_HandleTypeDef *hdmarx; /*!< SAI Rx DMA handle parameters */ + + HAL_LockTypeDef Lock; /*!< SAI locking object */ + + __IO HAL_SAI_StateTypeDef State; /*!< SAI communication state */ + + __IO uint32_t ErrorCode; /*!< SAI Error code */ }SAI_HandleTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -218,7 +217,7 @@ typedef struct */ #define HAL_SAI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ #define HAL_SAI_ERROR_OVR ((uint32_t)0x00000001) /*!< Overrun Error */ -#define HAL_SAI_ERROR_UDR ((uint32_t)0x00000002) /*!< Underrun error */ +#define HAL_SAI_ERROR_UDR ((uint32_t)0x00000002) /*!< Underrun error */ #define HAL_SAI_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */ /** * @} @@ -236,7 +235,7 @@ typedef struct ((SOURCE) == SAI_CLKSOURCE_EXT)) /** * @} - */ + */ /** @defgroup SAI_Audio_Frequency * @{ @@ -462,8 +461,8 @@ typedef struct /** @defgroup SAI_Block_Slot_Active * @{ */ -#define SAI_SLOT_NOTACTIVE ((uint32_t)0x00000000) -#define SAI_SLOTACTIVE_0 ((uint32_t)0x00010000) +#define SAI_SLOT_NOTACTIVE ((uint32_t)0x00000000) +#define SAI_SLOTACTIVE_0 ((uint32_t)0x00010000) #define SAI_SLOTACTIVE_1 ((uint32_t)0x00020000) #define SAI_SLOTACTIVE_2 ((uint32_t)0x00040000) #define SAI_SLOTACTIVE_3 ((uint32_t)0x00080000) @@ -645,6 +644,11 @@ typedef struct */ /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset SAI handle state + * @param __HANDLE__: specifies the SAI Handle. + * @retval None + */ +#define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET) /** @brief Enable or disable the specified SAI interrupts. * @param __HANDLE__: specifies the SAI Handle. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.c index f16ecfdf51..5785f30f0a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sd.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief SD card HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Secure Digital (SD) peripheral: @@ -1388,7 +1388,8 @@ __weak void HAL_SD_XferErrorCallback(SD_HandleTypeDef *hsd) /** * @brief SD Transfer complete Rx callback in non blocking mode. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ __weak void HAL_SD_DMA_RxCpltCallback(DMA_HandleTypeDef *hdma) @@ -1400,7 +1401,8 @@ __weak void HAL_SD_DMA_RxCpltCallback(DMA_HandleTypeDef *hdma) /** * @brief SD DMA transfer complete Rx error callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ __weak void HAL_SD_DMA_RxErrorCallback(DMA_HandleTypeDef *hdma) @@ -1412,7 +1414,8 @@ __weak void HAL_SD_DMA_RxErrorCallback(DMA_HandleTypeDef *hdma) /** * @brief SD Transfer complete Tx callback in non blocking mode. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ __weak void HAL_SD_DMA_TxCpltCallback(DMA_HandleTypeDef *hdma) @@ -1424,7 +1427,8 @@ __weak void HAL_SD_DMA_TxCpltCallback(DMA_HandleTypeDef *hdma) /** * @brief SD DMA transfer complete error Tx callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ __weak void HAL_SD_DMA_TxErrorCallback(DMA_HandleTypeDef *hdma) @@ -2167,7 +2171,8 @@ HAL_SD_ErrorTypedef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatu /** * @brief SD DMA transfer complete Rx callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SD_DMA_RxCplt(DMA_HandleTypeDef *hdma) @@ -2188,7 +2193,8 @@ static void SD_DMA_RxCplt(DMA_HandleTypeDef *hdma) /** * @brief SD DMA transfer Error Rx callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SD_DMA_RxError(DMA_HandleTypeDef *hdma) @@ -2201,7 +2207,8 @@ static void SD_DMA_RxError(DMA_HandleTypeDef *hdma) /** * @brief SD DMA transfer complete Tx callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SD_DMA_TxCplt(DMA_HandleTypeDef *hdma) @@ -2222,7 +2229,8 @@ static void SD_DMA_TxCplt(DMA_HandleTypeDef *hdma) /** * @brief SD DMA transfer Error Tx callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SD_DMA_TxError(DMA_HandleTypeDef *hdma) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.h index c1730c39a6..9ecb2500f2 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sd.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of SD HAL module. ****************************************************************************** * @attention @@ -63,11 +63,11 @@ */ typedef struct { - SD_TypeDef *Instance; /*!< SDIO register base address */ + SD_TypeDef *Instance; /*!< SDIO register base address */ SD_InitTypeDef Init; /*!< SD required parameters */ - HAL_LockTypeDef Lock; /*!< SD locking object */ + HAL_LockTypeDef Lock; /*!< SD locking object */ uint32_t CardType; /*!< SD card type */ @@ -79,13 +79,13 @@ typedef struct __IO uint32_t SdTransferCplt; /*!< SD transfer complete flag in non blocking mode */ - __IO uint32_t SdTransferErr; /*!< SD transfer error flag in non blocking mode */ + __IO uint32_t SdTransferErr; /*!< SD transfer error flag in non blocking mode */ __IO uint32_t DmaTransferCplt; /*!< SD DMA transfer complete flag */ __IO uint32_t SdOperation; /*!< SD transfer operation (read/write) */ - DMA_HandleTypeDef *hdmarx; /*!< SD Rx DMA handle parameters */ + DMA_HandleTypeDef *hdmarx; /*!< SD Rx DMA handle parameters */ DMA_HandleTypeDef *hdmatx; /*!< SD Tx DMA handle parameters */ @@ -199,7 +199,7 @@ typedef enum SD_CMD_RSP_TIMEOUT = (3), /*!< Command response timeout */ SD_DATA_TIMEOUT = (4), /*!< Data timeout */ SD_TX_UNDERRUN = (5), /*!< Transmit FIFO underrun */ - SD_RX_OVERRUN = (6), /*!< Receive FIFO overrun */ + SD_RX_OVERRUN = (6), /*!< Receive FIFO overrun */ SD_START_BIT_ERR = (7), /*!< Start bit not detected on all data signals in wide bus mode */ SD_CMD_OUT_OF_RANGE = (8), /*!< Command's argument was out of range. */ SD_ADDR_MISALIGNED = (9), /*!< Misaligned address */ @@ -231,20 +231,20 @@ typedef enum /** * @brief Standard error defines */ - SD_INTERNAL_ERROR = (34), + SD_INTERNAL_ERROR = (34), SD_NOT_CONFIGURED = (35), - SD_REQUEST_PENDING = (36), - SD_REQUEST_NOT_APPLICABLE = (37), - SD_INVALID_PARAMETER = (38), - SD_UNSUPPORTED_FEATURE = (39), - SD_UNSUPPORTED_HW = (40), - SD_ERROR = (41), + SD_REQUEST_PENDING = (36), + SD_REQUEST_NOT_APPLICABLE = (37), + SD_INVALID_PARAMETER = (38), + SD_UNSUPPORTED_FEATURE = (39), + SD_UNSUPPORTED_HW = (40), + SD_ERROR = (41), SD_OK = (0) }HAL_SD_ErrorTypedef; /** - * @brief SD Transfer state enumeration structure + * @brief SD Transfer state enumeration structure */ typedef enum { diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.c index 66b635cfb9..295b5e5bb1 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sdram.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief SDRAM HAL module driver. * This file provides a generic firmware to drive SDRAM memories mounted * as external device. @@ -20,7 +20,7 @@ with SDRAM memories: (#) Declare a SDRAM_HandleTypeDef handle structure, for example: - SDRAM_HandleTypeDef hdsram; and: + SDRAM_HandleTypeDef hdsram (++) Fill the SDRAM_HandleTypeDef handle "Init" field with the allowed values of the structure member. @@ -133,7 +133,8 @@ /** * @brief Performs the SDRAM device initialization sequence. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param Timing: Pointer to SDRAM control timing structure * @retval HAL status */ @@ -168,7 +169,8 @@ HAL_StatusTypeDef HAL_SDRAM_Init(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_TimingTy /** * @brief Perform the SDRAM device initialization sequence. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @retval HAL status */ HAL_StatusTypeDef HAL_SDRAM_DeInit(SDRAM_HandleTypeDef *hsdram) @@ -190,7 +192,8 @@ HAL_StatusTypeDef HAL_SDRAM_DeInit(SDRAM_HandleTypeDef *hsdram) /** * @brief SDRAM MSP Init. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @retval None */ __weak void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram) @@ -202,7 +205,8 @@ __weak void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram) /** * @brief SDRAM MSP DeInit. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @retval None */ __weak void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram) @@ -214,7 +218,8 @@ __weak void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram) /** * @brief This function handles SDRAM refresh error interrupt request. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @retval HAL status */ void HAL_SDRAM_IRQHandler(SDRAM_HandleTypeDef *hsdram) @@ -232,7 +237,8 @@ void HAL_SDRAM_IRQHandler(SDRAM_HandleTypeDef *hsdram) /** * @brief SDRAM Refresh error callback. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @retval None */ __weak void HAL_SDRAM_RefreshErrorCallback(SDRAM_HandleTypeDef *hsdram) @@ -244,7 +250,8 @@ __weak void HAL_SDRAM_RefreshErrorCallback(SDRAM_HandleTypeDef *hsdram) /** * @brief DMA transfer complete callback. - * @param hdma: DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ __weak void HAL_SDRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma) @@ -286,7 +293,8 @@ __weak void HAL_SDRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma) /** * @brief Reads 8-bit data buffer from the SDRAM memory. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param pAddress: Pointer to read start address * @param pDstBuffer: Pointer to destination buffer * @param BufferSize: Size of the buffer to read from memory @@ -326,7 +334,8 @@ HAL_StatusTypeDef HAL_SDRAM_Read_8b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddr /** * @brief Writes 8-bit data buffer to SDRAM memory. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param pAddress: Pointer to write start address * @param pSrcBuffer: Pointer to source buffer to write * @param BufferSize: Size of the buffer to write to memory @@ -369,7 +378,8 @@ HAL_StatusTypeDef HAL_SDRAM_Write_8b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAdd /** * @brief Reads 16-bit data buffer from the SDRAM memory. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param pAddress: Pointer to read start address * @param pDstBuffer: Pointer to destination buffer * @param BufferSize: Size of the buffer to read from memory @@ -408,7 +418,8 @@ HAL_StatusTypeDef HAL_SDRAM_Read_16b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAdd /** * @brief Writes 16-bit data buffer to SDRAM memory. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param pAddress: Pointer to write start address * @param pSrcBuffer: Pointer to source buffer to write * @param BufferSize: Size of the buffer to write to memory @@ -450,7 +461,8 @@ HAL_StatusTypeDef HAL_SDRAM_Write_16b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAd /** * @brief Reads 32-bit data buffer from the SDRAM memory. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param pAddress: Pointer to read start address * @param pDstBuffer: Pointer to destination buffer * @param BufferSize: Size of the buffer to read from memory @@ -489,7 +501,8 @@ HAL_StatusTypeDef HAL_SDRAM_Read_32b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAdd /** * @brief Writes 32-bit data buffer to SDRAM memory. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param pAddress: Pointer to write start address * @param pSrcBuffer: Pointer to source buffer to write * @param BufferSize: Size of the buffer to write to memory @@ -531,7 +544,8 @@ HAL_StatusTypeDef HAL_SDRAM_Write_32b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAd /** * @brief Reads a Words data from the SDRAM memory using DMA transfer. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param pAddress: Pointer to read start address * @param pDstBuffer: Pointer to destination buffer * @param BufferSize: Size of the buffer to read from memory @@ -571,7 +585,8 @@ HAL_StatusTypeDef HAL_SDRAM_Read_DMA(SDRAM_HandleTypeDef *hsdram, uint32_t *pAdd /** * @brief Writes a Words data buffer to SDRAM memory using DMA transfer. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param pAddress: Pointer to write start address * @param pSrcBuffer: Pointer to source buffer to write * @param BufferSize: Size of the buffer to write to memory @@ -630,7 +645,8 @@ HAL_StatusTypeDef HAL_SDRAM_Write_DMA(SDRAM_HandleTypeDef *hsdram, uint32_t *pAd /** * @brief Enables dynamically SDRAM write protection. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @retval HAL status */ HAL_StatusTypeDef HAL_SDRAM_WriteProtection_Enable(SDRAM_HandleTypeDef *hsdram) @@ -655,7 +671,8 @@ HAL_StatusTypeDef HAL_SDRAM_WriteProtection_Enable(SDRAM_HandleTypeDef *hsdram) /** * @brief Disables dynamically SDRAM write protection. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @retval HAL status */ HAL_StatusTypeDef HAL_SDRAM_WriteProtection_Disable(SDRAM_HandleTypeDef *hsdram) @@ -680,10 +697,11 @@ HAL_StatusTypeDef HAL_SDRAM_WriteProtection_Disable(SDRAM_HandleTypeDef *hsdram) /** * @brief Sends Command to the SDRAM bank. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param Command: SDRAM command structure * @param Timeout: Timeout duration - * @retval HAL state + * @retval HAL status */ HAL_StatusTypeDef HAL_SDRAM_SendCommand(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command, uint32_t Timeout) { @@ -714,9 +732,10 @@ HAL_StatusTypeDef HAL_SDRAM_SendCommand(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_C /** * @brief Programs the SDRAM Memory Refresh rate. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param RefreshRate: The SDRAM refresh rate value - * @retval HAL state + * @retval HAL status */ HAL_StatusTypeDef HAL_SDRAM_ProgramRefreshRate(SDRAM_HandleTypeDef *hsdram, uint32_t RefreshRate) { @@ -740,9 +759,10 @@ HAL_StatusTypeDef HAL_SDRAM_ProgramRefreshRate(SDRAM_HandleTypeDef *hsdram, uint /** * @brief Sets the Number of consecutive SDRAM Memory auto Refresh commands. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @param AutoRefreshNumber: The SDRAM auto Refresh number - * @retval None + * @retval HAL status */ HAL_StatusTypeDef HAL_SDRAM_SetAutoRefreshNumber(SDRAM_HandleTypeDef *hsdram, uint32_t AutoRefreshNumber) { @@ -766,7 +786,8 @@ HAL_StatusTypeDef HAL_SDRAM_SetAutoRefreshNumber(SDRAM_HandleTypeDef *hsdram, ui /** * @brief Returns the SDRAM memory current mode. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @retval The SDRAM memory mode. */ uint32_t HAL_SDRAM_GetModeStatus(SDRAM_HandleTypeDef *hsdram) @@ -796,7 +817,8 @@ uint32_t HAL_SDRAM_GetModeStatus(SDRAM_HandleTypeDef *hsdram) /** * @brief Returns the SDRAM state. - * @param hsdram: SDRAM handle + * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains + * the configuration information for SDRAM module. * @retval HAL state */ HAL_SDRAM_StateTypeDef HAL_SDRAM_GetState(SDRAM_HandleTypeDef *hsdram) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.h index afc8f5c6e3..7d8c52410f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sdram.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of SDRAM HAL module. ****************************************************************************** * @attention @@ -89,8 +89,15 @@ typedef struct }SDRAM_HandleTypeDef; -/* Exported types ------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset SDRAM handle state + * @param __HANDLE__: specifies the SDRAM handle. + * @retval None + */ +#define __HAL_SDRAM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SDRAM_STATE_RESET) + /* Exported functions --------------------------------------------------------*/ /* Initialization/de-initialization functions **********************************/ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.c index 49ff894d8b..c5513fe78c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_smartcard.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief SMARTCARD HAL module driver. * This file provides firmware functions to manage the following * functionalities of the SMARTCARD peripheral: @@ -16,10 +16,10 @@ ##### How to use this driver ##### ============================================================================== [..] - The SMARTCARD HAL driver can be used as follow: + The SMARTCARD HAL driver can be used as follows: (#) Declare a SMARTCARD_HandleTypeDef handle structure. - (#) Initialize the SMARTCARD low level resources by implement the HAL_SMARTCARD_MspInit ()API: + (#) Initialize the SMARTCARD low level resources by implementing the HAL_SMARTCARD_MspInit() API: (##) Enable the USARTx interface clock. (##) SMARTCARD pins configuration: (+++) Enable the clock for the SMARTCARD GPIOs. @@ -28,10 +28,6 @@ and HAL_SMARTCARD_Receive_IT() APIs): (+++) Configure the USARTx interrupt priority. (+++) Enable the NVIC USART IRQ handle. - - -@@- The specific SMARTCARD interrupts (Transmission complete interrupt, - RXNE interrupt and Error Interrupts) will be managed using the macros - __SMARTCARD_ENABLE_IT() and __SMARTCARD_DISABLE_IT() inside the transmit and receive process. (##) DMA Configuration if you need to use DMA process (HAL_SMARTCARD_Transmit_DMA() and HAL_SMARTCARD_Receive_DMA() APIs): (+++) Declare a DMA handle structure for the Tx/Rx stream. @@ -42,13 +38,18 @@ (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx Stream. (#) Program the Baud Rate, Word Length , Stop Bit, Parity, Hardware - flow control and Mode(Receiver/Transmitter) in the hsc Init structure. + flow control and Mode(Receiver/Transmitter) in the SMARTCARD Init structure. (#) Initialize the SMARTCARD registers by calling the HAL_SMARTCARD_Init() API: - (++) These API's configures also the low level Hardware GPIO, CLOCK, CORTEX...etc) - by calling the customed HAL_SMARTCARD_MspInit(&hsc) API. - - (#) Three mode of operations are available within this driver : + (++) These APIs configure also the low level Hardware GPIO, CLOCK, CORTEX...etc) + by calling the customed HAL_SMARTCARD_MspInit() API. + [..] + (@) The specific SMARTCARD interrupts (Transmission complete interrupt, + RXNE interrupt and Error Interrupts) will be managed using the macros + __SMARTCARD_ENABLE_IT() and __SMARTCARD_DISABLE_IT() inside the transmit and receive process. + + [..] + Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -87,10 +88,10 @@ (+) __HAL_SMARTCARD_ENABLE: Enable the SMARTCARD peripheral (+) __HAL_SMARTCARD_DISABLE: Disable the SMARTCARD peripheral - (+) __HAL_SMARTCARD_GET_FLAG : Checks whether the specified SMARTCARD flag is set or not - (+) __HAL_SMARTCARD_CLEAR_FLAG : Clears the specified SMARTCARD pending flag - (+) __HAL_SMARTCARD_ENABLE_IT: Enables the specified SMARTCARD interrupt - (+) __HAL_SMARTCARD_DISABLE_IT: Disables the specified SMARTCARD interrupt + (+) __HAL_SMARTCARD_GET_FLAG : Check whether the specified SMARTCARD flag is set or not + (+) __HAL_SMARTCARD_CLEAR_FLAG : Clear the specified SMARTCARD pending flag + (+) __HAL_SMARTCARD_ENABLE_IT: Enable the specified SMARTCARD interrupt + (+) __HAL_SMARTCARD_DISABLE_IT: Disable the specified SMARTCARD interrupt [..] (@) You can refer to the SMARTCARD HAL driver header file for more useful macros @@ -182,18 +183,7 @@ static HAL_StatusTypeDef SMARTCARD_WaitOnFlagUntilTimeout(SMARTCARD_HandleTypeDe (++) Parity: If the parity is enabled, then the MSB bit of the data written in the data register is transmitted but is changed by the parity bit. Depending on the frame length defined by the M bit (8-bits or 9-bits), - the possible SmartCard frame formats are as listed in the following table: - +-------------------------------------------------------------+ - | M bit | PCE bit | USART frame | - |---------------------|---------------------------------------| - | 0 | 0 | | SB | 8 bit data | STB | | - |---------|-----------|---------------------------------------| - | 0 | 1 | | SB | 7 bit data | PB | STB | | - |---------|-----------|---------------------------------------| - | 1 | 0 | | SB | 9 bit data | STB | | - |---------|-----------|---------------------------------------| - | 1 | 1 | | SB | 8 bit data | PB | STB | | - +-------------------------------------------------------------+ + please refer to Reference manual for possible SMARTDARD frame formats. (++) USART polarity (++) USART phase (++) USART LastBit @@ -225,7 +215,8 @@ static HAL_StatusTypeDef SMARTCARD_WaitOnFlagUntilTimeout(SMARTCARD_HandleTypeDe /** * @brief Initializes the SmartCard mode according to the specified * parameters in the SMARTCARD_InitTypeDef and create the associated handle . - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval HAL status */ HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc) @@ -287,7 +278,8 @@ HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc) /** * @brief DeInitializes the USART SmartCard peripheral - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval HAL status */ HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc) @@ -317,7 +309,8 @@ HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc) /** * @brief SMARTCARD MSP Init - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval None */ __weak void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc) @@ -329,7 +322,8 @@ HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc) /** * @brief SMARTCARD MSP DeInit - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval None */ __weak void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc) @@ -358,33 +352,33 @@ HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc) While receiving data, transmission should be avoided as the data to be transmitted could be corrupted. - (#) There are two mode of transfer: + (#) There are two modes of transfer: (++) Blocking mode: The communication is performed in polling mode. The HAL status of all data processing is returned by the same function after finishing transfer. - (++) No-Blocking mode: The communication is performed using Interrupts - or DMA, These API's return the HAL status. + (++) Non Blocking mode: The communication is performed using Interrupts + or DMA, These APIs return the HAL status. The end of the data processing will be indicated through the dedicated SMARTCARD IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. The HAL_SMARTCARD_TxCpltCallback(), HAL_SMARTCARD_RxCpltCallback() user callbacks - will be executed respectivelly at the end of the transmit or Receive process - The HAL_SMARTCARD_ErrorCallback()user callback will be executed when a communication error is detected + will be executed respectivelly at the end of the Transmit or Receive process + The HAL_SMARTCARD_ErrorCallback() user callback will be executed when a communication error is detected - (#) Blocking mode API's are : + (#) Blocking mode APIs are : (++) HAL_SMARTCARD_Transmit() (++) HAL_SMARTCARD_Receive() - (#) Non-Blocking mode API's with Interrupt are : + (#) Non Blocking mode APIs with Interrupt are : (++) HAL_SMARTCARD_Transmit_IT() (++) HAL_SMARTCARD_Receive_IT() (++) HAL_SMARTCARD_IRQHandler() - (#) No-Blocking mode functions with DMA are : + (#) Non Blocking mode functions with DMA are : (++) HAL_SMARTCARD_Transmit_DMA() (++) HAL_SMARTCARD_Receive_DMA() - (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: + (#) A set of Transfer Complete Callbacks are provided in non Blocking mode: (++) HAL_SMARTCARD_TxCpltCallback() (++) HAL_SMARTCARD_RxCpltCallback() (++) HAL_SMARTCARD_ErrorCallback() @@ -395,16 +389,20 @@ HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc) /** * @brief Send an amount of data in blocking mode - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent + * @param Timeout: Timeout duration * @retval HAL status */ HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout) { uint16_t* tmp; - - if(hsc->State == HAL_SMARTCARD_STATE_READY) + uint32_t tmp1 = 0; + + tmp1 = hsc->State; + if((tmp1 == HAL_SMARTCARD_STATE_READY) || (tmp1 == HAL_SMARTCARD_STATE_BUSY_RX)) { if((pData == NULL) || (Size == 0)) { @@ -415,8 +413,16 @@ HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t * __HAL_LOCK(hsc); hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE; - hsc->State = HAL_SMARTCARD_STATE_BUSY_TX; - + /* Check if a non-blocking receive process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_RX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX_RX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX; + } + hsc->TxXferSize = Size; hsc->TxXferCount = Size; while(hsc->TxXferCount > 0) @@ -454,8 +460,15 @@ HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t * return HAL_TIMEOUT; } - hsc->State = HAL_SMARTCARD_STATE_READY; - + /* Check if a non-blocking receive process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX_RX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_RX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_READY; + } /* Process Unlocked */ __HAL_UNLOCK(hsc); @@ -469,16 +482,20 @@ HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t * /** * @brief Receive an amount of data in blocking mode - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @param pData: pointer to data buffer * @param Size: amount of data to be received + * @param Timeout: Timeout duration * @retval HAL status */ HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout) { uint16_t* tmp; - - if(hsc->State == HAL_SMARTCARD_STATE_READY) + uint32_t tmp1 = 0; + + tmp1 = hsc->State; + if((tmp1 == HAL_SMARTCARD_STATE_READY) || (tmp1 == HAL_SMARTCARD_STATE_BUSY_TX)) { if((pData == NULL) || (Size == 0)) { @@ -489,7 +506,16 @@ HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *p __HAL_LOCK(hsc); hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE; - hsc->State = HAL_SMARTCARD_STATE_BUSY_RX; + + /* Check if a non-blocking transmit process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX_RX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_RX; + } hsc->RxXferSize = Size; hsc->RxXferCount = Size; @@ -531,7 +557,16 @@ HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *p } } } - hsc->State = HAL_SMARTCARD_STATE_READY; + + /* Check if a non-blocking transmit process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX_RX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_READY; + } /* Process Unlocked */ __HAL_UNLOCK(hsc); @@ -546,14 +581,18 @@ HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *p /** * @brief Send an amount of data in non blocking mode - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @retval HAL status */ HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size) { - if(hsc->State == HAL_SMARTCARD_STATE_READY) + uint32_t tmp1 = 0; + + tmp1 = hsc->State; + if((tmp1 == HAL_SMARTCARD_STATE_READY) || (tmp1 == HAL_SMARTCARD_STATE_BUSY_RX)) { if((pData == NULL) || (Size == 0)) { @@ -568,7 +607,15 @@ HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_ hsc->TxXferCount = Size; hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE; - hsc->State = HAL_SMARTCARD_STATE_BUSY_TX; + /* Check if a non-blocking receive process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_RX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX_RX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX; + } /* Enable the SMARTCARD Parity Error Interrupt */ __SMARTCARD_ENABLE_IT(hsc, SMARTCARD_IT_PE); @@ -592,14 +639,18 @@ HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_ /** * @brief Receive an amount of data in non blocking mode - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @param pData: pointer to data buffer * @param Size: amount of data to be received * @retval HAL status */ HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size) { - if(hsc->State == HAL_SMARTCARD_STATE_READY) + uint32_t tmp1 = 0; + + tmp1 = hsc->State; + if((tmp1 == HAL_SMARTCARD_STATE_READY) || (tmp1 == HAL_SMARTCARD_STATE_BUSY_TX)) { if((pData == NULL) || (Size == 0)) { @@ -614,7 +665,15 @@ HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t hsc->RxXferCount = Size; hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE; - hsc->State = HAL_SMARTCARD_STATE_BUSY_RX; + /* Check if a non-blocking transmit process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX_RX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_RX; + } /* Enable the SMARTCARD Data Register not empty Interrupt */ __SMARTCARD_ENABLE_IT(hsc, SMARTCARD_IT_RXNE); @@ -638,7 +697,8 @@ HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t /** * @brief Send an amount of data in non blocking mode - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @retval HAL status @@ -646,10 +706,10 @@ HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size) { uint32_t *tmp; - uint32_t tmpstate; + uint32_t tmp1 = 0; - tmpstate = hsc->State; - if((tmpstate == HAL_SMARTCARD_STATE_READY) || (tmpstate == HAL_SMARTCARD_STATE_BUSY_RX)) + tmp1 = hsc->State; + if((tmp1 == HAL_SMARTCARD_STATE_READY) || (tmp1 == HAL_SMARTCARD_STATE_BUSY_RX)) { if((pData == NULL) || (Size == 0)) { @@ -664,7 +724,15 @@ HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8 hsc->TxXferCount = Size; hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE; - hsc->State = HAL_SMARTCARD_STATE_BUSY_TX; + /* Check if a non-blocking receive process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_RX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX_RX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX; + } /* Set the SMARTCARD DMA transfert complete callback */ hsc->hdmatx->XferCpltCallback = SMARTCARD_DMATransmitCplt; @@ -693,7 +761,8 @@ HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8 /** * @brief Receive an amount of data in non blocking mode - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @param pData: pointer to data buffer * @param Size: amount of data to be received * @note When the SMARTCARD parity is enabled (PCE = 1) the data received contain the parity bit.s @@ -702,10 +771,10 @@ HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8 HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size) { uint32_t *tmp; - uint32_t tmpstate; + uint32_t tmp1 = 0; - tmpstate = hsc->State; - if((tmpstate == HAL_SMARTCARD_STATE_READY) || (tmpstate == HAL_SMARTCARD_STATE_BUSY_TX)) + tmp1 = hsc->State; + if((tmp1 == HAL_SMARTCARD_STATE_READY) || (tmp1 == HAL_SMARTCARD_STATE_BUSY_TX)) { if((pData == NULL) || (Size == 0)) { @@ -719,7 +788,15 @@ HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_ hsc->RxXferSize = Size; hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE; - hsc->State = HAL_SMARTCARD_STATE_BUSY_RX; + /* Check if a non-blocking transmit process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX_RX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_RX; + } /* Set the SMARTCARD DMA transfert complete callback */ hsc->hdmarx->XferCpltCallback = SMARTCARD_DMAReceiveCplt; @@ -748,62 +825,59 @@ HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_ /** * @brief This function handles SMARTCARD interrupt request. - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval None */ void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc) { uint32_t tmp1 = 0, tmp2 = 0; - tmp1 = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_PE); + tmp1 = hsc->Instance->SR; tmp2 = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_PE); + /* SMARTCARD parity error interrupt occured --------------------------------*/ - if((tmp1 != RESET) && (tmp2 != RESET)) + if(((tmp1 & SMARTCARD_FLAG_PE) != RESET) && (tmp2 != RESET)) { __HAL_SMARTCARD_CLEAR_FLAG(hsc, SMARTCARD_FLAG_PE); hsc->ErrorCode |= HAL_SMARTCARD_ERROR_PE; } - tmp1 = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_FE); tmp2 = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_ERR); /* SMARTCARD frame error interrupt occured ---------------------------------*/ - if((tmp1 != RESET) && (tmp2 != RESET)) + if(((tmp1 & SMARTCARD_FLAG_FE) != RESET) && (tmp2 != RESET)) { __HAL_SMARTCARD_CLEAR_FLAG(hsc, SMARTCARD_FLAG_FE); hsc->ErrorCode |= HAL_SMARTCARD_ERROR_FE; } - tmp1 = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_NE); tmp2 = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_ERR); /* SMARTCARD noise error interrupt occured ---------------------------------*/ - if((tmp1 != RESET) && (tmp2 != RESET)) + if(((tmp1 & SMARTCARD_FLAG_NE) != RESET) && (tmp2 != RESET)) { __HAL_SMARTCARD_CLEAR_FLAG(hsc, SMARTCARD_FLAG_NE); hsc->ErrorCode |= HAL_SMARTCARD_ERROR_NE; } - - tmp1 = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_ORE); + tmp2 = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_ERR); /* SMARTCARD Over-Run interrupt occured ------------------------------------*/ - if((tmp1 != RESET) && (tmp2 != RESET)) + if(((tmp1 & SMARTCARD_FLAG_ORE) != RESET) && (tmp2 != RESET)) { __HAL_SMARTCARD_CLEAR_FLAG(hsc, SMARTCARD_FLAG_ORE); hsc->ErrorCode |= HAL_SMARTCARD_ERROR_ORE; } - tmp1 = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_RXNE); tmp2 = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_RXNE); /* SMARTCARD in mode Receiver ----------------------------------------------*/ - if((tmp1 != RESET) && (tmp2 != RESET)) + if(((tmp1 & SMARTCARD_FLAG_RXNE) != RESET) && (tmp2 != RESET)) { SMARTCARD_Receive_IT(hsc); __HAL_SMARTCARD_CLEAR_FLAG(hsc, SMARTCARD_FLAG_RXNE); } - - tmp1 = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_TC); + tmp2 = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_TC); /* SMARTCARD in mode Transmitter -------------------------------------------*/ - if((tmp1 != RESET) && (tmp2 != RESET)) + if(((tmp1 & SMARTCARD_FLAG_TC) != RESET) && (tmp2 != RESET)) { SMARTCARD_Transmit_IT(hsc); __HAL_SMARTCARD_CLEAR_FLAG(hsc, SMARTCARD_FLAG_TC); @@ -820,7 +894,8 @@ void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc) /** * @brief Tx Transfer completed callbacks - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval None */ __weak void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc) @@ -832,7 +907,8 @@ void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc) /** * @brief Rx Transfer completed callbacks - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval None */ __weak void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc) @@ -844,7 +920,8 @@ __weak void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc) /** * @brief SMARTCARD error callbacks - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval None */ __weak void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc) @@ -875,7 +952,8 @@ __weak void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc) /** * @brief return the SMARTCARD state - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval HAL state */ HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc) @@ -900,7 +978,8 @@ uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc) /** * @brief DMA SMARTCARD transmit process complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SMARTCARD_DMATransmitCplt(DMA_HandleTypeDef *hdma) @@ -923,14 +1002,23 @@ static void SMARTCARD_DMATransmitCplt(DMA_HandleTypeDef *hdma) else { /* No Timeout */ - hsc->State= HAL_SMARTCARD_STATE_READY; + /* Check if a non-blocking receive process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX_RX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_RX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_READY; + } HAL_SMARTCARD_TxCpltCallback(hsc); } } /** * @brief DMA SMARTCARD receive process complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SMARTCARD_DMAReceiveCplt(DMA_HandleTypeDef *hdma) @@ -943,14 +1031,23 @@ static void SMARTCARD_DMAReceiveCplt(DMA_HandleTypeDef *hdma) in the USART CR3 register */ hsc->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DMAR); - hsc->State= HAL_SMARTCARD_STATE_READY; - + /* Check if a non-blocking transmit process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX_RX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_READY; + } + HAL_SMARTCARD_RxCpltCallback(hsc); } /** * @brief DMA SMARTCARD communication error callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SMARTCARD_DMAError(DMA_HandleTypeDef *hdma) @@ -1031,18 +1128,18 @@ static HAL_StatusTypeDef SMARTCARD_WaitOnFlagUntilTimeout(SMARTCARD_HandleTypeDe /** * @brief Send an amount of data in non blocking mode - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval HAL status */ static HAL_StatusTypeDef SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc) { uint16_t* tmp; - - if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX) + uint32_t tmp1 = 0; + + tmp1 = hsc->State; + if((tmp1 == HAL_SMARTCARD_STATE_BUSY_TX) || (tmp1 == HAL_SMARTCARD_STATE_BUSY_TX_RX)) { - /* Process Locked */ - __HAL_LOCK(hsc); - if(hsc->Init.WordLength == SMARTCARD_WORDLENGTH_9B) { tmp = (uint16_t*) hsc->pTxBuffPtr; @@ -1072,20 +1169,21 @@ static HAL_StatusTypeDef SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc) /* Disable the SMARTCARD Error Interrupt: (Frame error, noise error, overrun error) */ __SMARTCARD_DISABLE_IT(hsc, SMARTCARD_IT_ERR); - hsc->State = HAL_SMARTCARD_STATE_READY; - - /* Call the Process Unlocked before calling the Tx call back API to give the possibiity to - start again the Transmission under the Tx call back API */ - __HAL_UNLOCK(hsc); + /* Check if a non-blocking receive process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX_RX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_RX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_READY; + } HAL_SMARTCARD_TxCpltCallback(hsc); return HAL_OK; } - /* Process Unlocked */ - __HAL_UNLOCK(hsc); - return HAL_OK; } else @@ -1096,18 +1194,18 @@ static HAL_StatusTypeDef SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc) /** * @brief Receive an amount of data in non blocking mode - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval HAL status */ static HAL_StatusTypeDef SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc) { uint16_t* tmp; - - if(hsc->State == HAL_SMARTCARD_STATE_BUSY_RX) + uint32_t tmp1 = 0; + + tmp1 = hsc->State; + if((tmp1 == HAL_SMARTCARD_STATE_BUSY_RX) || (tmp1 == HAL_SMARTCARD_STATE_BUSY_TX_RX)) { - /* Process Locked */ - __HAL_LOCK(hsc); - if(hsc->Init.WordLength == SMARTCARD_WORDLENGTH_9B) { tmp = (uint16_t*) hsc->pRxBuffPtr; @@ -1147,20 +1245,20 @@ static HAL_StatusTypeDef SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc) /* Disable the SMARTCARD Error Interrupt: (Frame error, noise error, overrun error) */ __SMARTCARD_DISABLE_IT(hsc, SMARTCARD_IT_ERR); - hsc->State = HAL_SMARTCARD_STATE_READY; - - /* Call the Process Unlocked before calling the Rx call back API to give the possibiity to - start again the receiption under the Rx call back API */ - __HAL_UNLOCK(hsc); + /* Check if a non-blocking transmit process is ongoing or not */ + if(hsc->State == HAL_SMARTCARD_STATE_BUSY_TX_RX) + { + hsc->State = HAL_SMARTCARD_STATE_BUSY_TX; + } + else + { + hsc->State = HAL_SMARTCARD_STATE_READY; + } HAL_SMARTCARD_RxCpltCallback(hsc); return HAL_OK; } - - /* Process Unlocked */ - __HAL_UNLOCK(hsc); - return HAL_OK; } else @@ -1171,7 +1269,8 @@ static HAL_StatusTypeDef SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc) /** * @brief Configure the SMARTCARD peripheral - * @param hsc: usart handle + * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains + * the configuration information for SMARTCARD module. * @retval None */ static void SMARTCARD_SetConfig(SMARTCARD_HandleTypeDef *hsc) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.h index c7273feb0b..899bda9a5b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_smartcard.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of SMARTCARD HAL module. ****************************************************************************** * @attention @@ -91,13 +91,13 @@ typedef struct data bit (MSB) has to be output on the SCLK pin in synchronous mode. This parameter can be a value of @ref SMARTCARD_Last_Bit */ - uint32_t Prescaler; /*!< Specifies the SmartCard Prescaler + uint32_t Prescaler; /*!< Specifies the SmartCard Prescaler. This parameter must be a number between Min_Data = 0 and Max_Data = 255 */ - uint32_t GuardTime; /*!< Specifies the SmartCard Guard Time + uint32_t GuardTime; /*!< Specifies the SmartCard Guard Time. This parameter must be a number between Min_Data = 0 and Max_Data = 255 */ - uint32_t NACKState; /*!< Specifies the SmartCard NACK Transmission state + uint32_t NACKState; /*!< Specifies the SmartCard NACK Transmission state. This parameter can be a value of @ref SmartCard_NACK_State */ }SMARTCARD_InitTypeDef; @@ -106,13 +106,14 @@ typedef struct */ typedef enum { - HAL_SMARTCARD_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ - HAL_SMARTCARD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ - HAL_SMARTCARD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ - HAL_SMARTCARD_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ - HAL_SMARTCARD_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ - HAL_SMARTCARD_STATE_TIMEOUT = 0x03, /*!< Timeout state */ - HAL_SMARTCARD_STATE_ERROR = 0x04 /*!< Error */ + HAL_SMARTCARD_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ + HAL_SMARTCARD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ + HAL_SMARTCARD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ + HAL_SMARTCARD_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ + HAL_SMARTCARD_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ + HAL_SMARTCARD_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ + HAL_SMARTCARD_STATE_TIMEOUT = 0x03, /*!< Timeout state */ + HAL_SMARTCARD_STATE_ERROR = 0x04 /*!< Error */ }HAL_SMARTCARD_StateTypeDef; /** @@ -313,6 +314,12 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset SMARTCARD handle state + * @param __HANDLE__: specifies the SMARTCARD Handle. + * @retval None + */ +#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SMARTCARD_STATE_RESET) + /** @brief Flushs the Smartcard DR register * @param __HANDLE__: specifies the SMARTCARD Handle. */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.c index 40370dcf4c..f3dce533b7 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_spi.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief SPI HAL module driver. * * This file provides firmware functions to manage the following @@ -22,7 +22,7 @@ (#) Declare a SPI_HandleTypeDef handle structure, for example: SPI_HandleTypeDef hspi; - (#)Initialize the SPI low level resources by implement the HAL_SPI_MspInit ()API: + (#)Initialize the SPI low level resources by implementing the HAL_SPI_MspInit ()API: (##) Enable the SPIx interface clock (##) SPI pins configuration (+++) Enable the clock for the SPI GPIOs @@ -43,7 +43,7 @@ (#) Initialize the SPI registers by calling the HAL_SPI_Init() API: (++) This API configures also the low level Hardware GPIO, CLOCK, CORTEX...etc) - by calling the customed HAL_SPI_MspInit(&hspi) API. + by calling the customed HAL_SPI_MspInit() API. @endverbatim ****************************************************************************** @@ -123,7 +123,7 @@ static HAL_StatusTypeDef SPI_WaitOnFlagUntilTimeout(SPI_HandleTypeDef *hspi, uin [..] This subsection provides a set of functions allowing to initialize and de-initialiaze the SPIx peripheral: - (+) User must Implement HAL_SPI_MspInit() function in which he configures + (+) User must implement HAL_SPI_MspInit() function in which he configures all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ). (+) Call the function HAL_SPI_Init() to configure the selected device with @@ -149,7 +149,8 @@ static HAL_StatusTypeDef SPI_WaitOnFlagUntilTimeout(SPI_HandleTypeDef *hspi, uin /** * @brief Initializes the SPI according to the specified parameters * in the SPI_InitTypeDef and create the associated handle. - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi) @@ -209,7 +210,8 @@ HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi) /** * @brief DeInitializes the SPI peripheral - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi) @@ -237,7 +239,8 @@ HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi) /** * @brief SPI MSP Init - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) @@ -249,7 +252,8 @@ HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi) /** * @brief SPI MSP DeInit - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi) @@ -275,12 +279,12 @@ HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi) [..] The SPI supports master and slave mode : - (#) There are two mode of transfer: + (#) There are two modes of transfer: (++) Blocking mode: The communication is performed in polling mode. The HAL status of all data processing is returned by the same function after finishing transfer. (++) No-Blocking mode: The communication is performed using Interrupts - or DMA, These API's return the HAL status. + or DMA, These APIs return the HAL status. The end of the data processing will be indicated through the dedicated SPI IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. @@ -288,23 +292,23 @@ HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi) will be executed respectivelly at the end of the transmit or Receive process The HAL_SPI_ErrorCallback()user callback will be executed when a communication error is detected - (#) Blocking mode API's are : + (#) Blocking mode APIs are : (++) HAL_SPI_Transmit()in 1Line (simplex) and 2Lines (full duplex) mode (++) HAL_SPI_Receive() in 1Line (simplex) and 2Lines (full duplex) mode (++) HAL_SPI_TransmitReceive() in full duplex mode - (#) Non-Blocking mode API's with Interrupt are : + (#) Non Blocking mode API's with Interrupt are : (++) HAL_SPI_Transmit_IT()in 1Line (simplex) and 2Lines (full duplex) mode (++) HAL_SPI_Receive_IT() in 1Line (simplex) and 2Lines (full duplex) mode (++) HAL_SPI_TransmitReceive_IT()in full duplex mode (++) HAL_SPI_IRQHandler() - (#) No-Blocking mode functions with DMA are : + (#) Non Blocking mode functions with DMA are : (++) HAL_SPI_Transmit_DMA()in 1Line (simplex) and 2Lines (full duplex) mode (++) HAL_SPI_Receive_DMA() in 1Line (simplex) and 2Lines (full duplex) mode (++) HAL_SPI_TransmitReceie_DMA() in full duplex mode - (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: + (#) A set of Transfer Complete Callbacks are provided in non Blocking mode: (++) HAL_SPI_TxCpltCallback() (++) HAL_SPI_RxCpltCallback() (++) HAL_SPI_ErrorCallback() @@ -316,7 +320,8 @@ HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi) /** * @brief Transmit an amount of data in blocking mode - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @param Timeout: Timeout duration @@ -454,7 +459,8 @@ HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint /** * @brief Receive an amount of data in blocking mode - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @param Timeout: Timeout duration @@ -627,7 +633,8 @@ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint1 /** * @brief Transmit and Receive an amount of data in blocking mode - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @param pTxData: pointer to transmission data buffer * @param pRxData: pointer to reception data buffer to be * @param Size: amount of data to be sent @@ -871,7 +878,8 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD /** * @brief Transmit an amount of data in no-blocking mode with Interrupt - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @retval HAL status @@ -945,7 +953,8 @@ HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, u /** * @brief Receive an amount of data in no-blocking mode with Interrupt - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @retval HAL status @@ -1023,7 +1032,8 @@ HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, ui /** * @brief Transmit and Receive an amount of data in no-blocking mode with Interrupt - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @param pTxData: pointer to transmission data buffer * @param pRxData: pointer to reception data buffer to be * @param Size: amount of data to be sent @@ -1095,7 +1105,8 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *p /** * @brief Transmit an amount of data in no-blocking mode with DMA - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @retval HAL status @@ -1173,7 +1184,8 @@ HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, /** * @brief Receive an amount of data in no-blocking mode with DMA - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @param pData: pointer to data buffer * @note When the CRC feature is enabled the pData Length must be Size + 1. * @param Size: amount of data to be sent @@ -1257,7 +1269,8 @@ HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, u /** * @brief Transmit and Receive an amount of data in no-blocking mode with DMA - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @param pTxData: pointer to transmission data buffer * @param pRxData: pointer to reception data buffer * @note When the CRC feature is enabled the pRxData Length must be Size + 1 @@ -1360,7 +1373,8 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t * /** * @brief This function handles SPI interrupt request. - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval HAL status */ void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi) @@ -1388,20 +1402,20 @@ void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi) if(__HAL_SPI_GET_IT_SOURCE(hspi, SPI_IT_ERR) != RESET) { - /* SPI CRC error interrupt occured ---------------------------------------*/ + /* SPI CRC error interrupt occurred ---------------------------------------*/ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_CRCERR) != RESET) { hspi->ErrorCode |= HAL_SPI_ERROR_CRC; __HAL_SPI_CLEAR_CRCERRFLAG(hspi); } - /* SPI Mode Fault error interrupt occured --------------------------------*/ + /* SPI Mode Fault error interrupt occurred --------------------------------*/ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_MODF) != RESET) { hspi->ErrorCode |= HAL_SPI_ERROR_MODF; __HAL_SPI_CLEAR_MODFFLAG(hspi); } - /* SPI Overrun error interrupt occured -----------------------------------*/ + /* SPI Overrun error interrupt occurred -----------------------------------*/ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_OVR) != RESET) { if(hspi->State != HAL_SPI_STATE_BUSY_TX) @@ -1411,7 +1425,7 @@ void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi) } } - /* SPI Frame error interrupt occured -------------------------------------*/ + /* SPI Frame error interrupt occurred -------------------------------------*/ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_FRE) != RESET) { hspi->ErrorCode |= HAL_SPI_ERROR_FRE; @@ -1429,7 +1443,8 @@ void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi) /** * @brief Tx Transfer completed callbacks - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) @@ -1441,7 +1456,8 @@ __weak void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) /** * @brief Rx Transfer completed callbacks - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi) @@ -1453,7 +1469,8 @@ __weak void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi) /** * @brief Tx and Rx Transfer completed callbacks - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) @@ -1465,7 +1482,8 @@ __weak void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) /** * @brief SPI error callbacks - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi) @@ -1473,7 +1491,7 @@ __weak void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) /* NOTE : - This function Should not be modified, when the callback is needed, the HAL_SPI_ErrorCallback() could be implenetd in the user file. - The ErrorCode parameter in the hspi handle is updated by the SPI processes - and user can use HAL_SPI_GetError() API to check the latest error occured. + and user can use HAL_SPI_GetError() API to check the latest error occurred. */ } @@ -1498,8 +1516,9 @@ __weak void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) /** * @brief Return the SPI state - * @param hspi : SPI handle - * @retval SPI state + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. + * @retval HAL state */ HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi) { @@ -1508,7 +1527,8 @@ HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi) /** * @brief Return the SPI error code - * @param hspi : SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval SPI Error Code */ HAL_SPI_ErrorTypeDef HAL_SPI_GetError(SPI_HandleTypeDef *hspi) @@ -1522,7 +1542,8 @@ HAL_SPI_ErrorTypeDef HAL_SPI_GetError(SPI_HandleTypeDef *hspi) /** * @brief Interrupt Handler to close Tx transfer - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval void */ static void SPI_TxCloseIRQHandler(SPI_HandleTypeDef *hspi) @@ -1582,7 +1603,8 @@ static void SPI_TxCloseIRQHandler(SPI_HandleTypeDef *hspi) /** * @brief Interrupt Handler to transmit amount of data in no-blocking mode - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval void */ static void SPI_TxISR(SPI_HandleTypeDef *hspi) @@ -1613,7 +1635,8 @@ static void SPI_TxISR(SPI_HandleTypeDef *hspi) /** * @brief Interrupt Handler to close Rx transfer - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval void */ static void SPI_RxCloseIRQHandler(SPI_HandleTypeDef *hspi) @@ -1690,7 +1713,8 @@ static void SPI_RxCloseIRQHandler(SPI_HandleTypeDef *hspi) /** * @brief Interrupt Handler to receive amount of data in 2Lines mode - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval void */ static void SPI_2LinesRxISR(SPI_HandleTypeDef *hspi) @@ -1716,7 +1740,8 @@ static void SPI_2LinesRxISR(SPI_HandleTypeDef *hspi) /** * @brief Interrupt Handler to receive amount of data in no-blocking mode - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval void */ static void SPI_RxISR(SPI_HandleTypeDef *hspi) @@ -1749,7 +1774,8 @@ static void SPI_RxISR(SPI_HandleTypeDef *hspi) /** * @brief DMA SPI transmit process complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMATransmitCplt(DMA_HandleTypeDef *hdma) @@ -1794,7 +1820,8 @@ static void SPI_DMATransmitCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA SPI receive process complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMAReceiveCplt(DMA_HandleTypeDef *hdma) @@ -1854,7 +1881,8 @@ static void SPI_DMAReceiveCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA SPI transmit receive process complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMATransmitReceiveCplt(DMA_HandleTypeDef *hdma) @@ -1921,7 +1949,8 @@ static void SPI_DMATransmitReceiveCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA SPI communication error callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMAError(DMA_HandleTypeDef *hdma) @@ -1936,7 +1965,8 @@ static void SPI_DMAError(DMA_HandleTypeDef *hdma) /** * @brief This function handles SPI Communication Timeout. - * @param hspi: SPI handle + * @param hspi: pointer to a SPI_HandleTypeDef structure that contains + * the configuration information for SPI module. * @retval HAL status */ static HAL_StatusTypeDef SPI_WaitOnFlagUntilTimeout(SPI_HandleTypeDef *hspi, uint32_t Flag, FlagStatus Status, uint32_t Timeout) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.h index c8929d36d8..ec0b458807 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_spi.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of SPI HAL module. ****************************************************************************** * @attention @@ -346,6 +346,13 @@ typedef struct __SPI_HandleTypeDef /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset SPI handle state + * @param __HANDLE__: specifies the SPI handle. + * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. + * @retval None + */ +#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET) + /** @brief Enable or disable the specified SPI interrupts. * @param __HANDLE__: specifies the SPI handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.c index 9aef8953de..f947eef1d7 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sram.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief SRAM HAL module driver. * This file provides a generic firmware to drive SRAM memories * mounted as external device. @@ -134,7 +134,8 @@ /** * @brief Performs the SRAM device initialization sequence - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @param Timing: Pointer to SRAM control timing structure * @param ExtTiming: Pointer to SRAM extended mode timing structure * @retval HAL status @@ -170,7 +171,8 @@ HAL_StatusTypeDef HAL_SRAM_Init(SRAM_HandleTypeDef *hsram, FMC_NORSRAM_TimingTyp /** * @brief Performs the SRAM device De-initialization sequence. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @retval HAL status */ HAL_StatusTypeDef HAL_SRAM_DeInit(SRAM_HandleTypeDef *hsram) @@ -191,7 +193,8 @@ HAL_StatusTypeDef HAL_SRAM_DeInit(SRAM_HandleTypeDef *hsram) /** * @brief SRAM MSP Init. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @retval None */ __weak void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram) @@ -203,7 +206,8 @@ __weak void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram) /** * @brief SRAM MSP DeInit. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @retval None */ __weak void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram) @@ -215,8 +219,9 @@ __weak void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram) /** * @brief DMA transfer complete callback. - * @param hsram: pointer to SRAM handle - * @retval none + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. + * @retval None */ __weak void HAL_SRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma) { @@ -227,8 +232,9 @@ __weak void HAL_SRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma) /** * @brief DMA transfer complete error callback. - * @param hsram: pointer to SRAM handle - * @retval none + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. + * @retval None */ __weak void HAL_SRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma) { @@ -257,7 +263,8 @@ __weak void HAL_SRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma) /** * @brief Reads 8-bit buffer from SRAM memory. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @param pAddress: Pointer to read start address * @param pDstBuffer: Pointer to destination buffer * @param BufferSize: Size of the buffer to read from memory @@ -292,7 +299,8 @@ HAL_StatusTypeDef HAL_SRAM_Read_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress /** * @brief Writes 8-bit buffer to SRAM memory. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @param pAddress: Pointer to write start address * @param pSrcBuffer: Pointer to source buffer to write * @param BufferSize: Size of the buffer to write to memory @@ -333,7 +341,8 @@ HAL_StatusTypeDef HAL_SRAM_Write_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddres /** * @brief Reads 16-bit buffer from SRAM memory. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @param pAddress: Pointer to read start address * @param pDstBuffer: Pointer to destination buffer * @param BufferSize: Size of the buffer to read from memory @@ -368,7 +377,8 @@ HAL_StatusTypeDef HAL_SRAM_Read_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddres /** * @brief Writes 16-bit buffer to SRAM memory. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @param pAddress: Pointer to write start address * @param pSrcBuffer: Pointer to source buffer to write * @param BufferSize: Size of the buffer to write to memory @@ -409,7 +419,8 @@ HAL_StatusTypeDef HAL_SRAM_Write_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddre /** * @brief Reads 32-bit buffer from SRAM memory. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @param pAddress: Pointer to read start address * @param pDstBuffer: Pointer to destination buffer * @param BufferSize: Size of the buffer to read from memory @@ -442,7 +453,8 @@ HAL_StatusTypeDef HAL_SRAM_Read_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddres /** * @brief Writes 32-bit buffer to SRAM memory. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @param pAddress: Pointer to write start address * @param pSrcBuffer: Pointer to source buffer to write * @param BufferSize: Size of the buffer to write to memory @@ -481,7 +493,8 @@ HAL_StatusTypeDef HAL_SRAM_Write_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddre /** * @brief Reads a Words data from the SRAM memory using DMA transfer. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @param pAddress: Pointer to read start address * @param pDstBuffer: Pointer to destination buffer * @param BufferSize: Size of the buffer to read from memory @@ -513,7 +526,8 @@ HAL_StatusTypeDef HAL_SRAM_Read_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddres /** * @brief Writes a Words data buffer to SRAM memory using DMA transfer. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @param pAddress: Pointer to write start address * @param pSrcBuffer: Pointer to source buffer to write * @param BufferSize: Size of the buffer to write to memory @@ -570,7 +584,8 @@ HAL_StatusTypeDef HAL_SRAM_Write_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddre /** * @brief Enables dynamically SRAM write operation. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @retval HAL status */ HAL_StatusTypeDef HAL_SRAM_WriteOperation_Enable(SRAM_HandleTypeDef *hsram) @@ -592,7 +607,8 @@ HAL_StatusTypeDef HAL_SRAM_WriteOperation_Enable(SRAM_HandleTypeDef *hsram) /** * @brief Disables dynamically SRAM write operation. - * @param hsram: pointer to SRAM handle + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. * @retval HAL status */ HAL_StatusTypeDef HAL_SRAM_WriteOperation_Disable(SRAM_HandleTypeDef *hsram) @@ -636,8 +652,9 @@ HAL_StatusTypeDef HAL_SRAM_WriteOperation_Disable(SRAM_HandleTypeDef *hsram) /** * @brief Returns the SRAM controller state - * @param hsram: pointer to SRAM handle - * @retval SRAM controller state + * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains + * the configuration information for SRAM module. + * @retval HAL state */ HAL_SRAM_StateTypeDef HAL_SRAM_GetState(SRAM_HandleTypeDef *hsram) { diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.h index 0cb6a33a68..968a1968de 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sram.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of SRAM HAL module. ****************************************************************************** * @attention @@ -97,8 +97,15 @@ typedef struct }SRAM_HandleTypeDef; -/* Exported constants --------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ + +/** @brief Reset SRAM handle state + * @param __HANDLE__: SRAM handle + * @retval None + */ +#define __HAL_SRAM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SRAM_STATE_RESET) + /* Exported functions --------------------------------------------------------*/ /* Initialization/de-initialization functions **********************************/ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.c index 4691f46a45..1ff74a73b0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_tim.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief TIM HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Timer (TIM) peripheral: @@ -193,7 +193,8 @@ static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma); /** * @brief Initializes the TIM Time base Unit according to the specified * parameters in the TIM_HandleTypeDef and create the associated handle. - * @param htim: TIM Base handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim) @@ -229,7 +230,8 @@ HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim) /** * @brief DeInitializes the TIM Base peripheral - * @param htim: TIM Base handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim) @@ -256,7 +258,8 @@ HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim) /** * @brief Initializes the TIM Base MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) @@ -268,7 +271,8 @@ __weak void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) /** * @brief DeInitializes TIM Base MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim) @@ -280,7 +284,8 @@ __weak void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Base generation. - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim) @@ -303,7 +308,8 @@ HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim) /** * @brief Stops the TIM Base generation. - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim) @@ -326,7 +332,8 @@ HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Base generation in interrupt mode. - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim) @@ -346,7 +353,8 @@ HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim) /** * @brief Stops the TIM Base generation in interrupt mode. - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim) @@ -365,7 +373,8 @@ HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Base generation in DMA mode. - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param pData: The source Buffer address. * @param Length: The length of data to be transferred from memory to peripheral. * @retval HAL status @@ -411,7 +420,8 @@ HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pDat /** * @brief Stops the TIM Base generation in DMA mode. - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim) @@ -460,7 +470,8 @@ HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim) /** * @brief Initializes the TIM Output Compare according to the specified * parameters in the TIM_HandleTypeDef and create the associated handle. - * @param htim: TIM Output Compare handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef* htim) @@ -496,7 +507,8 @@ HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef* htim) /** * @brief DeInitializes the TIM peripheral - * @param htim: TIM Output Compare handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim) @@ -523,7 +535,8 @@ HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim) /** * @brief Initializes the TIM Output Compare MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim) @@ -535,7 +548,8 @@ __weak void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim) /** * @brief DeInitializes TIM Output Compare MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim) @@ -547,8 +561,9 @@ __weak void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Output Compare signal generation. - * @param htim : TIM Output Compare handle - * @param Channel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -579,8 +594,9 @@ HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Stops the TIM Output Compare signal generation. - * @param htim : TIM handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -611,8 +627,9 @@ HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Starts the TIM Output Compare signal generation in interrupt mode. - * @param htim : TIM OC handle - * @param Channel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -677,8 +694,9 @@ HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Stops the TIM Output Compare signal generation in interrupt mode. - * @param htim : TIM Output Compare handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -743,8 +761,9 @@ HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Starts the TIM Output Compare signal generation in DMA mode. - * @param htim : TIM Output Compare handle - * @param Channel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -862,8 +881,9 @@ HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel /** * @brief Stops the TIM Output Compare signal generation in DMA mode. - * @param htim : TIM Output Compare handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -957,7 +977,8 @@ HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Initializes the TIM PWM Time Base according to the specified * parameters in the TIM_HandleTypeDef and create the associated handle. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim) @@ -993,7 +1014,8 @@ HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim) /** * @brief DeInitializes the TIM peripheral - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim) @@ -1020,7 +1042,8 @@ HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim) /** * @brief Initializes the TIM PWM MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim) @@ -1032,7 +1055,8 @@ __weak void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim) /** * @brief DeInitializes TIM PWM MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim) @@ -1044,8 +1068,9 @@ __weak void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim) /** * @brief Starts the PWM signal generation. - * @param htim : TIM handle - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1076,8 +1101,9 @@ HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Stops the PWM signal generation. - * @param htim : TIM handle - * @param Channel : TIM Channels to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1111,8 +1137,9 @@ HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Starts the PWM signal generation in interrupt mode. - * @param htim : TIM handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1177,8 +1204,9 @@ HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel /** * @brief Stops the PWM signal generation in interrupt mode. - * @param htim : TIM handle - * @param Channel : TIM Channels to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1243,8 +1271,9 @@ HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT (TIM_HandleTypeDef *htim, uint32_t Channel /** * @brief Starts the TIM PWM signal generation in DMA mode. - * @param htim : TIM handle - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1362,8 +1391,9 @@ HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channe /** * @brief Stops the TIM PWM signal generation in DMA mode. - * @param htim : TIM handle - * @param Channel : TIM Channels to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1457,7 +1487,8 @@ HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel /** * @brief Initializes the TIM Input Capture Time base according to the specified * parameters in the TIM_HandleTypeDef and create the associated handle. - * @param htim: TIM Input Capture handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim) @@ -1493,7 +1524,8 @@ HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim) /** * @brief DeInitializes the TIM peripheral - * @param htim: TIM Input Capture handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim) @@ -1520,7 +1552,8 @@ HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim) /** * @brief Initializes the TIM INput Capture MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim) @@ -1532,7 +1565,8 @@ __weak void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim) /** * @brief DeInitializes TIM Input Capture MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim) @@ -1544,8 +1578,9 @@ __weak void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Input Capture measurement. - * @param hdma : TIM Input Capture handle - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1570,8 +1605,9 @@ HAL_StatusTypeDef HAL_TIM_IC_Start (TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Stops the TIM Input Capture measurement. - * @param htim : TIM handle - * @param Channel : TIM Channels to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1596,8 +1632,9 @@ HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Starts the TIM Input Capture measurement in interrupt mode. - * @param hdma : TIM Input Capture handle - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1655,8 +1692,9 @@ HAL_StatusTypeDef HAL_TIM_IC_Start_IT (TIM_HandleTypeDef *htim, uint32_t Channel /** * @brief Stops the TIM Input Capture measurement in interrupt mode. - * @param htim : TIM handle - * @param Channel : TIM Channels to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1715,8 +1753,9 @@ HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Starts the TIM Input Capture measurement on in DMA mode. - * @param htim : TIM Input Capture handle - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1830,8 +1869,9 @@ HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel /** * @brief Stops the TIM Input Capture measurement on in DMA mode. - * @param htim : TIM Input Capture handle - * @param Channel : TIM Channels to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -1919,7 +1959,8 @@ HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Initializes the TIM One Pulse Time Base according to the specified * parameters in the TIM_HandleTypeDef and create the associated handle. - * @param htim: TIM OnePulse handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param OnePulseMode: Select the One pulse mode. * This parameter can be one of the following values: * @arg TIM_OPMODE_SINGLE: Only one pulse will be generated. @@ -1966,7 +2007,8 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePul /** * @brief DeInitializes the TIM One Pulse - * @param htim: TIM One Pulse handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim) @@ -1993,7 +2035,8 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim) /** * @brief Initializes the TIM One Pulse MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim) @@ -2005,7 +2048,8 @@ __weak void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim) /** * @brief DeInitializes TIM One Pulse MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim) @@ -2017,8 +2061,9 @@ __weak void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM One Pulse signal generation. - * @param htim : TIM One Pulse handle - * @param OutputChannel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param OutputChannel : TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2050,8 +2095,9 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t Outpu /** * @brief Stops the TIM One Pulse signal generation. - * @param htim : TIM One Pulse handle - * @param OutputChannel : TIM Channels to be disable + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param OutputChannel : TIM Channels to be disable. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2083,8 +2129,9 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t Output /** * @brief Starts the TIM One Pulse signal generation in interrupt mode. - * @param htim : TIM One Pulse handle - * @param OutputChannel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param OutputChannel : TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2122,8 +2169,9 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t Ou /** * @brief Stops the TIM One Pulse signal generation in interrupt mode. - * @param htim : TIM One Pulse handle - * @param OutputChannel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param OutputChannel : TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2185,7 +2233,8 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Out */ /** * @brief Initializes the TIM Encoder Interface and create the associated handle. - * @param htim: TIM Encoder Interface handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sConfig: TIM Encoder Interface configuration structure * @retval HAL status */ @@ -2272,7 +2321,8 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, TIM_Encoder_Ini /** * @brief DeInitializes the TIM Encoder interface - * @param htim: TIM Encoder handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim) @@ -2299,7 +2349,8 @@ HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim) /** * @brief Initializes the TIM Encoder Interface MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim) @@ -2311,7 +2362,8 @@ __weak void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim) /** * @brief DeInitializes TIM Encoder Interface MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim) @@ -2323,8 +2375,9 @@ __weak void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Encoder Interface. - * @param htim : TIM Encoder Interface handle - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2364,8 +2417,9 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channe /** * @brief Stops the TIM Encoder Interface. - * @param htim : TIM Encoder Interface handle - * @param Channel : TIM Channels to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2406,8 +2460,9 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel /** * @brief Starts the TIM Encoder Interface in interrupt mode. - * @param htim : TIM Encoder Interface handle - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2453,8 +2508,9 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Cha /** * @brief Stops the TIM Encoder Interface in interrupt mode. - * @param htim : TIM Encoder Interface handle - * @param Channel : TIM Channels to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be disabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2503,8 +2559,9 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Chan /** * @brief Starts the TIM Encoder Interface in DMA mode. - * @param htim : TIM Encoder Interface handle - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2622,8 +2679,9 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Ch /** * @brief Stops the TIM Encoder Interface in DMA mode. - * @param htim : TIM Encoder Interface handle - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2688,7 +2746,8 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Cha */ /** * @brief This function handles TIM interrupts requests. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim) @@ -2844,9 +2903,10 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim) /** * @brief Initializes the TIM Output Compare Channels according to the specified * parameters in the TIM_OC_InitTypeDef. - * @param htim: TIM Output Compare handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sConfig: TIM Output Compare configuration structure - * @param Channel : TIM Channels to be enabled + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -2917,9 +2977,10 @@ HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitT /** * @brief Initializes the TIM Input Capture Channels according to the specified * parameters in the TIM_IC_InitTypeDef. - * @param htim: TIM IC handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sConfig: TIM Input Capture configuration structure - * @param Channel : TIM Channels to be enabled + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -3013,9 +3074,10 @@ HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitT /** * @brief Initializes the TIM PWM channels according to the specified * parameters in the TIM_OC_InitTypeDef. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sConfig: TIM PWM configuration structure - * @param Channel : TIM Channels to be enabled + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -3113,13 +3175,14 @@ HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_Init /** * @brief Initializes the TIM One Pulse Channels according to the specified * parameters in the TIM_OnePulse_InitTypeDef. - * @param htim: TIM One Pulse handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sConfig: TIM One Pulse configuration structure - * @param OutputChannel : TIM Channels to be enabled + * @param OutputChannel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @param InputChannel : TIM Channels to be enabled + * @param InputChannel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -3225,8 +3288,9 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_O /** * @brief Configure the DMA Burst to transfer Data from the memory to the TIM peripheral - * @param htim: TIM handle - * @param BurstBaseAddress: TIM Base address from when the DMA will starts the Data write + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param BurstBaseAddress: TIM Base address from when the DMA will starts the Data write. * This parameters can be on of the following values: * @arg TIM_DMABase_CR1 * @arg TIM_DMABase_CR2 @@ -3247,7 +3311,7 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_O * @arg TIM_DMABase_CCR4 * @arg TIM_DMABase_BDTR * @arg TIM_DMABase_DCR - * @param BurstRequestSrc: TIM DMA Request sources + * @param BurstRequestSrc: TIM DMA Request sources. * This parameters can be on of the following values: * @arg TIM_DMA_UPDATE: TIM update Interrupt source * @arg TIM_DMA_CC1: TIM Capture Compare 1 DMA source @@ -3258,7 +3322,7 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_O * @arg TIM_DMA_TRIGGER: TIM Trigger DMA source * @param BurstBuffer: The Buffer address. * @param BurstLength: DMA Burst length. This parameter can be one value - * between: TIM_DMABurstLength_1Transfer and TIM_DMABurstLength_18Transfers. + * between TIM_DMABurstLength_1Transfer and TIM_DMABurstLength_18Transfers. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, @@ -3388,7 +3452,8 @@ HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t /** * @brief Stops the TIM DMA Burst mode - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param BurstRequestSrc: TIM DMA Request sources to disable * @retval HAL status */ @@ -3406,8 +3471,9 @@ HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t B /** * @brief Configure the DMA Burst to transfer Data from the TIM peripheral to the memory - * @param htim: TIM handle - * @param BurstBaseAddress: TIM Base address from when the DMA will starts the Data read + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param BurstBaseAddress: TIM Base address from when the DMA will starts the Data read. * This parameters can be on of the following values: * @arg TIM_DMABase_CR1 * @arg TIM_DMABase_CR2 @@ -3428,7 +3494,7 @@ HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t B * @arg TIM_DMABase_CCR4 * @arg TIM_DMABase_BDTR * @arg TIM_DMABase_DCR - * @param BurstRequestSrc: TIM DMA Request sources + * @param BurstRequestSrc: TIM DMA Request sources. * This parameters can be on of the following values: * @arg TIM_DMA_UPDATE: TIM update Interrupt source * @arg TIM_DMA_CC1: TIM Capture Compare 1 DMA source @@ -3439,7 +3505,7 @@ HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t B * @arg TIM_DMA_TRIGGER: TIM Trigger DMA source * @param BurstBuffer: The Buffer address. * @param BurstLength: DMA Burst length. This parameter can be one value - * between: TIM_DMABurstLength_1Transfer and TIM_DMABurstLength_18Transfers. + * between TIM_DMABurstLength_1Transfer and TIM_DMABurstLength_18Transfers. * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, @@ -3570,7 +3636,8 @@ HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t B /** * @brief Stop the DMA burst reading - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param BurstRequestSrc: TIM DMA Request sources to disable. * @retval HAL status */ @@ -3588,7 +3655,8 @@ HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t Bu /** * @brief Generate a software event - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param EventSource: specifies the event source. * This parameter can be one of the following values: * @arg TIM_EventSource_Update: Timer update Event source @@ -3630,15 +3698,16 @@ HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventS /** * @brief Configures the OCRef clear feature - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sClearInputConfig: pointer to a TIM_ClearInputConfigTypeDef structure that * contains the OCREF clear feature and parameters for the TIM peripheral. - * @param Channel: specifies the TIM Channel + * @param Channel: specifies the TIM Channel. * This parameter can be one of the following values: - * @arg TIM_Channel_1: TIM Channel 1 - * @arg TIM_Channel_2: TIM Channel 2 - * @arg TIM_Channel_3: TIM Channel 3 - * @arg TIM_Channel_4: TIM Channel 4 + * @arg TIM_CHANNEL_1: TIM Channel 1 selected + * @arg TIM_CHANNEL_2: TIM Channel 2 selected + * @arg TIM_CHANNEL_3: TIM Channel 3 selected + * @arg TIM_CHANNEL_4: TIM Channel 4 selected * @retval HAL status */ HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim, TIM_ClearInputConfigTypeDef * sClearInputConfig, uint32_t Channel) @@ -3738,7 +3807,8 @@ HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim, TIM_ClearInp /** * @brief Configures the clock source to be used - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sClockSourceConfig: pointer to a TIM_ClockConfigTypeDef structure that * contains the clock source information for the TIM peripheral. * @retval HAL status @@ -3871,7 +3941,8 @@ HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockCo /** * @brief Selects the signal connected to the TI1 input: direct from CH1_input * or a XOR combination between CH1_input, CH2_input & CH3_input - * @param htim: TIM handle. + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module.. * @param TI1_Selection: Indicate whether or not channel 1 is connected to the * output of a XOR gate. * This parameter can be one of the following values: @@ -3905,7 +3976,8 @@ HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_S /** * @brief Configures the TIM in Slave mode - * @param htim: TIM handle. + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module.. * @param sSlaveConfig: pointer to a TIM_SlaveConfigTypeDef structure that * contains the selected trigger (internal trigger input, filtered * timer input or external trigger input) and the ) and the Slave @@ -4052,8 +4124,9 @@ HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization(TIM_HandleTypeDef *htim, TI /** * @brief Read the captured value from Capture Compare unit - * @param htim: TIM handle. - * @param Channel : TIM Channels to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module.. + * @param Channel: TIM Channels to be enabled. * This parameter can be one of the following values: * @arg TIM_CHANNEL_1: TIM Channel 1 selected * @arg TIM_CHANNEL_2: TIM Channel 2 selected @@ -4145,7 +4218,8 @@ uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Period elapsed callback in non blocking mode - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) @@ -4157,7 +4231,8 @@ __weak void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) } /** * @brief Output Compare callback in non blocking mode - * @param htim : TIM OC handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim) @@ -4168,7 +4243,8 @@ __weak void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim) } /** * @brief Input Capture callback in non blocking mode - * @param htim : TIM IC handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) @@ -4180,7 +4256,8 @@ __weak void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) /** * @brief PWM Pulse finished callback in non blocking mode - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) @@ -4192,7 +4269,8 @@ __weak void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) /** * @brief Hall Trigger detection callback in non blocking mode - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim) @@ -4204,7 +4282,8 @@ __weak void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim) /** * @brief Timer error callback in non blocking mode - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim) @@ -4226,7 +4305,7 @@ __weak void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim) ##### Peripheral State functions ##### ============================================================================== [..] - This subsection permit to get in run-time the status of the peripheral + This subsection permits to get in run-time the status of the peripheral and the data flow. @endverbatim @@ -4235,7 +4314,8 @@ __weak void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim) /** * @brief Return the TIM Base state - * @param htim: TIM Base handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL state */ HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim) @@ -4245,7 +4325,8 @@ HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim) /** * @brief Return the TIM OC state - * @param htim: TIM Ouput Compare handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL state */ HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(TIM_HandleTypeDef *htim) @@ -4255,7 +4336,8 @@ HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(TIM_HandleTypeDef *htim) /** * @brief Return the TIM PWM state - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL state */ HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(TIM_HandleTypeDef *htim) @@ -4265,7 +4347,8 @@ HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(TIM_HandleTypeDef *htim) /** * @brief Return the TIM Input Capture state - * @param htim: TIM IC handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL state */ HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(TIM_HandleTypeDef *htim) @@ -4275,7 +4358,8 @@ HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(TIM_HandleTypeDef *htim) /** * @brief Return the TIM One Pulse Mode state - * @param htim: TIM OPM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL state */ HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(TIM_HandleTypeDef *htim) @@ -4285,7 +4369,8 @@ HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(TIM_HandleTypeDef *htim) /** * @brief Return the TIM Encoder Mode state - * @param htim: TIM Encoder handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL state */ HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(TIM_HandleTypeDef *htim) @@ -4299,7 +4384,8 @@ HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(TIM_HandleTypeDef *htim) /** * @brief TIM DMA error callback - * @param hdma : pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void HAL_TIM_DMAError(DMA_HandleTypeDef *hdma) @@ -4313,7 +4399,8 @@ void HAL_TIM_DMAError(DMA_HandleTypeDef *hdma) /** * @brief TIM DMA Delay Pulse complete callback. - * @param hdma : pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void HAL_TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma) @@ -4326,7 +4413,8 @@ void HAL_TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma) } /** * @brief TIM DMA Capture complete callback. - * @param hdma : pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void HAL_TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma) @@ -4341,7 +4429,8 @@ void HAL_TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma) /** * @brief TIM DMA Period Elapse complete callback. - * @param hdma : pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma) @@ -4355,7 +4444,8 @@ static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma) /** * @brief TIM DMA Trigger callback. - * @param hdma : pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.h index c324399105..d676c2a0bf 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_tim.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of TIM HAL module. ****************************************************************************** * @attention @@ -52,9 +52,9 @@ /** @addtogroup TIM * @{ - */ + */ -/* Exported types ------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ /** * @brief TIM Time base Configuration Structure definition @@ -69,7 +69,7 @@ typedef struct uint32_t Period; /*!< Specifies the period value to be loaded into the active Auto-Reload Register at the next update event. - This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ + This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ uint32_t ClockDivision; /*!< Specifies the clock division. This parameter can be a value of @ref TIM_ClockDivision */ @@ -89,12 +89,12 @@ typedef struct */ typedef struct -{ +{ uint32_t OCMode; /*!< Specifies the TIM mode. This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */ uint32_t Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register. - This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ + This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ uint32_t OCPolarity; /*!< Specifies the output polarity. This parameter can be a value of @ref TIM_Output_Compare_Polarity */ @@ -121,12 +121,12 @@ typedef struct * @brief TIM One Pulse Mode Configuration Structure definition */ typedef struct -{ +{ uint32_t OCMode; /*!< Specifies the TIM mode. This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */ uint32_t Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register. - This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ + This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ uint32_t OCPolarity; /*!< Specifies the output polarity. This parameter can be a value of @ref TIM_Output_Compare_Polarity */ @@ -159,7 +159,7 @@ typedef struct */ typedef struct -{ +{ uint32_t ICPolarity; /*!< Specifies the active edge of the input signal. This parameter can be a value of @ref TIM_Input_Capture_Polarity */ @@ -204,7 +204,7 @@ typedef struct This parameter can be a value of @ref TIM_Input_Capture_Prescaler */ uint32_t IC2Filter; /*!< Specifies the input capture filter. - This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ + This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ } TIM_Encoder_InitTypeDef; /** @@ -212,14 +212,14 @@ typedef struct */ typedef struct { - uint32_t ClockSource; /*!< TIM clock sources + uint32_t ClockSource; /*!< TIM clock sources. This parameter can be a value of @ref TIM_Clock_Source */ - uint32_t ClockPolarity; /*!< TIM clock polarity + uint32_t ClockPolarity; /*!< TIM clock polarity. This parameter can be a value of @ref TIM_Clock_Polarity */ - uint32_t ClockPrescaler; /*!< TIM clock prescaler + uint32_t ClockPrescaler; /*!< TIM clock prescaler. This parameter can be a value of @ref TIM_Clock_Prescaler */ - uint32_t ClockFilter; /*!< TIM clock filter - This parameter can be a value of @ref TIM_Clock_Filter */ + uint32_t ClockFilter; /*!< TIM clock filter. + This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ }TIM_ClockConfigTypeDef; /** @@ -227,16 +227,16 @@ typedef struct */ typedef struct { - uint32_t ClearInputState; /*!< TIM clear Input state + uint32_t ClearInputState; /*!< TIM clear Input state. This parameter can be ENABLE or DISABLE */ - uint32_t ClearInputSource; /*!< TIM clear Input sources + uint32_t ClearInputSource; /*!< TIM clear Input sources. This parameter can be a value of @ref TIM_ClearInput_Source */ - uint32_t ClearInputPolarity; /*!< TIM Clear Input polarity + uint32_t ClearInputPolarity; /*!< TIM Clear Input polarity. This parameter can be a value of @ref TIM_ClearInput_Polarity */ - uint32_t ClearInputPrescaler; /*!< TIM Clear Input prescaler + uint32_t ClearInputPrescaler; /*!< TIM Clear Input prescaler. This parameter can be a value of @ref TIM_ClearInput_Prescaler */ - uint32_t ClearInputFilter; /*!< TIM Clear Input filter - This parameter can be a value of @ref TIM_ClearInput_Filter */ + uint32_t ClearInputFilter; /*!< TIM Clear Input filter. + This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ }TIM_ClearInputConfigTypeDef; /** @@ -252,7 +252,7 @@ typedef struct { uint32_t TriggerPrescaler; /*!< Input trigger prescaler This parameter can be a value of @ref TIM_Trigger_Prescaler */ uint32_t TriggerFilter; /*!< Input trigger filter - This parameter can be a value of @ref TIM_Trigger_Filter */ + This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ }TIM_SlaveConfigTypeDef; @@ -263,9 +263,9 @@ typedef enum { HAL_TIM_STATE_RESET = 0x00, /*!< Peripheral not yet initialized or disabled */ HAL_TIM_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ - HAL_TIM_STATE_BUSY = 0x02, /*!< An internal process is ongoing */ - HAL_TIM_STATE_TIMEOUT = 0x03, /*!< Timeout state */ - HAL_TIM_STATE_ERROR = 0x04 /*!< Reception process is ongoing */ + HAL_TIM_STATE_BUSY = 0x02, /*!< An internal process is ongoing */ + HAL_TIM_STATE_TIMEOUT = 0x03, /*!< Timeout state */ + HAL_TIM_STATE_ERROR = 0x04 /*!< Reception process is ongoing */ }HAL_TIM_StateTypeDef; /** @@ -275,9 +275,9 @@ typedef enum { HAL_TIM_ACTIVE_CHANNEL_1 = 0x01, /*!< The active channel is 1 */ HAL_TIM_ACTIVE_CHANNEL_2 = 0x02, /*!< The active channel is 2 */ - HAL_TIM_ACTIVE_CHANNEL_3 = 0x04, /*!< The active channel is 3 */ + HAL_TIM_ACTIVE_CHANNEL_3 = 0x04, /*!< The active channel is 3 */ HAL_TIM_ACTIVE_CHANNEL_4 = 0x08, /*!< The active channel is 4 */ - HAL_TIM_ACTIVE_CHANNEL_CLEARED = 0x00 /*!< All active channels cleared */ + HAL_TIM_ACTIVE_CHANNEL_CLEARED = 0x00 /*!< All active channels cleared */ }HAL_TIM_ActiveChannel; /** @@ -285,13 +285,13 @@ typedef enum */ typedef struct { - TIM_TypeDef *Instance; /*!< Register base address */ + TIM_TypeDef *Instance; /*!< Register base address */ TIM_Base_InitTypeDef Init; /*!< TIM Time Base required parameters */ - HAL_TIM_ActiveChannel Channel; /*!< Active channel */ + HAL_TIM_ActiveChannel Channel; /*!< Active channel */ DMA_HandleTypeDef *hdma[7]; /*!< DMA Handlers array This array is accessed by a @ref DMA_Handle_index */ HAL_LockTypeDef Lock; /*!< Locking object */ - __IO HAL_TIM_StateTypeDef State; /*!< TIM operation state */ + __IO HAL_TIM_StateTypeDef State; /*!< TIM operation state */ }TIM_HandleTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -312,15 +312,15 @@ typedef struct /** @defgroup TIM_ETR_Polarity * @{ */ -#define TIM_ETRPOLARITY_INVERTED (TIM_SMCR_ETP) /*!< Polarity for ETR source */ -#define TIM_ETRPOLARITY_NONINVERTED ((uint32_t)0x0000) /*!< Polarity for ETR source */ +#define TIM_ETRPOLARITY_INVERTED (TIM_SMCR_ETP) /*!< Polarity for ETR source */ +#define TIM_ETRPOLARITY_NONINVERTED ((uint32_t)0x0000) /*!< Polarity for ETR source */ /** * @} */ /** @defgroup TIM_ETR_Prescaler * @{ - */ + */ #define TIM_ETRPRESCALER_DIV1 ((uint32_t)0x0000) /*!< No prescaler is used */ #define TIM_ETRPRESCALER_DIV2 (TIM_SMCR_ETPS_0) /*!< ETR input source is divided by 2 */ #define TIM_ETRPRESCALER_DIV4 (TIM_SMCR_ETPS_1) /*!< ETR input source is divided by 4 */ @@ -332,7 +332,6 @@ typedef struct /** @defgroup TIM_Counter_Mode * @{ */ - #define TIM_COUNTERMODE_UP ((uint32_t)0x0000) #define TIM_COUNTERMODE_DOWN TIM_CR1_DIR #define TIM_COUNTERMODE_CENTERALIGNED1 TIM_CR1_CMS_0 @@ -346,12 +345,11 @@ typedef struct ((MODE) == TIM_COUNTERMODE_CENTERALIGNED3)) /** * @} - */ - + */ + /** @defgroup TIM_ClockDivision * @{ */ - #define TIM_CLOCKDIVISION_DIV1 ((uint32_t)0x0000) #define TIM_CLOCKDIVISION_DIV2 (TIM_CR1_CKD_0) #define TIM_CLOCKDIVISION_DIV4 (TIM_CR1_CKD_1) @@ -366,7 +364,6 @@ typedef struct /** @defgroup TIM_Output_Compare_and_PWM_modes * @{ */ - #define TIM_OCMODE_TIMING ((uint32_t)0x0000) #define TIM_OCMODE_ACTIVE (TIM_CCMR1_OC1M_0) #define TIM_OCMODE_INACTIVE (TIM_CCMR1_OC1M_1) @@ -392,7 +389,6 @@ typedef struct /** @defgroup TIM_Output_Compare_State * @{ */ - #define TIM_OUTPUTSTATE_DISABLE ((uint32_t)0x0000) #define TIM_OUTPUTSTATE_ENABLE (TIM_CCER_CC1E) @@ -400,7 +396,8 @@ typedef struct ((STATE) == TIM_OUTPUTSTATE_ENABLE)) /** * @} - */ + */ + /** @defgroup TIM_Output_Fast_State * @{ */ @@ -411,11 +408,11 @@ typedef struct ((STATE) == TIM_OCFAST_ENABLE)) /** * @} - */ + */ + /** @defgroup TIM_Output_Compare_N_State * @{ */ - #define TIM_OUTPUTNSTATE_DISABLE ((uint32_t)0x0000) #define TIM_OUTPUTNSTATE_ENABLE (TIM_CCER_CC1NE) @@ -424,11 +421,10 @@ typedef struct /** * @} */ - + /** @defgroup TIM_Output_Compare_Polarity * @{ */ - #define TIM_OCPOLARITY_HIGH ((uint32_t)0x0000) #define TIM_OCPOLARITY_LOW (TIM_CCER_CC1P) @@ -441,7 +437,6 @@ typedef struct /** @defgroup TIM_Output_Compare_N_Polarity * @{ */ - #define TIM_OCNPOLARITY_HIGH ((uint32_t)0x0000) #define TIM_OCNPOLARITY_LOW (TIM_CCER_CC1NP) @@ -454,7 +449,6 @@ typedef struct /** @defgroup TIM_Output_Compare_Idle_State * @{ */ - #define TIM_OCIDLESTATE_SET (TIM_CR2_OIS1) #define TIM_OCIDLESTATE_RESET ((uint32_t)0x0000) #define IS_TIM_OCIDLE_STATE(STATE) (((STATE) == TIM_OCIDLESTATE_SET) || \ @@ -466,7 +460,6 @@ typedef struct /** @defgroup TIM_Output_Compare_N_Idle_State * @{ */ - #define TIM_OCNIDLESTATE_SET (TIM_CR2_OIS1N) #define TIM_OCNIDLESTATE_RESET ((uint32_t)0x0000) #define IS_TIM_OCNIDLE_STATE(STATE) (((STATE) == TIM_OCNIDLESTATE_SET) || \ @@ -478,7 +471,6 @@ typedef struct /** @defgroup TIM_Channel * @{ */ - #define TIM_CHANNEL_1 ((uint32_t)0x0000) #define TIM_CHANNEL_2 ((uint32_t)0x0004) #define TIM_CHANNEL_3 ((uint32_t)0x0008) @@ -495,35 +487,32 @@ typedef struct ((CHANNEL) == TIM_CHANNEL_2)) #define IS_TIM_OPM_CHANNELS(CHANNEL) (((CHANNEL) == TIM_CHANNEL_1) || \ - ((CHANNEL) == TIM_CHANNEL_2)) + ((CHANNEL) == TIM_CHANNEL_2)) #define IS_TIM_COMPLEMENTARY_CHANNELS(CHANNEL) (((CHANNEL) == TIM_CHANNEL_1) || \ ((CHANNEL) == TIM_CHANNEL_2) || \ ((CHANNEL) == TIM_CHANNEL_3)) /** * @} - */ - + */ /** @defgroup TIM_Input_Capture_Polarity * @{ */ - #define TIM_ICPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING #define TIM_ICPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING #define TIM_ICPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE - + #define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPOLARITY_RISING) || \ ((POLARITY) == TIM_ICPOLARITY_FALLING) || \ ((POLARITY) == TIM_ICPOLARITY_BOTHEDGE)) /** * @} - */ + */ /** @defgroup TIM_Input_Capture_Selection * @{ */ - #define TIM_ICSELECTION_DIRECTTI (TIM_CCMR1_CC1S_0) /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to IC1, IC2, IC3 or IC4, respectively */ #define TIM_ICSELECTION_INDIRECTTI (TIM_CCMR1_CC1S_1) /*!< TIM Input 1, 2, 3 or 4 is selected to be @@ -535,12 +524,11 @@ typedef struct ((SELECTION) == TIM_ICSELECTION_TRC)) /** * @} - */ + */ /** @defgroup TIM_Input_Capture_Prescaler * @{ */ - #define TIM_ICPSC_DIV1 ((uint32_t)0x0000) /*!< Capture performed each time an edge is detected on the capture input */ #define TIM_ICPSC_DIV2 (TIM_CCMR1_IC1PSC_0) /*!< Capture performed once every 2 events */ #define TIM_ICPSC_DIV4 (TIM_CCMR1_IC1PSC_1) /*!< Capture performed once every 4 events */ @@ -557,17 +545,17 @@ typedef struct /** @defgroup TIM_One_Pulse_Mode * @{ */ - #define TIM_OPMODE_SINGLE (TIM_CR1_OPM) #define TIM_OPMODE_REPETITIVE ((uint32_t)0x0000) #define IS_TIM_OPM_MODE(MODE) (((MODE) == TIM_OPMODE_SINGLE) || \ ((MODE) == TIM_OPMODE_REPETITIVE)) /** * @} - */ + */ + /** @defgroup TIM_Encoder_Mode * @{ - */ + */ #define TIM_ENCODERMODE_TI1 (TIM_SMCR_SMS_0) #define TIM_ENCODERMODE_TI2 (TIM_SMCR_SMS_1) #define TIM_ENCODERMODE_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) @@ -576,7 +564,8 @@ typedef struct ((MODE) == TIM_ENCODERMODE_TI12)) /** * @} - */ + */ + /** @defgroup TIM_Interrupt_definition * @{ */ @@ -598,17 +587,14 @@ typedef struct ((IT) == TIM_IT_CC4) || \ ((IT) == TIM_IT_COM) || \ ((IT) == TIM_IT_TRIGGER) || \ - ((IT) == TIM_IT_BREAK)) + ((IT) == TIM_IT_BREAK)) /** * @} */ -#define TIM_COMMUTATION_TRGI (TIM_CR2_CCUS) -#define TIM_COMMUTATION_SOFTWARE ((uint32_t)0x0000) /** @defgroup TIM_DMA_sources * @{ */ - #define TIM_DMA_UPDATE (TIM_DIER_UDE) #define TIM_DMA_CC1 (TIM_DIER_CC1DE) #define TIM_DMA_CC2 (TIM_DIER_CC2DE) @@ -617,15 +603,13 @@ typedef struct #define TIM_DMA_COM (TIM_DIER_COMDE) #define TIM_DMA_TRIGGER (TIM_DIER_TDE) #define IS_TIM_DMA_SOURCE(SOURCE) ((((SOURCE) & 0xFFFF80FF) == 0x00000000) && ((SOURCE) != 0x00000000)) - /** * @} */ - + /** @defgroup TIM_Event_Source * @{ */ - #define TIM_EventSource_Update TIM_EGR_UG #define TIM_EventSource_CC1 TIM_EGR_CC1G #define TIM_EventSource_CC2 TIM_EGR_CC2G @@ -634,16 +618,14 @@ typedef struct #define TIM_EventSource_COM TIM_EGR_COMG #define TIM_EventSource_Trigger TIM_EGR_TG #define TIM_EventSource_Break TIM_EGR_BG -#define IS_TIM_EVENT_SOURCE(SOURCE) ((((SOURCE) & 0xFFFFFF00) == 0x00000000) && ((SOURCE) != 0x00000000)) - +#define IS_TIM_EVENT_SOURCE(SOURCE) ((((SOURCE) & 0xFFFFFF00) == 0x00000000) && ((SOURCE) != 0x00000000)) /** * @} - */ + */ /** @defgroup TIM_Flag_definition * @{ - */ - + */ #define TIM_FLAG_UPDATE (TIM_SR_UIF) #define TIM_FLAG_CC1 (TIM_SR_CC1IF) #define TIM_FLAG_CC2 (TIM_SR_CC2IF) @@ -668,14 +650,14 @@ typedef struct ((FLAG) == TIM_FLAG_CC1OF) || \ ((FLAG) == TIM_FLAG_CC2OF) || \ ((FLAG) == TIM_FLAG_CC3OF) || \ - ((FLAG) == TIM_FLAG_CC4OF)) + ((FLAG) == TIM_FLAG_CC4OF)) /** * @} */ /** @defgroup TIM_Clock_Source * @{ - */ + */ #define TIM_CLOCKSOURCE_ETRMODE2 (TIM_SMCR_ETPS_1) #define TIM_CLOCKSOURCE_INTERNAL (TIM_SMCR_ETPS_0) #define TIM_CLOCKSOURCE_ITR0 ((uint32_t)0x0000) @@ -699,7 +681,7 @@ typedef struct ((CLOCK) == TIM_CLOCKSOURCE_ETRMODE1)) /** * @} - */ + */ /** @defgroup TIM_Clock_Polarity * @{ @@ -718,9 +700,10 @@ typedef struct /** * @} */ + /** @defgroup TIM_Clock_Prescaler * @{ - */ + */ #define TIM_CLOCKPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */ #define TIM_CLOCKPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Clock: Capture performed once every 2 events. */ #define TIM_CLOCKPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Clock: Capture performed once every 4 events. */ @@ -732,15 +715,15 @@ typedef struct ((PRESCALER) == TIM_CLOCKPRESCALER_DIV8)) /** * @} - */ + */ + /** @defgroup TIM_Clock_Filter * @{ */ - #define IS_TIM_CLOCKFILTER(ICFILTER) ((ICFILTER) <= 0xF) /** * @} - */ + */ /** @defgroup TIM_ClearInput_Source * @{ @@ -763,7 +746,7 @@ typedef struct ((POLARITY) == TIM_CLEARINPUTPOLARITY_NONINVERTED)) /** * @} - */ + */ /** @defgroup TIM_ClearInput_Prescaler * @{ @@ -779,113 +762,15 @@ typedef struct /** * @} */ - + /** @defgroup TIM_ClearInput_Filter * @{ */ - #define IS_TIM_CLEARINPUT_FILTER(ICFILTER) ((ICFILTER) <= 0xF) -/** - * @} - */ - -/** @defgroup TIM_OSSR_Off_State_Selection_for_Run_mode_state - * @{ - */ -#define TIM_OSSR_ENABLE (TIM_BDTR_OSSR) -#define TIM_OSSR_DISABLE ((uint32_t)0x0000) - -#define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSR_ENABLE) || \ - ((STATE) == TIM_OSSR_DISABLE)) /** * @} */ - -/** @defgroup TIM_OSSI_Off_State_Selection_for_Idle_mode_state - * @{ - */ -#define TIM_OSSI_ENABLE (TIM_BDTR_OSSI) -#define TIM_OSSI_DISABLE ((uint32_t)0x0000) -#define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSI_ENABLE) || \ - ((STATE) == TIM_OSSI_DISABLE)) -/** - * @} - */ -/** @defgroup TIM_Lock_level - * @{ - */ -#define TIM_LOCKLEVEL_OFF ((uint32_t)0x0000) -#define TIM_LOCKLEVEL_1 (TIM_BDTR_LOCK_0) -#define TIM_LOCKLEVEL_2 (TIM_BDTR_LOCK_1) -#define TIM_LOCKLEVEL_3 (TIM_BDTR_LOCK) - -#define IS_TIM_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM_LOCKLEVEL_OFF) || \ - ((LEVEL) == TIM_LOCKLEVEL_1) || \ - ((LEVEL) == TIM_LOCKLEVEL_2) || \ - ((LEVEL) == TIM_LOCKLEVEL_3)) -/** - * @} - */ -/** @defgroup TIM_Break_Input_enable_disable - * @{ - */ -#define TIM_BREAK_ENABLE (TIM_BDTR_BKE) -#define TIM_BREAK_DISABLE ((uint32_t)0x0000) - -#define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_BREAK_ENABLE) || \ - ((STATE) == TIM_BREAK_DISABLE)) -/** - * @} - */ -/** @defgroup TIM_Break_Polarity - * @{ - */ -#define TIM_BREAKPOLARITY_LOW ((uint32_t)0x0000) -#define TIM_BREAKPOLARITY_HIGH (TIM_BDTR_BKP) - -#define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BREAKPOLARITY_LOW) || \ - ((POLARITY) == TIM_BREAKPOLARITY_HIGH)) -/** - * @} - */ -/** @defgroup TIM_AOE_Bit_Set_Reset - * @{ - */ -#define TIM_AUTOMATICOUTPUT_ENABLE (TIM_BDTR_AOE) -#define TIM_AUTOMATICOUTPUT_DISABLE ((uint32_t)0x0000) - -#define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AUTOMATICOUTPUT_ENABLE) || \ - ((STATE) == TIM_AUTOMATICOUTPUT_DISABLE)) -/** - * @} - */ - -/** @defgroup TIM_Master_Mode_Selection - * @{ - */ -#define TIM_TRGO_RESET ((uint32_t)0x0000) -#define TIM_TRGO_ENABLE (TIM_CR2_MMS_0) -#define TIM_TRGO_UPDATE (TIM_CR2_MMS_1) -#define TIM_TRGO_OC1 ((TIM_CR2_MMS_1 | TIM_CR2_MMS_0)) -#define TIM_TRGO_OC1REF (TIM_CR2_MMS_2) -#define TIM_TRGO_OC2REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_0)) -#define TIM_TRGO_OC3REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_1)) -#define TIM_TRGO_OC4REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0)) - -#define IS_TIM_TRGO_SOURCE(SOURCE) (((SOURCE) == TIM_TRGO_RESET) || \ - ((SOURCE) == TIM_TRGO_ENABLE) || \ - ((SOURCE) == TIM_TRGO_UPDATE) || \ - ((SOURCE) == TIM_TRGO_OC1) || \ - ((SOURCE) == TIM_TRGO_OC1REF) || \ - ((SOURCE) == TIM_TRGO_OC2REF) || \ - ((SOURCE) == TIM_TRGO_OC3REF) || \ - ((SOURCE) == TIM_TRGO_OC4REF)) - - -/** - * @} - */ /** @defgroup TIM_Slave_Mode * @{ */ @@ -902,23 +787,11 @@ typedef struct ((MODE) == TIM_SLAVEMODE_EXTERNAL1)) /** * @} - */ - -/** @defgroup TIM_Master_Slave_Mode - * @{ */ -#define TIM_MASTERSLAVEMODE_ENABLE ((uint32_t)0x0080) -#define TIM_MASTERSLAVEMODE_DISABLE ((uint32_t)0x0000) -#define IS_TIM_MSM_STATE(STATE) (((STATE) == TIM_MASTERSLAVEMODE_ENABLE) || \ - ((STATE) == TIM_MASTERSLAVEMODE_DISABLE)) -/** - * @} - */ /** @defgroup TIM_Trigger_Selection * @{ */ - #define TIM_TS_ITR0 ((uint32_t)0x0000) #define TIM_TS_ITR1 ((uint32_t)0x0010) #define TIM_TS_ITR2 ((uint32_t)0x0020) @@ -969,7 +842,7 @@ typedef struct /** @defgroup TIM_Trigger_Prescaler * @{ - */ + */ #define TIM_TRIGGERPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */ #define TIM_TRIGGERPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Trigger: Capture performed once every 2 events. */ #define TIM_TRIGGERPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Trigger: Capture performed once every 4 events. */ @@ -986,30 +859,26 @@ typedef struct /** @defgroup TIM_Trigger_Filter * @{ */ - #define IS_TIM_TRIGGERFILTER(ICFILTER) ((ICFILTER) <= 0xF) /** * @} - */ + */ /** @defgroup TIM_TI1_Selection * @{ */ - #define TIM_TI1SELECTION_CH1 ((uint32_t)0x0000) #define TIM_TI1SELECTION_XORCOMBINATION (TIM_CR2_TI1S) #define IS_TIM_TI1SELECTION(TI1SELECTION) (((TI1SELECTION) == TIM_TI1SELECTION_CH1) || \ ((TI1SELECTION) == TIM_TI1SELECTION_XORCOMBINATION)) - /** * @} */ - + /** @defgroup TIM_DMA_Base_address * @{ */ - #define TIM_DMABase_CR1 (0x00000000) #define TIM_DMABase_CR2 (0x00000001) #define TIM_DMABase_SMCR (0x00000002) @@ -1049,7 +918,7 @@ typedef struct ((BASE) == TIM_DMABase_CCR4) || \ ((BASE) == TIM_DMABase_BDTR) || \ ((BASE) == TIM_DMABase_DCR) || \ - ((BASE) == TIM_DMABase_OR)) + ((BASE) == TIM_DMABase_OR)) /** * @} */ @@ -1057,7 +926,6 @@ typedef struct /** @defgroup TIM_DMA_Burst_Length * @{ */ - #define TIM_DMABurstLength_1Transfer (0x00000000) #define TIM_DMABurstLength_2Transfers (0x00000100) #define TIM_DMABurstLength_3Transfers (0x00000200) @@ -1096,11 +964,11 @@ typedef struct ((LENGTH) == TIM_DMABurstLength_18Transfers)) /** * @} - */ + */ + /** @defgroup TIM_Input_Capture_Filer_Value * @{ */ - #define IS_TIM_IC_FILTER(ICFILTER) ((ICFILTER) <= 0xF) /** * @} @@ -1137,6 +1005,12 @@ typedef struct /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset TIM handle state + * @param __HANDLE__: TIM handle + * @retval None + */ +#define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_TIM_STATE_RESET) + /** * @brief Enable the TIM peripheral. * @param __HANDLE__: TIM handle @@ -1173,8 +1047,8 @@ typedef struct } \ } while(0) -/* The Main Output Enable of a timer instance is disabled only if all the CCx and CCxN - channels have been disabled */ +/* The Main Output of a timer instance is disabled only if all the CCx and CCxN + channels have been disabled */ /** * @brief Disable the TIM main Output. * @param __HANDLE__: TIM handle @@ -1189,7 +1063,7 @@ typedef struct (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE); \ } \ } \ - } while(0) + } while(0) #define __HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER |= (__INTERRUPT__)) #define __HAL_TIM_ENABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER |= (__DMA__)) @@ -1215,7 +1089,7 @@ typedef struct ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= (uint16_t)~TIM_CCMR1_IC2PSC) :\ ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= (uint16_t)~TIM_CCMR2_IC3PSC) :\ ((__HANDLE__)->Instance->CCMR2 &= (uint16_t)~TIM_CCMR2_IC4PSC)) - + /** * @brief Sets the TIM Capture Compare Register value on runtime without * calling another time ConfigChannel function. @@ -1232,13 +1106,34 @@ typedef struct #define __HAL_TIM_SetCompare(__HANDLE__, __CHANNEL__, __COMPARE__) \ (*(__IO uint32_t *)(&((__HANDLE__)->Instance->CCR1) + ((__CHANNEL__) >> 2)) = (__COMPARE__)) +/** + * @brief Gets the TIM Capture Compare Register value on runtime + * @param __HANDLE__: TIM handle. + * @param __CHANNEL__ : TIM Channel associated with the capture compare register + * This parameter can be one of the following values: + * @arg TIM_CHANNEL_1: get capture/compare 1 register value + * @arg TIM_CHANNEL_2: get capture/compare 2 register value + * @arg TIM_CHANNEL_3: get capture/compare 3 register value + * @arg TIM_CHANNEL_4: get capture/compare 4 register value + * @retval None + */ +#define __HAL_TIM_GetCompare(__HANDLE__, __CHANNEL__) \ + (*(__IO uint32_t *)(&((__HANDLE__)->Instance->CCR1) + ((__CHANNEL__) >> 2))) + /** * @brief Sets the TIM Counter Register value on runtime. * @param __HANDLE__: TIM handle. * @param __COUNTER__: specifies the Counter register new value. * @retval None */ -#define __HAL_TIM_SetCounter(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__)) +#define __HAL_TIM_SetCounter(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__)) + +/** + * @brief Gets the TIM Counter Register value on runtime. + * @param __HANDLE__: TIM handle. + * @retval None + */ +#define __HAL_TIM_GetCounter(__HANDLE__) ((__HANDLE__)->Instance->CNT) /** * @brief Sets the TIM Autoreload Register value on runtime without calling @@ -1247,11 +1142,17 @@ typedef struct * @param __AUTORELOAD__: specifies the Counter register new value. * @retval None */ -#define __HAL_TIM_SetAutoreload(__HANDLE__, __AUTORELOAD__) \ - do{ \ - (__HANDLE__)->Instance->ARR = (__AUTORELOAD__); \ - (__HANDLE__)->Init.Period = (__AUTORELOAD__); \ +#define __HAL_TIM_SetAutoreload(__HANDLE__, __AUTORELOAD__) \ + do{ \ + (__HANDLE__)->Instance->ARR = (__AUTORELOAD__); \ + (__HANDLE__)->Init.Period = (__AUTORELOAD__); \ } while(0) +/** + * @brief Gets the TIM Autoreload Register value on runtime + * @param __HANDLE__: TIM handle. + * @retval None + */ +#define __HAL_TIM_GetAutoreload(__HANDLE__) ((__HANDLE__)->Instance->ARR) /** * @brief Sets the TIM Clock Division value on runtime without calling @@ -1261,16 +1162,22 @@ typedef struct * This parameter can be one of the following value: * @arg TIM_CLOCKDIVISION_DIV1 * @arg TIM_CLOCKDIVISION_DIV2 - * @arg TIM_CLOCKDIVISION_DIV4 + * @arg TIM_CLOCKDIVISION_DIV4 * @retval None */ #define __HAL_TIM_SetClockDivision(__HANDLE__, __CKD__) \ - do{ \ + do{ \ (__HANDLE__)->Instance->CR1 &= (uint16_t)(~TIM_CR1_CKD); \ - (__HANDLE__)->Instance->CR1 |= (__CKD__); \ + (__HANDLE__)->Instance->CR1 |= (__CKD__); \ (__HANDLE__)->Init.ClockDivision = (__CKD__); \ } while(0) - +/** + * @brief Gets the TIM Clock Division value on runtime + * @param __HANDLE__: TIM handle. + * @retval None + */ +#define __HAL_TIM_GetClockDivision(__HANDLE__) ((__HANDLE__)->Instance->CR1 & TIM_CR1_CKD) + /** * @brief Sets the TIM Input Capture prescaler on runtime without calling * another time HAL_TIM_IC_ConfigChannel() function. @@ -1293,8 +1200,24 @@ typedef struct do{ \ __HAL_TIM_ResetICPrescalerValue((__HANDLE__), (__CHANNEL__)); \ __HAL_TIM_SetICPrescalerValue((__HANDLE__), (__CHANNEL__), (__ICPSC__)); \ - } while(0) + } while(0) +/** + * @brief Gets the TIM Input Capture prescaler on runtime + * @param __HANDLE__: TIM handle. + * @param __CHANNEL__ : TIM Channels to be configured. + * This parameter can be one of the following values: + * @arg TIM_CHANNEL_1: get input capture 1 prescaler value + * @arg TIM_CHANNEL_2: get input capture 2 prescaler value + * @arg TIM_CHANNEL_3: get input capture 3 prescaler value + * @arg TIM_CHANNEL_4: get input capture 4 prescaler value + * @retval None + */ +#define __HAL_TIM_GetICPrescaler(__HANDLE__, __CHANNEL__) \ + (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC1PSC) :\ + ((__CHANNEL__) == TIM_CHANNEL_2) ? (((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC2PSC) >> 8) :\ + ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC3PSC) :\ + (((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC4PSC)) >> 8) /** * @} */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.c index a4d7d2b9fc..ad535d93c5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_tim_ex.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief TIM HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Timer extension peripheral: @@ -145,7 +145,8 @@ static void TIM_CCxNChannelCmd(TIM_TypeDef* TIMx, uint32_t Channel, uint32_t Cha */ /** * @brief Initializes the TIM Hall Sensor Interface and create the associated handle. - * @param htim: TIM Encoder Interface handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sConfig: TIM Hall Sensor configuration structure * @retval HAL status */ @@ -218,7 +219,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSen /** * @brief DeInitializes the TIM Hall Sensor interface - * @param htim: TIM Hall Sensor handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim) @@ -245,7 +247,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim) /** * @brief Initializes the TIM Hall Sensor MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim) @@ -257,7 +260,8 @@ __weak void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim) /** * @brief DeInitializes TIM Hall Sensor MSP. - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim) @@ -269,7 +273,8 @@ __weak void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Hall Sensor Interface. - * @param htim : TIM Hall Sensor handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim) @@ -290,7 +295,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim) /** * @brief Stops the TIM Hall sensor Interface. - * @param htim : TIM Hall Sensor handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim) @@ -311,7 +317,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Hall Sensor Interface in interrupt mode. - * @param htim : TIM Hall Sensor handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim) @@ -335,7 +342,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim) /** * @brief Stops the TIM Hall Sensor Interface in interrupt mode. - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim) @@ -359,7 +367,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Hall Sensor Interface in DMA mode. - * @param htim : TIM Hall Sensor handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param pData: The destination Buffer address. * @param Length: The length of data to be transferred from TIM peripheral to memory. * @retval HAL status @@ -408,7 +417,8 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32 /** * @brief Stops the TIM Hall Sensor Interface in DMA mode. - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim) @@ -458,13 +468,14 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim) /** * @brief Starts the TIM Output Compare signal generation on the complementary * output. - * @param htim : TIM Output Compare handle - * @param Channel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be enabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel) @@ -488,13 +499,14 @@ HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Stops the TIM Output Compare signal generation on the complementary * output. - * @param htim : TIM handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel) @@ -518,13 +530,14 @@ HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Starts the TIM Output Compare signal generation in interrupt mode * on the complementary output. - * @param htim : TIM OC handle - * @param Channel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be enabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel) @@ -582,13 +595,14 @@ HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Chann /** * @brief Stops the TIM Output Compare signal generation in interrupt mode * on the complementary output. - * @param htim : TIM Output Compare handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel) @@ -646,13 +660,14 @@ HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channe /** * @brief Starts the TIM Output Compare signal generation in DMA mode * on the complementary output. - * @param htim : TIM Output Compare handle - * @param Channel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be enabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @param pData: The source Buffer address. * @param Length: The length of data to be transferred from memory to TIM peripheral * @retval HAL status @@ -763,13 +778,14 @@ HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Chan /** * @brief Stops the TIM Output Compare signal generation in DMA mode * on the complementary output. - * @param htim : TIM Output Compare handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel) @@ -863,13 +879,14 @@ HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Chann /** * @brief Starts the PWM signal generation on the complementary output. - * @param htim : TIM handle - * @param Channel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be enabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel) @@ -892,13 +909,14 @@ HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel /** * @brief Stops the PWM signal generation on the complementary output. - * @param htim : TIM handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel) @@ -922,13 +940,14 @@ HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel) /** * @brief Starts the PWM signal generation in interrupt mode on the * complementary output. - * @param htim : TIM handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel) @@ -989,13 +1008,14 @@ HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Chan /** * @brief Stops the PWM signal generation in interrupt mode on the * complementary output. - * @param htim : TIM handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT (TIM_HandleTypeDef *htim, uint32_t Channel) @@ -1056,13 +1076,14 @@ HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT (TIM_HandleTypeDef *htim, uint32_t Chan /** * @brief Starts the TIM PWM signal generation in DMA mode on the * complementary output - * @param htim : TIM handle - * @param Channel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be enabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @param pData: The source Buffer address. * @param Length: The length of data to be transferred from memory to TIM peripheral * @retval HAL status @@ -1173,13 +1194,14 @@ HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Cha /** * @brief Stops the TIM PWM signal generation in DMA mode on the complementary * output - * @param htim : TIM handle - * @param Channel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param Channel: TIM Channel to be disabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected - * @arg TIM_CHANNEL_3: TIM Channel 3 selected - * @arg TIM_CHANNEL_4: TIM Channel 4 selected + * TIM_CHANNEL_1/ + * TIM_CHANNEL_2/ + * TIM_CHANNEL_3/ + * TIM_CHANNEL_4 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel) @@ -1262,11 +1284,12 @@ HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Chan /** * @brief Starts the TIM One Pulse signal generation on the complemetary * output. - * @param htim : TIM One Pulse handle - * @param OutputChannel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param OutputChannel: TIM Channel to be enabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected + * TIM_CHANNEL_1 / + * IM_CHANNEL_2 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel) @@ -1287,11 +1310,11 @@ HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t Ou /** * @brief Stops the TIM One Pulse signal generation on the complementary * output. - * @param htim : TIM One Pulse handle - * @param OutputChannel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param OutputChannel: TIM Channel to be disabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected + * TIM_CHANNEL_1 / TIM_CHANNEL_2 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel) @@ -1316,11 +1339,11 @@ HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t Out /** * @brief Starts the TIM One Pulse signal generation in interrupt mode on the * complementary channel. - * @param htim : TIM One Pulse handle - * @param OutputChannel : TIM Channel to be enabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param OutputChannel: TIM Channel to be enabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected + * TIM_CHANNEL_1 / IM_CHANNEL_2 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel) @@ -1347,11 +1370,11 @@ HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t /** * @brief Stops the TIM One Pulse signal generation in interrupt mode on the * complementary channel. - * @param htim : TIM One Pulse handle - * @param OutputChannel : TIM Channel to be disabled + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param OutputChannel: TIM Channel to be disabled. * This parameter can be one of the following values: - * @arg TIM_CHANNEL_1: TIM Channel 1 selected - * @arg TIM_CHANNEL_2: TIM Channel 2 selected + * TIM_CHANNEL_1 / IM_CHANNEL_2 * @retval HAL status */ HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel) @@ -1402,21 +1425,22 @@ HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t */ /** * @brief Configure the TIM commutation event sequence. - * @note: this function is mandatory to use the commutation event in order to + * @note This function is mandatory to use the commutation event in order to * update the configuration at each commutation detection on the TRGI input of the Timer, * the typical use of this feature is with the use of another Timer(interface Timer) * configured in Hall sensor interface, this interface Timer will generate the * commutation at its TRGO output (connected to Timer used in this function) each time * the TI1 of the Interface Timer detect a commutation at its input TI1. - * @param htim: TIM handle - * @param InputTrigger : the Internal trigger corresponding to the Timer Interfacing with the Hall sensor + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param InputTrigger: the Internal trigger corresponding to the Timer Interfacing with the Hall sensor. * This parameter can be one of the following values: - * @arg TIM_TS_ITR0: Internal trigger 0 selected - * @arg TIM_TS_ITR1: Internal trigger 1 selected - * @arg TIM_TS_ITR2: Internal trigger 2 selected - * @arg TIM_TS_ITR3: Internal trigger 3 selected - * @arg TIM_TS_NONE: No trigger is needed - * @param CommutationSource : the Commutation Event source + * TIM_TS_ITR0 / + * TIM_TS_ITR1 / + * TIM_TS_ITR2 / + * TIM_TS_ITR3 / + * TIM_TS_NONE + * @param CommutationSource: the Commutation Event source. * This parameter can be one of the following values: * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit @@ -1451,21 +1475,22 @@ HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent(TIM_HandleTypeDef *htim, uint /** * @brief Configure the TIM commutation event sequence with interrupt. - * @note: this function is mandatory to use the commutation event in order to + * @note This function is mandatory to use the commutation event in order to * update the configuration at each commutation detection on the TRGI input of the Timer, * the typical use of this feature is with the use of another Timer(interface Timer) * configured in Hall sensor interface, this interface Timer will generate the * commutation at its TRGO output (connected to Timer used in this function) each time * the TI1 of the Interface Timer detect a commutation at its input TI1. - * @param htim: TIM handle - * @param InputTrigger : the Internal trigger corresponding to the Timer Interfacing with the Hall sensor + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param InputTrigger: the Internal trigger corresponding to the Timer Interfacing with the Hall sensor. * This parameter can be one of the following values: - * @arg TIM_TS_ITR0: Internal trigger 0 selected - * @arg TIM_TS_ITR1: Internal trigger 1 selected - * @arg TIM_TS_ITR2: Internal trigger 2 selected - * @arg TIM_TS_ITR3: Internal trigger 3 selected - * @arg TIM_TS_NONE: No trigger is needed - * @param CommutationSource : the Commutation Event source + * TIM_TS_ITR0 / + * TIM_TS_ITR1 / + * TIM_TS_ITR2 / + * TIM_TS_ITR3 / + * TIM_TS_NONE + * @param CommutationSource: the Commutation Event source. * This parameter can be one of the following values: * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit @@ -1503,22 +1528,23 @@ HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_IT(TIM_HandleTypeDef *htim, u /** * @brief Configure the TIM commutation event sequence with DMA. - * @note: this function is mandatory to use the commutation event in order to + * @note This function is mandatory to use the commutation event in order to * update the configuration at each commutation detection on the TRGI input of the Timer, * the typical use of this feature is with the use of another Timer(interface Timer) * configured in Hall sensor interface, this interface Timer will generate the * commutation at its TRGO output (connected to Timer used in this function) each time * the TI1 of the Interface Timer detect a commutation at its input TI1. * @note: The user should configure the DMA in his own software, in This function only the COMDE bit is set - * @param htim: TIM handle - * @param InputTrigger : the Internal trigger corresponding to the Timer Interfacing with the Hall sensor + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. + * @param InputTrigger: the Internal trigger corresponding to the Timer Interfacing with the Hall sensor. * This parameter can be one of the following values: - * @arg TIM_TS_ITR0: Internal trigger 0 selected - * @arg TIM_TS_ITR1: Internal trigger 1 selected - * @arg TIM_TS_ITR2: Internal trigger 2 selected - * @arg TIM_TS_ITR3: Internal trigger 3 selected - * @arg TIM_TS_NONE: No trigger is needed - * @param CommutationSource : the Commutation Event source + * TIM_TS_ITR0 / + * TIM_TS_ITR1 / + * TIM_TS_ITR2 / + * TIM_TS_ITR3 / + * TIM_TS_NONE + * @param CommutationSource: the Commutation Event source. * This parameter can be one of the following values: * @arg TIM_COMMUTATION_TRGI: Commutation source is the TRGI of the Interface Timer * @arg TIM_COMMUTATION_SOFTWARE: Commutation source is set by software using the COMG bit @@ -1562,7 +1588,8 @@ HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_DMA(TIM_HandleTypeDef *htim, /** * @brief Configures the TIM in master mode. - * @param htim: TIM handle. + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sMasterConfig: pointer to a TIM_MasterConfigTypeDef structure that * contains the selected trigger output (TRGO) and the Master/Slave * mode. @@ -1599,7 +1626,8 @@ HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, /** * @brief Configures the Break feature, dead time, Lock level, OSSI/OSSR State * and the AOE(automatic output enable). - * @param htim: TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @param sBreakDeadTimeConfig: pointer to a TIM_ConfigBreakDeadConfig_TypeDef structure that * contains the BDTR Register configuration information for the TIM peripheral. * @retval HAL status @@ -1641,7 +1669,8 @@ HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim, /** * @brief Configures the TIM2, TIM5 and TIM11 Remapping input capabilities. - * @param htim: TIM handle. + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module.. * @param TIM_Remap: specifies the TIM input remapping source. * This parameter can be one of the following values: * @arg TIM_TIM2_TIM8_TRGO: TIM2 ITR1 input is connected to TIM8 Trigger output(default) @@ -1697,7 +1726,8 @@ HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap) /** * @brief Hall commutation changed callback in non blocking mode - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef *htim) @@ -1709,7 +1739,8 @@ __weak void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef *htim) /** * @brief Hall Break detection callback in non blocking mode - * @param htim : TIM handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval None */ __weak void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim) @@ -1731,7 +1762,7 @@ __weak void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim) ##### Extension Peripheral State functions ##### ============================================================================== [..] - This subsection permit to get in run-time the status of the peripheral + This subsection permits to get in run-time the status of the peripheral and the data flow. @endverbatim @@ -1740,7 +1771,8 @@ __weak void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim) /** * @brief Return the TIM Hall Sensor interface state - * @param htim: TIM Hall Sensor handle + * @param htim: pointer to a TIM_HandleTypeDef structure that contains + * the configuration information for TIM module. * @retval HAL state */ HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim) @@ -1754,7 +1786,8 @@ HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim) /** * @brief TIM DMA Commutation callback. - * @param hdma : pointer to DMA handle. + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ void HAL_TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.h index 5e3bc61460..d18d0b219a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_tim_ex.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of TIM HAL Extension module. ****************************************************************************** * @attention @@ -79,10 +79,10 @@ typedef struct * @brief TIM Master configuration Structure definition */ typedef struct { - uint32_t MasterOutputTrigger; /*!< Trigger output (TRGO) selection - This parameter can be a value of @ref TIM_Master_Mode_Selection */ - uint32_t MasterSlaveMode; /*!< Master/slave mode selection - This parameter can be a value of @ref TIM_Master_Slave_Mode */ + uint32_t MasterOutputTrigger; /*!< Trigger output (TRGO) selection. + This parameter can be a value of @ref TIMEx_Master_Mode_Selection */ + uint32_t MasterSlaveMode; /*!< Master/slave mode selection. + This parameter can be a value of @ref TIMEx_Master_Slave_Mode */ }TIM_MasterConfigTypeDef; /** @@ -90,27 +90,145 @@ typedef struct { */ typedef struct { - uint32_t OffStateRunMode; /*!< TIM off state in run mode - This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */ - uint32_t OffStateIDLEMode; /*!< TIM off state in IDLE mode - This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */ - uint32_t LockLevel; /*!< TIM Lock level - This parameter can be a value of @ref TIM_Lock_level */ - uint32_t DeadTime; /*!< TIM dead Time + uint32_t OffStateRunMode; /*!< TIM off state in run mode. + This parameter can be a value of @ref TIMEx_OSSR_Off_State_Selection_for_Run_mode_state */ + uint32_t OffStateIDLEMode; /*!< TIM off state in IDLE mode. + This parameter can be a value of @ref TIMEx_OSSI_Off_State_Selection_for_Idle_mode_state */ + uint32_t LockLevel; /*!< TIM Lock level. + This parameter can be a value of @ref TIMEx_Lock_level */ + uint32_t DeadTime; /*!< TIM dead Time. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */ - uint32_t BreakState; /*!< TIM Break State - This parameter can be a value of @ref TIM_Break_Input_enable_disable */ - uint32_t BreakPolarity; /*!< TIM Break input polarity - This parameter can be a value of @ref TIM_Break_Polarity */ - uint32_t AutomaticOutput; /*!< TIM Automatic Output Enable state - This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */ + uint32_t BreakState; /*!< TIM Break State. + This parameter can be a value of @ref TIMEx_Break_Input_enable_disable */ + uint32_t BreakPolarity; /*!< TIM Break input polarity. + This parameter can be a value of @ref TIMEx_Break_Polarity */ + uint32_t AutomaticOutput; /*!< TIM Automatic Output Enable state. + This parameter can be a value of @ref TIMEx_AOE_Bit_Set_Reset */ }TIM_BreakDeadTimeConfigTypeDef; /* Exported constants --------------------------------------------------------*/ /** @defgroup TIMEx_Exported_Constants * @{ */ +/** @defgroup TIMEx_OSSR_Off_State_Selection_for_Run_mode_state + * @{ + */ +#define TIM_OSSR_ENABLE (TIM_BDTR_OSSR) +#define TIM_OSSR_DISABLE ((uint32_t)0x0000) +#define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSR_ENABLE) || \ + ((STATE) == TIM_OSSR_DISABLE)) +/** + * @} + */ + +/** @defgroup TIMEx_OSSI_Off_State_Selection_for_Idle_mode_state + * @{ + */ +#define TIM_OSSI_ENABLE (TIM_BDTR_OSSI) +#define TIM_OSSI_DISABLE ((uint32_t)0x0000) + +#define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSI_ENABLE) || \ + ((STATE) == TIM_OSSI_DISABLE)) +/** + * @} + */ +/** @defgroup TIMEx_Lock_level + * @{ + */ +#define TIM_LOCKLEVEL_OFF ((uint32_t)0x0000) +#define TIM_LOCKLEVEL_1 (TIM_BDTR_LOCK_0) +#define TIM_LOCKLEVEL_2 (TIM_BDTR_LOCK_1) +#define TIM_LOCKLEVEL_3 (TIM_BDTR_LOCK) + +#define IS_TIM_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM_LOCKLEVEL_OFF) || \ + ((LEVEL) == TIM_LOCKLEVEL_1) || \ + ((LEVEL) == TIM_LOCKLEVEL_2) || \ + ((LEVEL) == TIM_LOCKLEVEL_3)) +/** + * @} + */ +/** @defgroup TIMEx_Break_Input_enable_disable + * @{ + */ +#define TIM_BREAK_ENABLE (TIM_BDTR_BKE) +#define TIM_BREAK_DISABLE ((uint32_t)0x0000) + +#define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_BREAK_ENABLE) || \ + ((STATE) == TIM_BREAK_DISABLE)) +/** + * @} + */ +/** @defgroup TIMEx_Break_Polarity + * @{ + */ +#define TIM_BREAKPOLARITY_LOW ((uint32_t)0x0000) +#define TIM_BREAKPOLARITY_HIGH (TIM_BDTR_BKP) + +#define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BREAKPOLARITY_LOW) || \ + ((POLARITY) == TIM_BREAKPOLARITY_HIGH)) +/** + * @} + */ +/** @defgroup TIMEx_AOE_Bit_Set_Reset + * @{ + */ +#define TIM_AUTOMATICOUTPUT_ENABLE (TIM_BDTR_AOE) +#define TIM_AUTOMATICOUTPUT_DISABLE ((uint32_t)0x0000) + +#define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AUTOMATICOUTPUT_ENABLE) || \ + ((STATE) == TIM_AUTOMATICOUTPUT_DISABLE)) +/** + * @} + */ + +/** @defgroup TIMEx_Master_Mode_Selection + * @{ + */ +#define TIM_TRGO_RESET ((uint32_t)0x0000) +#define TIM_TRGO_ENABLE (TIM_CR2_MMS_0) +#define TIM_TRGO_UPDATE (TIM_CR2_MMS_1) +#define TIM_TRGO_OC1 ((TIM_CR2_MMS_1 | TIM_CR2_MMS_0)) +#define TIM_TRGO_OC1REF (TIM_CR2_MMS_2) +#define TIM_TRGO_OC2REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_0)) +#define TIM_TRGO_OC3REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_1)) +#define TIM_TRGO_OC4REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0)) + +#define IS_TIM_TRGO_SOURCE(SOURCE) (((SOURCE) == TIM_TRGO_RESET) || \ + ((SOURCE) == TIM_TRGO_ENABLE) || \ + ((SOURCE) == TIM_TRGO_UPDATE) || \ + ((SOURCE) == TIM_TRGO_OC1) || \ + ((SOURCE) == TIM_TRGO_OC1REF) || \ + ((SOURCE) == TIM_TRGO_OC2REF) || \ + ((SOURCE) == TIM_TRGO_OC3REF) || \ + ((SOURCE) == TIM_TRGO_OC4REF)) + + +/** + * @} + */ + +/** @defgroup TIMEx_Master_Slave_Mode + * @{ + */ + +#define TIM_MASTERSLAVEMODE_ENABLE ((uint32_t)0x0080) +#define TIM_MASTERSLAVEMODE_DISABLE ((uint32_t)0x0000) +#define IS_TIM_MSM_STATE(STATE) (((STATE) == TIM_MASTERSLAVEMODE_ENABLE) || \ + ((STATE) == TIM_MASTERSLAVEMODE_DISABLE)) +/** + * @} + */ + +/** @defgroup TIMEx_Commutation_Mode + * @{ + */ +#define TIM_COMMUTATION_TRGI (TIM_CR2_CCUS) +#define TIM_COMMUTATION_SOFTWARE ((uint32_t)0x0000) +/** + * @} + */ + /** @defgroup TIMEx_Remap * @{ */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.c index 9c6f49eb2c..c1b743ee9b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_uart.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief UART HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Universal Asynchronous Receiver Transmitter (UART) peripheral: @@ -21,7 +21,7 @@ (#) Declare a UART_HandleTypeDef handle structure. - (#) Initialize the UART low level resources by implement the HAL_UART_MspInit() API: + (#) Initialize the UART low level resources by implementing the HAL_UART_MspInit() API: (##) Enable the USARTx interface clock. (##) UART pins configuration: (+++) Enable the clock for the UART GPIOs. @@ -42,7 +42,7 @@ interrupt on the DMA Tx/Rx Stream. (#) Program the Baud Rate, Word Length, Stop Bit, Parity, Hardware - flow control and Mode(Receiver/Transmitter) in the huart Init structure. + flow control and Mode(Receiver/Transmitter) in the Init structure. (#) For the UART asynchronous mode, initialize the UART registers by calling the HAL_UART_Init() API. @@ -55,16 +55,19 @@ (#) For the Multi-Processor mode, initialize the UART registers by calling the HAL_MultiProcessor_Init() API. - -@- The specific UART interrupts (Transmission complete interrupt, + [..] + (@) The specific UART interrupts (Transmission complete interrupt, RXNE interrupt and Error Interrupts) will be managed using the macros __HAL_UART_ENABLE_IT() and __HAL_UART_DISABLE_IT() inside the transmit and receive process. - -@- These API's(HAL_UART_Init() and HAL_HalfDuplex_Init()) configures also the + [..] + (@) These APIs (HAL_UART_Init() and HAL_HalfDuplex_Init()) configure also the low level Hardware GPIO, CLOCK, CORTEX...etc) by calling the customed HAL_UART_MspInit() API. - (#) Three mode of operations are available within this driver : + [..] + Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -114,10 +117,10 @@ (+) __HAL_UART_ENABLE: Enable the UART peripheral (+) __HAL_UART_DISABLE: Disable the UART peripheral - (+) __HAL_UART_GET_FLAG : Checks whether the specified UART flag is set or not - (+) __HAL_UART_CLEAR_FLAG : Clears the specified UART pending flag - (+) __HAL_UART_ENABLE_IT: Enables the specified UART interrupt - (+) __HAL_UART_DISABLE_IT: Disables the specified UART interrupt + (+) __HAL_UART_GET_FLAG : Check whether the specified UART flag is set or not + (+) __HAL_UART_CLEAR_FLAG : Clear the specified UART pending flag + (+) __HAL_UART_ENABLE_IT: Enable the specified UART interrupt + (+) __HAL_UART_DISABLE_IT: Disable the specified UART interrupt [..] (@) You can refer to the UART HAL driver header file for more useful macros @@ -205,18 +208,7 @@ static HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, (++) Parity: If the parity is enabled, then the MSB bit of the data written in the data register is transmitted but is changed by the parity bit. Depending on the frame length defined by the M bit (8-bits or 9-bits), - the possible UART frame formats are as listed in the following table: - +-------------------------------------------------------------+ - | M bit | PCE bit | UART frame | - |---------------------|---------------------------------------| - | 0 | 0 | | SB | 8 bit data | STB | | - |---------|-----------|---------------------------------------| - | 0 | 1 | | SB | 7 bit data | PB | STB | | - |---------|-----------|---------------------------------------| - | 1 | 0 | | SB | 9 bit data | STB | | - |---------|-----------|---------------------------------------| - | 1 | 1 | | SB | 8 bit data | PB | STB | | - +-------------------------------------------------------------+ + please refer to Reference manual for possible UART frame formats. (++) Hardware flow control (++) Receiver/transmitter modes (++) Over Sampling Methode @@ -232,7 +224,8 @@ static HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, /** * @brief Initializes the UART mode according to the specified parameters in * the UART_InitTypeDef and create the associated handle. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status */ HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart) @@ -259,9 +252,9 @@ HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart) /* Init the low level hardware */ HAL_UART_MspInit(huart); } - - huart->State = HAL_UART_STATE_BUSY; - + + huart->State = HAL_UART_STATE_BUSY; + /* Disable the peripheral */ __HAL_UART_DISABLE(huart); @@ -287,7 +280,8 @@ HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart) /** * @brief Initializes the half-duplex mode according to the specified * parameters in the UART_InitTypeDef and create the associated handle. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status */ HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart) @@ -303,7 +297,9 @@ HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart) /* Init the low level hardware */ HAL_UART_MspInit(huart); } - + + huart->State = HAL_UART_STATE_BUSY; + /* Disable the peripheral */ __HAL_UART_DISABLE(huart); @@ -332,7 +328,8 @@ HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart) /** * @brief Initializes the LIN mode according to the specified * parameters in the UART_InitTypeDef and create the associated handle. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @param BreakDetectLength: Specifies the LIN break detection length. * This parameter can be one of the following values: * @arg UART_LINBREAKDETECTLENGTH_10B: 10-bit break detection @@ -354,7 +351,9 @@ HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLe /* Init the low level hardware */ HAL_UART_MspInit(huart); } - + + huart->State = HAL_UART_STATE_BUSY; + /* Disable the peripheral */ __HAL_UART_DISABLE(huart); @@ -387,7 +386,8 @@ HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLe /** * @brief Initializes the Multi-Processor mode according to the specified * parameters in the UART_InitTypeDef and create the associated handle. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @param Address: USART address * @param WakeUpMethode: specifies the USART wakeup method. * This parameter can be one of the following values: @@ -412,7 +412,9 @@ HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Add /* Init the low level hardware */ HAL_UART_MspInit(huart); } - + + huart->State = HAL_UART_STATE_BUSY; + /* Disable the peripheral */ __HAL_UART_DISABLE(huart); @@ -446,7 +448,8 @@ HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Add /** * @brief DeInitializes the UART peripheral. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status */ HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart) @@ -476,7 +479,8 @@ HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart) /** * @brief UART MSP Init. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval None */ __weak void HAL_UART_MspInit(UART_HandleTypeDef *huart) @@ -488,7 +492,8 @@ HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart) /** * @brief UART MSP DeInit. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval None */ __weak void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) @@ -517,7 +522,7 @@ HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart) (++) Blocking mode: The communication is performed in polling mode. The HAL status of all data processing is returned by the same function after finishing transfer. - (++) Non-Blocking mode: The communication is performed using Interrupts + (++) Non blocking mode: The communication is performed using Interrupts or DMA, these APIs return the HAL status. The end of the data processing will be indicated through the dedicated UART IRQ when using Interrupt mode or the DMA IRQ when @@ -527,20 +532,20 @@ HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart) The HAL_UART_ErrorCallback() user callback will be executed when a communication error is detected. - (#) Blocking mode API's are: + (#) Blocking mode APIs are: (++) HAL_UART_Transmit() (++) HAL_UART_Receive() - (#) Non-Blocking mode API's with Interrupt are: + (#) Non Blocking mode APIs with Interrupt are: (++) HAL_UART_Transmit_IT() (++) HAL_UART_Receive_IT() (++) HAL_UART_IRQHandler() - (#) No-Blocking mode functions with DMA are: + (#) Non Blocking mode functions with DMA are: (++) HAL_UART_Transmit_DMA() (++) HAL_UART_Receive_DMA() - (#) A set of Transfer Complete Callbacks are provided in Non-Blocking mode: + (#) A set of Transfer Complete Callbacks are provided in non blocking mode: (++) HAL_UART_TxCpltCallback() (++) HAL_UART_RxCpltCallback() (++) HAL_UART_ErrorCallback() @@ -556,7 +561,8 @@ HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart) /** * @brief Sends an amount of data in blocking mode. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @param Timeout: Timeout duration @@ -649,7 +655,8 @@ HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, u /** * @brief Receives an amount of data in blocking mode. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be received * @param Timeout: Timeout duration @@ -748,7 +755,8 @@ HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, ui /** * @brief Sends an amount of data in non blocking mode. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -805,7 +813,8 @@ HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData /** * @brief Receives an amount of data in non blocking mode - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be received * @retval HAL status @@ -862,7 +871,8 @@ HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, /** * @brief Sends an amount of data in non blocking mode. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -928,7 +938,8 @@ HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pDat /** * @brief Receives an amount of data in non blocking mode. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @param pData: Pointer to data buffer * @param Size: Amount of data to be received * @note When the UART parity is enabled (PCE = 1) the data received contain the parity bit. @@ -954,7 +965,7 @@ HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData huart->RxXferSize = Size; huart->ErrorCode = HAL_UART_ERROR_NONE; - /* Check if a transmit rocess is ongoing or not */ + /* Check if a transmit process is ongoing or not */ if(huart->State == HAL_UART_STATE_BUSY_TX) { huart->State = HAL_UART_STATE_BUSY_TX_RX; @@ -994,8 +1005,9 @@ HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData /** * @brief Pauses the DMA Transfer. - * @param huart: UART handle - * @retval None + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. + * @retval HAL status */ HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart) { @@ -1027,8 +1039,9 @@ HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart) /** * @brief Resumes the DMA Transfer. - * @param huart: UART handle - * @retval None + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. + * @retval HAL status */ HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart) { @@ -1067,8 +1080,9 @@ HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart) /** * @brief Stops the DMA Transfer. - * @param huart: UART handle - * @retval None + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. + * @retval HAL status */ HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart) { @@ -1102,7 +1116,8 @@ HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart) /** * @brief This function handles UART interrupt request. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval None */ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart) @@ -1178,7 +1193,8 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart) /** * @brief Tx Transfer completed callbacks. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval None */ __weak void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) @@ -1190,7 +1206,8 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart) /** * @brief Tx Half Transfer completed callbacks. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval None */ __weak void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart) @@ -1202,7 +1219,8 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart) /** * @brief Rx Transfer completed callbacks. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval None */ __weak void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) @@ -1214,7 +1232,8 @@ __weak void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) /** * @brief Rx Half Transfer completed callbacks. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval None */ __weak void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart) @@ -1226,7 +1245,8 @@ __weak void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart) /** * @brief UART error callbacks. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval None */ __weak void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) @@ -1259,7 +1279,8 @@ __weak void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart) /** * @brief Transmits break characters. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status */ HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart) @@ -1285,7 +1306,8 @@ HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart) /** * @brief Enters the UART in mute mode. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status */ HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart) @@ -1311,7 +1333,8 @@ HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart) /** * @brief Exits the UART mute mode: wake up software. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status */ HAL_StatusTypeDef HAL_MultiProcessor_ExitMuteMode(UART_HandleTypeDef *huart) @@ -1337,9 +1360,9 @@ HAL_StatusTypeDef HAL_MultiProcessor_ExitMuteMode(UART_HandleTypeDef *huart) /** * @brief Enables the UART transmitter and disables the UART receiver. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status - * @retval None */ HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart) { @@ -1372,7 +1395,8 @@ HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart) /** * @brief Enables the UART receiver and disables the UART transmitter. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status */ HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart) @@ -1417,10 +1441,10 @@ HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart) ============================================================================== [..] This subsection provides a set of functions allowing to return the State of - UART communication process, return Peripheral Errors occured during communication + UART communication process, return Peripheral Errors occurred during communication process (+) HAL_UART_GetState() API can be helpful to check in run-time the state of the UART peripheral. - (+) HAL_UART_GetError() check in run-time errors that could be occured durung communication. + (+) HAL_UART_GetError() check in run-time errors that could be occurred during communication. @endverbatim * @{ @@ -1428,7 +1452,8 @@ HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart) /** * @brief Returns the UART state. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL state */ HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart) @@ -1468,7 +1493,7 @@ static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma) /* Wait for UART TC Flag */ if(UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TC, RESET, UART_TIMEOUT_VALUE) != HAL_OK) { - /* Timeout Occured */ + /* Timeout occurred */ huart->State = HAL_UART_STATE_TIMEOUT; HAL_UART_ErrorCallback(huart); } @@ -1490,7 +1515,8 @@ static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA UART transmit process half complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void UART_DMATxHalfCplt(DMA_HandleTypeDef *hdma) @@ -1528,7 +1554,8 @@ static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA UART receive process half complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma) @@ -1555,7 +1582,8 @@ static void UART_DMAError(DMA_HandleTypeDef *hdma) /** * @brief This function handles UART Communication Timeout. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @param Flag: specifies the UART flag to check. * @param Status: The new Flag status (SET or RESET). * @param Timeout: Timeout duration @@ -1623,7 +1651,8 @@ static HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, /** * @brief Sends an amount of data in non blocking mode. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status */ static HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart) @@ -1634,9 +1663,6 @@ static HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart) tmp1 = huart->State; if((tmp1 == HAL_UART_STATE_BUSY_TX) || (tmp1 == HAL_UART_STATE_BUSY_TX_RX)) { - /* Process Locked */ - __HAL_LOCK(huart); - if(huart->Init.WordLength == UART_WORDLENGTH_9B) { tmp = (uint16_t*) huart->pTxBuffPtr; @@ -1675,28 +1701,21 @@ static HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart) huart->State = HAL_UART_STATE_READY; } - /* Call the Process Unlocked before calling the Tx callback API to give the possibility to - start again the Transmission under the Tx callback API */ - __HAL_UNLOCK(huart); - HAL_UART_TxCpltCallback(huart); return HAL_OK; } - - /* Process Unlocked */ - __HAL_UNLOCK(huart); - - return HAL_OK; + return HAL_OK; } else { - return HAL_BUSY; + return HAL_BUSY; } } /** * @brief Receives an amount of data in non blocking mode - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval HAL status */ static HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart) @@ -1707,9 +1726,6 @@ static HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart) tmp1 = huart->State; if((tmp1 == HAL_UART_STATE_BUSY_RX) || (tmp1 == HAL_UART_STATE_BUSY_TX_RX)) { - /* Process Locked */ - __HAL_LOCK(huart); - if(huart->Init.WordLength == UART_WORDLENGTH_9B) { tmp = (uint16_t*) huart->pRxBuffPtr; @@ -1738,8 +1754,9 @@ static HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart) if(--huart->RxXferCount == 0) { - while(HAL_IS_BIT_SET(huart->Instance->SR, UART_FLAG_RXNE)) - { + if(UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_RXNE, SET, UART_TIMEOUT_VALUE) != HAL_OK) + { + return HAL_TIMEOUT; } __HAL_UART_DISABLE_IT(huart, UART_IT_RXNE); @@ -1758,17 +1775,10 @@ static HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart) huart->State = HAL_UART_STATE_READY; } - /* Call the Process Unlocked before calling the Rx callback API to give the possibility to - start again the reception under the Rx callback API */ - __HAL_UNLOCK(huart); - HAL_UART_RxCpltCallback(huart); return HAL_OK; } - /* Process Unlocked */ - __HAL_UNLOCK(huart); - return HAL_OK; } else @@ -1779,7 +1789,8 @@ static HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart) /** * @brief Configures the UART peripheral. - * @param huart: UART handle + * @param huart: pointer to a UART_HandleTypeDef structure that contains + * the configuration information for the specified UART module. * @retval None */ static void UART_SetConfig(UART_HandleTypeDef *huart) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.h index 194f4571a8..3b50ffc6a6 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_uart.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of UART HAL module. ****************************************************************************** * @attention @@ -300,19 +300,32 @@ typedef struct #define UART_IT_LBD ((uint32_t)0x20000040) #define UART_IT_CTS ((uint32_t)0x30000400) - + #define UART_IT_ERR ((uint32_t)0x30000001) /** * @} */ - + /** * @} */ /* Exported macro ------------------------------------------------------------*/ - + +/** @brief Reset UART handle state + * @param __HANDLE__: specifies the UART Handle. + * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or + * UART peripheral. + * @retval None + */ +#define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_UART_STATE_RESET) + +/** @brief Flushs the UART DR register + * @param __HANDLE__: specifies the UART Handle. + */ +#define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) + /** @brief Checks whether the specified UART flag is set or not. * @param __HANDLE__: specifies the UART Handle. * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.c index f0b7dbd0ff..f8dea94931 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_usart.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief USART HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Universal Synchronous Asynchronous Receiver Transmitter (USART) peripheral: @@ -18,7 +18,7 @@ The USART HAL driver can be used as follows: (#) Declare a USART_HandleTypeDef handle structure. - (#) Initialize the USART low level resources by implement the HAL_USART_MspInit ()API: + (#) Initialize the USART low level resources by implementing the HAL_USART_MspInit () API: (##) Enable the USARTx interface clock. (##) USART pins configuration: (+++) Enable the clock for the USART GPIOs. @@ -40,14 +40,14 @@ flow control and Mode(Receiver/Transmitter) in the husart Init structure. (#) Initialize the USART registers by calling the HAL_USART_Init() API: - (++) These API's configures also the low level Hardware GPIO, CLOCK, CORTEX...etc) + (++) These APIs configures also the low level Hardware GPIO, CLOCK, CORTEX...etc) by calling the customed HAL_USART_MspInit(&husart) API. -@@- The specific USART interrupts (Transmission complete interrupt, RXNE interrupt and Error Interrupts) will be managed using the macros __USART_ENABLE_IT() and __USART_DISABLE_IT() inside the transmit and receive process. - (#) Three mode of operations are available within this driver : + (#) Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= @@ -97,10 +97,10 @@ (+) __HAL_USART_ENABLE: Enable the USART peripheral (+) __HAL_USART_DISABLE: Disable the USART peripheral - (+) __HAL_USART_GET_FLAG : Checks whether the specified USART flag is set or not - (+) __HAL_USART_CLEAR_FLAG : Clears the specified USART pending flag - (+) __HAL_USART_ENABLE_IT: Enables the specified USART interrupt - (+) __HAL_USART_DISABLE_IT: Disables the specified USART interrupt + (+) __HAL_USART_GET_FLAG : Check whether the specified USART flag is set or not + (+) __HAL_USART_CLEAR_FLAG : Clear the specified USART pending flag + (+) __HAL_USART_ENABLE_IT: Enable the specified USART interrupt + (+) __HAL_USART_DISABLE_IT: Disable the specified USART interrupt [..] (@) You can refer to the USART HAL driver header file for more useful macros @@ -150,7 +150,7 @@ #ifdef HAL_USART_MODULE_ENABLED /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ -#define DYMMY_DATA 0xFFFF +#define DUMMY_DATA 0xFFFF #define USART_TIMEOUT_VALUE 22000 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ @@ -189,18 +189,7 @@ static HAL_StatusTypeDef USART_WaitOnFlagUntilTimeout(USART_HandleTypeDef *husar (++) Parity: If the parity is enabled, then the MSB bit of the data written in the data register is transmitted but is changed by the parity bit. Depending on the frame length defined by the M bit (8-bits or 9-bits), - the possible USART frame formats are as listed in the following table: - +-------------------------------------------------------------+ - | M bit | PCE bit | USART frame | - |---------------------|---------------------------------------| - | 0 | 0 | | SB | 8 bit data | STB | | - |---------|-----------|---------------------------------------| - | 0 | 1 | | SB | 7 bit data | PB | STB | | - |---------|-----------|---------------------------------------| - | 1 | 0 | | SB | 9 bit data | STB | | - |---------|-----------|---------------------------------------| - | 1 | 1 | | SB | 8 bit data | PB | STB | | - +-------------------------------------------------------------+ + please refer to Reference manual for possible USART frame formats. (++) USART polarity (++) USART phase (++) USART LastBit @@ -217,7 +206,8 @@ static HAL_StatusTypeDef USART_WaitOnFlagUntilTimeout(USART_HandleTypeDef *husar /** * @brief Initializes the USART mode according to the specified * parameters in the USART_InitTypeDef and create the associated handle. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval HAL status */ HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart) @@ -260,7 +250,8 @@ HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart) /** * @brief DeInitializes the USART peripheral. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval HAL status */ HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart) @@ -290,7 +281,8 @@ HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart) /** * @brief USART MSP Init. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ __weak void HAL_USART_MspInit(USART_HandleTypeDef *husart) @@ -302,7 +294,8 @@ HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart) /** * @brief USART MSP DeInit. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ __weak void HAL_USART_MspDeInit(USART_HandleTypeDef *husart) @@ -331,7 +324,7 @@ HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart) The USART supports master mode only: it cannot receive or send data related to an input clock (SCLK is always an output). - (#) There are two mode of transfer: + (#) There are two modes of transfer: (++) Blocking mode: The communication is performed in polling mode. The HAL status of all data processing is returned by the same function after finishing transfer. @@ -341,28 +334,28 @@ HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart) dedicated USART IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. The HAL_USART_TxCpltCallback(), HAL_USART_RxCpltCallback() and HAL_USART_TxRxCpltCallback() - user callbacks + user callbacks will be executed respectivelly at the end of the transmit or Receive process - The HAL_USART_ErrorCallback()user callback will be executed when a communication + The HAL_USART_ErrorCallback() user callback will be executed when a communication error is detected - (#) Blocking mode API's are : - (++) HAL_USART_Transmit()in simplex mode + (#) Blocking mode APIs are : + (++) HAL_USART_Transmit() in simplex mode (++) HAL_USART_Receive() in full duplex receive only (++) HAL_USART_TransmitReceive() in full duplex mode - (#) Non-Blocking mode API's with Interrupt are : + (#) Non Blocking mode APIs with Interrupt are : (++) HAL_USART_Transmit_IT()in simplex mode (++) HAL_USART_Receive_IT() in full duplex receive only - (++) HAL_USART_TransmitReceive_IT()in full duplex mode + (++) HAL_USART_TransmitReceive_IT() in full duplex mode (++) HAL_USART_IRQHandler() - (#) No-Blocking mode functions with DMA are : + (#) Non Blocking mode functions with DMA are : (++) HAL_USART_Transmit_DMA()in simplex mode (++) HAL_USART_Receive_DMA() in full duplex receive only (++) HAL_USART_TransmitReceie_DMA() in full duplex mode - (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: + (#) A set of Transfer Complete Callbacks are provided in non Blocking mode: (++) HAL_USART_TxCpltCallback() (++) HAL_USART_RxCpltCallback() (++) HAL_USART_ErrorCallback() @@ -374,9 +367,11 @@ HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart) /** * @brief Simplex Send an amount of data in blocking mode. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @param pTxData: Pointer to data buffer * @param Size: Amount of data to be sent + * @param Timeout: Timeout duration * @retval HAL status */ HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout) @@ -449,9 +444,11 @@ HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxDa /** * @brief Full-Duplex Receive an amount of data in blocking mode. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @param pRxData: Pointer to data buffer * @param Size: Amount of data to be received + * @param Timeout: Timeout duration * @retval HAL status */ HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout) @@ -484,7 +481,7 @@ HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxDat return HAL_TIMEOUT; } /* Send dummy byte in order to generate clock */ - husart->Instance->DR = (DYMMY_DATA & (uint16_t)0x01FF); + husart->Instance->DR = (DUMMY_DATA & (uint16_t)0x01FF); /* Wait for RXNE Flag */ if(USART_WaitOnFlagUntilTimeout(husart, USART_FLAG_RXNE, RESET, Timeout) != HAL_OK) @@ -512,7 +509,7 @@ HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxDat } /* Send Dummy Byte in order to generate clock */ - husart->Instance->DR = (DYMMY_DATA & (uint16_t)0x00FF); + husart->Instance->DR = (DUMMY_DATA & (uint16_t)0x00FF); /* Wait until RXNE flag is set to receive the byte */ if(USART_WaitOnFlagUntilTimeout(husart, USART_FLAG_RXNE, RESET, Timeout) != HAL_OK) @@ -548,9 +545,12 @@ HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxDat /** * @brief Full-Duplex Send receive an amount of data in full-duplex mode (blocking mode). - * @param husart: USART handle - * @param pTxData: Pointer to data buffer + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. + * @param pTxData: Pointer to data transmitted buffer + * @param pRxData: Pointer to data received buffer * @param Size: Amount of data to be sent + * @param Timeout: Timeout duration * @retval HAL status */ HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout) @@ -656,7 +656,8 @@ HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t /** * @brief Simplex Send an amount of data in non-blocking mode. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @param pTxData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status @@ -705,7 +706,8 @@ HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pT /** * @brief Simplex Receive an amount of data in non-blocking mode. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @param pRxData: Pointer to data buffer * @param Size: Amount of data to be received * @retval HAL status @@ -741,7 +743,7 @@ HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRx __HAL_UNLOCK(husart); /* Send dummy byte in order to generate the clock for the slave to send data */ - husart->Instance->DR = (DYMMY_DATA & (uint16_t)0x01FF); + husart->Instance->DR = (DUMMY_DATA & (uint16_t)0x01FF); return HAL_OK; } @@ -753,8 +755,10 @@ HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRx /** * @brief Full-Duplex Send receive an amount of data in full-duplex mode (non-blocking). - * @param husart: USART handle - * @param pTxData: Pointer to data buffer + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. + * @param pTxData: Pointer to data transmitted buffer + * @param pRxData: Pointer to data received buffer * @param Size: Amount of data to be received * @retval HAL status */ @@ -804,8 +808,9 @@ HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint /** * @brief Simplex Send an amount of data in non-blocking mode. - * @param husart: USART handle - * @param pData: Pointer to data buffer + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. + * @param pTxData: Pointer to data buffer * @param Size: Amount of data to be sent * @retval HAL status */ @@ -859,7 +864,8 @@ HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *p /** * @brief Full-Duplex Receive an amount of data in non-blocking mode. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @param pRxData: Pointer to data buffer * @param Size: Amount of data to be received * @retval HAL status @@ -927,8 +933,10 @@ HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pR /** * @brief Full-Duplex Transmit Receive an amount of data in non-blocking mode. - * @param husart: USART handle - * @param pRxData: Pointer to data buffer + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. + * @param pTxData: Pointer to data transmitted buffer + * @param pRxData: Pointer to data received buffer * @param Size: Amount of data to be received * @note When the USART parity is enabled (PCE = 1) the data received contain the parity bit. * @retval HAL status @@ -1001,8 +1009,9 @@ HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uin /** * @brief Pauses the DMA Transfer. - * @param husart: USART handle - * @retval None + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. + * @retval HAL status */ HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart) { @@ -1035,8 +1044,9 @@ HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart) /** * @brief Resumes the DMA Transfer. - * @param husart: USART handle - * @retval None + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. + * @retval HAL status */ HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart) { @@ -1076,8 +1086,9 @@ HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart) /** * @brief Stops the DMA Transfer. - * @param husart: USART handle - * @retval None + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. + * @retval HAL status */ HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart) { @@ -1111,7 +1122,8 @@ HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart) /** * @brief This function handles USART interrupt request. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ void HAL_USART_IRQHandler(USART_HandleTypeDef *husart) @@ -1195,7 +1207,8 @@ void HAL_USART_IRQHandler(USART_HandleTypeDef *husart) /** * @brief Tx Transfer completed callbacks. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ __weak void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart) @@ -1207,7 +1220,8 @@ void HAL_USART_IRQHandler(USART_HandleTypeDef *husart) /** * @brief Tx Half Transfer completed callbacks. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ __weak void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart) @@ -1219,7 +1233,8 @@ void HAL_USART_IRQHandler(USART_HandleTypeDef *husart) /** * @brief Rx Transfer completed callbacks. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ __weak void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart) @@ -1231,7 +1246,8 @@ __weak void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart) /** * @brief Rx Half Transfer completed callbacks. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ __weak void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart) @@ -1243,7 +1259,8 @@ __weak void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart) /** * @brief Tx/Rx Transfers completed callback for the non-blocking process. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ __weak void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart) @@ -1255,7 +1272,8 @@ __weak void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart) /** * @brief USART error callbacks. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ __weak void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart) @@ -1279,10 +1297,10 @@ __weak void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart) [..] This subsection provides a set of functions allowing to return the State of USART communication - process, return Peripheral Errors occured during communication process + process, return Peripheral Errors occurred during communication process (+) HAL_USART_GetState() API can be helpful to check in run-time the state of the USART peripheral. - (+) HAL_USART_GetError() check in run-time errors that could be occured durung + (+) HAL_USART_GetError() check in run-time errors that could be occurred during communication. @endverbatim * @{ @@ -1290,7 +1308,8 @@ __weak void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart) /** * @brief Returns the USART state. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval HAL state */ HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart) @@ -1329,7 +1348,7 @@ static void USART_DMATransmitCplt(DMA_HandleTypeDef *hdma) /* Wait for USART TC Flag */ if(USART_WaitOnFlagUntilTimeout(husart, USART_FLAG_TC, RESET, USART_TIMEOUT_VALUE) != HAL_OK) { - /* Timeout Occured */ + /* Timeout occurred */ husart->State = HAL_USART_STATE_TIMEOUT; HAL_USART_ErrorCallback(husart); } @@ -1352,7 +1371,8 @@ static void USART_DMATransmitCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA USART transmit process half complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void USART_DMATxHalfCplt(DMA_HandleTypeDef *hdma) @@ -1385,7 +1405,8 @@ static void USART_DMAReceiveCplt(DMA_HandleTypeDef *hdma) /** * @brief DMA USART receive process half complete callback - * @param hdma : DMA handle + * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * the configuration information for the specified DMA module. * @retval None */ static void USART_DMARxHalfCplt(DMA_HandleTypeDef *hdma) @@ -1414,7 +1435,8 @@ static void USART_DMAError(DMA_HandleTypeDef *hdma) /** * @brief This function handles USART Communication Timeout. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @param Flag: specifies the USART flag to check. * @param Status: The new Flag status (SET or RESET). * @param Timeout: Timeout duration @@ -1483,7 +1505,8 @@ static HAL_StatusTypeDef USART_WaitOnFlagUntilTimeout(USART_HandleTypeDef *husar /** * @brief Simplex Send an amount of data in non-blocking mode. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval HAL status * @note The USART errors are not managed to avoid the overrun error. */ @@ -1493,9 +1516,6 @@ static HAL_StatusTypeDef USART_Transmit_IT(USART_HandleTypeDef *husart) if(husart->State == HAL_USART_STATE_BUSY_TX) { - /* Process Locked */ - __HAL_LOCK(husart); - if(husart->Init.WordLength == USART_WORDLENGTH_9B) { tmp = (uint16_t*) husart->pTxBuffPtr; @@ -1524,18 +1544,10 @@ static HAL_StatusTypeDef USART_Transmit_IT(USART_HandleTypeDef *husart) husart->State = HAL_USART_STATE_READY; - /* Call the Process Unlocked before calling the Tx callback API to give the possibility to - start again the Transmission under the Tx callback API */ - __HAL_UNLOCK(husart); - HAL_USART_TxCpltCallback(husart); return HAL_OK; } - - /* Process Unlocked */ - __HAL_UNLOCK(husart); - return HAL_OK; } else @@ -1546,7 +1558,8 @@ static HAL_StatusTypeDef USART_Transmit_IT(USART_HandleTypeDef *husart) /** * @brief Simplex Receive an amount of data in non-blocking mode. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval HAL status */ static HAL_StatusTypeDef USART_Receive_IT(USART_HandleTypeDef *husart) @@ -1554,9 +1567,6 @@ static HAL_StatusTypeDef USART_Receive_IT(USART_HandleTypeDef *husart) uint16_t* tmp; if(husart->State == HAL_USART_STATE_BUSY_RX) { - /* Process Locked */ - __HAL_LOCK(husart); - if(husart->Init.WordLength == USART_WORDLENGTH_9B) { tmp = (uint16_t*) husart->pRxBuffPtr; @@ -1573,7 +1583,7 @@ static HAL_StatusTypeDef USART_Receive_IT(USART_HandleTypeDef *husart) if(--husart->RxXferCount != 0x00) { /* Send dummy byte in order to generate the clock for the slave to send the next data */ - husart->Instance->DR = (DYMMY_DATA & (uint16_t)0x01FF); + husart->Instance->DR = (DUMMY_DATA & (uint16_t)0x01FF); } } else @@ -1590,7 +1600,7 @@ static HAL_StatusTypeDef USART_Receive_IT(USART_HandleTypeDef *husart) if(--husart->RxXferCount != 0x00) { /* Send dummy byte in order to generate the clock for the slave to send the next data */ - husart->Instance->DR = (DYMMY_DATA & (uint16_t)0x00FF); + husart->Instance->DR = (DUMMY_DATA & (uint16_t)0x00FF); } } @@ -1606,18 +1616,10 @@ static HAL_StatusTypeDef USART_Receive_IT(USART_HandleTypeDef *husart) __USART_DISABLE_IT(husart, USART_IT_ERR); husart->State = HAL_USART_STATE_READY; - /* Call the Process Unlocked before calling the Rx callback API to give the possibility to - start again the reception under the Rx callback API */ - __HAL_UNLOCK(husart); - HAL_USART_RxCpltCallback(husart); return HAL_OK; } - - /* Process Unlocked */ - __HAL_UNLOCK(husart); - return HAL_OK; } else @@ -1628,7 +1630,8 @@ static HAL_StatusTypeDef USART_Receive_IT(USART_HandleTypeDef *husart) /** * @brief Full-Duplex Send receive an amount of data in full-duplex mode (non-blocking). - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval HAL status */ static HAL_StatusTypeDef USART_TransmitReceive_IT(USART_HandleTypeDef *husart) @@ -1738,7 +1741,8 @@ static HAL_StatusTypeDef USART_TransmitReceive_IT(USART_HandleTypeDef *husart) /** * @brief Configures the USART peripheral. - * @param husart: USART handle + * @param husart: pointer to a USART_HandleTypeDef structure that contains + * the configuration information for the specified USART module. * @retval None */ static void USART_SetConfig(USART_HandleTypeDef *husart) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.h index b73c341ff1..b1f77bc18b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_usart.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of USART HAL module. ****************************************************************************** * @attention @@ -62,7 +62,7 @@ typedef struct { uint32_t BaudRate; /*!< This member configures the Usart communication baud rate. The baud rate is computed using the following formula: - - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate))) + - IntegerDivider = ((PCLKx) / (8 * (husart->Init.BaudRate))) - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */ uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. @@ -251,7 +251,7 @@ typedef struct * @} */ -/** @defgroup Usart_NACK_State +/** @defgroup USART_NACK_State * @{ */ #define USARTNACK_ENABLED ((uint32_t)USART_CR3_NACK) @@ -262,7 +262,7 @@ typedef struct * @} */ -/** @defgroup Usart_Flags +/** @defgroup USART_Flags * Elements values convention: 0xXXXX * - 0xXXXX : Flag mask in the SR register * @{ @@ -298,24 +298,29 @@ typedef struct #define USART_IT_LBD ((uint32_t)0x20000040) #define USART_IT_CTS ((uint32_t)0x30000400) - + #define USART_IT_ERR ((uint32_t)0x30000001) /** * @} */ - + /** * @} */ /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset USART handle state + * @param __HANDLE__: specifies the USART Handle. + * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. + * @retval None + */ +#define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET) /** @brief Checks whether the specified Smartcard flag is set or not. * @param __HANDLE__: specifies the USART Handle. - * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or - * UART peripheral. + * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. * @param __FLAG__: specifies the flag to check. * This parameter can be one of the following values: * @arg USART_FLAG_TXE: Transmit data register empty flag @@ -333,8 +338,7 @@ typedef struct /** @brief Clears the specified Smartcard pending flags. * @param __HANDLE__: specifies the USART Handle. - * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or - * UART peripheral. + * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. * @param __FLAG__: specifies the flag to check. * This parameter can be any combination of the following values: * @arg USART_FLAG_TC: Transmission Complete flag. @@ -356,8 +360,7 @@ typedef struct /** @brief Enables or disables the specified Usart interrupts. * @param __HANDLE__: specifies the USART Handle. - * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or - * UART peripheral. + * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. * @param __INTERRUPT__: specifies the USART interrupt source to check. * This parameter can be one of the following values: * @arg USART_IT_TXE: Transmit Data Register empty interrupt @@ -381,8 +384,7 @@ typedef struct /** @brief Checks whether the specified Usart interrupt has occurred or not. * @param __HANDLE__: specifies the USART Handle. - * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or - * UART peripheral. + * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. * @param __IT__: specifies the USART interrupt source to check. * This parameter can be one of the following values: * @arg USART_IT_TXE: Transmit Data Register empty interrupt diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c index 499542aa78..1144565874 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_wwdg.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief WWDG HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Window Watchdog (WWDG) peripheral: @@ -144,7 +144,8 @@ /** * @brief Initializes the WWDG according to the specified * parameters in the WWDG_InitTypeDef and creates the associated handle. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval HAL status */ HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg) @@ -206,7 +207,8 @@ HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg) /** * @brief DeInitializes the WWDG peripheral. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval HAL status */ HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg) @@ -238,7 +240,8 @@ HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg) /** * @brief Initializes the WWDG MSP. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval None */ __weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg) @@ -250,7 +253,8 @@ __weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg) /** * @brief DeInitializes the WWDG MSP. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval None */ __weak void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg) @@ -283,7 +287,8 @@ __weak void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg) /** * @brief Starts the WWDG. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval HAL status */ HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg) @@ -309,7 +314,8 @@ HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg) /** * @brief Starts the WWDG with interrupt enabled. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval HAL status */ HAL_StatusTypeDef HAL_WWDG_Start_IT(WWDG_HandleTypeDef *hwwdg) @@ -332,7 +338,8 @@ HAL_StatusTypeDef HAL_WWDG_Start_IT(WWDG_HandleTypeDef *hwwdg) /** * @brief Refreshes the WWDG. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval HAL status */ HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg, uint32_t Counter) @@ -368,7 +375,8 @@ HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg, uint32_t Counter) * generated and the corresponding Interrupt Service Routine (ISR) can * be used to trigger specific actions (such as communications or data * logging), before resetting the device. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval None */ void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg) @@ -392,7 +400,8 @@ void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg) /** * @brief Early Wakeup WWDG callback. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval None */ __weak void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg) @@ -423,7 +432,8 @@ __weak void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg) /** * @brief Returns the WWDG state. - * @param hwwdg: WWDG handle + * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. * @retval HAL state */ HAL_WWDG_StateTypeDef HAL_WWDG_GetState(WWDG_HandleTypeDef *hwwdg) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.h index 51500c82f8..0e57cc4c08 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_wwdg.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of WWDG HAL module. ****************************************************************************** * @attention @@ -74,13 +74,13 @@ typedef enum */ typedef struct { - uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG. + uint32_t Prescaler; /*!< Specifies the prescaler. This parameter can be a value of @ref WWDG_Prescaler */ uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter. This parameter must be a number lower than Max_Data = 0x80 */ - uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value. + uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value. This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */ }WWDG_InitTypeDef; @@ -102,10 +102,6 @@ typedef struct /* Exported constants --------------------------------------------------------*/ -/** @defgroup WWDG_Exported_Constants - * @{ - */ - /** @defgroup WWDG_BitAddress_AliasRegion * @{ */ @@ -140,7 +136,7 @@ typedef struct /** * @} */ - + /** @defgroup WWDG_Prescaler * @{ */ @@ -152,7 +148,7 @@ typedef struct #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_PRESCALER_1) || \ ((PRESCALER) == WWDG_PRESCALER_2) || \ ((PRESCALER) == WWDG_PRESCALER_4) || \ - ((PRESCALER) == WWDG_PRESCALER_8)) + ((PRESCALER) == WWDG_PRESCALER_8)) /** * @} @@ -176,12 +172,14 @@ typedef struct * @} */ -/** - * @} - */ - /* Exported macro ------------------------------------------------------------*/ +/** @brief Reset WWDG handle state + * @param __HANDLE__: WWDG handle + * @retval None + */ +#define __HAL_WWDG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_WWDG_STATE_RESET) + /** * @brief Enables the WWDG peripheral. * @param __HANDLE__: WWDG handle @@ -216,7 +214,6 @@ typedef struct */ #define __HAL_WWDG_ENABLE_IT(__INTERRUPT__) (*(__IO uint32_t *) CFR_BASE |= (__INTERRUPT__)) - /* Exported functions --------------------------------------------------------*/ /* Initialization/de-initialization functions **********************************/ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.c index 536659e4ff..a3732cd5cc 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_fmc.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief FMC Low Layer HAL module driver. * * This file provides firmware functions to manage the following diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.h index 2e651798cd..3650d8eb2e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_fmc.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of FMC HAL module. ****************************************************************************** * @attention @@ -63,70 +63,69 @@ #define FMC_PCCARD_TypeDef FMC_Bank4_TypeDef #define FMC_SDRAM_TypeDef FMC_Bank5_6_TypeDef -#define FMC_NORSRAM_DEVICE FMC_Bank1 -#define FMC_NORSRAM_EXTENDED_DEVICE FMC_Bank1E -#define FMC_NAND_DEVICE FMC_Bank2_3 -#define FMC_PCCARD_DEVICE FMC_Bank4 -#define FMC_SDRAM_DEVICE FMC_Bank5_6 - +#define FMC_NORSRAM_DEVICE FMC_Bank1 +#define FMC_NORSRAM_EXTENDED_DEVICE FMC_Bank1E +#define FMC_NAND_DEVICE FMC_Bank2_3 +#define FMC_PCCARD_DEVICE FMC_Bank4 +#define FMC_SDRAM_DEVICE FMC_Bank5_6 /** - * @brief FMC_NORSRAM Configuration Structure definition + * @brief FMC_NORSRAM Configuration Structure definition */ typedef struct { uint32_t NSBank; /*!< Specifies the NORSRAM memory device that will be used. - This parameter can be a value of @ref FMC_NORSRAM_Bank */ - + This parameter can be a value of @ref FMC_NORSRAM_Bank */ + uint32_t DataAddressMux; /*!< Specifies whether the address and data values are multiplexed on the data bus or not. This parameter can be a value of @ref FMC_Data_Address_Bus_Multiplexing */ - + uint32_t MemoryType; /*!< Specifies the type of external memory attached to the corresponding memory device. This parameter can be a value of @ref FMC_Memory_Type */ - + uint32_t MemoryDataWidth; /*!< Specifies the external memory device width. This parameter can be a value of @ref FMC_NORSRAM_Data_Width */ - + uint32_t BurstAccessMode; /*!< Enables or disables the burst access mode for Flash memory, valid only with synchronous burst Flash memories. This parameter can be a value of @ref FMC_Burst_Access_Mode */ - + uint32_t WaitSignalPolarity; /*!< Specifies the wait signal polarity, valid only when accessing the Flash memory in burst mode. This parameter can be a value of @ref FMC_Wait_Signal_Polarity */ - + uint32_t WrapMode; /*!< Enables or disables the Wrapped burst access mode for Flash memory, valid only when accessing Flash memories in burst mode. This parameter can be a value of @ref FMC_Wrap_Mode */ - + uint32_t WaitSignalActive; /*!< Specifies if the wait signal is asserted by the memory one clock cycle before the wait state or during the wait state, valid only when accessing memories in burst mode. This parameter can be a value of @ref FMC_Wait_Timing */ - + uint32_t WriteOperation; /*!< Enables or disables the write operation in the selected device by the FMC. This parameter can be a value of @ref FMC_Write_Operation */ - + uint32_t WaitSignal; /*!< Enables or disables the wait state insertion via wait signal, valid for Flash memory access in burst mode. This parameter can be a value of @ref FMC_Wait_Signal */ - + uint32_t ExtendedMode; /*!< Enables or disables the extended mode. This parameter can be a value of @ref FMC_Extended_Mode */ - + uint32_t AsynchronousWait; /*!< Enables or disables wait signal during asynchronous transfers, valid only with asynchronous Flash memories. This parameter can be a value of @ref FMC_AsynchronousWait */ - + uint32_t WriteBurst; /*!< Enables or disables the write burst operation. - This parameter can be a value of @ref FMC_Write_Burst */ - + This parameter can be a value of @ref FMC_Write_Burst */ + uint32_t ContinuousClock; /*!< Enables or disables the FMC clock output to external memory devices. This parameter is only enabled through the FMC_BCR1 register, and don't care through FMC_BCR2..4 registers. - This parameter can be a value of @ref FMC_Continous_Clock */ + This parameter can be a value of @ref FMC_Continous_Clock */ }FMC_NORSRAM_InitTypeDef; @@ -139,28 +138,28 @@ typedef struct the duration of the address setup time. This parameter can be a value between Min_Data = 0 and Max_Data = 15. @note This parameter is not used with synchronous NOR Flash memories. */ - + uint32_t AddressHoldTime; /*!< Defines the number of HCLK cycles to configure the duration of the address hold time. This parameter can be a value between Min_Data = 1 and Max_Data = 15. @note This parameter is not used with synchronous NOR Flash memories. */ - + uint32_t DataSetupTime; /*!< Defines the number of HCLK cycles to configure the duration of the data setup time. This parameter can be a value between Min_Data = 1 and Max_Data = 255. @note This parameter is used for SRAMs, ROMs and asynchronous multiplexed NOR Flash memories. */ - + uint32_t BusTurnAroundDuration; /*!< Defines the number of HCLK cycles to configure the duration of the bus turnaround. This parameter can be a value between Min_Data = 0 and Max_Data = 15. @note This parameter is only used for multiplexed NOR Flash memories. */ - + uint32_t CLKDivision; /*!< Defines the period of CLK clock output signal, expressed in number of HCLK cycles. This parameter can be a value between Min_Data = 2 and Max_Data = 16. @note This parameter is not used for asynchronous NOR Flash, SRAM or ROM accesses. */ - + uint32_t DataLatency; /*!< Defines the number of memory clock cycles to issue to the memory before getting the first data. The parameter value depends on the memory type as shown below: @@ -168,10 +167,9 @@ typedef struct - It is don't care in asynchronous NOR, SRAM or ROM accesses - It may assume a value between Min_Data = 2 and Max_Data = 17 in NOR Flash memories with synchronous burst mode enable */ - + uint32_t AccessMode; /*!< Specifies the asynchronous access mode. This parameter can be a value of @ref FMC_Access_Mode */ - }FMC_NORSRAM_TimingTypeDef; /** @@ -180,29 +178,28 @@ typedef struct typedef struct { uint32_t NandBank; /*!< Specifies the NAND memory device that will be used. - This parameter can be a value of @ref FMC_NAND_Bank */ - + This parameter can be a value of @ref FMC_NAND_Bank */ + uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the NAND Memory device. This parameter can be any value of @ref FMC_Wait_feature */ - + uint32_t MemoryDataWidth; /*!< Specifies the external memory device width. This parameter can be any value of @ref FMC_NAND_Data_Width */ - + uint32_t EccComputation; /*!< Enables or disables the ECC computation. This parameter can be any value of @ref FMC_ECC */ - + uint32_t ECCPageSize; /*!< Defines the page size for the extended ECC. This parameter can be any value of @ref FMC_ECC_Page_Size */ - + uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the delay between CLE low and RE low. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */ - + uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the delay between ALE low and RE low. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - -}FMC_NAND_InitTypeDef; +}FMC_NAND_InitTypeDef; /** * @brief FMC_NAND_PCCARD Timing parameters structure definition @@ -214,45 +211,43 @@ typedef struct to common/Attribute or I/O memory space (depending on the memory space timing to be configured). This parameter can be a value between Min_Data = 0 and Max_Data = 255 */ - + uint32_t WaitSetupTime; /*!< Defines the minimum number of HCLK cycles to assert the command for NAND-Flash read or write access to common/Attribute or I/O memory space (depending on the memory space timing to be configured). This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - + uint32_t HoldSetupTime; /*!< Defines the number of HCLK clock cycles to hold address (and data for write access) after the command de-assertion for NAND-Flash read or write access to common/Attribute or I/O memory space (depending on the memory space timing to be configured). This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - + uint32_t HiZSetupTime; /*!< Defines the number of HCLK clock cycles during which the data bus is kept in HiZ after the start of a NAND-Flash write access to common/Attribute or I/O memory space (depending on the memory space timing to be configured). This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - }FMC_NAND_PCC_TimingTypeDef; /** - * @brief FMC_NAND Configuration Structure definition + * @brief FMC_NAND Configuration Structure definition */ typedef struct { uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the PCCARD Memory device. This parameter can be any value of @ref FMC_Wait_feature */ - + uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the delay between CLE low and RE low. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */ - + uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the delay between ALE low and RE low. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - -}FMC_PCCARD_InitTypeDef; +}FMC_PCCARD_InitTypeDef; /** * @brief FMC_SDRAM Configuration Structure definition @@ -260,37 +255,36 @@ typedef struct typedef struct { uint32_t SDBank; /*!< Specifies the SDRAM memory device that will be used. - This parameter can be a value of @ref FMC_SDRAM_Bank */ - + This parameter can be a value of @ref FMC_SDRAM_Bank */ + uint32_t ColumnBitsNumber; /*!< Defines the number of bits of column address. This parameter can be a value of @ref FMC_SDRAM_Column_Bits_number. */ - + uint32_t RowBitsNumber; /*!< Defines the number of bits of column address. This parameter can be a value of @ref FMC_SDRAM_Row_Bits_number. */ - + uint32_t MemoryDataWidth; /*!< Defines the memory device width. This parameter can be a value of @ref FMC_SDRAM_Memory_Bus_Width. */ - + uint32_t InternalBankNumber; /*!< Defines the number of the device's internal banks. This parameter can be of @ref FMC_SDRAM_Internal_Banks_Number. */ - + uint32_t CASLatency; /*!< Defines the SDRAM CAS latency in number of memory clock cycles. This parameter can be a value of @ref FMC_SDRAM_CAS_Latency. */ - + uint32_t WriteProtection; /*!< Enables the SDRAM device to be accessed in write mode. This parameter can be a value of @ref FMC_SDRAM_Write_Protection. */ - + uint32_t SDClockPeriod; /*!< Define the SDRAM Clock Period for both SDRAM devices and they allow to disable the clock before changing frequency. This parameter can be a value of @ref FMC_SDRAM_Clock_Period. */ - + uint32_t ReadBurst; /*!< This bit enable the SDRAM controller to anticipate the next read commands during the CAS latency and stores data in the Read FIFO. This parameter can be a value of @ref FMC_SDRAM_Read_Burst. */ - + uint32_t ReadPipeDelay; /*!< Define the delay in system clock cycles on read data path. This parameter can be a value of @ref FMC_SDRAM_Read_Pipe_Delay. */ - }FMC_SDRAM_InitTypeDef; /** @@ -301,32 +295,31 @@ typedef struct uint32_t LoadToActiveDelay; /*!< Defines the delay between a Load Mode Register command and an active or Refresh command in number of memory clock cycles. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */ - + uint32_t ExitSelfRefreshDelay; /*!< Defines the delay from releasing the self refresh command to issuing the Activate command in number of memory clock cycles. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */ - + uint32_t SelfRefreshTime; /*!< Defines the minimum Self Refresh period in number of memory clock cycles. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */ - + uint32_t RowCycleDelay; /*!< Defines the delay between the Refresh command and the Activate command and the delay between two consecutive Refresh commands in number of memory clock cycles. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */ - + uint32_t WriteRecoveryTime; /*!< Defines the Write recovery Time in number of memory clock cycles. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */ - + uint32_t RPDelay; /*!< Defines the delay between a Precharge Command and an other command in number of memory clock cycles. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */ - + uint32_t RCDDelay; /*!< Defines the delay between the Activate Command and a Read/Write command in number of memory clock cycles. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */ - -}FMC_SDRAM_TimingTypeDef; +}FMC_SDRAM_TimingTypeDef; /** * @brief SDRAM command parameters structure definition @@ -334,25 +327,23 @@ typedef struct typedef struct { uint32_t CommandMode; /*!< Defines the command issued to the SDRAM device. - This parameter can be a value of @ref FMC_SDRAM_Command_Mode. */ - + This parameter can be a value of @ref FMC_SDRAM_Command_Mode. */ + uint32_t CommandTarget; /*!< Defines which device (1 or 2) the command will be issued to. - This parameter can be a value of @ref FMC_SDRAM_Command_Target. */ - + This parameter can be a value of @ref FMC_SDRAM_Command_Target. */ + uint32_t AutoRefreshNumber; /*!< Defines the number of consecutive auto refresh command issued in auto refresh mode. - This parameter can be a value between Min_Data = 1 and Max_Data = 16 */ - - uint32_t ModeRegisterDefinition; /*!< Defines the SDRAM Mode register content */ - + This parameter can be a value between Min_Data = 1 and Max_Data = 16 */ + uint32_t ModeRegisterDefinition; /*!< Defines the SDRAM Mode register content */ }FMC_SDRAM_CommandTypeDef; /* Exported constants --------------------------------------------------------*/ /** @defgroup FMC_NOR_SRAM_Controller * @{ - */ - + */ + /** @defgroup FMC_NORSRAM_Bank * @{ */ @@ -474,7 +465,7 @@ typedef struct #define FMC_WRITE_OPERATION_ENABLE ((uint32_t)0x00001000) #define IS_FMC_WRITE_OPERATION(OPERATION) (((OPERATION) == FMC_WRITE_OPERATION_DISABLE) || \ - ((OPERATION) == FMC_WRITE_OPERATION_ENABLE)) + ((OPERATION) == FMC_WRITE_OPERATION_ENABLE)) /** * @} */ @@ -630,7 +621,7 @@ typedef struct #define FMC_NAND_PCC_WAIT_FEATURE_ENABLE ((uint32_t)0x00000002) #define IS_FMC_WAIT_FEATURE(FEATURE) (((FEATURE) == FMC_NAND_PCC_WAIT_FEATURE_DISABLE) || \ - ((FEATURE) == FMC_NAND_PCC_WAIT_FEATURE_ENABLE)) + ((FEATURE) == FMC_NAND_PCC_WAIT_FEATURE_ENABLE)) /** * @} */ @@ -1131,16 +1122,16 @@ typedef struct * @retval None */ #define __FMC_NAND_ENABLE(__INSTANCE__, __BANK__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->PCR2 |= FMC_PCR2_PBKEN): \ - ((__INSTANCE__)->PCR3 |= FMC_PCR3_PBKEN)) + ((__INSTANCE__)->PCR3 |= FMC_PCR3_PBKEN)) /** * @brief Disable the NAND device access. * @param __INSTANCE__: FMC_NAND Instance * @param __BANK__: FMC_NAND Bank * @retval None - */ + */ #define __FMC_NAND_DISABLE(__INSTANCE__, __BANK__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->PCR2 &= ~FMC_PCR2_PBKEN): \ - ((__INSTANCE__)->PCR3 &= ~FMC_PCR3_PBKEN)) + ((__INSTANCE__)->PCR3 &= ~FMC_PCR3_PBKEN)) /** * @} */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.c index 21d5b75b07..70e1694fed 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_fsmc.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief FSMC Low Layer HAL module driver. * * This file provides firmware functions to manage the following diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.h index 62ff87be57..b48e21ba9e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_fsmc.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of FSMC HAL module. ****************************************************************************** * @attention @@ -62,69 +62,68 @@ #define FSMC_NAND_TypeDef FSMC_Bank2_3_TypeDef #define FSMC_PCCARD_TypeDef FSMC_Bank4_TypeDef -#define FSMC_NORSRAM_DEVICE FSMC_Bank1 -#define FSMC_NORSRAM_EXTENDED_DEVICE FSMC_Bank1E -#define FSMC_NAND_DEVICE FSMC_Bank2_3 -#define FSMC_PCCARD_DEVICE FSMC_Bank4 +#define FSMC_NORSRAM_DEVICE FSMC_Bank1 +#define FSMC_NORSRAM_EXTENDED_DEVICE FSMC_Bank1E +#define FSMC_NAND_DEVICE FSMC_Bank2_3 +#define FSMC_PCCARD_DEVICE FSMC_Bank4 /** - * @brief FSMC_NORSRAM Configuration Structure definition + * @brief FSMC_NORSRAM Configuration Structure definition */ typedef struct { uint32_t NSBank; /*!< Specifies the NORSRAM memory device that will be used. - This parameter can be a value of @ref FSMC_NORSRAM_Bank */ - + This parameter can be a value of @ref FSMC_NORSRAM_Bank */ + uint32_t DataAddressMux; /*!< Specifies whether the address and data values are multiplexed on the data bus or not. This parameter can be a value of @ref FSMC_Data_Address_Bus_Multiplexing */ - + uint32_t MemoryType; /*!< Specifies the type of external memory attached to the corresponding memory device. This parameter can be a value of @ref FSMC_Memory_Type */ - + uint32_t MemoryDataWidth; /*!< Specifies the external memory device width. This parameter can be a value of @ref FSMC_NORSRAM_Data_Width */ - + uint32_t BurstAccessMode; /*!< Enables or disables the burst access mode for Flash memory, valid only with synchronous burst Flash memories. This parameter can be a value of @ref FSMC_Burst_Access_Mode */ - + uint32_t WaitSignalPolarity; /*!< Specifies the wait signal polarity, valid only when accessing the Flash memory in burst mode. This parameter can be a value of @ref FSMC_Wait_Signal_Polarity */ - + uint32_t WrapMode; /*!< Enables or disables the Wrapped burst access mode for Flash memory, valid only when accessing Flash memories in burst mode. This parameter can be a value of @ref FSMC_Wrap_Mode */ - + uint32_t WaitSignalActive; /*!< Specifies if the wait signal is asserted by the memory one clock cycle before the wait state or during the wait state, valid only when accessing memories in burst mode. This parameter can be a value of @ref FSMC_Wait_Timing */ - + uint32_t WriteOperation; /*!< Enables or disables the write operation in the selected device by the FSMC. This parameter can be a value of @ref FSMC_Write_Operation */ - + uint32_t WaitSignal; /*!< Enables or disables the wait state insertion via wait signal, valid for Flash memory access in burst mode. This parameter can be a value of @ref FSMC_Wait_Signal */ - + uint32_t ExtendedMode; /*!< Enables or disables the extended mode. This parameter can be a value of @ref FSMC_Extended_Mode */ - + uint32_t AsynchronousWait; /*!< Enables or disables wait signal during asynchronous transfers, valid only with asynchronous Flash memories. This parameter can be a value of @ref FSMC_AsynchronousWait */ - + uint32_t WriteBurst; /*!< Enables or disables the write burst operation. - This parameter can be a value of @ref FSMC_Write_Burst */ + This parameter can be a value of @ref FSMC_Write_Burst */ }FSMC_NORSRAM_InitTypeDef; - /** - * @brief FSMC_NORSRAM Timing parameters structure definition + * @brief FSMC_NORSRAM Timing parameters structure definition */ typedef struct { @@ -132,28 +131,28 @@ typedef struct the duration of the address setup time. This parameter can be a value between Min_Data = 0 and Max_Data = 15. @note This parameter is not used with synchronous NOR Flash memories. */ - + uint32_t AddressHoldTime; /*!< Defines the number of HCLK cycles to configure the duration of the address hold time. This parameter can be a value between Min_Data = 1 and Max_Data = 15. @note This parameter is not used with synchronous NOR Flash memories. */ - + uint32_t DataSetupTime; /*!< Defines the number of HCLK cycles to configure the duration of the data setup time. This parameter can be a value between Min_Data = 1 and Max_Data = 255. @note This parameter is used for SRAMs, ROMs and asynchronous multiplexed NOR Flash memories. */ - + uint32_t BusTurnAroundDuration; /*!< Defines the number of HCLK cycles to configure the duration of the bus turnaround. This parameter can be a value between Min_Data = 0 and Max_Data = 15. @note This parameter is only used for multiplexed NOR Flash memories. */ - + uint32_t CLKDivision; /*!< Defines the period of CLK clock output signal, expressed in number of HCLK cycles. This parameter can be a value between Min_Data = 2 and Max_Data = 16. @note This parameter is not used for asynchronous NOR Flash, SRAM or ROM accesses. */ - + uint32_t DataLatency; /*!< Defines the number of memory clock cycles to issue to the memory before getting the first data. The parameter value depends on the memory type as shown below: @@ -161,40 +160,40 @@ typedef struct - It is don't care in asynchronous NOR, SRAM or ROM accesses - It may assume a value between Min_Data = 2 and Max_Data = 17 in NOR Flash memories with synchronous burst mode enable */ - + uint32_t AccessMode; /*!< Specifies the asynchronous access mode. This parameter can be a value of @ref FSMC_Access_Mode */ - + }FSMC_NORSRAM_TimingTypeDef; /** - * @brief FSMC_NAND Configuration Structure definition + * @brief FSMC_NAND Configuration Structure definition */ typedef struct { uint32_t NandBank; /*!< Specifies the NAND memory device that will be used. - This parameter can be a value of @ref FSMC_NAND_Bank */ - + This parameter can be a value of @ref FSMC_NAND_Bank */ + uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the NAND Memory device. This parameter can be any value of @ref FSMC_Wait_feature */ - + uint32_t MemoryDataWidth; /*!< Specifies the external memory device width. This parameter can be any value of @ref FSMC_NAND_Data_Width */ - + uint32_t EccComputation; /*!< Enables or disables the ECC computation. This parameter can be any value of @ref FSMC_ECC */ - + uint32_t ECCPageSize; /*!< Defines the page size for the extended ECC. This parameter can be any value of @ref FSMC_ECC_Page_Size */ - + uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the delay between CLE low and RE low. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */ - + uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the delay between ALE low and RE low. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - + }FSMC_NAND_InitTypeDef; /** @@ -207,45 +206,45 @@ typedef struct to common/Attribute or I/O memory space (depending on the memory space timing to be configured). This parameter can be a value between Min_Data = 0 and Max_Data = 255 */ - + uint32_t WaitSetupTime; /*!< Defines the minimum number of HCLK cycles to assert the command for NAND-Flash read or write access to common/Attribute or I/O memory space (depending on the memory space timing to be configured). This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - + uint32_t HoldSetupTime; /*!< Defines the number of HCLK clock cycles to hold address (and data for write access) after the command de-assertion for NAND-Flash read or write access to common/Attribute or I/O memory space (depending on the memory space timing to be configured). This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - + uint32_t HiZSetupTime; /*!< Defines the number of HCLK clock cycles during which the data bus is kept in HiZ after the start of a NAND-Flash write access to common/Attribute or I/O memory space (depending on the memory space timing to be configured). This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - + }FSMC_NAND_PCC_TimingTypeDef; /** - * @brief FSMC_NAND Configuration Structure definition - */ + * @brief FSMC_NAND Configuration Structure definition + */ typedef struct { uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the PCCARD Memory device. This parameter can be any value of @ref FSMC_Wait_feature */ - + uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the delay between CLE low and RE low. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */ - + uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the delay between ALE low and RE low. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */ - -}FSMC_PCCARD_InitTypeDef; + +}FSMC_PCCARD_InitTypeDef; /* Exported constants --------------------------------------------------------*/ @@ -379,7 +378,7 @@ typedef struct #define FSMC_WRITE_OPERATION_ENABLE ((uint32_t)0x00001000) #define IS_FSMC_WRITE_OPERATION(OPERATION) (((OPERATION) == FSMC_WRITE_OPERATION_DISABLE) || \ - ((OPERATION) == FSMC_WRITE_OPERATION_ENABLE)) + ((OPERATION) == FSMC_WRITE_OPERATION_ENABLE)) /** * @} */ @@ -542,7 +541,7 @@ typedef struct #define FSMC_NAND_PCC_WAIT_FEATURE_ENABLE ((uint32_t)0x00000002) #define IS_FSMC_WAIT_FEATURE(FEATURE) (((FEATURE) == FSMC_NAND_PCC_WAIT_FEATURE_DISABLE) || \ - ((FEATURE) == FSMC_NAND_PCC_WAIT_FEATURE_ENABLE)) + ((FEATURE) == FSMC_NAND_PCC_WAIT_FEATURE_ENABLE)) /** * @} */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.c index f06ceb8062..63e45ebf2f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_sdmmc.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief SDMMC Low Layer HAL module driver. * * This file provides firmware functions to manage the following diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.h index 8eaaecfe8b..bd89c41b31 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_sdmmc.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of SDMMC HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.c index cbad9541e9..6a0564b200 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_usb.c * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief USB Low Layer HAL module driver. * * This file provides firmware functions to manage the following diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.h index 97c41de1e5..2a7510df95 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_usb.h * @author MCD Application Team - * @version V1.0.0 - * @date 18-February-2014 + * @version V1.1.0RC2 + * @date 14-May-2014 * @brief Header file of USB Core HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.c index 463794abff..3897195bc4 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file system_stm32f4xx.c * @author MCD Application Team - * @version V2.0.0 - * @date 18-February-2014 + * @version V2.1.0RC2 + * @date 14-May-2014 * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. * * This file provides two functions and one global variable to be called from @@ -79,7 +79,16 @@ * @{ */ -#include "stm32f4xx_hal.h" +#include "stm32f4xx.h" +#include "hal_tick.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ /** * @} @@ -219,11 +228,16 @@ void SystemInit(void) #endif /* Configure the Cube driver */ + SystemCoreClock = 16000000; // At this stage the HSI is used as system clock HAL_Init(); /* Configure the System clock source, PLL Multiplier and Divider factors, AHB/APBx prescalers and Flash settings */ SetSysClock(); + + /* Reset the timer to avoid issues after the RAM initialization */ + TIM_MST_RESET_ON; + TIM_MST_RESET_OFF; } /** @@ -674,12 +688,6 @@ uint8_t SetSysClock_PLL_HSI(void) return 1; // OK } -/* Used for the different timeouts in the HAL */ -void SysTick_Handler(void) -{ - HAL_IncTick(); -} - /** * @} */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.h index e3a3b0d34a..af7e4497ad 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file system_stm32f4xx.h * @author MCD Application Team - * @version V2.0.0 - * @date 18-February-2014 + * @version V2.1.0RC2 + * @date 14-May-2014 * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. ****************************************************************************** * @attention @@ -32,8 +32,8 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - ****************************************************************************** - */ + ****************************************************************************** + */ /** @addtogroup CMSIS * @{ diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/analogin_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/analogin_api.c index def4d5129b..8ecbcb2770 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/analogin_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "clk_freqs.h" static const PinMap PinMap_ADC[] = { @@ -38,8 +38,7 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (ADCName)NC) - error("ADC pin mapping failed"); + MBED_ASSERT(obj->adc != (ADCName)NC); SIM->SCGC6 |= SIM_SCGC6_ADC0_MASK; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_api.c index 111340ba57..77a8d21cbc 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_api.c @@ -13,19 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, 1); return 1 << ((pin & 0x7F) >> 2); } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) + obj->pin = pin; + if (pin == (PinName)NC) return; - obj->pin = pin; obj->mask = gpio_set(pin); unsigned int port = (unsigned int)pin >> PORT_SHIFT; @@ -42,6 +44,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { case PIN_INPUT : *obj->reg_dir &= ~obj->mask; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_object.h b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_object.h index 58c9d4b096..ca2c0d64f8 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } else { @@ -39,6 +42,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c index d6d476d6f0..b2801bbd7c 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "clk_freqs.h" static const PinMap PinMap_I2C_SDA[] = { @@ -54,8 +54,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2C_Type*)pinmap_merge(i2c_sda, i2c_scl); - if ((int)obj->i2c == NC) - error("I2C pin mapping failed"); + MBED_ASSERT((int)obj->i2c != NC); SIM->SCGC4 |= SIM_SCGC4_I2C0_MASK; SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pinmap.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pinmap.c index 9adef24d09..89f83c2cd9 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pinmap.c @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" -#include "error.h" void pin_function(PinName pin, int function) { - if (pin == (PinName)NC) - return; + MBED_ASSERT(pin != (PinName)NC); uint32_t port_n = (uint32_t)pin >> PORT_SHIFT; uint32_t pin_n = (uint32_t)(pin & 0x7C) >> 2; @@ -31,8 +30,7 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (PinName)NC) { return; } - + MBED_ASSERT(pin != (PinName)NC); __IO uint32_t* pin_pcr = (__IO uint32_t*)(PORTA_BASE + pin); // pin pullup bits: [1:0] -> 11 = (0x3) diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c index 35b8901149..bc417ee900 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_PWM[] = { // LEDs @@ -53,8 +53,7 @@ static float pwm_clock = 0; void pwmout_init(pwmout_t* obj, PinName pin) { // determine the channel PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (PWMName)NC) - error("PwmOut pin mapping failed"); + MBED_ASSERT(pwm != (PWMName)NC); uint32_t clkdiv = 0; float clkval = SystemCoreClock / 1000000.0f; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/serial_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/serial_api.c index 7d61305f2f..075b587308 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/serial_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "serial_api.h" // math.h required for floating point operations for baud rate calculation @@ -22,7 +23,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_UART_TX[] = { {PTB17, UART_0, 3}, @@ -47,8 +47,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) - error("Serial pinout mapping failed"); + MBED_ASSERT((int)uart != NC); obj->uart = (UART_Type *)uart; // enable clk @@ -117,6 +116,9 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven)); + MBED_ASSERT((data_bits == 8) || (data_bits == 9)); // save C2 state uint32_t c2_state = (obj->uart->C2 & (UART_C2_RE_MASK | UART_C2_TE_MASK)); @@ -125,9 +127,6 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b obj->uart->C2 &= ~(UART_C2_RE_MASK | UART_C2_TE_MASK); // 8 data bits = 0 ... 9 data bits = 1 - if ((data_bits < 8) || (data_bits > 9)) - error("Invalid number of bits (%d) in serial format, should be 8..9", data_bits); - data_bits -= 8; uint32_t parity_enable, parity_select; @@ -136,22 +135,16 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityOdd : parity_enable = 1; parity_select = 1; data_bits++; break; case ParityEven: parity_enable = 1; parity_select = 0; data_bits++; break; default: - error("Invalid serial parity setting"); - return; + break; } - // 1 stop bits = 0, 2 stop bits = 1 - if ((stop_bits != 1) && (stop_bits != 2)) - error("Invalid stop bits specified"); stop_bits -= 1; uint32_t m10 = 0; - // 9 data bits + parity + // 9 data bits + parity - only uart0 support if (data_bits == 2) { - // only uart0 supports 10 bit communication - if (obj->index != 0) - error("Invalid number of bits (9) to be used with parity"); + MBED_ASSERT(obj->index == 0); data_bits = 0; m10 = 1; } diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/spi_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/spi_api.c index 2bc6691dfa..974da330e9 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/spi_api.c @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "spi_api.h" #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "clk_freqs.h" static const PinMap PinMap_SPI_SCLK[] = { @@ -56,9 +56,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl); - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); SIM->SCGC5 |= SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK; SIM->SCGC6 |= SIM_SCGC6_SPI0_MASK; @@ -90,13 +88,8 @@ void spi_free(spi_t *obj) { // [TODO] } void spi_format(spi_t *obj, int bits, int mode, int slave) { - if ((bits < 4) || (bits > 16)) - error("SPI: Only frames between 4 and 16-bit supported"); - - - if ((mode < 0) || (mode > 3)) { - error("SPI mode unsupported"); - } + MBED_ASSERT((bits > 4) || (bits < 16)); + MBED_ASSERT((mode >= 0) && (mode <= 3)); uint32_t polarity = (mode & 0x2) ? 1 : 0; uint32_t phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/spi_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/spi_api.c index f3e583bd8a..5f948a5d91 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/spi_api.c @@ -19,7 +19,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_SCLK[] = { {PTB0, SPI_0, 3}, @@ -51,9 +50,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl); - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -87,13 +84,8 @@ void spi_free(spi_t *obj) { // [TODO] } void spi_format(spi_t *obj, int bits, int mode, int slave) { - if (bits != 8) { - error("Only 8bits SPI supported"); - } - - if ((mode < 0) || (mode > 3)) { - error("SPI mode unsupported"); - } + MBED_ASSERT(bits == 8); + MBED_ASSERT((mode >= 0) && (mode <= 3)); uint8_t polarity = (mode & 0x2) ? 1 : 0; uint8_t phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/spi_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/spi_api.c index 67685819a2..e9f13ecbf1 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/spi_api.c @@ -19,7 +19,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "clk_freqs.h" #include "PeripheralPins.h" @@ -33,9 +32,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl); - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -67,13 +64,8 @@ void spi_free(spi_t *obj) { // [TODO] } void spi_format(spi_t *obj, int bits, int mode, int slave) { - if (bits != 8) { - error("Only 8bits SPI supported"); - } - - if ((mode < 0) || (mode > 3)) { - error("SPI mode unsupported"); - } + MBED_ASSERT(bits == 8); + MBED_ASSERT((mode >= 0) && (mode <= 3)); uint8_t polarity = (mode & 0x2) ? 1 : 0; uint8_t phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/spi_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/spi_api.c index ea09ebc9f6..f4b699e8d7 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/spi_api.c @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "spi_api.h" #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_SCLK[] = { {PTA15, SPI_0, 2}, @@ -90,9 +90,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl); - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -125,13 +123,8 @@ void spi_free(spi_t *obj) { // [TODO] } void spi_format(spi_t *obj, int bits, int mode, int slave) { - if ((bits != 8) && (bits != 16)) { - error("Only 8/16 bits SPI supported"); - } - - if ((mode < 0) || (mode > 3)) { - error("SPI mode unsupported"); - } + MBED_ASSERT((bits == 8) || (bits == 16)); + MBED_ASSERT((mode >= 0) && (mode <= 3)); uint8_t polarity = (mode & 0x2) ? 1 : 0; uint8_t phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogin_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogin_api.c index e4146cca27..4e3f52c35c 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogin_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "clk_freqs.h" #include "PeripheralPins.h" @@ -27,9 +27,7 @@ void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); SIM->SCGC6 |= SIM_SCGC6_ADC0_MASK; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogout_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogout_api.c index 31252fe8ac..f48c797d09 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/analogout_api.c @@ -13,21 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "PeripheralPins.h" #define RANGE_12BIT 0xFFF - void analogout_init(dac_t *obj, PinName pin) { obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); - if (obj->dac == (DACName)NC) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(obj->dac != (DACName)NC); SIM->SCGC6 |= SIM_SCGC6_DAC0_MASK; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_api.c index 8341b5d029..bb3556fe2c 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_api.c @@ -13,18 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, 1); return 1 << ((pin & 0x7F) >> 2); } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == (PinName)NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); unsigned int port = (unsigned int)pin >> PORT_SHIFT; @@ -41,8 +44,13 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_object.h b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/i2c_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/i2c_api.c index b0d80da6f9..44099d6b3d 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/i2c_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "clk_freqs.h" #include "PeripheralPins.h" @@ -43,9 +43,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2C_Type*)pinmap_merge(i2c_sda, i2c_scl); - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); // enable power switch ((int)obj->i2c) { diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pinmap.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pinmap.c index 9bb5c3f220..c67d237676 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pinmap.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" -#include "error.h" void pin_function(PinName pin, int function) { - if (pin == (PinName)NC) return; + MBED_ASSERT(pin != (PinName)NC); uint32_t port_n = (uint32_t)pin >> PORT_SHIFT; uint32_t pin_n = (uint32_t)(pin & 0x7C) >> 2; @@ -30,7 +30,7 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (PinName)NC) { return; } + MBED_ASSERT(pin != (PinName)NC); __IO uint32_t* pin_pcr = (__IO uint32_t*)(PORTA_BASE + pin); diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c index 2101758480..3a7be521da 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "clk_freqs.h" #include "PeripheralPins.h" @@ -26,9 +26,8 @@ static float pwm_clock; void pwmout_init(pwmout_t* obj, PinName pin) { // determine the channel PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (PWMName)NC) - error("PwmOut pin mapping failed"); - + MBED_ASSERT(pwm != (PWMName)NC); + uint32_t clkdiv = 0; float clkval; if (mcgpllfll_frequency()) { @@ -37,11 +36,11 @@ void pwmout_init(pwmout_t* obj, PinName pin) { } else { SIM->SOPT2 |= SIM_SOPT2_TPMSRC(2); // Clock source: ExtOsc clkval = extosc_frequency() / 1000000.0f; - } + } while (clkval > 1) { clkdiv++; - clkval /= 2.0; + clkval /= 2.0; if (clkdiv == 7) break; } diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/serial_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/serial_api.c index feaeb9f031..4945b7683d 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/serial_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "serial_api.h" // math.h required for floating point operations for baud rate calculation @@ -22,7 +23,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "clk_freqs.h" #include "PeripheralPins.h" @@ -61,9 +61,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)uart != NC); obj->uart = (UARTLP_Type *)uart; // enable clk @@ -150,17 +148,16 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven)); + MBED_ASSERT(data_bits == 8); // TODO: Support other number of data bits (also in the write method!) + // save C2 state uint8_t c2_state = (obj->uart->C2 & (UARTLP_C2_RE_MASK | UARTLP_C2_TE_MASK)); // Disable UART before changing registers obj->uart->C2 &= ~(UARTLP_C2_RE_MASK | UARTLP_C2_TE_MASK); - // TODO: Support other number of data bits (also in the write method!) - if ((data_bits < 8) || (data_bits > 8)) { - error("Invalid number of bits (%d) in serial format, should be 8", data_bits); - } uint8_t parity_enable, parity_select; switch (parity) { @@ -168,14 +165,9 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityOdd : parity_enable = 1; parity_select = 1; data_bits++; break; case ParityEven: parity_enable = 1; parity_select = 0; data_bits++; break; default: - error("Invalid serial parity setting"); - return; + break; } - // 1 stop bits = 0, 2 stop bits = 1 - if ((stop_bits != 1) && (stop_bits != 2)) { - error("Invalid stop bits specified"); - } stop_bits -= 1; // data bits, parity and parity mode @@ -290,7 +282,7 @@ void serial_pinout_tx(PinName tx) { } void serial_break_set(serial_t *obj) { - obj->uart->C2 |= UARTLP_C2_SBK_MASK; + obj->uart->C2 |= UARTLP_C2_SBK_MASK; } void serial_break_clear(serial_t *obj) { diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/analogin_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/analogin_api.c index 215deb6182..2e11e90118 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/analogin_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "PeripheralNames.h" #include "fsl_adc_hal.h" #include "fsl_clock_manager.h" @@ -49,9 +49,8 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); + uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT; clock_manager_set_gate(kClockModuleADC, instance, true); diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_api.c index ed2f1219b5..a789bb005b 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "fsl_port_hal.h" @@ -20,6 +21,7 @@ #include "fsl_sim_hal.h" uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); uint32_t pin_num = pin & 0xFF; pin_function(pin, (int)kPortMuxAsGpio); @@ -27,11 +29,10 @@ uint32_t gpio_set(PinName pin) { } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) { - return; - } - obj->pinName = pin; + if (pin == (PinName)NC) + return; + uint32_t port = pin >> GPIO_PORT_SHIFT; uint32_t pin_num = pin & 0xFF; clock_hal_set_gate(kSimClockModulePORT, port, true); @@ -43,6 +44,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pinName != (PinName)NC); uint32_t port = obj->pinName >> GPIO_PORT_SHIFT; uint32_t pin_num = obj->pinName & 0xFF; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_object.h b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_object.h index a1d3b611e9..723210e4ca 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/gpio_object.h @@ -16,6 +16,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "fsl_gpio_hal.h" #ifdef __cplusplus @@ -27,6 +28,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pinName != (PinName)NC); uint32_t port = obj->pinName >> GPIO_PORT_SHIFT; uint32_t pin = obj->pinName & 0xFF; @@ -34,6 +36,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pinName != (PinName)NC); uint32_t port = obj->pinName >> GPIO_PORT_SHIFT; uint32_t pin = obj->pinName & 0xFF; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c index 7d8e7f8da5..60b2f81cc2 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "fsl_clock_manager.h" #include "fsl_i2c_hal.h" #include "fsl_port_hal.h" @@ -50,9 +50,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { uint32_t i2c_sda = pinmap_peripheral(sda, PinMap_I2C_SDA); uint32_t i2c_scl = pinmap_peripheral(scl, PinMap_I2C_SCL); obj->instance = pinmap_merge(i2c_sda, i2c_scl); - if ((int)obj->instance == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->instance != NC); clock_manager_set_gate(kClockModuleI2C, obj->instance, true); clock_manager_set_gate(kClockModulePORT, sda >> GPIO_PORT_SHIFT, true); diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pinmap.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pinmap.c index f03db67a9f..ecd34ee9eb 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pinmap.c @@ -13,25 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" #include "fsl_clock_manager.h" #include "fsl_port_hal.h" void pin_function(PinName pin, int function) { - if (pin == (PinName)NC) { - return; - } - + MBED_ASSERT(pin != (PinName)NC); clock_manager_set_gate(kClockModulePORT, pin >> GPIO_PORT_SHIFT, true); port_hal_mux_control(pin >> GPIO_PORT_SHIFT, pin & 0xFF, (port_mux_t)function); } void pin_mode(PinName pin, PinMode mode) { - if (pin == (PinName)NC) { - return; - } - + MBED_ASSERT(pin != (PinName)NC); uint32_t instance = pin >> GPIO_PORT_SHIFT; uint32_t pinName = pin & 0xFF; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pwmout_api.c index 6d7244cfe2..a4d102ae7a 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pwmout_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "fsl_ftm_hal.h" #include "fsl_mcg_hal.h" #include "fsl_clock_manager.h" @@ -73,9 +73,8 @@ static float pwm_clock_mhz; void pwmout_init(pwmout_t* obj, PinName pin) { PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (PWMName)NC) { - error("PwmOut pin mapping failed"); - } + MBED_ASSERT(pwm != (PWMName)NC); + obj->pwm_name = pwm; uint32_t pwm_base_clock; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/serial_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/serial_api.c index ec2dc689bd..463b57bf1a 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/serial_api.c @@ -17,12 +17,12 @@ // math.h required for floating point operations for baud rate calculation #include +#include "mbed_assert.h" #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "fsl_uart_hal.h" #include "fsl_clock_manager.h" #include "fsl_uart_features.h" @@ -85,9 +85,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { uint32_t uart_tx = pinmap_peripheral(tx, PinMap_UART_TX); uint32_t uart_rx = pinmap_peripheral(rx, PinMap_UART_RX); obj->index = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)obj->index == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)obj->index != NC); uart_config_t uart_config; uart_config.baudRate = 9600; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/spi_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/spi_api.c index 78a94f47e1..1d7b88594f 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/spi_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "spi_api.h" - #include +#include "mbed_assert.h" +#include "spi_api.h" #include "cmsis.h" #include "pinmap.h" #include "error.h" @@ -93,9 +93,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel uint32_t spi_cntl = pinmap_merge(spi_sclk, spi_ssel); obj->instance = pinmap_merge(spi_data, spi_cntl); - if ((int)obj->instance == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->instance != NC); // enable power and clocking clock_manager_set_gate(kClockModuleSPI, obj->instance, true); diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/enet/src/fsl_enet_irq.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/enet/src/fsl_enet_irq.c index c7f5db2eaf..f2aba40637 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/enet/src/fsl_enet_irq.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/enet/src/fsl_enet_irq.c @@ -33,7 +33,7 @@ /******************************************************************************* * Variables ******************************************************************************/ -extern void *enetIfHandle; + /* Internal irq number*/ typedef enum _enet_irq_number @@ -81,24 +81,7 @@ uint8_t enetIntMap[kEnetIntNum] = /******************************************************************************* * Code ******************************************************************************/ -#if defined (K64F12_SERIES) || defined (K70F12_SERIES) -void ENET_Transmit_IRQHandler(void) -{ - enet_mac_tx_isr(enetIfHandle); -} - -void ENET_Receive_IRQHandler(void) -{ - enet_mac_rx_isr(enetIfHandle); -} - -#if FSL_FEATURE_ENET_SUPPORT_PTP -void ENET_1588_Timer_IRQHandler(void) -{ - enet_mac_ts_isr(enetIfHandle); -} -#endif -#endif +/* The code was moved to k64f mac file (eth) */ /******************************************************************************* * EOF diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/analogin_api.c index 45a1ab22b0..c0802c9675 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/analogin_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define ANALOGIN_MEDIAN_FILTER 1 #define ADC_10BIT_RANGE 0x3FF @@ -37,9 +37,7 @@ void analogin_init(analogin_t *obj, PinName pin) { const PinMap *map = PinMap_ADC; obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); //(NRF_ADC_Type *) - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); while (map->pin != NC) { if (map->pin == pin){ @@ -50,12 +48,12 @@ void analogin_init(analogin_t *obj, PinName pin) { } obj->adc_pin = (uint8_t)analogInputPin; - NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled; + NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled; NRF_ADC->CONFIG = (ADC_CONFIG_RES_10bit << ADC_CONFIG_RES_Pos) | (ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling<< ADC_CONFIG_INPSEL_Pos) | (ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling << ADC_CONFIG_REFSEL_Pos) | (analogInputPin << ADC_CONFIG_PSEL_Pos) | - (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos); + (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos); } uint16_t analogin_read_u16(analogin_t *obj) { diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_api.c index 9804d8748c..571b232ec5 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_api.c @@ -13,14 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; - obj->mask = (1ul<mask = (1ul << pin); obj->reg_set = &NRF_GPIO->OUTSET; obj->reg_clr = &NRF_GPIO->OUTCLR; @@ -33,20 +35,21 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { case PIN_INPUT : - NRF_GPIO->PIN_CNF[obj->pin] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + NRF_GPIO->PIN_CNF[obj->pin] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); - break; - case PIN_OUTPUT: - NRF_GPIO->PIN_CNF[obj->pin] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + break; + case PIN_OUTPUT: + NRF_GPIO->PIN_CNF[obj->pin] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); - break; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/i2c_api.c index c8a2a05ba4..f1c704272f 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/i2c_api.c @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" - - static const PinMap PinMap_I2C_SDA[] = { {p22, I2C_0, 1}, @@ -52,7 +50,7 @@ void twi_master_init(i2c_t *obj, PinName sda, PinName scl, int frequency) { (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)); obj->i2c->PSELSCL = scl; - obj->i2c->PSELSDA = sda; + obj->i2c->PSELSDA = sda; // set default frequency at 100k i2c_frequency(obj, frequency); i2c_interface_enable(obj); @@ -64,30 +62,28 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c = (I2CName)pinmap_merge(i2c_sda,i2c_scl); obj->i2c = (NRF_TWI_Type *)i2c; - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); obj->scl=scl; obj->sda=sda; obj->i2c->EVENTS_ERROR = 0; - obj->i2c->ENABLE = TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos; - obj->i2c->POWER = 0; + obj->i2c->ENABLE = TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos; + obj->i2c->POWER = 0; for(int i=0;i<100;i++){ } - obj->i2c->POWER = 1; + obj->i2c->POWER = 1; twi_master_init(obj,sda,scl,100000); } void i2c_reset(i2c_t *obj) { obj->i2c->EVENTS_ERROR = 0; - obj->i2c->ENABLE = TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos; - obj->i2c->POWER = 0; + obj->i2c->ENABLE = TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos; + obj->i2c->POWER = 0; for(int i=0;i<100;i++){ } - obj->i2c->POWER = 1; + obj->i2c->POWER = 1; twi_master_init(obj,obj->sda,obj->scl,obj->freq); } @@ -107,7 +103,7 @@ int i2c_stop(i2c_t *obj) { timeOut--; if(timeOut<0) return 1; - } + } addrSet = 0; i2c_reset(obj); return 0; @@ -122,7 +118,7 @@ int i2c_do_write(i2c_t *obj, int value) { if(timeOut<0) return 1; } - obj->i2c->EVENTS_TXDSENT = 0; + obj->i2c->EVENTS_TXDSENT = 0; return 0; } @@ -166,17 +162,17 @@ void i2c_frequency(i2c_t *obj, int hz) { } int checkError(i2c_t *obj){ - if (obj->i2c->EVENTS_ERROR == 1){ - if (obj->i2c->ERRORSRC & TWI_ERRORSRC_ANACK_Msk){ + if (obj->i2c->EVENTS_ERROR == 1){ + if (obj->i2c->ERRORSRC & TWI_ERRORSRC_ANACK_Msk){ obj->i2c->EVENTS_ERROR = 0; - obj->i2c->TASKS_STOP = 1; + obj->i2c->TASKS_STOP = 1; return I2C_ERROR_BUS_BUSY; } obj->i2c->EVENTS_ERROR = 0; obj->i2c->TASKS_STOP = 1; - return I2C_ERROR_NO_SLAVE; - } + return I2C_ERROR_NO_SLAVE; + } return 0; } @@ -190,7 +186,7 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { // Read in all except last byte for (count = 0; count < (length - 1); count++) { status = i2c_do_read(obj,&data[count], 0); - if (status) { + if (status) { errorResult = checkError(obj); i2c_reset(obj); if(errorResult<0){ @@ -211,7 +207,7 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { while(!obj->i2c->EVENTS_STOPPED){ } obj->i2c->EVENTS_STOPPED = 0; - } + } return length; } @@ -219,7 +215,7 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) { int status, errorResult; obj->i2c->ADDRESS = (address>>1); obj->i2c->SHORTS = 0; - obj->i2c->TASKS_STARTTX = 1; + obj->i2c->TASKS_STARTTX = 1; for (int i=0; ii2c->TASKS_STARTRX = 1; } else{ - obj->i2c->TASKS_STARTTX = 1; + obj->i2c->TASKS_STARTTX = 1; } } else{ diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/pinmap.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/pinmap.c index 2c63ac2fa3..3e5f230741 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/pinmap.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" @@ -20,10 +21,10 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (PinName)NC) { return; } + MBED_ASSERT(pin != (PinName)NC); uint32_t pin_number = (uint32_t)pin; NRF_GPIO->PIN_CNF[pin_number] &= ~GPIO_PIN_CNF_PULL_Msk; - NRF_GPIO->PIN_CNF[pin_number] |= (mode<PIN_CNF[pin_number] |= (mode << GPIO_PIN_CNF_PULL_Pos); } diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/pwmout_api.c index e457e1c311..e2c641ea25 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/pwmout_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" @@ -44,8 +45,8 @@ static const PinMap PinMap_PWM[] = { {p19, PWM_1, 1}, {p20, PWM_1, 1}, {p21, PWM_1, 1}, - {p22, PWM_1, 1}, - {p23, PWM_1, 1}, + {p22, PWM_1, 1}, + {p23, PWM_1, 1}, {p24, PWM_1, 1}, {p25, PWM_1, 1}, {p28, PWM_1, 1}, @@ -55,7 +56,7 @@ static const PinMap PinMap_PWM[] = { }; static NRF_TIMER_Type *Timers[1] = { - NRF_TIMER2 + NRF_TIMER2 }; uint16_t PERIOD = 20000/TIMER_PRECISION;//20ms @@ -200,9 +201,7 @@ void pwmout_init(pwmout_t* obj, PinName pin) { uint8_t pwmOutSuccess = 0; PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (PWMName)NC){ - error("PwmOut pin mapping failed"); - } + MBED_ASSERT(pwm != (PWMName)NC); if(PWM_taken[(uint8_t)pwm]){ for(uint8_t i = 1; !pwmOutSuccess && (i #include +#include "mbed_assert.h" #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" + /****************************************************************************** * INITIALIZATION ******************************************************************************/ @@ -65,14 +66,12 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)uart != NC); obj->uart = (NRF_UART_Type *)uart; - //pin configurations -- - //outputs + //pin configurations -- + //outputs NRF_GPIO->DIR |= (1<DIR |= (1<uart->BAUDRATE = UART_BAUDRATE_BAUDRATE_Baud1200; return; - } + } - for(int i=1;i<16;i++){ + for(int i=1;i<16;i++){ if(baudrateuart->BAUDRATE = acceptedSpeeds[i-1][1]; return; @@ -133,7 +132,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b // 0: 1 stop bits, 1: 2 stop bits // int parity_enable, parity_select; switch (parity) { - case ParityNone: + case ParityNone: obj->uart->CONFIG = 0; break; default: @@ -149,11 +148,11 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b static inline void uart_irq(uint32_t iir, uint32_t index) { SerialIrq irq_type; switch (iir) { - case 1: - irq_type = TxIrq; + case 1: + irq_type = TxIrq; break; - case 2: - irq_type = RxIrq; + case 2: + irq_type = RxIrq; break; default: return; @@ -165,7 +164,7 @@ static inline void uart_irq(uint32_t iir, uint32_t index) { } #ifdef __cplusplus extern "C" { -#endif +#endif void UART0_IRQHandler() { uint32_t irtype =0; @@ -180,7 +179,7 @@ void UART0_IRQHandler() } #ifdef __cplusplus } -#endif +#endif void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) { irq_handler = handler; serial_irq_ids[obj->index] = id; diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/spi_api.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/spi_api.c index c773fc2391..6a51a629c1 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/spi_api.c @@ -14,6 +14,7 @@ * limitations under the License. */ //#include +#include "mbed_assert.h" #include "spi_api.h" #include "cmsis.h" #include "pinmap.h" @@ -22,7 +23,7 @@ static const PinMap PinMap_SPI_SCLK[] = { {SPI_PSELSCK0 , SPI_0, 0x01}, {SPI_PSELSCK1, SPI_1, 0x02}, - {SPIS_PSELSCK, SPIS, 0x03}, + {SPIS_PSELSCK, SPIS, 0x03}, {NC , NC , 0} }; @@ -59,20 +60,18 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso); SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); SPIName spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - //SPIName + //SPIName if(ssel==NC){ obj->spi = (NRF_SPI_Type*)spi; obj->spis = (NRF_SPIS_Type*)NC; } else{ obj->spi = (NRF_SPI_Type*)NC; - obj->spis = (NRF_SPIS_Type*)spi; + obj->spis = (NRF_SPIS_Type*)spi; } - - if ((int)obj->spi == NC && (int)obj->spis == NC) { - error("SPI pinout mapping failed"); - } - // pin out the spi pins + MBED_ASSERT((int)obj->spi != NC && (int)obj->spis != NC); + + // pin out the spi pins if (ssel != NC) {//slave obj->spis->POWER=0; obj->spis->POWER=1; @@ -108,7 +107,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel obj->spis->MAXRX=SPIS_MESSAGE_SIZE; obj->spis->MAXTX=SPIS_MESSAGE_SIZE; obj->spis->TXDPTR = (uint32_t)&m_tx_buf[0]; - obj->spis->RXDPTR = (uint32_t)&m_rx_buf[0]; + obj->spis->RXDPTR = (uint32_t)&m_rx_buf[0]; obj->spis->SHORTS = (SPIS_SHORTS_END_ACQUIRE_Enabled<spi->POWER=0; obj->spi->POWER=1; - //NRF_GPIO->DIR |= (1<DIR |= (1<PIN_CNF[mosi] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) @@ -141,10 +140,10 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel obj->spi->PSELMISO = miso; - obj->spi->EVENTS_READY = 0U; + obj->spi->EVENTS_READY = 0U; spi_format(obj, 8, 0, 0); // 8 bits, mode 0, master - spi_frequency(obj, 1000000); + spi_frequency(obj, 1000000); } } @@ -197,10 +196,10 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { } //default to msb first if(slave){ - obj->spis->CONFIG = (config_mode | (SPI_CONFIG_ORDER_MsbFirst << SPI_CONFIG_ORDER_Pos) ); + obj->spis->CONFIG = (config_mode | (SPI_CONFIG_ORDER_MsbFirst << SPI_CONFIG_ORDER_Pos) ); } else{ - obj->spi->CONFIG = (config_mode | (SPI_CONFIG_ORDER_MsbFirst << SPI_CONFIG_ORDER_Pos) ); + obj->spi->CONFIG = (config_mode | (SPI_CONFIG_ORDER_MsbFirst << SPI_CONFIG_ORDER_Pos) ); } spi_enable(obj,slave); @@ -212,7 +211,7 @@ void spi_frequency(spi_t *obj, int hz) { spi_disable(obj,0); if(hz<250000) { //125Kbps - obj->spi->FREQUENCY = (uint32_t) SPI_FREQUENCY_FREQUENCY_K125; + obj->spi->FREQUENCY = (uint32_t) SPI_FREQUENCY_FREQUENCY_K125; } else if(hz<500000){//250Kbps obj->spi->FREQUENCY = (uint32_t) SPI_FREQUENCY_FREQUENCY_K250; @@ -230,7 +229,7 @@ void spi_frequency(spi_t *obj, int hz) { obj->spi->FREQUENCY = (uint32_t) SPI_FREQUENCY_FREQUENCY_M4; } else{//8Mbps - obj->spi->FREQUENCY = (uint32_t) SPI_FREQUENCY_FREQUENCY_M8; + obj->spi->FREQUENCY = (uint32_t) SPI_FREQUENCY_FREQUENCY_M8; } spi_enable(obj,0); @@ -260,7 +259,7 @@ int spi_master_write(spi_t *obj, int value) { return spi_read(obj); } -//static inline int spis_writeable(spi_t *obj) { +//static inline int spis_writeable(spi_t *obj) { // return (obj->spis->EVENTS_ACQUIRED==1); //} @@ -268,12 +267,12 @@ int spi_slave_receive(spi_t *obj) { return obj->spis->EVENTS_END; }; -int spi_slave_read(spi_t *obj) { +int spi_slave_read(spi_t *obj) { return m_rx_buf[0]; } -void spi_slave_write(spi_t *obj, int value) { - m_tx_buf[0]= value & 0xFF; +void spi_slave_write(spi_t *obj, int value) { + m_tx_buf[0]= value & 0xFF; obj->spis->TASKS_RELEASE=1; obj->spis->EVENTS_ACQUIRED=0; obj->spis->EVENTS_END=0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/analogin_api.c index 0930d0fe5a..14a980da5d 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/analogin_api.c @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" @@ -50,9 +50,8 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { volatile uint32_t tmp; obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (uint32_t)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); + pinmap_pinout(pin, PinMap_ADC); __IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + (pin & 0x1FF)); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_api.c index 50727713da..97863afb3c 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" @@ -26,6 +27,7 @@ static void gpio_enable(void) { } uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); if (!gpio_enabled) gpio_enable(); @@ -39,13 +41,14 @@ uint32_t gpio_set(PinName pin) { } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); unsigned int port = (unsigned int)(pin >> PORT_SHIFT); - + obj->reg_set = &LPC_GPIO_PORT->SET[port]; obj->reg_clr = &LPC_GPIO_PORT->CLR[port]; obj->reg_in = &LPC_GPIO_PORT->PIN[port]; @@ -57,8 +60,13 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/i2c_api.c index d1e771d334..718ef5ea0f 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/i2c_api.c @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #if DEVICE_I2C @@ -96,10 +95,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (LPC_I2C0_Type *)pinmap_merge(i2c_sda, i2c_scl); - - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); // enable power i2c_power_enable(obj); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/pinmap.c index d6628be206..366b2e8c8b 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/pinmap.c @@ -13,15 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" void pin_function(PinName pin, int function) { - if (pin == (uint32_t)NC) - { - return; - } - + MBED_ASSERT(pin != (PinName)NC); __IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + (pin & 0x1FF)); // pin function bits: [2:0] -> 111 = (0x7) @@ -29,11 +26,7 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (uint32_t)NC) - { - return; - } - + MBED_ASSERT(pin != (PinName)NC); if ((pin == P0_4) || (pin == P0_5)) { // The true open-drain pins PIO0_4 and PIO0_5 can be configured for different I2C-bus speeds. return; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/serial_api.c index 9e51e10653..dc9495ef82 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/serial_api.c @@ -15,6 +15,7 @@ */ // math.h required for floating point operations for baud rate calculation +#include "mbed_assert.h" #include #include #include @@ -22,7 +23,6 @@ #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #if DEVICE_SERIAL @@ -82,9 +82,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)uart != NC); switch (uart) { case UART_0: @@ -252,17 +250,14 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + stop_bits -= 1; - + if (obj->index == 0) { - // 0: 5 data bits ... 3: 8 data bits - if (data_bits < 5 || data_bits > 8) { - error("Invalid number of bits (%d) in serial format, should be 5..8", data_bits); - } + MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) || + (parity == ParityForced1) || (parity == ParityForced0)); data_bits -= 5; int parity_enable, parity_select; @@ -273,7 +268,6 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityForced1: parity_enable = 1; parity_select = 2; break; case ParityForced0: parity_enable = 1; parity_select = 3; break; default: - error("Invalid serial parity setting"); return; } @@ -284,18 +278,16 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b } else { // 0: 7 data bits ... 2: 9 data bits - if (data_bits < 7 || data_bits > 9) { - error("Invalid number of bits (%d) in serial format, should be 7..9", data_bits); - } + MBED_ASSERT((data_bits > 6) && (data_bits < 10)); + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven)); data_bits -= 7; - + int paritysel; switch (parity) { case ParityNone: paritysel = 0; break; case ParityEven: paritysel = 2; break; case ParityOdd : paritysel = 3; break; default: - error("Invalid serial parity setting"); return; } obj->mini_uart->CFG = (data_bits << 2) diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/spi_api.c index 4c01e37cfa..e6afbf19f3 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11U6X/spi_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include #include "spi_api.h" @@ -68,10 +69,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (LPC_SSP0_Type*)pinmap_merge(spi_data, spi_cntl); - - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -111,10 +109,7 @@ void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { ssp_disable(obj); - - if (!(bits >= 4 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } + MBED_ASSERT(((bits >= 4) && (bits <= 16)) || ((mode >= 0) && (mode <= 3))); int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.c index 9078d2c002..795f0dc476 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" @@ -46,9 +47,7 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Power up ADC LPC_SYSCON->PDRUNCFG &= ~ (1 << 4); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.c index 4ddf5dc943..8a5a55a5e0 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.c @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); int f = ((pin == P0_0) || (pin == P0_10) || (pin == P0_11) || @@ -31,9 +33,10 @@ uint32_t gpio_set(PinName pin) { } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); unsigned int port = (unsigned int)pin >> PORT_SHIFT; @@ -49,8 +52,13 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.c index 374751c331..04175a8e0c 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_I2C_SDA[] = { {P0_5, I2C_0, 1}, @@ -87,10 +87,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (LPC_I2C_Type *)pinmap_merge(i2c_sda, i2c_scl); - - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); // enable power i2c_power_enable(obj); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.c index d7a157a1df..e3b52e866b 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" @@ -20,27 +21,27 @@ #define LPC_IOCON1_BASE (LPC_IOCON_BASE + 0x60) void pin_function(PinName pin, int function) { + MBED_ASSERT(pin != (PinName)NC); if (pin == (PinName)NC) return; uint32_t pin_number = (uint32_t)pin; __IO uint32_t *reg = (pin_number < 32) ? - (__IO uint32_t*)(LPC_IOCON0_BASE + 4 * pin_number) : - (__IO uint32_t*)(LPC_IOCON1_BASE + 4 * (pin_number - 32)); + (__IO uint32_t*)(LPC_IOCON0_BASE + 4 * pin_number) : + (__IO uint32_t*)(LPC_IOCON1_BASE + 4 * (pin_number - 32)); // pin function bits: [2:0] -> 111 = (0x7) *reg = (*reg & ~0x7) | (function & 0x7); } void pin_mode(PinName pin, PinMode mode) { - if (pin == (PinName)NC) { return; } - + MBED_ASSERT(pin != (PinName)NC); uint32_t pin_number = (uint32_t)pin; uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2; __IO uint32_t *reg = (pin_number < 32) ? - (__IO uint32_t*)(LPC_IOCON0_BASE + 4 * pin_number) : - (__IO uint32_t*)(LPC_IOCON1_BASE + 4 * (pin_number - 32)); + (__IO uint32_t*)(LPC_IOCON0_BASE + 4 * pin_number) : + (__IO uint32_t*)(LPC_IOCON1_BASE + 4 * (pin_number - 32)); uint32_t tmp = *reg; // pin mode bits: [4:3] -> 11000 = (0x3 << 3) diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.c index 29ebdbe000..f69ff01b92 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define TCR_CNT_EN 0x00000001 #define TCR_RESET 0x00000002 @@ -69,9 +69,8 @@ static LPC_CTxxBx_Type *Timers[4] = { void pwmout_init(pwmout_t* obj, PinName pin) { // determine the channel PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (PWMName)NC) - error("PwmOut pin mapping failed"); - + MBED_ASSERT(pwm != (PWMName)NC); + obj->pwm = pwm; // Timer registers @@ -143,7 +142,7 @@ void pwmout_period_us(pwmout_t* obj, int us) { // for 16bit timer, set prescaler to avoid overflow if (timer == LPC_CT16B0 || timer == LPC_CT16B1) { - uint16_t high_period_ticks = period_ticks >> 16; + uint16_t high_period_ticks = period_ticks >> 16; timer->PR = high_period_ticks; period_ticks /= (high_period_ticks + 1); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.c index 123dd6af0d..96d66a16f0 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.c @@ -21,7 +21,6 @@ #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" /****************************************************************************** * INITIALIZATION @@ -55,10 +54,8 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } - + MBED_ASSERT((int)uart != NC); + obj->uart = (LPC_USART_Type *)uart; LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12); @@ -188,16 +185,12 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) || + (parity == ParityForced1) || (parity == ParityForced0)); + stop_bits -= 1; - - // 0: 5 data bits ... 3: 8 data bits - if (data_bits < 5 || data_bits > 8) { - error("Invalid number of bits (%d) in serial format, should be 5..8", data_bits); - } data_bits -= 5; int parity_enable, parity_select; @@ -208,8 +201,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityForced1: parity_enable = 1; parity_select = 2; break; case ParityForced0: parity_enable = 1; parity_select = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->LCR = data_bits << 0 diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.c index 1018d9c543..388d4b085a 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include #include "spi_api.h" #include "cmsis.h" @@ -62,10 +63,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (LPC_SSPx_Type*)pinmap_merge(spi_data, spi_cntl); - - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -104,12 +102,10 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { + MBED_ASSERT((bits >= 4 && bits <= 16) || (mode >= 0 && mode <= 3)); + ssp_disable(obj); - if (!(bits >= 4 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } - int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c index 108bf6ef67..1415ee456d 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c @@ -69,12 +69,12 @@ int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t LPC_CAN->IF1_ARB1 = BFN_PREP(id, CANIFn_ARB1_ID); LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_XTD | BFN_PREP(id >> 16, CANIFn_ARB2_ID); LPC_CAN->IF1_MSK1 = BFN_PREP(mask, CANIFn_MSK1_MSK); - LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MXTD | CANIFn_MSK2_MDIR | BFN_PREP(mask >> 16, CANIFn_MSK2_MSK); + LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MXTD /* | CANIFn_MSK2_MDIR */ | BFN_PREP(mask >> 16, CANIFn_MSK2_MSK); } else { // Mark message valid, Direction = TX, Set Identifier and mask everything LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | BFN_PREP(id << 2, CANIFn_ARB2_ID); - LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MDIR | BFN_PREP(mask << 2, CANIFn_MSK2_MSK); + LPC_CAN->IF1_MSK2 = /* CANIFn_MSK2_MDIR | */ BFN_PREP(mask << 2, CANIFn_MSK2_MSK); } // Use mask, single message object and set DLC @@ -286,16 +286,22 @@ int can_write(can_t *obj, CAN_Message msg, int cc) { // Make sure the interface is available while( LPC_CAN->IF1_CMDREQ & CANIFn_CMDREQ_BUSY ); + // Set the direction bit based on the message type + uint32_t direction = 0; + if (msg.type == CANData) { + direction = CANIFn_ARB2_DIR; + } + if(msg.format == CANExtended) { - // Mark message valid, Direction = TX, Extended Frame, Set Identifier and mask everything + // Mark message valid, Extended Frame, Set Identifier and mask everything LPC_CAN->IF1_ARB1 = BFN_PREP(msg.id, CANIFn_ARB1_ID); - LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_XTD | CANIFn_ARB2_DIR | BFN_PREP(msg.id >> 16, CANIFn_ARB2_ID); + LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_XTD | direction | BFN_PREP(msg.id >> 16, CANIFn_ARB2_ID); LPC_CAN->IF1_MSK1 = BFN_PREP(ID_EXT_MASK, CANIFn_MSK1_MSK); LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MXTD | CANIFn_MSK2_MDIR | BFN_PREP(ID_EXT_MASK >> 16, CANIFn_MSK2_MSK); } else { - // Mark message valid, Direction = TX, Set Identifier and mask everything - LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_DIR | BFN_PREP(msg.id << 2, CANIFn_ARB2_ID); + // Mark message valid, Set Identifier and mask everything + LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | direction | BFN_PREP(msg.id << 2, CANIFn_ARB2_ID); LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MDIR | BFN_PREP(ID_STD_MASK << 2, CANIFn_MSK2_MSK); } @@ -364,8 +370,13 @@ int can_read(can_t *obj, CAN_Message *msg, int handle) { msg->id = (LPC_CAN->IF2_ARB2 & CANIFn_ARB2_ID_MASK) >> 2; } - // TODO: Remote frame support - msg->type = CANData; + if (LPC_CAN->IF2_ARB2 & CANIFn_ARB2_DIR) { + msg->type = CANRemote; + } + else { + msg->type = CANData; + } + msg->len = BFN_GET(LPC_CAN->IF2_MCTRL, CANIFn_MCTRL_DLC); // TODO: If > 8, len = 8 msg->data[0] = BFN_GET(LPC_CAN->IF2_DA1, CANIFn_DA1_DATA0); msg->data[1] = BFN_GET(LPC_CAN->IF2_DA1, CANIFn_DA1_DATA1); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/analogin_api.c index 1d8610a420..96602bbce8 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/analogin_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" @@ -43,10 +44,7 @@ static inline int div_round_up(int x, int y) { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (uint32_t)NC) { - error("ADC pin mapping failed"); - return; - } + MBED_ASSERT(obj->adc != (uint32_t)NC); // Power up ADC LPC_SYSCON->PDRUNCFG &= ~ (1 << 4); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_api.c index e899331579..5875ca9e85 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "reserved_pins.h" @@ -20,24 +21,26 @@ static const PinName reserved_pins[] = TARGET_RESERVED_PINS; uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); // PIO default value of following ports are not same as others unsigned i; int f = 0; - for (i = 0; i < sizeof(reserved_pins) / sizeof(PinName); i ++) + for (i = 0; i < sizeof(reserved_pins) / sizeof(PinName); i ++) { if (pin == reserved_pins[i]) { f = 1; break; } - + } pin_function(pin, f); return ((pin & 0x0F00) >> 8); } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + LPC_GPIO_TypeDef *port_reg = ((LPC_GPIO_TypeDef *) (LPC_GPIO0_BASE + (((pin & 0xF000) >> PORT_SHIFT) * 0x10000))); obj->reg_mask_read = &port_reg->MASKED_ACCESS[1 << gpio_set(pin)]; @@ -50,9 +53,14 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); int pin_number = ((obj->pin & 0x0F00) >> 8); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~(1 << pin_number); break; - case PIN_OUTPUT: *obj->reg_dir |= (1 << pin_number); break; + case PIN_INPUT : + *obj->reg_dir &= ~(1 << pin_number); + break; + case PIN_OUTPUT: + *obj->reg_dir |= (1 << pin_number); + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_object.h index 2ece747074..2d93b59850 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -28,6 +30,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); uint32_t pin_number = ((obj->pin & 0x0F00) >> 8); if (value) *obj->reg_write |= (1 << pin_number); @@ -36,6 +39,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_mask_read) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/i2c_api.c index 9a58c8e93a..71b1925c02 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/i2c_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" @@ -87,10 +88,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (LPC_I2C_TypeDef *)pinmap_merge(i2c_sda, i2c_scl); - - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); // enable power i2c_power_enable(obj); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pinmap.c index 8006ca18f1..9c76cea99f 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pinmap.c @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" void pin_function(PinName pin, int function) { - if (pin == (uint32_t)NC) return; - + MBED_ASSERT(pin != (PinName)NC); uint32_t offset = (uint32_t)pin & 0xff; __IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + offset); @@ -27,10 +27,9 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (uint32_t)NC) { return; } - + MBED_ASSERT(pin != (PinName)NC); uint32_t offset = (uint32_t)pin & 0xff; - uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2; + uint32_t drain = ((uint32_t)mode & (uint32_t)OpenDrain) >> 2; __IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + offset); uint32_t tmp = *reg; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pwmout_api.c index 6fff9b67c1..4500af4610 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pwmout_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define TCR_CNT_EN 0x00000001 #define TCR_RESET 0x00000002 @@ -64,9 +64,8 @@ static LPC_TMR_TypeDef *Timers[3] = { void pwmout_init(pwmout_t* obj, PinName pin) { // determine the channel PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (uint32_t)NC) - error("PwmOut pin mapping failed"); - + MBED_ASSERT(pwm != (uint32_t)NC); + obj->pwm = pwm; // Timer registers diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/serial_api.c index 55bfc1a5a8..815f918ac5 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/serial_api.c @@ -14,6 +14,7 @@ * limitations under the License. */ // math.h required for floating point operations for baud rate calculation +#include "mbed_assert.h" #include #include #include @@ -21,7 +22,6 @@ #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" /****************************************************************************** * INITIALIZATION @@ -57,9 +57,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)uart != NC); obj->uart = (LPC_UART_TypeDef *)uart; LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12); @@ -183,16 +181,12 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) || + (parity == ParityForced1) || (parity == ParityForced0)); + stop_bits -= 1; - - // 0: 5 data bits ... 3: 8 data bits - if (data_bits < 5 || data_bits > 8) { - error("Invalid number of bits (%d) in serial format, should be 5..8", data_bits); - } data_bits -= 5; int parity_enable, parity_select; @@ -203,8 +197,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityForced1: parity_enable = 1; parity_select = 2; break; case ParityForced0: parity_enable = 1; parity_select = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->LCR = data_bits << 0 diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/spi_api.c index f7380b4ac0..a98dc182a1 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/spi_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include #include "spi_api.h" #include "cmsis.h" @@ -58,10 +59,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (LPC_SSP_TypeDef*)pinmap_merge(spi_data, spi_cntl); - - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -100,12 +98,9 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { + MBED_ASSERT((bits >= 4 && bits <= 16) || (mode >= 0 && mode <= 3)); ssp_disable(obj); - if (!(bits >= 4 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } - int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/analogin_api.c index 43a7a237a8..795f0dc476 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/analogin_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" @@ -46,9 +47,7 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (uint32_t)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Power up ADC LPC_SYSCON->PDRUNCFG &= ~ (1 << 4); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_api.c index fc1120afde..9300b42d04 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_api.c @@ -13,24 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" uint32_t gpio_set(PinName pin) { - int f = ((pin == P0_11) || - (pin == P0_12) || - (pin == P0_13) || - (pin == P0_14)) ? (1) : (0); - + MBED_ASSERT(pin != (PinName)NC); + int f = ((pin == P0_11) || (pin == P0_12) || + (pin == P0_13) || (pin == P0_14)) ? (1) : (0); pin_function(pin, f); - + return (1 << ((int)pin & 0x1F)); } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); unsigned int port = (unsigned int)pin >> PORT_SHIFT; @@ -46,8 +46,13 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/i2c_api.c index 374751c331..5b671a4eed 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/i2c_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" @@ -87,10 +88,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (LPC_I2C_Type *)pinmap_merge(i2c_sda, i2c_scl); - - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); // enable power i2c_power_enable(obj); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/pinmap.c index 4e2445c658..70003372c3 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/pinmap.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" @@ -20,7 +21,7 @@ #define LPC_IOCON1_BASE (LPC_IOCON_BASE + 0x60) void pin_function(PinName pin, int function) { - if (pin == (uint32_t)NC) return; + MBED_ASSERT(pin != (PinName)NC); uint32_t pin_number = (uint32_t)pin; @@ -33,7 +34,7 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (uint32_t)NC) { return; } + MBED_ASSERT(pin != (PinName)NC); uint32_t pin_number = (uint32_t)pin; uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/pwmout_api.c index 6019056f21..0d4fa92729 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/pwmout_api.c @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define TCR_CNT_EN 0x00000001 #define TCR_RESET 0x00000002 @@ -73,9 +71,8 @@ static unsigned int pwm_clock_mhz; void pwmout_init(pwmout_t* obj, PinName pin) { // determine the channel PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (uint32_t)NC) - error("PwmOut pin mapping failed"); - + MBED_ASSERT(pwm != (uint32_t)NC); + obj->pwm = pwm; // Timer registers diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/serial_api.c index 3b405a2c68..1e8da47b82 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/serial_api.c @@ -14,6 +14,7 @@ * limitations under the License. */ // math.h required for floating point operations for baud rate calculation +#include "mbed_assert.h" #include #include #include @@ -21,7 +22,6 @@ #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" /****************************************************************************** * INITIALIZATION @@ -55,9 +55,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)uart != NC); obj->uart = (LPC_USART_Type *)uart; LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12); @@ -186,16 +184,12 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) || + (parity == ParityForced1) || (parity == ParityForced0)); + stop_bits -= 1; - - // 0: 5 data bits ... 3: 8 data bits - if (data_bits < 5 || data_bits > 8) { - error("Invalid number of bits (%d) in serial format, should be 5..8", data_bits); - } data_bits -= 5; int parity_enable, parity_select; @@ -206,8 +200,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityForced1: parity_enable = 1; parity_select = 2; break; case ParityForced0: parity_enable = 1; parity_select = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->LCR = data_bits << 0 diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/spi_api.c index 1018d9c543..cacd5a2a66 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/spi_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include #include "spi_api.h" #include "cmsis.h" @@ -62,10 +63,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (LPC_SSPx_Type*)pinmap_merge(spi_data, spi_cntl); - - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -105,10 +103,7 @@ void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { ssp_disable(obj); - - if (!(bits >= 4 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } + MBED_ASSERT((bits >= 4 && bits <= 16) || (mode >= 0 && mode <= 3)); int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogin_api.c index 57e835e875..27964f4bfb 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogin_api.c @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define ANALOGIN_MEDIAN_FILTER 1 @@ -55,9 +54,8 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (uint32_t)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); + uint32_t port = (pin >> 5); // enable clock for GPIOx LPC_SYSCON->SYSAHBCLKCTRL0 |= (1UL << (14 + port)); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogout_api.c index e2c6acf9ef..5c9d57a1b8 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogout_api.c @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" void analogout_init(dac_t *obj, PinName pin) { - if (pin != P0_12) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(pin == P0_12); LPC_SYSCON->SYSAHBCLKCTRL0 |= (1 << 29); LPC_SYSCON->PDRUNCFG &= ~(1 << 12); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_api.c index f16536b1e6..624a4d76b5 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" @@ -26,7 +27,7 @@ static void gpio_enable(void) { } uint32_t gpio_set(PinName pin) { - + MBED_ASSERT(pin != (PinName)NC); if (!gpio_enabled) gpio_enable(); @@ -34,9 +35,10 @@ uint32_t gpio_set(PinName pin) { } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); unsigned int port = (unsigned int)(pin >> 5); @@ -52,8 +54,13 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_object.h index 8f8d5eb595..35ef92f18e 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,8 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); + if (value) *obj->reg_set = obj->mask; else @@ -38,6 +42,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c index 09d7ec6b55..1ad7d05f60 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static uint8_t repeated_start = 0; @@ -42,9 +41,7 @@ static inline void i2c_interface_enable(i2c_t *obj) { } void i2c_init(i2c_t *obj, PinName sda, PinName scl) { - if ((sda != P0_23) | (scl != P0_22)) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((sda == P0_23) || (scl == P0_22)); // Enables clock for I2C0 LPC_SYSCON->SYSAHBCLKCTRL1 |= (1 << 13); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pinmap.c index d39c6912dc..abc15268ad 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pinmap.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" @@ -20,7 +21,7 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (uint32_t)NC) { return; } + MBED_ASSERT(pin != (PinName)NC); if ((pin == P0_22) || (pin == P0_23)) { // The true open-drain pins PIO0_22 and PIO0_23 can be configured for different I2C-bus speeds. diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c index 2ebcf155ba..b64fdf6ec9 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" @@ -38,9 +38,8 @@ static int get_available_sct(void) { } void pwmout_init(pwmout_t* obj, PinName pin) { - if (pin == (uint32_t)NC) - error("PwmOut pin mapping failed"); - + MBED_ASSERT(pin != (uint32_t)NC); + int sct_n = get_available_sct(); if (sct_n == -1) { error("No available SCT"); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/serial_api.c index 462b765f63..944696e5d7 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/serial_api.c @@ -14,6 +14,7 @@ * limitations under the License. */ // math.h required for floating point operations for baud rate calculation +#include "mbed_assert.h" #include #include @@ -91,7 +92,7 @@ static void switch_pin(const SWM_Map *swm, PinName pn) for (int n = 0; n < sizeof(LPC_SWM->PINASSIGN)/sizeof(*LPC_SWM->PINASSIGN); n ++) { regVal = LPC_SWM->PINASSIGN[n]; for (int j = 0; j <= 24; j += 8) { - if (((regVal >> j) & 0xFF) == pn) + if (((regVal >> j) & 0xFF) == pn) regVal |= (0xFF << j); } LPC_SWM->PINASSIGN[n] = regVal; @@ -195,16 +196,11 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + MBED_ASSERT((data_bits > 6) && (data_bits < 10)); // 0: 7 data bits ... 2: 9 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityEven) || (parity == ParityOdd)); + stop_bits -= 1; - - // 0: 7 data bits ... 2: 9 data bits - if (data_bits < 7 || data_bits > 9) { - error("Invalid number of bits (%d) in serial format, should be 7..9", data_bits); - } data_bits -= 7; int paritysel; @@ -213,8 +209,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityEven: paritysel = 2; break; case ParityOdd : paritysel = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->CFG = (data_bits << 2) diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/spi_api.c index 10e03656da..774e347dc4 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/spi_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include #include "spi_api.h" @@ -126,10 +127,7 @@ void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { spi_disable(obj); - - if (!(bits >= 1 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } + MBED_ASSERT((bits >= 1 && bits <= 16) && (mode >= 0 && mode <= 3)); int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/PinNames.h new file mode 100644 index 0000000000..fce1161714 --- /dev/null +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/PinNames.h @@ -0,0 +1,138 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 MBED_PINNAMES_H +#define MBED_PINNAMES_H + +#include "cmsis.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + PIN_INPUT, + PIN_OUTPUT +} PinDirection; + +#define PORT_SHIFT 5 + +typedef enum { + // LPC Pin Names + P0_0 = LPC_GPIO0_BASE, + P0_1, P0_2, P0_3, P0_4, P0_5, P0_6, P0_7, P0_8, P0_9, P0_10, P0_11, P0_12, P0_13, P0_14, P0_15, P0_16, P0_17, P0_18, P0_19, P0_20, P0_21, P0_22, P0_23, P0_24, P0_25, P0_26, P0_27, P0_28, P0_29, P0_30, P0_31, + P1_0, P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7, P1_8, P1_9, P1_10, P1_11, P1_12, P1_13, P1_14, P1_15, P1_16, P1_17, P1_18, P1_19, P1_20, P1_21, P1_22, P1_23, P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31, + P2_0, P2_1, P2_2, P2_3, P2_4, P2_5, P2_6, P2_7, P2_8, P2_9, P2_10, P2_11, P2_12, P2_13, P2_14, P2_15, P2_16, P2_17, P2_18, P2_19, P2_20, P2_21, P2_22, P2_23, P2_24, P2_25, P2_26, P2_27, P2_28, P2_29, P2_30, P2_31, + P3_0, P3_1, P3_2, P3_3, P3_4, P3_5, P3_6, P3_7, P3_8, P3_9, P3_10, P3_11, P3_12, P3_13, P3_14, P3_15, P3_16, P3_17, P3_18, P3_19, P3_20, P3_21, P3_22, P3_23, P3_24, P3_25, P3_26, P3_27, P3_28, P3_29, P3_30, P3_31, + P4_0, P4_1, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7, P4_8, P4_9, P4_10, P4_11, P4_12, P4_13, P4_14, P4_15, P4_16, P4_17, P4_18, P4_19, P4_20, P4_21, P4_22, P4_23, P4_24, P4_25, P4_26, P4_27, P4_28, P4_29, P4_30, P4_31, + + // mbed DIP Pin Names + p5 = P0_9, + p6 = P0_8, + p7 = P0_7, + p8 = P0_6, + p9 = P0_0, + p10 = P0_1, + p11 = P0_18, + p12 = P0_17, + p13 = P0_15, + p14 = P0_16, + p15 = P0_23, + p16 = P0_24, + p17 = P0_25, + p18 = P0_26, + p19 = P1_30, + p20 = P1_31, + p21 = P2_5, + p22 = P2_4, + p23 = P2_3, + p24 = P2_2, + p25 = P2_1, + p26 = P2_0, + p27 = P0_11, + p28 = P0_10, + p29 = P0_5, + p30 = P0_4, + + // Other mbed Pin Names +#ifdef MCB1700 + LED1 = P1_28, + LED2 = P1_29, + LED3 = P1_31, + LED4 = P2_2, +#else + LED1 = P1_18, + LED2 = P1_20, + LED3 = P1_21, + LED4 = P1_23, +#endif + USBTX = P0_2, + USBRX = P0_3, + + // Arch Pro Pin Names + D0 = P4_29, + D1 = P4_28, + D2 = P0_4, + D3 = P0_5, + D4 = P2_2, + D5 = P2_3, + D6 = P2_4, + D7 = P2_5, + D8 = P0_0, + D9 = P0_1, + D10 = P0_6, + D11 = P0_9, + D12 = P0_8, + D13 = P0_7, + D14 = P0_27, + D15 = P0_28, + + A0 = P0_23, + A1 = P0_24, + A2 = P0_25, + A3 = P0_26, + A4 = P1_30, + A5 = P1_31, + + I2C_SCL = D15, + I2C_SDA = D14, + + // Not connected + NC = (int)0xFFFFFFFF +} PinName; + +typedef enum { + PullUp = 0, + PullDown = 3, + PullNone = 2, + OpenDrain = 4, + PullDefault = PullDown +} PinMode; + +// version of PINCON_TypeDef using register arrays +typedef struct { + __IO uint32_t PINSEL[11]; + uint32_t RESERVED0[5]; + __IO uint32_t PINMODE[10]; + __IO uint32_t PINMODE_OD[5]; +} PINCONARRAY_TypeDef; + +#define PINCONARRAY ((PINCONARRAY_TypeDef *)LPC_PINCON_BASE) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/device.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/device.h new file mode 100644 index 0000000000..a60f677905 --- /dev/null +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/device.h @@ -0,0 +1,60 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 MBED_DEVICE_H +#define MBED_DEVICE_H + +#define DEVICE_PORTIN 1 +#define DEVICE_PORTOUT 1 +#define DEVICE_PORTINOUT 1 + +#define DEVICE_INTERRUPTIN 1 + +#define DEVICE_ANALOGIN 1 +#define DEVICE_ANALOGOUT 1 + +#define DEVICE_SERIAL 1 +#define DEVICE_SERIAL_FC 1 + +#define DEVICE_I2C 1 +#define DEVICE_I2CSLAVE 1 + +#define DEVICE_SPI 1 +#define DEVICE_SPISLAVE 1 + +#define DEVICE_CAN 1 + +#define DEVICE_RTC 1 + +#define DEVICE_ETHERNET 1 + +#define DEVICE_PWMOUT 1 + +#define DEVICE_SEMIHOST 0 +#define DEVICE_LOCALFILESYSTEM 0 +#define DEVICE_ID_LENGTH 0 +#define DEVICE_MAC_OFFSET 0 + +#define DEVICE_SLEEP 1 + +#define DEVICE_DEBUG_AWARENESS 1 + +#define DEVICE_STDIO_MESSAGES 1 + +#define DEVICE_ERROR_PATTERN 1 + +#include "objects.h" + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/reserved_pins.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/reserved_pins.h new file mode 100644 index 0000000000..b392cd2f21 --- /dev/null +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/reserved_pins.h @@ -0,0 +1,8 @@ +// List of reserved pins for MBED LPC1768 + +#ifndef RESERVED_PINS_H +#define RESERVED_PINS_H + +#define TARGET_RESERVED_PINS {} + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/analogin_api.c index 982845b2c2..2015c0d43d 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/analogin_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define ANALOGIN_MEDIAN_FILTER 1 @@ -44,9 +44,7 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // ensure power is turned on LPC_SC->PCONP |= (1 << 12); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/analogout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/analogout_api.c index 103b644f17..ae64e8e179 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/analogout_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_DAC[] = { {P0_26, DAC_0, 2}, @@ -26,9 +26,7 @@ static const PinMap PinMap_DAC[] = { void analogout_init(dac_t *obj, PinName pin) { obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); - if (obj->dac == (DACName)NC) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(obj->dac != (DACName)NC); // power is on by default, set DAC clk divider is /4 LPC_SC->PCLKSEL0 &= ~(0x3 << 22); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/can_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/can_api.c index 35b62ba241..5aab445133 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/can_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/can_api.c @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "can_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include #include @@ -258,9 +258,7 @@ void can_init(can_t *obj, PinName rd, PinName td) { CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD); CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD); obj->dev = (LPC_CAN_TypeDef *)pinmap_merge(can_rd, can_td); - if ((int)obj->dev == NC) { - error("CAN pin mapping failed"); - } + MBED_ASSERT((int)obj->dev != NC); switch ((int)obj->dev) { case CAN_1: LPC_SC->PCONP |= 1 << 13; break; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_api.c index a3903a74fa..6a133b67aa 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_api.c @@ -13,21 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, 0); return (1 << ((int)pin & 0x1F)); } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); - - LPC_GPIO_TypeDef *port_reg = (LPC_GPIO_TypeDef *) ((int)pin & ~0x1F); + LPC_GPIO_TypeDef *port_reg = (LPC_GPIO_TypeDef *)((int)pin & ~0x1F); obj->reg_set = &port_reg->FIOSET; obj->reg_clr = &port_reg->FIOCLR; obj->reg_in = &port_reg->FIOPIN; @@ -39,8 +41,13 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c index 3a405016be..c7eea7cee7 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_I2C_SDA[] = { {P0_0 , I2C_1, 3}, @@ -96,10 +96,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (LPC_I2C_TypeDef *)pinmap_merge(i2c_sda, i2c_scl); - - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); // enable power i2c_power_enable(obj); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/pinmap.c index be017ce181..c5619a86bb 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/pinmap.c @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" void pin_function(PinName pin, int function) { - if (pin == (PinName)NC) return; - + MBED_ASSERT(pin != (PinName)NC); + uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0; int index = pin_number >> 4; int offset = (pin_number & 0xF) << 1; @@ -28,7 +29,7 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (PinName)NC) { return; } + MBED_ASSERT(pin != (PinName)NC); uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0; int index = pin_number >> 5; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/pwmout_api.c index b4e8bc6acf..b8e2050e1d 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/pwmout_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define TCR_CNT_EN 0x00000001 #define TCR_RESET 0x00000002 @@ -57,9 +57,8 @@ static unsigned int pwm_clock_mhz; void pwmout_init(pwmout_t* obj, PinName pin) { // determine the channel PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (PWMName)NC) - error("PwmOut pin mapping failed"); - + MBED_ASSERT(pwm != (PWMName)NC); + obj->pwm = pwm; obj->MR = PWM_MATCH[pwm]; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c index c9bbee6bf0..6c056730cc 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c @@ -14,6 +14,7 @@ * limitations under the License. */ // math.h required for floating point operations for baud rate calculation +#include "mbed_assert.h" #include #include #include @@ -21,7 +22,6 @@ #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "gpio_api.h" /****************************************************************************** @@ -89,9 +89,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)uart != NC); obj->uart = (LPC_UART_TypeDef *)uart; // enable power @@ -150,6 +148,7 @@ void serial_free(serial_t *obj) { // serial_baud // set the baud rate, taking in to account the current SystemFrequency void serial_baud(serial_t *obj, int baudrate) { + MBED_ASSERT((int)obj->uart <= UART_3); // The LPC2300 and LPC1700 have a divider and a fractional divider to control the // baud rate. The formula is: // @@ -165,7 +164,7 @@ void serial_baud(serial_t *obj, int baudrate) { case UART_1: LPC_SC->PCLKSEL0 &= ~(0x3 << 8); LPC_SC->PCLKSEL0 |= (0x1 << 8); break; case UART_2: LPC_SC->PCLKSEL1 &= ~(0x3 << 16); LPC_SC->PCLKSEL1 |= (0x1 << 16); break; case UART_3: LPC_SC->PCLKSEL1 &= ~(0x3 << 18); LPC_SC->PCLKSEL1 |= (0x1 << 18); break; - default: error("serial_baud"); break; + default: break; } uint32_t PCLK = SystemCoreClock; @@ -245,16 +244,12 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) || + (parity == ParityForced1) || (parity == ParityForced0)); + stop_bits -= 1; - - // 0: 5 data bits ... 3: 8 data bits - if (data_bits < 5 || data_bits > 8) { - error("Invalid number of bits (%d) in serial format, should be 5..8", data_bits); - } data_bits -= 5; int parity_enable, parity_select; @@ -265,8 +260,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityForced1: parity_enable = 1; parity_select = 2; break; case ParityForced0: parity_enable = 1; parity_select = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->LCR = data_bits << 0 diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/spi_api.c index f45254657c..27e9f1cf84 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/spi_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include #include "spi_api.h" @@ -64,9 +65,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso); SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (LPC_SSP_TypeDef*)pinmap_merge(spi_data, spi_cntl); - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -98,9 +97,7 @@ void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { ssp_disable(obj); - if (!(bits >= 4 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } + MBED_ASSERT(((bits >= 4) && (bits <= 16)) && (mode >= 0 && mode <= 3)); int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogin_api.c index 0958fbaf7a..4c3770e836 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogin_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define ANALOGIN_MEDIAN_FILTER 1 @@ -42,9 +42,7 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // ensure power is turned on LPC_SC->PCONP |= (1 << 12); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogout_api.c index 1cb557cead..66c77ceace 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogout_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_DAC[] = { {P0_26, DAC_0, 2}, @@ -25,9 +25,7 @@ static const PinMap PinMap_DAC[] = { void analogout_init(dac_t *obj, PinName pin) { obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); - if (obj->dac == (DACName)NC) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(obj->dac != (DACName)NC); // power is on by default, set DAC clk divider is /4 LPC_SC->PCLKSEL0 &= ~(0x3 << 22); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/can_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/can_api.c index f7ddf5278d..a3170acc1d 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/can_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/can_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "can_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include #include @@ -161,9 +161,7 @@ void can_init(can_t *obj, PinName rd, PinName td) { CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD); CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD); obj->dev = (LPC_CAN_TypeDef *)pinmap_merge(can_rd, can_td); - if ((int)obj->dev == NC) { - error("CAN pin mapping failed"); - } + MBED_ASSERT((int)obj->dev != NC); switch ((int)obj->dev) { case CAN_1: LPC_SC->PCONP |= 1 << 13; break; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_api.c index b0c5a383bf..10ac3664fc 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" @@ -25,8 +26,8 @@ uint32_t gpio_set(PinName pin) { } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; - + if (pin == (PinName)NC) + return; obj->pin = pin; obj->mask = gpio_set(pin); @@ -43,6 +44,8 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + if (obj->pin == (PinName)NC) + return; switch (direction) { case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/i2c_api.c index ecb6fb8756..f4bceb4969 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/i2c_api.c @@ -16,7 +16,6 @@ #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_I2C_SDA[] = { {P0_0 , I2C_1, 3}, @@ -96,10 +95,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (LPC_I2C_TypeDef *)pinmap_merge(i2c_sda, i2c_scl); - - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); // enable power i2c_power_enable(obj); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pinmap.c index 84173661c9..1c82ad78cc 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pinmap.c @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" void pin_function(PinName pin, int function) { - if (pin == (PinName)NC) return; + MBED_ASSERT(pin != (PinName)NC); uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0; int index = pin_number >> 4; @@ -28,15 +29,13 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (PinName)NC) { return; } - + MBED_ASSERT((pin != (PinName)NC) && (mode != OpenDrain)); + uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0; int index = pin_number >> 5; int offset = pin_number & 0x1F; uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2; - - if (mode == OpenDrain) error("OpenDrain not supported on LPC2368"); - + if (!drain) { index = pin_number >> 4; offset = (pin_number & 0xF) << 1; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pwmout_api.c index c6da85102d..3773d7e6b7 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pwmout_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define TCR_CNT_EN 0x00000001 #define TCR_RESET 0x00000002 @@ -57,9 +57,8 @@ static unsigned int pwm_clock_mhz; void pwmout_init(pwmout_t* obj, PinName pin) { // determine the channel PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (PWMName)NC) - error("PwmOut pin mapping failed"); - + MBED_ASSERT(pwm != (PWMName)NC); + obj->pwm = pwm; obj->MR = PWM_MATCH[pwm]; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/serial_api.c index a4a4b311fb..1e0faf79b0 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/serial_api.c @@ -14,6 +14,7 @@ * limitations under the License. */ // math.h required for floating point operations for baud rate calculation +#include "mbed_assert.h" #include #include #include @@ -21,7 +22,6 @@ #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" /****************************************************************************** * INITIALIZATION @@ -65,9 +65,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)uart != NC); obj->uart = (LPC_UART_TypeDef *)uart; // enable power @@ -123,6 +121,7 @@ void serial_free(serial_t *obj) { // serial_baud // set the baud rate, taking in to account the current SystemFrequency void serial_baud(serial_t *obj, int baudrate) { + MBED_ASSERT((int)obj->uart <= UART_3); // The LPC2300 and LPC1700 have a divider and a fractional divider to control the // baud rate. The formula is: // @@ -138,7 +137,7 @@ void serial_baud(serial_t *obj, int baudrate) { case UART_1: LPC_SC->PCLKSEL0 &= ~(0x3 << 8); LPC_SC->PCLKSEL0 |= (0x1 << 8); break; case UART_2: LPC_SC->PCLKSEL1 &= ~(0x3 << 16); LPC_SC->PCLKSEL1 |= (0x1 << 16); break; case UART_3: LPC_SC->PCLKSEL1 &= ~(0x3 << 18); LPC_SC->PCLKSEL1 |= (0x1 << 18); break; - default: error("serial_baud"); break; + default: break; } uint32_t PCLK = SystemCoreClock; @@ -218,16 +217,12 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) || + (parity == ParityForced1) || (parity == ParityForced0)); + stop_bits -= 1; - - // 0: 5 data bits ... 3: 8 data bits - if (data_bits < 5 || data_bits > 8) { - error("Invalid number of bits (%d) in serial format, should be 5..8", data_bits); - } data_bits -= 5; int parity_enable, parity_select; @@ -238,8 +233,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityForced1: parity_enable = 1; parity_select = 2; break; case ParityForced0: parity_enable = 1; parity_select = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->LCR = data_bits << 0 diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/spi_api.c index 82fef6a885..9247eedbda 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/spi_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include #include "spi_api.h" @@ -64,10 +65,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso); SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (LPC_SSP_TypeDef*)pinmap_merge(spi_data, spi_cntl); - - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -98,12 +96,9 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { + MBED_ASSERT(((bits >= 4) && (bits <= 16)) && ((mode >= 0) && (mode <= 3))); ssp_disable(obj); - if (!(bits >= 4 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } - int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/analogin_api.c index 04e28939c5..7681e3f568 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/analogin_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" @@ -43,9 +44,7 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // ensure power is turned on LPC_SC->PCONP |= (1 << 12); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/analogout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/analogout_api.c index e43cc25982..e694c2fcfb 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/analogout_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_DAC[] = { {P0_26, DAC_0, 2}, @@ -25,9 +25,7 @@ static const PinMap PinMap_DAC[] = { void analogout_init(dac_t *obj, PinName pin) { obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); - if (obj->dac == (DACName)NC) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(obj->dac != (DACName)NC); // DAC enable bit must be set LPC_IOCON->P0_26 |= (1 << 16); // DACEN diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c index 0ff86f93bf..49a2efa72c 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c @@ -17,7 +17,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include #include @@ -244,9 +243,7 @@ void can_init(can_t *obj, PinName rd, PinName td) { CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD); CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD); obj->dev = (LPC_CAN_TypeDef *)pinmap_merge(can_rd, can_td); - if ((int)obj->dev == NC) { - error("CAN pin mapping failed"); - } + MBED_ASSERT((int)obj->dev != NC); switch ((int)obj->dev) { case CAN_1: LPC_SC->PCONP |= 1 << 13; break; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_api.c index b855a42aac..5f2f3d4c2b 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_api.c @@ -13,18 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, 0); return (1 << ((int)pin & 0x1F)); } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); LPC_GPIO_TypeDef *port_reg = (LPC_GPIO_TypeDef *) ((int)(LPC_GPIO0_BASE+pin) & ~0x1F); @@ -40,8 +43,14 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); + switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/i2c_api.c index 5619a51435..eaa103a585 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/i2c_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_I2C_SDA[] = { {P0_0 , I2C_1, 3}, @@ -108,9 +108,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (LPC_I2C_TypeDef *)pinmap_merge(i2c_sda, i2c_scl); - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); // enable power i2c_power_enable(obj); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/pinmap.c index d2e277ba9e..e10e0eb034 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/pinmap.c @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" void pin_function(PinName pin, int function) { - if (pin == (PinName)NC) return; - + MBED_ASSERT(pin != (PinName)NC); __IO uint32_t *reg = (__IO uint32_t*) (LPC_IOCON_BASE + 4 * pin); // pin function bits: [2:0] -> 111 = (0x7) @@ -26,7 +26,7 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (PinName)NC) { return; } + MBED_ASSERT(pin != (PinName)NC); uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/pwmout_api.c index 296eef80f6..3f34e397f9 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/pwmout_api.c @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define TCR_CNT_EN 0x00000001 #define TCR_RESET 0x00000002 @@ -66,9 +66,8 @@ static unsigned int pwm_clock_mhz; void pwmout_init(pwmout_t* obj, PinName pin) { // determine the channel PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (PWMName)NC) - error("PwmOut pin mapping failed"); - + MBED_ASSERT(pwm != (PWMName)NC); + obj->channel = pwm; obj->pwm = LPC_PWM0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/serial_api.c index 26d01224b7..202df6d340 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/serial_api.c @@ -72,9 +72,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)uart != NC); obj->uart = (LPC_UART_TypeDef *)uart; // enable power @@ -209,16 +207,12 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) || + (parity == ParityForced1) || (parity == ParityForced0)); + stop_bits -= 1; - - // 0: 5 data bits ... 3: 8 data bits - if (data_bits < 5 || data_bits > 8) { - error("Invalid number of bits (%d) in serial format, should be 5..8", data_bits); - } data_bits -= 5; int parity_enable, parity_select; @@ -229,8 +223,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityForced1: parity_enable = 1; parity_select = 2; break; case ParityForced0: parity_enable = 1; parity_select = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->LCR = data_bits << 0 diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/spi_api.c index 1dd93555d9..3d790608a8 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/spi_api.c @@ -84,9 +84,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso); SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (LPC_SSP_TypeDef*)pinmap_merge(spi_data, spi_cntl); - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // enable power and clocking switch ((int)obj->spi) { @@ -118,12 +116,9 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { + MBED_ASSERT(((bits >= 4) && (bits <= 16)) && ((mode >= 0) && (mode <= 3))); ssp_disable(obj); - if (!(bits >= 4 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } - int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/analogin_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/analogin_api.c index 045c0e7c9a..ecbb19d218 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/analogin_api.c @@ -15,10 +15,10 @@ * * Ported to NXP LPC43XX by Micromint USA */ +#include "mbed_assert.h" #include "analogin_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define ANALOGIN_MEDIAN_FILTER 1 @@ -41,10 +41,7 @@ void analogin_init(analogin_t *obj, PinName pin) { uint8_t num, chan; obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (uint32_t)NC) { - error("ADC pin mapping failed"); - } - + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure the pin as GPIO input if (pin < SFP_AIO0) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/analogout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/analogout_api.c index 9a2dedaf00..c1e5eed469 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/analogout_api.c @@ -15,10 +15,10 @@ * * Ported to NXP LPC43XX by Micromint USA */ +#include "mbed_assert.h" #include "analogout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_DAC[] = { {P_DAC0 , DAC_0, 0x0}, @@ -27,9 +27,7 @@ static const PinMap PinMap_DAC[] = { void analogout_init(dac_t *obj, PinName pin) { obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); - if (obj->dac == (DACName)NC) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(obj->dac != (DACName)NC); // Configure the pin as GPIO input pin_function(pin, (SCU_PINIO_PULLNONE | 0x0)); diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c index 54fe0a28ca..878087e6fe 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c @@ -15,10 +15,12 @@ * * Ported to NXP LPC43XX by Micromint USA */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); int f = 0; unsigned int port = (unsigned int)MBED_GPIO_PORT(pin); @@ -29,9 +31,10 @@ uint32_t gpio_set(PinName pin) { } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); LPC_GPIO_T *port_reg = (LPC_GPIO_T *) (LPC_GPIO_PORT_BASE); @@ -48,8 +51,13 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/pinmap.c index f55ec37505..4f1b48a926 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/pinmap.c @@ -15,11 +15,12 @@ * * Ported to NXP LPC43XX by Micromint USA */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" void pin_function(PinName pin, int function) { - if (pin == (uint32_t)NC) return; + MBED_ASSERT(pin != (PinName)NC); __IO uint32_t *reg = (__IO uint32_t*) MBED_SCU_REG(pin); @@ -28,9 +29,7 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (uint32_t)NC) { return; } - - if (mode == OpenDrain) error("OpenDrain not supported on LPC43XX"); + MBED_ASSERT((pin != (PinName)NC) && (mode == OpenDrain)); __IO uint32_t *reg = (__IO uint32_t*) MBED_SCU_REG(pin); uint32_t tmp = *reg; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/serial_api.c index 6efec95413..f9b39262d6 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/serial_api.c @@ -192,16 +192,12 @@ void serial_baud(serial_t *obj, int baudrate) { } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) || + (parity == ParityForced1) || (parity == ParityForced0)); + stop_bits -= 1; - - // 0: 5 data bits ... 3: 8 data bits - if (data_bits < 5 || data_bits > 8) { - error("Invalid number of bits (%d) in serial format, should be 5..8", data_bits); - } data_bits -= 5; int parity_enable, parity_select; @@ -212,8 +208,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityForced1: parity_enable = 1; parity_select = 2; break; case ParityForced0: parity_enable = 1; parity_select = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->LCR = data_bits << 0 diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/spi_api.c index 9db8e12a31..cb25a5a039 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/spi_api.c @@ -15,6 +15,7 @@ * * Ported to NXP LPC43XX by Micromint USA */ +#include "mbed_assert.h" #include #include "spi_api.h" @@ -59,9 +60,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (LPC_SSP_T*)pinmap_merge(spi_data, spi_cntl); - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC); // set default format and frequency if (ssel == NC) { @@ -86,12 +85,9 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { + MBED_ASSERT(((bits >= 4) && (bits <= 16)) || ((mode >= 0) && (mode <= 3))); ssp_disable(obj); - if (!(bits >= 4 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } - int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_api.c index 631c92b887..2059675243 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" @@ -40,9 +41,10 @@ uint32_t gpio_set(PinName pin) { } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); obj->reg_set = &LPC_GPIO_PORT->SET0; @@ -56,8 +58,13 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_object.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_object.h index 8f8d5eb595..16af304736 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -31,6 +33,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -38,6 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/i2c_api.c index f6424724c8..c0de44279d 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/i2c_api.c @@ -16,7 +16,6 @@ #include "i2c_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const SWM_Map SWM_I2C_SDA[] = { {7, 24}, @@ -50,7 +49,7 @@ static inline void i2c_interface_enable(i2c_t *obj) { } static inline void i2c_power_enable(i2c_t *obj) { - LPC_SYSCON->SYSAHBCLKCTRL |= (1<<5); + LPC_SYSCON->SYSAHBCLKCTRL |= (1<<5); LPC_SYSCON->PRESETCTRL &= ~(0x1<<6); LPC_SYSCON->PRESETCTRL |= (0x1<<6); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/pinmap.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/pinmap.c index d8ac966d46..b75dfbe990 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/pinmap.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" @@ -30,8 +31,8 @@ void pin_function(PinName pin, int function) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (uint32_t)NC) { return; } - + MBED_ASSERT(pin != (PinName)NC); + if ((pin == 10) || (pin == 11)) { // True open-drain pins can be configured for different I2C-bus speeds return; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/serial_api.c index d71d91c52d..e6d8da2f7f 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/serial_api.c @@ -14,6 +14,7 @@ * limitations under the License. */ // math.h required for floating point operations for baud rate calculation +#include "mbed_assert.h" #include #include @@ -180,15 +181,10 @@ void serial_baud(serial_t *obj, int baudrate) { void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); + MBED_ASSERT((data_bits > 6) && (data_bits < 10)); // 0: 7 data bits ... 2: 9 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityEven) || (parity == ParityOdd)); stop_bits -= 1; - - // 0: 7 data bits ... 2: 9 data bits - if (data_bits < 7 || data_bits > 9) { - error("Invalid number of bits (%d) in serial format, should be 7..9", data_bits); - } data_bits -= 7; int paritysel; @@ -197,8 +193,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b case ParityEven: paritysel = 2; break; case ParityOdd : paritysel = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->CFG = (data_bits << 2) @@ -296,7 +291,7 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi uint32_t regVal_rts, regVal_cts; swm_rts = &SWM_UART_RTS[obj->index]; - swm_cts = &SWM_UART_CTS[obj->index]; + swm_cts = &SWM_UART_CTS[obj->index]; regVal_rts = LPC_SWM->PINASSIGN[swm_rts->n] & ~(0xFF << swm_rts->offset); regVal_cts = LPC_SWM->PINASSIGN[swm_cts->n] & ~(0xFF << swm_cts->offset); @@ -310,15 +305,15 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi LPC_SWM->PINASSIGN[swm_rts->n] = regVal_rts | (rxflow << swm_rts->offset); if (FlowControlRTS == type) { LPC_SWM->PINASSIGN[swm_cts->n] = regVal_cts | (0xFF << swm_cts->offset); - obj->uart->CFG &= ~CTSEN; + obj->uart->CFG &= ~CTSEN; } } if ((FlowControlCTS == type || FlowControlRTSCTS == type) && (txflow != NC)) { LPC_SWM->PINASSIGN[swm_cts->n] = regVal_cts | (txflow << swm_cts->offset); obj->uart->CFG |= CTSEN; if (FlowControlCTS == type) { - LPC_SWM->PINASSIGN[swm_rts->n] = regVal_rts | (0xFF << swm_rts->offset); + LPC_SWM->PINASSIGN[swm_rts->n] = regVal_rts | (0xFF << swm_rts->offset); } - } + } } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/spi_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/spi_api.c index 41eb3538e6..6634c57ac6 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/spi_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include #include "spi_api.h" @@ -115,13 +116,9 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { + MBED_ASSERT(((bits >= 1) && (bits <= 16)) && ((mode >= 0) && (mode <= 3))); ssp_disable(obj); - if (!(bits >= 1 && bits <= 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } - - int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/analogin_api.c index 82700338f4..fe5ed1007e 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/analogin_api.c @@ -25,6 +25,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "wait_api.h" @@ -32,7 +33,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA(GPIO_Mode_AN, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)}, // ADC_IN0 @@ -53,10 +53,7 @@ void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name (ADC_1, ADC_2...) from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); @@ -76,7 +73,7 @@ void analogin_init(analogin_t *obj, PinName pin) { // Configure ADC ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; - ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; + ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_TRGO; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_api.c index 443c99f57b..1457290315 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_api.c @@ -27,22 +27,24 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" extern uint32_t Set_GPIO_Clock(uint32_t port_idx); -uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; +uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); @@ -51,7 +53,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; @@ -63,6 +64,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_object.h index ac414c2162..4f35e2d29b 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } @@ -57,6 +59,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/i2c_api.c index 73b7f1ba68..41b4b9e123 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/i2c_api.c @@ -27,17 +27,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C #include "cmsis.h" #include "pinmap.h" -#include "error.h" /* Timeout values for flags and events waiting loops. These timeouts are - not based on accurate values, they just guarantee that the application will - not remain stuck if the I2C communication is corrupted. */ + not based on accurate values, they just guarantee that the application will + not remain stuck if the I2C communication is corrupted. */ #define FLAG_TIMEOUT ((int)0x1000) #define LONG_TIMEOUT ((int)0x8000) @@ -51,19 +51,16 @@ static const PinMap PinMap_I2C_SCL[] = { {NC, NC, 0} }; -void i2c_init(i2c_t *obj, PinName sda, PinName scl) { +void i2c_init(i2c_t *obj, PinName sda, PinName scl) { // Determine the I2C to use I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock - if (obj->i2c == I2C_1) { + if (obj->i2c == I2C_1) { RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE); } //if (obj->i2c == I2C_2) { @@ -80,10 +77,11 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { i2c_reset(obj); // I2C configuration - i2c_frequency(obj, 100000); // 100 kHz per default + i2c_frequency(obj, 100000); // 100 kHz per default } void i2c_frequency(i2c_t *obj, int hz) { + MBED_ASSERT((hz == 100000) || (hz == 200000) || (hz == 400000)); //"Only 100kHz, 200kHz and 400kHz I2C frequencies are supported." I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c); I2C_InitTypeDef I2C_InitStructure; uint32_t tim = 0; @@ -101,7 +99,6 @@ void i2c_frequency(i2c_t *obj, int hz) { tim = 0x0010020A; // Fast mode break; default: - error("Only 100kHz, 200kHz and 400kHz I2C frequencies are supported."); break; } @@ -212,7 +209,7 @@ int i2c_byte_read(i2c_t *obj, int last) { int timeout; // Wait until the byte is received - timeout = FLAG_TIMEOUT; + timeout = FLAG_TIMEOUT; while (I2C_GetFlagStatus(i2c, I2C_ISR_RXNE) == RESET) { timeout--; if (timeout == 0) { @@ -244,13 +241,13 @@ int i2c_byte_write(i2c_t *obj, int data) { } void i2c_reset(i2c_t *obj) { - if (obj->i2c == I2C_1) { + if (obj->i2c == I2C_1) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE); } //if (obj->i2c == I2C_2) { // RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, ENABLE); - // RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, DISABLE); + // RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, DISABLE); //} } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/pinmap.c index 3f2812695e..6a417b3c0b 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "device.h" #include "pinmap.h" #include "error.h" @@ -66,8 +67,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); uint32_t otype = STM_PIN_OTYPE(data); @@ -104,15 +104,14 @@ void pin_function(PinName pin, int data) { //} //if ((pin == PA_15) || (pin == PB_3) || (pin == PB_4)) { // - //} + //} } /** * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -122,7 +121,8 @@ void pin_mode(PinName pin, PinMode mode) { // Configure pull-up/pull-down resistors uint32_t pupd = (uint32_t)mode; - if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down + if (pupd > 2) + pupd = 0; // Open-drain = No pull-up/No pull-down gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2))); gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2)); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/serial_api.c index c1b6da02e0..930180e3b6 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/serial_api.c @@ -27,10 +27,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -71,24 +71,21 @@ static void init_usart(serial_t *obj) { USART_Cmd(usart, ENABLE); } -void serial_init(serial_t *obj, PinName tx, PinName rx) { +void serial_init(serial_t *obj, PinName tx, PinName rx) { // Determine the UART to use (UART_1, UART_2, ...) UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { - RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); + RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); } if (obj->uart == UART_2) { - RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); } // Configure the UART pins @@ -101,7 +98,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { obj->baudrate = 9600; obj->databits = USART_WordLength_8b; obj->stopbits = USART_StopBits_1; - obj->parity = USART_Parity_No; + obj->parity = USART_Parity_No; init_usart(obj); @@ -140,7 +137,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b obj->parity = USART_Parity_Odd; break; case ParityEven: - case ParityForced1: + case ParityForced1: obj->parity = USART_Parity_Even; break; default: // ParityNone @@ -206,7 +203,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { } else { // TxIrq USART_ITConfig(usart, USART_IT_TC, ENABLE); - } + } NVIC_SetVector(irq_n, vector); NVIC_EnableIRQ(irq_n); @@ -223,12 +220,12 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { else { // TxIrq USART_ITConfig(usart, USART_IT_TXE, DISABLE); // Check if RxIrq is disabled too - if ((usart->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1; + if ((usart->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1; } if (all_disabled) NVIC_DisableIRQ(irq_n); - } + } } /****************************************************************************** diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/spi_api.c index 42cbc4c897..7ca0493e9f 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_0)}, @@ -64,11 +64,11 @@ static void init_spi(spi_t *obj) { SPI_Cmd(spi, DISABLE); SPI_InitStructure.SPI_Mode = obj->mode; - SPI_InitStructure.SPI_NSS = obj->nss; - SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; + SPI_InitStructure.SPI_NSS = obj->nss; + SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_DataSize = obj->bits; SPI_InitStructure.SPI_CPOL = obj->cpol; - SPI_InitStructure.SPI_CPHA = obj->cpha; + SPI_InitStructure.SPI_CPHA = obj->cpha; SPI_InitStructure.SPI_BaudRatePrescaler = obj->br_presc; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; @@ -90,17 +90,14 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_1) { - RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); + RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); } if (obj->spi == SPI_2) { - RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); } // Configure the SPI pins @@ -132,7 +129,7 @@ void spi_free(spi_t *obj) { SPI_I2S_DeInit(spi); } -void spi_format(spi_t *obj, int bits, int mode, int slave) { +void spi_format(spi_t *obj, int bits, int mode, int slave) { // Save new values if (bits == 8) { obj->bits = SPI_DataSize_8b; @@ -152,11 +149,11 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { break; case 2: obj->cpol = SPI_CPOL_High; - obj->cpha = SPI_CPHA_1Edge; + obj->cpha = SPI_CPHA_1Edge; break; default: obj->cpol = SPI_CPOL_High; - obj->cpha = SPI_CPHA_2Edge; + obj->cpha = SPI_CPHA_2Edge; break; } @@ -166,7 +163,7 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { } else { obj->mode = SPI_Mode_Slave; - obj->nss = SPI_NSS_Hard; + obj->nss = SPI_NSS_Hard; } init_spi(obj); @@ -201,7 +198,7 @@ static inline int ssp_readable(spi_t *obj) { SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); // Check if data is received status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_RXNE) != RESET) ? 1 : 0); - return status; + return status; } static inline int ssp_writeable(spi_t *obj) { @@ -213,7 +210,7 @@ static inline int ssp_writeable(spi_t *obj) { } static inline void ssp_write(spi_t *obj, int value) { - SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); + SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); while (!ssp_writeable(obj)); if(obj->bits == SPI_DataSize_8b) // 8 bit mode SPI_SendData8(spi, (uint8_t)value); @@ -222,12 +219,12 @@ static inline void ssp_write(spi_t *obj, int value) { } static inline int ssp_read(spi_t *obj) { - SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); + SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); while (!ssp_readable(obj)); if(obj->bits == SPI_DataSize_8b) // 8 bit mode return (int)SPI_ReceiveData8(spi); else // 16 bit mode - return (int)SPI_I2S_ReceiveData16(spi); + return (int)SPI_I2S_ReceiveData16(spi); } static inline int ssp_busy(spi_t *obj) { @@ -250,16 +247,16 @@ int spi_slave_read(spi_t *obj) { SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); if(obj->bits == SPI_DataSize_8b) // 8 bit mode return (int)SPI_ReceiveData8(spi); - else - return (int)SPI_I2S_ReceiveData16(spi); + else + return (int)SPI_I2S_ReceiveData16(spi); } void spi_slave_write(spi_t *obj, int value) { - SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); - while (!ssp_writeable(obj)); + SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); + while (!ssp_writeable(obj)); if(obj->bits == SPI_DataSize_8b) // 8 bit mode SPI_SendData8(spi, (uint8_t)value); - else + else SPI_I2S_SendData16(spi, (uint16_t)value); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/analogin_api.c index 538a89fd24..b9e0a58db7 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/analogin_api.c @@ -25,6 +25,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "wait_api.h" @@ -32,7 +33,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA(GPIO_Mode_AIN, 0)}, @@ -53,10 +53,7 @@ void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name (ADC_1, ADC_2...) from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); @@ -91,7 +88,7 @@ void analogin_init(analogin_t *obj, PinName pin) { ADC_ResetCalibration(adc); while(ADC_GetResetCalibrationStatus(adc)); ADC_StartCalibration(adc); - while(ADC_GetCalibrationStatus(adc)); + while(ADC_GetCalibrationStatus(adc)); } } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_api.c index a9b81bce62..e2751f3b67 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_api.c @@ -27,22 +27,24 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" extern uint32_t Set_GPIO_Clock(uint32_t port_idx); -uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; +uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); @@ -51,7 +53,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; @@ -63,6 +64,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_Out_PP, 0)); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_object.h index 84f8eb4d32..d3142d5c71 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } @@ -57,6 +59,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/i2c_api.c index 9e12e30ce4..48d9467ca1 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/i2c_api.c @@ -27,17 +27,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C #include "cmsis.h" #include "pinmap.h" -#include "error.h" /* Timeout values for flags and events waiting loops. These timeouts are - not based on accurate values, they just guarantee that the application will - not remain stuck if the I2C communication is corrupted. */ + not based on accurate values, they just guarantee that the application will + not remain stuck if the I2C communication is corrupted. */ #define FLAG_TIMEOUT ((int)0x1000) #define LONG_TIMEOUT ((int)0x8000) @@ -51,19 +51,16 @@ static const PinMap PinMap_I2C_SCL[] = { {NC, NC, 0} }; -void i2c_init(i2c_t *obj, PinName sda, PinName scl) { +void i2c_init(i2c_t *obj, PinName sda, PinName scl) { // Determine the I2C to use I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock - if (obj->i2c == I2C_1) { + if (obj->i2c == I2C_1) { RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE); } if (obj->i2c == I2C_2) { @@ -80,7 +77,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { i2c_reset(obj); // I2C configuration - i2c_frequency(obj, 100000); // 100 kHz per default + i2c_frequency(obj, 100000); // 100 kHz per default } void i2c_frequency(i2c_t *obj, int hz) { @@ -110,7 +107,7 @@ inline int i2c_start(i2c_t *obj) { I2C_ClearFlag(i2c, I2C_FLAG_AF); // Clear Acknowledge failure flag // Generate the START condition - I2C_GenerateSTART(i2c, ENABLE); + I2C_GenerateSTART(i2c, ENABLE); // Wait the START condition has been correctly sent timeout = FLAG_TIMEOUT; @@ -155,7 +152,7 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { i2c_start(obj); // Send slave address for read - I2C_Send7bitAddress(i2c, address, I2C_Direction_Receiver); + I2C_Send7bitAddress(i2c, address, I2C_Direction_Receiver); // Wait address is acknowledged timeout = FLAG_TIMEOUT; @@ -264,7 +261,7 @@ int i2c_byte_write(i2c_t *obj, int data) { I2C_SendData(i2c, (uint8_t)data); // Wait until the byte is transmitted - timeout = FLAG_TIMEOUT; + timeout = FLAG_TIMEOUT; //while (I2C_CheckEvent(i2c, I2C_EVENT_MASTER_BYTE_TRANSMITTED) == ERROR) { while ((I2C_GetFlagStatus(i2c, I2C_FLAG_TXE) == RESET) && (I2C_GetFlagStatus(i2c, I2C_FLAG_BTF) == RESET)) { @@ -278,13 +275,13 @@ int i2c_byte_write(i2c_t *obj, int data) { } void i2c_reset(i2c_t *obj) { - if (obj->i2c == I2C_1) { + if (obj->i2c == I2C_1) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE); } if (obj->i2c == I2C_2) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, ENABLE); - RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, DISABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, DISABLE); } } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/pinmap.c index e82f85b1cc..57de90c400 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "device.h" #include "pinmap.h" #include "error.h" @@ -75,8 +76,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (input, output, alternate function or analog) + output speed + AF */ void pin_function(PinName pin, int data) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); uint32_t afnum = STM_PIN_AFNUM(data); @@ -111,17 +111,16 @@ void pin_function(PinName pin, int data) { } if ((pin == PA_15) || (pin == PB_3) || (pin == PB_4)) { GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); - } + } } /** * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { + MBED_ASSERT(pin != (PinName)NC); GPIO_InitTypeDef GPIO_InitStructure; - if (pin == NC) return; - uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -131,32 +130,31 @@ void pin_mode(PinName pin, PinMode mode) { // Configure open-drain and pull-up/down switch (mode) { - case PullNone: - return; - case PullUp: - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; - break; - case PullDown: - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; - break; - case OpenDrain: - if (pin_index < 8) { - if ((gpio->CRL & (0x03 << (pin_index * 4))) > 0) { // MODE bits = Output mode - gpio->CRL |= (0x04 << (pin_index * 4)); // Set open-drain + case PullNone: + return; + case PullUp: + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + break; + case PullDown: + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; + break; + case OpenDrain: + if (pin_index < 8) { + if ((gpio->CRL & (0x03 << (pin_index * 4))) > 0) { // MODE bits = Output mode + gpio->CRL |= (0x04 << (pin_index * 4)); // Set open-drain + } + } else { + if ((gpio->CRH & (0x03 << ((pin_index % 8) * 4))) > 0) { // MODE bits = Output mode + gpio->CRH |= (0x04 << ((pin_index % 8) * 4)); // Set open-drain + } } - } - else { - if ((gpio->CRH & (0x03 << ((pin_index % 8) * 4))) > 0) { // MODE bits = Output mode - gpio->CRH |= (0x04 << ((pin_index % 8) * 4)); // Set open-drain - } - } - return; - default: - break; + return; + default: + break; } // Configure GPIO GPIO_InitStructure.GPIO_Pin = (uint16_t)(1 << pin_index); GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(gpio, &GPIO_InitStructure); + GPIO_Init(gpio, &GPIO_InitStructure); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/pwmout_api.c index c009314f60..adfe65f386 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/pwmout_api.c @@ -27,11 +27,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_PWM[] = { // TIM2 full remap @@ -46,10 +46,7 @@ static const PinMap PinMap_PWM[] = { void pwmout_init(pwmout_t* obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - - if (obj->pwm == (PWMName)NC) { - error("PWM pinout mapping failed"); - } + MBED_ASSERT(obj->pwm != (PWMName)NC); // Enable TIM clock if (obj->pwm == PWM_2) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/serial_api.c index 45f774f0d6..7a9cbe8bd5 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/serial_api.c @@ -27,10 +27,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -73,21 +73,18 @@ static void init_usart(serial_t *obj) { USART_Cmd(usart, ENABLE); } -void serial_init(serial_t *obj, PinName tx, PinName rx) { +void serial_init(serial_t *obj, PinName tx, PinName rx) { // Determine the UART to use (UART_1, UART_2, ...) UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { - RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); + RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); } else if (obj->uart == UART_2 ) { RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); } else if (obj->uart == UART_3 ) { @@ -102,7 +99,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { obj->baudrate = 9600; obj->databits = USART_WordLength_8b; obj->stopbits = USART_StopBits_1; - obj->parity = USART_Parity_No; + obj->parity = USART_Parity_No; init_usart(obj); @@ -142,7 +139,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b obj->parity = USART_Parity_Odd; break; case ParityEven: - case ParityForced1: + case ParityForced1: obj->parity = USART_Parity_Even; break; default: // ParityNone @@ -214,7 +211,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { } else { // TxIrq USART_ITConfig(usart, USART_IT_TC, ENABLE); - } + } NVIC_SetVector(irq_n, vector); NVIC_EnableIRQ(irq_n); @@ -231,12 +228,12 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { else { // TxIrq USART_ITConfig(usart, USART_IT_TXE, DISABLE); // Check if RxIrq is disabled too - if ((usart->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1; + if ((usart->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1; } if (all_disabled) NVIC_DisableIRQ(irq_n); - } + } } /****************************************************************************** diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/spi_api.c index 735a895158..b2d53cd3e1 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, @@ -67,11 +67,11 @@ static void init_spi(spi_t *obj) { SPI_Cmd(spi, DISABLE); SPI_InitStructure.SPI_Mode = obj->mode; - SPI_InitStructure.SPI_NSS = obj->nss; - SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; + SPI_InitStructure.SPI_NSS = obj->nss; + SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_DataSize = obj->bits; SPI_InitStructure.SPI_CPOL = obj->cpol; - SPI_InitStructure.SPI_CPHA = obj->cpha; + SPI_InitStructure.SPI_CPHA = obj->cpha; SPI_InitStructure.SPI_BaudRatePrescaler = obj->br_presc; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; @@ -91,14 +91,11 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_1) { - RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); + RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); } // Configure the SPI pins @@ -130,7 +127,7 @@ void spi_free(spi_t *obj) { SPI_I2S_DeInit(spi); } -void spi_format(spi_t *obj, int bits, int mode, int slave) { +void spi_format(spi_t *obj, int bits, int mode, int slave) { // Save new values if (bits == 8) { obj->bits = SPI_DataSize_8b; @@ -150,11 +147,11 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { break; case 2: obj->cpol = SPI_CPOL_High; - obj->cpha = SPI_CPHA_1Edge; + obj->cpha = SPI_CPHA_1Edge; break; default: obj->cpol = SPI_CPOL_High; - obj->cpha = SPI_CPHA_2Edge; + obj->cpha = SPI_CPHA_2Edge; break; } @@ -164,7 +161,7 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { } else { obj->mode = SPI_Mode_Slave; - obj->nss = SPI_NSS_Hard; + obj->nss = SPI_NSS_Hard; } init_spi(obj); @@ -196,7 +193,7 @@ static inline int ssp_readable(spi_t *obj) { SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); // Check if data is received status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_RXNE) != RESET) ? 1 : 0); - return status; + return status; } static inline int ssp_writeable(spi_t *obj) { @@ -208,13 +205,13 @@ static inline int ssp_writeable(spi_t *obj) { } static inline void ssp_write(spi_t *obj, int value) { - SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); + SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); while (!ssp_writeable(obj)); SPI_I2S_SendData(spi, (uint16_t)value); } static inline int ssp_read(spi_t *obj) { - SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); + SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); while (!ssp_readable(obj)); return (int)SPI_I2S_ReceiveData(spi); } @@ -241,8 +238,8 @@ int spi_slave_read(spi_t *obj) { } void spi_slave_write(spi_t *obj, int value) { - SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); - while (!ssp_writeable(obj)); + SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); + while (!ssp_writeable(obj)); SPI_I2S_SendData(spi, (uint16_t)value); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/analogin_api.c index 071960ef8d..f95f160382 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/analogin_api.c @@ -25,6 +25,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "wait_api.h" @@ -32,7 +33,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA(GPIO_Mode_AN, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)}, // ADC_IN1 @@ -63,10 +63,7 @@ void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); @@ -168,7 +165,7 @@ static inline uint16_t adc_read(analogin_t *obj) { break; case PA_7: channel = ADC_Channel_15; - break; + break; default: return 0; } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_api.c index adcbf1f924..5b97612803 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_api.c @@ -27,31 +27,32 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" extern uint32_t Set_GPIO_Clock(uint32_t port_idx); -uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; +uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); - + // Enable GPIO clock uint32_t gpio_add = Set_GPIO_Clock(port_index); GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; - + // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; @@ -63,6 +64,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)); } else { // PIN_INPUT diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_object.h index 46fdf92515..75013b4188 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } else { @@ -56,6 +58,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/i2c_api.c index 2df1c5140e..30b1978e0d 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/i2c_api.c @@ -27,17 +27,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C #include "cmsis.h" #include "pinmap.h" -#include "error.h" /* Timeout values for flags and events waiting loops. These timeouts are - not based on accurate values, they just guarantee that the application will - not remain stuck if the I2C communication is corrupted. */ + not based on accurate values, they just guarantee that the application will + not remain stuck if the I2C communication is corrupted. */ #define FLAG_TIMEOUT ((int)0x1000) #define LONG_TIMEOUT ((int)0x8000) @@ -62,19 +62,16 @@ static const PinMap PinMap_I2C_SCL[] = { {NC, NC, 0} }; -void i2c_init(i2c_t *obj, PinName sda, PinName scl) { +void i2c_init(i2c_t *obj, PinName sda, PinName scl) { // Determine the I2C to use I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock - if (obj->i2c == I2C_1) { + if (obj->i2c == I2C_1) { RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE); } if (obj->i2c == I2C_2) { @@ -94,10 +91,11 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { i2c_reset(obj); // I2C configuration - i2c_frequency(obj, 100000); // 100 kHz per default + i2c_frequency(obj, 100000); // 100 kHz per default } void i2c_frequency(i2c_t *obj, int hz) { + MBED_ASSERT((hz == 100000) || (hz == 200000) || (hz == 400000) || (hz == 1000000)); I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c); I2C_InitTypeDef I2C_InitStructure; uint32_t tim; @@ -140,7 +138,6 @@ void i2c_frequency(i2c_t *obj, int hz) { } break; default: - error("Only 100kHz, 200kHz, 400kHz and 1MHz I2C frequencies are supported."); break; } @@ -252,7 +249,7 @@ int i2c_byte_read(i2c_t *obj, int last) { int timeout; // Wait until the byte is received - timeout = FLAG_TIMEOUT; + timeout = FLAG_TIMEOUT; while (I2C_GetFlagStatus(i2c, I2C_ISR_RXNE) == RESET) { timeout--; if (timeout == 0) { @@ -284,7 +281,7 @@ int i2c_byte_write(i2c_t *obj, int data) { } void i2c_reset(i2c_t *obj) { - if (obj->i2c == I2C_1) { + if (obj->i2c == I2C_1) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE); } @@ -294,7 +291,7 @@ void i2c_reset(i2c_t *obj) { } if (obj->i2c == I2C_3) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C3, ENABLE); - RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C3, DISABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C3, DISABLE); } } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/pinmap.c index 65addc0801..e59aade4b0 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "device.h" #include "pinmap.h" #include "error.h" @@ -71,7 +72,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); @@ -108,14 +109,14 @@ void pin_function(PinName pin, int data) { //} //if ((pin == PA_15) || (pin == PB_3) || (pin == PB_4)) { // - //} + //} } /** * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -126,7 +127,8 @@ void pin_mode(PinName pin, PinMode mode) { // Configure pull-up/pull-down resistors uint32_t pupd = (uint32_t)mode; - if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down + if (pupd > 2) + pupd = 0; // Open-drain = No pull-up/No pull-down gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2))); gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2)); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/pwmout_api.c index 11cf12d417..8a8a057d9a 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/pwmout_api.c @@ -27,11 +27,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" // TIM2 cannot be used because already used by the us_ticker static const PinMap PinMap_PWM[] = { @@ -85,13 +85,10 @@ static const PinMap PinMap_PWM[] = { {NC, NC, 0} }; -void pwmout_init(pwmout_t* obj, PinName pin) { +void pwmout_init(pwmout_t* obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - - if (obj->pwm == (PWMName)NC) { - error("PWM pinout mapping failed"); - } + MBED_ASSERT(obj->pwm != (PWMName)NC); // Enable TIM clock if (obj->pwm == PWM_1) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); @@ -126,7 +123,7 @@ void pwmout_write(pwmout_t* obj, float value) { obj->pulse = (uint32_t)((float)obj->period * value); - // Configure channels + // Configure channels TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_Pulse = obj->pulse; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; @@ -215,7 +212,7 @@ void pwmout_write(pwmout_t* obj, float value) { break; default: return; - } + } } float pwmout_read(pwmout_t* obj) { @@ -239,7 +236,7 @@ void pwmout_period_us(pwmout_t* obj, int us) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; float dc = pwmout_read(obj); - TIM_Cmd(tim, DISABLE); + TIM_Cmd(tim, DISABLE); obj->period = us; diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/serial_api.c index 2a7b487ca7..07be4d81e3 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/serial_api.c @@ -27,10 +27,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -85,27 +85,24 @@ static void init_usart(serial_t *obj) { USART_Cmd(usart, ENABLE); } -void serial_init(serial_t *obj, PinName tx, PinName rx) { +void serial_init(serial_t *obj, PinName tx, PinName rx) { // Determine the UART to use UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); // Get the peripheral name from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { - RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); + RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); } if (obj->uart == UART_2) { - RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); } if (obj->uart == UART_3) { - RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); } // Configure the UART pins @@ -118,7 +115,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { obj->baudrate = 9600; obj->databits = USART_WordLength_8b; obj->stopbits = USART_StopBits_1; - obj->parity = USART_Parity_No; + obj->parity = USART_Parity_No; init_usart(obj); @@ -157,7 +154,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b obj->parity = USART_Parity_Odd; break; case ParityEven: - case ParityForced1: + case ParityForced1: obj->parity = USART_Parity_Even; break; default: // ParityNone @@ -233,7 +230,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { USART_ITConfig(usart, USART_IT_RXNE, ENABLE); } else { // TxIrq USART_ITConfig(usart, USART_IT_TC, ENABLE); - } + } NVIC_SetVector(irq_n, vector); NVIC_EnableIRQ(irq_n); @@ -249,12 +246,12 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { } else { // TxIrq USART_ITConfig(usart, USART_IT_TXE, DISABLE); // Check if RxIrq is disabled too - if ((usart->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1; + if ((usart->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1; } if (all_disabled) NVIC_DisableIRQ(irq_n); - } + } } /****************************************************************************** diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/spi_api.c index 9ed17343eb..4729a03b19 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_11, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)}, @@ -75,17 +75,17 @@ static void init_spi(spi_t *obj) { SPI_Cmd(spi, DISABLE); SPI_InitStructure.SPI_Mode = obj->mode; - SPI_InitStructure.SPI_NSS = obj->nss; - SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; + SPI_InitStructure.SPI_NSS = obj->nss; + SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_DataSize = obj->bits; SPI_InitStructure.SPI_CPOL = obj->cpol; - SPI_InitStructure.SPI_CPHA = obj->cpha; + SPI_InitStructure.SPI_CPHA = obj->cpha; SPI_InitStructure.SPI_BaudRatePrescaler = obj->br_presc; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(spi, &SPI_InitStructure); - SPI_RxFIFOThresholdConfig(spi, SPI_RxFIFOThreshold_QF); + SPI_RxFIFOThresholdConfig(spi, SPI_RxFIFOThreshold_QF); SPI_Cmd(spi, ENABLE); } @@ -101,17 +101,14 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_2) { - RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); } if (obj->spi == SPI_3) { - RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE); } // Configure the SPI pins @@ -142,7 +139,7 @@ void spi_free(spi_t *obj) { SPI_I2S_DeInit(spi); } -void spi_format(spi_t *obj, int bits, int mode, int slave) { +void spi_format(spi_t *obj, int bits, int mode, int slave) { // Save new values if (bits == 8) { obj->bits = SPI_DataSize_8b; @@ -161,11 +158,11 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { break; case 2: obj->cpol = SPI_CPOL_High; - obj->cpha = SPI_CPHA_1Edge; + obj->cpha = SPI_CPHA_1Edge; break; default: obj->cpol = SPI_CPOL_High; - obj->cpha = SPI_CPHA_2Edge; + obj->cpha = SPI_CPHA_2Edge; break; } @@ -174,7 +171,7 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { obj->nss = SPI_NSS_Soft; } else { obj->mode = SPI_Mode_Slave; - obj->nss = SPI_NSS_Hard; + obj->nss = SPI_NSS_Hard; } init_spi(obj); @@ -207,7 +204,7 @@ static inline int ssp_readable(spi_t *obj) { SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); // Check if data is received status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_RXNE) != RESET) ? 1 : 0); - return status; + return status; } static inline int ssp_writeable(spi_t *obj) { @@ -219,7 +216,7 @@ static inline int ssp_writeable(spi_t *obj) { } static inline void ssp_write(spi_t *obj, int value) { - SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); + SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); while (!ssp_writeable(obj)); if (obj->bits == SPI_DataSize_8b) { SPI_SendData8(spi, (uint8_t)value); @@ -229,7 +226,7 @@ static inline void ssp_write(spi_t *obj, int value) { } static inline int ssp_read(spi_t *obj) { - SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); + SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); while (!ssp_readable(obj)); if (obj->bits == SPI_DataSize_8b) { return (int)SPI_ReceiveData8(spi); @@ -264,8 +261,8 @@ int spi_slave_read(spi_t *obj) { } void spi_slave_write(spi_t *obj, int value) { - SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); - while (!ssp_writeable(obj)); + SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); + while (!ssp_writeable(obj)); if (obj->bits == SPI_DataSize_8b) { SPI_SendData8(spi, (uint8_t)value); } else { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/analogin_api.c index 7273585439..2fb9135a07 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/analogin_api.c @@ -32,7 +32,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "stm32f4xx_hal.h" static const PinMap PinMap_ADC[] = { @@ -59,13 +58,10 @@ ADC_HandleTypeDef AdcHandle; int adc_inited = 0; -void analogin_init(analogin_t *obj, PinName pin) { +void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name (ADC_1, ADC_2...) from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC error: pinout mapping failed."); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); @@ -93,8 +89,8 @@ void analogin_init(analogin_t *obj, PinName pin) { AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; AdcHandle.Init.NbrOfConversion = 1; AdcHandle.Init.DMAContinuousRequests = DISABLE; - AdcHandle.Init.EOCSelection = DISABLE; - HAL_ADC_Init(&AdcHandle); + AdcHandle.Init.EOCSelection = DISABLE; + HAL_ADC_Init(&AdcHandle); } } @@ -120,7 +116,7 @@ static inline uint16_t adc_read(analogin_t *obj) { break; case PA_3: sConfig.Channel = ADC_CHANNEL_3; - break; + break; case PA_4: sConfig.Channel = ADC_CHANNEL_4; break; @@ -132,13 +128,13 @@ static inline uint16_t adc_read(analogin_t *obj) { break; case PA_7: sConfig.Channel = ADC_CHANNEL_7; - break; + break; case PB_0: sConfig.Channel = ADC_CHANNEL_8; break; case PB_1: sConfig.Channel = ADC_CHANNEL_9; - break; + break; case PC_0: sConfig.Channel = ADC_CHANNEL_10; break; @@ -156,7 +152,7 @@ static inline uint16_t adc_read(analogin_t *obj) { break; case PC_5: sConfig.Channel = ADC_CHANNEL_15; - break; + break; default: return 0; } @@ -168,7 +164,7 @@ static inline uint16_t adc_read(analogin_t *obj) { HAL_ADC_PollForConversion(&AdcHandle, 10); // Wait end of conversion if (HAL_ADC_GetState(&AdcHandle) == HAL_ADC_STATE_EOC_REG) - { + { return(HAL_ADC_GetValue(&AdcHandle)); // Get conversion value } else diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/gpio_api.c index 4dd63ed069..72fa34eebb 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/gpio_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" @@ -34,17 +35,17 @@ extern uint32_t Set_GPIO_Clock(uint32_t port_idx); -uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; +uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; - + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); // Enable GPIO clock @@ -52,7 +53,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRRL; @@ -64,6 +64,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(STM_MODE_OUTPUT_PP, GPIO_NOPULL, 0)); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/gpio_object.h index 15c1f77179..53d67abccd 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } @@ -57,6 +59,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/i2c_api.c index c478dc5552..3457b05344 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/i2c_api.c @@ -27,18 +27,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "stm32f4xx_hal.h" /* Timeout values for flags and events waiting loops. These timeouts are - not based on accurate values, they just guarantee that the application will - not remain stuck if the I2C communication is corrupted. */ + not based on accurate values, they just guarantee that the application will + not remain stuck if the I2C communication is corrupted. */ #define FLAG_TIMEOUT ((int)0x1000) #define LONG_TIMEOUT ((int)0x8000) @@ -65,19 +65,16 @@ static const PinMap PinMap_I2C_SCL[] = { I2C_HandleTypeDef I2cHandle; -void i2c_init(i2c_t *obj, PinName sda, PinName scl) { +void i2c_init(i2c_t *obj, PinName sda, PinName scl) { // Determine the I2C to use I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C error: pinout mapping failed."); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock - if (obj->i2c == I2C_1) { + if (obj->i2c == I2C_1) { __I2C1_CLK_ENABLE(); } if (obj->i2c == I2C_2) { @@ -97,27 +94,25 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { i2c_reset(obj); // I2C configuration - i2c_frequency(obj, 100000); // 100 kHz per default + i2c_frequency(obj, 100000); // 100 kHz per default } void i2c_frequency(i2c_t *obj, int hz) { + MBED_ASSERT((hz != 0) && (hz <= 400000)); I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c); - if ((hz != 0) && (hz <= 400000)) { - // I2C configuration - I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - I2cHandle.Init.ClockSpeed = hz; - I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; - I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_2; - I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; - I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; - I2cHandle.Init.OwnAddress1 = 0; - I2cHandle.Init.OwnAddress2 = 0; - HAL_I2C_Init(&I2cHandle); - } - else { - error("I2C error: frequency setting failed (max 400kHz)."); - } + + // I2C configuration + I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; + I2cHandle.Init.ClockSpeed = hz; + I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; + I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_2; + I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; + I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; + I2cHandle.Init.OwnAddress1 = 0; + I2cHandle.Init.OwnAddress2 = 0; + HAL_I2C_Init(&I2cHandle); + } inline int i2c_start(i2c_t *obj) { @@ -152,7 +147,7 @@ inline int i2c_stop(i2c_t *obj) { return 0; } -int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { +int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { if (length == 0) return 0; I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c); @@ -208,7 +203,7 @@ int i2c_byte_write(i2c_t *obj, int data) { i2c->DR = (uint8_t)data; // Wait until the byte is transmitted - timeout = FLAG_TIMEOUT; + timeout = FLAG_TIMEOUT; while ((__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_TXE) == RESET) && (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_BTF) == RESET)) { if ((timeout--) == 0) { @@ -220,7 +215,7 @@ int i2c_byte_write(i2c_t *obj, int data) { } void i2c_reset(i2c_t *obj) { - if (obj->i2c == I2C_1) { + if (obj->i2c == I2C_1) { __I2C1_FORCE_RESET(); __I2C1_RELEASE_RESET(); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pinmap.c index b88ddeda79..70deb55e4a 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "device.h" #include "pinmap.h" #include "error.h" @@ -74,7 +75,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { break; default: error("Pinmap error: wrong port number."); - break; + break; } return gpio_add; } @@ -83,8 +84,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); uint32_t pupd = STM_PIN_PUPD(data); @@ -113,15 +113,14 @@ void pin_function(PinName pin, int data) { //} //if ((pin == PA_15) || (pin == PB_3) || (pin == PB_4)) { // - //} + //} } /** * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -131,7 +130,8 @@ void pin_mode(PinName pin, PinMode mode) { // Configure pull-up/pull-down resistors uint32_t pupd = (uint32_t)mode; - if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down + if (pupd > 2) + pupd = 0; // Open-drain = No pull-up/No pull-down gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2))); gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2)); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pwmout_api.c index 7ebc9d4c51..230e4c2bef 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pwmout_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" @@ -87,11 +88,8 @@ static TIM_HandleTypeDef TimHandle; void pwmout_init(pwmout_t* obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - - if (obj->pwm == (PWMName)NC) { - error("PWM error: pinout mapping failed."); - } - + MBED_ASSERT(obj->pwm != (PWMName)NC); + // Enable TIM clock if (obj->pwm == PWM_1) __TIM1_CLK_ENABLE(); if (obj->pwm == PWM_2) __TIM2_CLK_ENABLE(); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/serial_api.c index 4495626de3..1ffd46a9df 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/serial_api.c @@ -30,7 +30,6 @@ #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include #include "stm32f4xx_hal.h" @@ -73,20 +72,17 @@ static void init_uart(serial_t *obj) { UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; UartHandle.Init.Mode = UART_MODE_TX_RX; - HAL_UART_Init(&UartHandle); + HAL_UART_Init(&UartHandle); } -void serial_init(serial_t *obj, PinName tx, PinName rx) { +void serial_init(serial_t *obj, PinName tx, PinName rx) { // Determine the UART to use (UART_1, UART_2, ...) UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial error: pinout mapping failed."); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { @@ -109,7 +105,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { obj->baudrate = 9600; obj->databits = UART_WORDLENGTH_8B; obj->stopbits = UART_STOPBITS_1; - obj->parity = UART_PARITY_NONE; + obj->parity = UART_PARITY_NONE; init_uart(obj); @@ -149,7 +145,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b obj->parity = UART_PARITY_ODD; break; case ParityEven: - case ParityForced1: + case ParityForced1: obj->parity = UART_PARITY_EVEN; break; default: // ParityNone @@ -225,7 +221,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { } else { // TxIrq __HAL_UART_ENABLE_IT(&UartHandle, UART_IT_TC); - } + } NVIC_SetVector(irq_n, vector); NVIC_EnableIRQ(irq_n); @@ -242,12 +238,12 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { else { // TxIrq __HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TXE); // Check if RxIrq is disabled too - if ((UartHandle.Instance->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1; + if ((UartHandle.Instance->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1; } if (all_disabled) NVIC_DisableIRQ(irq_n); - } + } } /****************************************************************************** diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/spi_api.c index 345ca66935..4d0303338f 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/spi_api.c @@ -34,7 +34,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "stm32f4xx_hal.h" static const PinMap PinMap_SPI_MOSI[] = { @@ -112,10 +111,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI error: pinout mapping failed."); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_1) { @@ -157,7 +153,7 @@ void spi_free(spi_t *obj) { HAL_SPI_DeInit(&SpiHandle); } -void spi_format(spi_t *obj, int bits, int mode, int slave) { +void spi_format(spi_t *obj, int bits, int mode, int slave) { // Save new values if (bits == 8) { obj->bits = SPI_DATASIZE_8BIT; @@ -177,11 +173,11 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { break; case 2: obj->cpol = SPI_POLARITY_HIGH; - obj->cpha = SPI_PHASE_1EDGE; + obj->cpha = SPI_PHASE_1EDGE; break; default: obj->cpol = SPI_POLARITY_HIGH; - obj->cpha = SPI_PHASE_2EDGE; + obj->cpha = SPI_PHASE_2EDGE; break; } @@ -191,7 +187,7 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { } else { obj->mode = SPI_MODE_SLAVE; - obj->nss = SPI_NSS_HARD_INPUT; + obj->nss = SPI_NSS_HARD_INPUT; } init_spi(obj); @@ -231,7 +227,7 @@ static inline int ssp_readable(spi_t *obj) { SpiHandle.Instance = (SPI_TypeDef *)(obj->spi); // Check if data is received status = ((__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_RXNE) != RESET) ? 1 : 0); - return status; + return status; } static inline int ssp_writeable(spi_t *obj) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/analogin_api.c index 51277bde0d..91701a8a5f 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/analogin_api.c @@ -25,6 +25,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #if DEVICE_ANALOGIN @@ -63,10 +64,7 @@ void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name (ADC_1, ADC_2...) from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_api.c index 5686e79d03..5b97612803 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" @@ -34,15 +35,16 @@ extern uint32_t Set_GPIO_Clock(uint32_t port_idx); uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); @@ -51,7 +53,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; @@ -63,6 +64,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)); } else { // PIN_INPUT diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_object.h index 46fdf92515..75013b4188 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } else { @@ -56,6 +58,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/i2c_api.c index 0d5b571427..fe432ee37f 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/i2c_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C #include "cmsis.h" #include "pinmap.h" -#include "error.h" /* Timeout values for flags and events waiting loops. These timeouts are not based on accurate values, they just guarantee that the application will @@ -61,10 +61,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock if (obj->i2c == I2C_1) { @@ -89,6 +86,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { } void i2c_frequency(i2c_t *obj, int hz) { + MBED_ASSERT((hz == 100000) || (hz == 200000) || (hz == 400000) || (hz == 1000000)); I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c); I2C_InitTypeDef I2C_InitStructure; uint32_t tim = 0; @@ -111,28 +109,27 @@ void i2c_frequency(i2c_t *obj, int hz) { - Fall time = 10ns */ switch (hz) { - case 100000: - tim = 0x10805E89; // Standard mode - break; - case 200000: - tim = 0x00905E82; // Fast Mode - break; - case 400000: - tim = 0x00901850; // Fast Mode - break; - case 1000000: - tim = 0x00700818; // Fast Mode Plus - // Enable the Fast Mode Plus capability - if (obj->i2c == I2C_1) { - SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C1, ENABLE); - } - if (obj->i2c == I2C_2) { - SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C2, ENABLE); - } - break; - default: - error("Only 100kHz, 200kHz, 400kHz and 1MHz I2C frequencies are supported."); - break; + case 100000: + tim = 0x10805E89; // Standard mode + break; + case 200000: + tim = 0x00905E82; // Fast Mode + break; + case 400000: + tim = 0x00901850; // Fast Mode + break; + case 1000000: + tim = 0x00700818; // Fast Mode Plus + // Enable the Fast Mode Plus capability + if (obj->i2c == I2C_1) { + SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C1, ENABLE); + } + if (obj->i2c == I2C_2) { + SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C2, ENABLE); + } + break; + default: + break; } // I2C configuration diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pinmap.c index 30b6e15d3b..dca0305b81 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pinmap.h" #include "PortNames.h" #include "error.h" @@ -66,7 +67,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); @@ -111,7 +112,7 @@ void pin_function(PinName pin, int data) { * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pwmout_api.c index b4b6f5eb43..1c9e475e43 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pwmout_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pwmout_api.h" #if DEVICE_PWMOUT #include "cmsis.h" #include "pinmap.h" -#include "error.h" // TIM1 cannot be used because already used by the us_ticker static const PinMap PinMap_PWM[] = { @@ -65,10 +65,7 @@ static const PinMap PinMap_PWM[] = { void pwmout_init(pwmout_t* obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - - if (obj->pwm == (PWMName)NC) { - error("PWM pinout mapping failed"); - } + MBED_ASSERT(obj->pwm != (PWMName)NC); // Enable TIM clock if (obj->pwm == TIM_3) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/serial_api.c index ce3b92f7cd..1d57bf0b32 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/serial_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #if DEVICE_SERIAL #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -84,10 +84,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/spi_api.c index 6f88dea70e..e529c2719c 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_0)}, @@ -98,10 +98,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/analogin_api.c index 6eb3ad2b70..98a4e81038 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/analogin_api.c @@ -25,13 +25,13 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #if DEVICE_ANALOGIN #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "wait_api.h" static const PinMap PinMap_ADC[] = { @@ -62,10 +62,7 @@ void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_api.c index 1bb7f79a34..6ec02db5ad 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" @@ -34,15 +35,16 @@ extern uint32_t Set_GPIO_Clock(uint32_t port_idx); uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); @@ -51,7 +53,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; @@ -63,6 +64,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_Out_PP, 0)); } else { // PIN_INPUT diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_object.h index aa2a3f7b21..d731d97d05 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } else { @@ -56,6 +58,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/i2c_api.c index 48e9e0bf3e..f0ae80b59a 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/i2c_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C #include "cmsis.h" #include "pinmap.h" -#include "error.h" /* Timeout values for flags and events waiting loops. These timeouts are not based on accurate values, they just guarantee that the application will @@ -61,10 +61,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock if (obj->i2c == I2C_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c index 58b6de14f3..7beb6e92e5 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pinmap.h" #include "PortNames.h" #include "error.h" @@ -77,8 +78,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (input, output, alternate function or analog) + output speed + AF */ void pin_function(PinName pin, int data) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); uint32_t afnum = STM_PIN_AFNUM(data); @@ -120,10 +120,9 @@ void pin_function(PinName pin, int data) { * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { + MBED_ASSERT(pin != (PinName)NC); GPIO_InitTypeDef GPIO_InitStructure; - if (pin == NC) return; - uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pwmout_api.c index 9fa74d67d3..f3fd6aab11 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pwmout_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pwmout_api.h" #if DEVICE_PWMOUT #include "cmsis.h" #include "pinmap.h" -#include "error.h" // TIM4 cannot be used because already used by the us_ticker static const PinMap PinMap_PWM[] = { @@ -76,10 +76,7 @@ static const PinMap PinMap_PWM[] = { void pwmout_init(pwmout_t* obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - - if (obj->pwm == (PWMName)NC) { - error("PWM pinout mapping failed"); - } + MBED_ASSERT(obj->pwm != (PWMName)NC); // Enable TIM clock if (obj->pwm == PWM_1) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/serial_api.c index 869639ce14..9bee4cb5df 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/serial_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #if DEVICE_SERIAL #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -87,10 +87,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/spi_api.c index 466f3c03b2..5adc176bec 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(GPIO_Mode_AF_PP, 0)}, @@ -95,10 +95,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c index f0467de01f..a4a92683a9 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c @@ -25,6 +25,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #if DEVICE_ANALOGIN @@ -32,7 +33,6 @@ #include "wait_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA(GPIO_Mode_AN, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)}, // ADC_IN1 @@ -63,10 +63,7 @@ void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogout_api.c index cb2ce0009c..8a61f5f774 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogout_api.c @@ -25,13 +25,13 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogout_api.h" #if DEVICE_ANALOGOUT #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define DAC_RANGE (0xFFF) // 12 bits @@ -46,10 +46,7 @@ void analogout_init(dac_t *obj, PinName pin) { // Get the peripheral name (DAC_1, ...) from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); - - if (obj->dac == (DACName)NC) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(obj->dac != (DACName)NC); dac = (DAC_TypeDef *)(obj->dac); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_api.c index 5686e79d03..5b97612803 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" @@ -34,15 +35,16 @@ extern uint32_t Set_GPIO_Clock(uint32_t port_idx); uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); @@ -51,7 +53,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; @@ -63,6 +64,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)); } else { // PIN_INPUT diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_object.h index 46fdf92515..75013b4188 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } else { @@ -56,6 +58,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c index 96ccaf7617..5d7b23acf6 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C @@ -68,10 +69,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock if (obj->i2c == I2C_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pinmap.c index 3cd9a2103a..50c7792349 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pinmap.h" #include "PortNames.h" #include "error.h" @@ -67,8 +68,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); uint32_t otype = STM_PIN_OTYPE(data); @@ -111,8 +111,7 @@ void pin_function(PinName pin, int data) { * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -122,7 +121,8 @@ void pin_mode(PinName pin, PinMode mode) { // Configure pull-up/pull-down resistors uint32_t pupd = (uint32_t)mode; - if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down + if (pupd > 2) + pupd = 0; // Open-drain = No pull-up/No pull-down gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2))); gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2)); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c index 85c8155223..a83d106849 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #if DEVICE_SERIAL #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -95,10 +95,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { // Get the peripheral name from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/spi_api.c index 08b1d4c21b..d49b6b28cf 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_11, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)}, @@ -101,10 +101,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_2) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/analogin_api.c index 9be09ab146..94f4bc39b7 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/analogin_api.c @@ -25,6 +25,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #if DEVICE_ANALOGIN @@ -32,7 +33,6 @@ #include "wait_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC1_IN0 @@ -61,10 +61,7 @@ int adc_inited = 0; void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC error: pinout mapping failed."); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_api.c index 8a4f8cb4a3..316295d4da 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" @@ -34,15 +35,16 @@ extern uint32_t Set_GPIO_Clock(uint32_t port_idx); uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); @@ -51,7 +53,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRRL; @@ -63,6 +64,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(STM_MODE_OUTPUT_PP, GPIO_NOPULL, 0)); } else { // PIN_INPUT diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_object.h index ebe377b942..a8c99da3b6 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } else { @@ -56,6 +58,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c index 7a29bf78de..085baa85fb 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C #include "cmsis.h" #include "pinmap.h" -#include "error.h" /* Timeout values for flags and events waiting loops. These timeouts are not based on accurate values, they just guarantee that the application will @@ -66,10 +66,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C error: pinout mapping failed."); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock if (obj->i2c == I2C_1) { @@ -99,26 +96,24 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { } void i2c_frequency(i2c_t *obj, int hz) { + MBED_ASSERT((hz != 0) && (hz <= 400000)); I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c); - if ((hz != 0) && (hz <= 400000)) { - // I2C configuration - I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - I2cHandle.Init.ClockSpeed = hz; - I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; - I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_2; - I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; - I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; - I2cHandle.Init.OwnAddress1 = 0; - I2cHandle.Init.OwnAddress2 = 0; - HAL_I2C_Init(&I2cHandle); - if (obj->slave) { - /* Enable Address Acknowledge */ - I2cHandle.Instance->CR1 |= I2C_CR1_ACK; - } - } else { - error("I2C error: frequency setting failed (max 400kHz)."); + // I2C configuration + I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; + I2cHandle.Init.ClockSpeed = hz; + I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; + I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_2; + I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; + I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; + I2cHandle.Init.OwnAddress1 = 0; + I2cHandle.Init.OwnAddress2 = 0; + HAL_I2C_Init(&I2cHandle); + if (obj->slave) { + /* Enable Address Acknowledge */ + I2cHandle.Instance->CR1 |= I2C_CR1_ACK; } + } inline int i2c_start(i2c_t *obj) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/mbed_overrides.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/mbed_overrides.c index 60d7941d83..a9352cc902 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/mbed_overrides.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/mbed_overrides.c @@ -31,4 +31,6 @@ void mbed_sdk_init() { // Update the SystemCoreClock variable. SystemCoreClockUpdate(); + // Need to restart HAL driver after the RAM is initialized + HAL_Init(); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/pinmap.c index 53fe5ab305..dd55e6dcac 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pinmap.h" #include "PortNames.h" #include "error.h" @@ -82,8 +83,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); uint32_t pupd = STM_PIN_PUPD(data); @@ -119,8 +119,7 @@ void pin_function(PinName pin, int data) { * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -130,7 +129,8 @@ void pin_mode(PinName pin, PinMode mode) { // Configure pull-up/pull-down resistors uint32_t pupd = (uint32_t)mode; - if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down + if (pupd > 2) + pupd = 0; // Open-drain = No pull-up/No pull-down gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2))); gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2)); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/pwmout_api.c index d9e42f0bae..934fb67b45 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/pwmout_api.c @@ -44,7 +44,7 @@ static const PinMap PinMap_PWM[] = { {PA_2, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH3 // {PA_2, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH3 // {PA_2, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH1 - {PA_3, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH3 + {PA_3, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH4 // {PA_3, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH4 // {PA_3, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH2 {PA_5, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH1 @@ -142,30 +142,28 @@ void pwmout_write(pwmout_t* obj, float value) { sConfig.OCNIdleState = TIM_OCNIDLESTATE_RESET; switch (obj->pin) { + // Channels 1 case PA_0: -// case PA_2: case PA_5: case PA_6: case PA_8: case PA_15: case PB_4: case PB_6: -// case PB_8: -// case PB_9: case PC_6: channel = TIM_CHANNEL_1; break; + // Channels 1N case PA_7: case PB_13: channel = TIM_CHANNEL_1; complementary_channel = 1; break; + // Channels 2 case PA_1: -// case PA_3: -// case PA_7: case PA_9: case PB_3: case PB_5: @@ -173,36 +171,38 @@ void pwmout_write(pwmout_t* obj, float value) { case PC_7: channel = TIM_CHANNEL_2; break; + // Channels 2N case PB_0: case PB_14: channel = TIM_CHANNEL_2; complementary_channel = 1; break; + // Channels 3 case PA_2: - case PA_3: case PA_10: -// case PB_0: case PB_8: case PB_10: case PC_8: channel = TIM_CHANNEL_3; break; + // Channels 3N case PB_1: case PB_15: channel = TIM_CHANNEL_3; complementary_channel = 1; break; + // Channels 4 -// case PA_3: + case PA_3: case PA_11: -// case PB_1: case PB_9: case PC_9: channel = TIM_CHANNEL_4; break; + default: return; } @@ -238,6 +238,9 @@ void pwmout_period_us(pwmout_t* obj, int us) { __HAL_TIM_DISABLE(&TimHandle); + // Update the SystemCoreClock variable + SystemCoreClockUpdate(); + TimHandle.Init.Period = us - 1; TimHandle.Init.Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick TimHandle.Init.ClockDivision = 0; diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c index f9630f7f92..d3bd6a3d48 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #if DEVICE_SERIAL #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -85,10 +85,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial error: pinout mapping failed."); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c index 28b68efac1..990c5899c7 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, @@ -111,10 +111,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI error: pinout mapping failed."); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/us_ticker.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/us_ticker.c index d82a3c5aa8..8ef83ba041 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/us_ticker.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/us_ticker.c @@ -29,10 +29,7 @@ #include "us_ticker_api.h" #include "PeripheralNames.h" -// 32-bit timer selection -#define TIM_MST TIM5 -#define TIM_MST_IRQ TIM5_IRQn -#define TIM_MST_RCC __TIM5_CLK_ENABLE() +#define TIM_MST TIM5 static TIM_HandleTypeDef TimMasterHandle; static int us_ticker_inited = 0; @@ -41,23 +38,9 @@ void us_ticker_init(void) { if (us_ticker_inited) return; us_ticker_inited = 1; - // Enable timer clock - TIM_MST_RCC; - - // Configure time base TimMasterHandle.Instance = TIM_MST; - TimMasterHandle.Init.Period = 0xFFFFFFFF; - TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick - TimMasterHandle.Init.ClockDivision = 0; - TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP; - TimMasterHandle.Init.RepetitionCounter = 0; - HAL_TIM_OC_Init(&TimMasterHandle); - NVIC_SetVector(TIM_MST_IRQ, (uint32_t)us_ticker_irq_handler); - NVIC_EnableIRQ(TIM_MST_IRQ); - - // Enable timer - HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_1); + HAL_InitTick(0); // The passed value is not used } uint32_t us_ticker_read() { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/analogin_api.c index a24d97c689..9e352048e4 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/analogin_api.c @@ -25,6 +25,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #if DEVICE_ANALOGIN @@ -32,7 +33,6 @@ #include "wait_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC1_IN0 @@ -61,10 +61,7 @@ int adc_inited = 0; void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC error: pinout mapping failed."); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/analogout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/analogout_api.c index 1e81a42d51..991acd2a63 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/analogout_api.c @@ -25,6 +25,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogout_api.h" #if DEVICE_ANALOGOUT @@ -49,10 +50,7 @@ void analogout_init(dac_t *obj, PinName pin) { // Get the peripheral name (DAC_1, ...) from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); - - if (obj->dac == (DACName)NC) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(obj->dac != (DACName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_DAC); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_api.c index 7c2bf1d792..de541d16d7 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" @@ -34,15 +35,16 @@ extern uint32_t Set_GPIO_Clock(uint32_t port_idx); uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); @@ -51,7 +53,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; @@ -63,6 +64,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(STM_MODE_OUTPUT_PP, GPIO_NOPULL, 0)); } else { // PIN_INPUT diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_object.h index 46fdf92515..75013b4188 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } else { @@ -56,6 +58,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/i2c_api.c index c0e58d0d9b..cda12adb35 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/i2c_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C @@ -65,10 +66,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C error: pinout mapping failed."); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock if (obj->i2c == I2C_1) { @@ -93,6 +91,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { } void i2c_frequency(i2c_t *obj, int hz) { + MBED_ASSERT((hz == 100000) || (hz == 400000) || (hz == 1000000)); I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c); // Common settings: I2C clock = 32 MHz, Analog filter = ON, Digital filter coefficient = 0 @@ -107,7 +106,6 @@ void i2c_frequency(i2c_t *obj, int hz) { I2cHandle.Init.Timing = 0x0030040E; // Fast mode Plus with Rise Time = 60ns and Fall Time = 100ns break; default: - error("Only 100kHz, 400kHz and 1MHz I2C frequencies are supported."); break; } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/pinmap.c index 5024f4ba7a..66292a3da2 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pinmap.h" #include "PortNames.h" #include "error.h" @@ -82,8 +83,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); uint32_t pupd = STM_PIN_PUPD(data); @@ -119,8 +119,7 @@ void pin_function(PinName pin, int data) { * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -130,7 +129,8 @@ void pin_mode(PinName pin, PinMode mode) { // Configure pull-up/pull-down resistors uint32_t pupd = (uint32_t)mode; - if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down + if (pupd > 2) + pupd = 0; // Open-drain = No pull-up/No pull-down gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPD0 << (pin_index * 2))); gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2)); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/serial_api.c index 7d1a9d4594..e1a5b5d3c4 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/serial_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #if DEVICE_SERIAL #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -101,10 +101,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial error: pinout mapping failed."); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable UART clock if (obj->uart == UART_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/spi_api.c index 2ee90a054f..035d38555f 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, @@ -105,10 +105,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI error: pinout mapping failed."); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogin_api.c index 9c6a4a6f33..333edb19c9 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogin_api.c @@ -25,13 +25,13 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #if DEVICE_ANALOGIN #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "wait_api.h" static const PinMap PinMap_ADC[] = { @@ -66,10 +66,7 @@ void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogout_api.c index 16f5ef6746..c921f44526 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogout_api.c @@ -25,13 +25,13 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogout_api.h" #if DEVICE_ANALOGOUT #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define RANGE_12BIT (0xFFF) @@ -46,10 +46,7 @@ void analogout_init(dac_t *obj, PinName pin) { // Get the peripheral name (DAC_1, ...) from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); - - if (obj->dac == (DACName)NC) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(obj->dac != (DACName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_DAC); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_api.c index 5339743b60..1183c2805c 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" @@ -34,16 +35,16 @@ extern uint32_t Set_GPIO_Clock(uint32_t port_idx); uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; - + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); // Enable GPIO clock @@ -51,7 +52,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRRL; @@ -63,6 +63,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)); } else { // PIN_INPUT diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_object.h index c3ae5ac506..ea803c0fbc 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } else { @@ -56,6 +58,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c index da67f8f219..6bb78042bf 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c @@ -27,13 +27,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C #include "cmsis.h" #include "pinmap.h" -#include "error.h" + /* Timeout values for flags and events waiting loops. These timeouts are not based on accurate values, they just guarantee that the application will @@ -61,10 +62,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock if (obj->i2c == I2C_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/pinmap.c index 715f165286..0bfc6811c4 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pinmap.h" #include "PortNames.h" #include "error.h" @@ -66,7 +67,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); @@ -110,7 +111,7 @@ void pin_function(PinName pin, int data) { * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -121,7 +122,8 @@ void pin_mode(PinName pin, PinMode mode) { // Configure pull-up/pull-down resistors uint32_t pupd = (uint32_t)mode; - if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down + if (pupd > 2) + pupd = 0; // Open-drain = No pull-up/No pull-down gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2))); gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2)); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/pwmout_api.c index a9162ad572..50c4fca738 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/pwmout_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pwmout_api.h" #if DEVICE_PWMOUT #include "cmsis.h" #include "pinmap.h" -#include "error.h" // TIM5 cannot be used because already used by the us_ticker static const PinMap PinMap_PWM[] = { @@ -77,10 +77,7 @@ static const PinMap PinMap_PWM[] = { void pwmout_init(pwmout_t* obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - - if (obj->pwm == (PWMName)NC) { - error("PWM pinout mapping failed"); - } + MBED_ASSERT(obj->pwm != (PWMName)NC); // Enable TIM clock if (obj->pwm == PWM_2) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/serial_api.c index dfa8bcc876..6568fa503e 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/serial_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #if DEVICE_SERIAL #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -91,10 +91,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/spi_api.c index 44cb74cfad..b1304dc92b 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_AF_SPI1)}, @@ -105,10 +105,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/analogin_api.c index 1733895d99..80dee1e28d 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/analogin_api.c @@ -25,6 +25,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogin_api.h" #include "wait_api.h" @@ -32,7 +33,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA(GPIO_Mode_AN, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)}, // ADC_IN1 @@ -63,10 +63,7 @@ void analogin_init(analogin_t *obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - - if (obj->adc == (ADCName)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc == (ADCName)NC); // Configure GPIO pinmap_pinout(pin, PinMap_ADC); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/analogout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/analogout_api.c index cd768bc739..9de3c92f51 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/analogout_api.c @@ -25,13 +25,13 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "mbed_assert.h" #include "analogout_api.h" #if DEVICE_ANALOGOUT #include "cmsis.h" #include "pinmap.h" -#include "error.h" #define RANGE_12BIT (0xFFF) @@ -46,10 +46,7 @@ void analogout_init(dac_t *obj, PinName pin) { // Get the peripheral name (DAC_1, ...) from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); - - if (obj->dac == (DACName)NC) { - error("DAC pin mapping failed"); - } + MBED_ASSERT(obj->dac == (DACName)NC); dac = (DAC_TypeDef *)(obj->dac); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/gpio_api.c index 5686e79d03..6743f91187 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/gpio_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" @@ -34,7 +35,7 @@ extern uint32_t Set_GPIO_Clock(uint32_t port_idx); uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); @@ -42,7 +43,9 @@ uint32_t gpio_set(PinName pin) { } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); @@ -51,7 +54,6 @@ void gpio_init(gpio_t *obj, PinName pin) { GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; @@ -63,6 +65,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)); } else { // PIN_INPUT diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/gpio_object.h index 46fdf92515..75013b4188 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/gpio_object.h @@ -30,6 +30,7 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" @@ -48,6 +49,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) { *obj->reg_set = obj->mask; } else { @@ -56,6 +58,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/i2c_api.c index c6e24a6e91..ee7acf1282 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/i2c_api.c @@ -27,13 +27,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C #include "cmsis.h" #include "pinmap.h" -#include "error.h" /* Timeout values for flags and events waiting loops. These timeouts are not based on accurate values, they just guarantee that the application will @@ -68,10 +68,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl); - - if (obj->i2c == (I2CName)NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT(obj->i2c != (I2CName)NC); // Enable I2C clock if (obj->i2c == I2C_1) { @@ -98,6 +95,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { } void i2c_frequency(i2c_t *obj, int hz) { + MBED_ASSERT((hz == 100000) || (hz == 200000) || (hz == 400000) || (hz == 1000000)); I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c); I2C_InitTypeDef I2C_InitStructure; uint32_t tim; @@ -140,7 +138,6 @@ void i2c_frequency(i2c_t *obj, int hz) { } break; default: - error("Only 100kHz, 200kHz, 400kHz and 1MHz I2C frequencies are supported."); break; } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/pinmap.c index d446e5f2c5..b8989a93c0 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/pinmap.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pinmap.h" #include "PortNames.h" #include "error.h" @@ -71,7 +72,7 @@ uint32_t Set_GPIO_Clock(uint32_t port_idx) { * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); @@ -115,7 +116,7 @@ void pin_function(PinName pin, int data) { * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -126,7 +127,8 @@ void pin_mode(PinName pin, PinMode mode) { // Configure pull-up/pull-down resistors uint32_t pupd = (uint32_t)mode; - if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down + if (pupd > 2) + pupd = 0; // Open-drain = No pull-up/No pull-down gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2))); gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2)); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/pwmout_api.c index 1d83cdb6e2..a37f7b3c82 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/pwmout_api.c @@ -27,11 +27,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" // TIM2 cannot be used because already used by the us_ticker static const PinMap PinMap_PWM[] = { @@ -88,10 +88,7 @@ static const PinMap PinMap_PWM[] = { void pwmout_init(pwmout_t* obj, PinName pin) { // Get the peripheral name from the pin and assign it to the object obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - - if (obj->pwm == (PWMName)NC) { - error("PWM pinout mapping failed"); - } + MBED_ASSERT(obj->pwm == (PWMName)NC); // Enable TIM clock if (obj->pwm == PWM_1) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/serial_api.c index b7a8181240..f8408aabbd 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/serial_api.c @@ -27,10 +27,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "serial_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include static const PinMap PinMap_UART_TX[] = { @@ -92,10 +92,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { // Get the peripheral name from the pin and assign it to the object obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - - if (obj->uart == (UARTName)NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT(obj->uart != (UARTName)NC); // Enable USART clock if (obj->uart == UART_1) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/spi_api.c index 67d890ccbe..5bae376b15 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F3XX/spi_api.c @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -34,7 +35,6 @@ #include #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_MOSI[] = { {PA_11, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)}, @@ -102,9 +102,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - if (obj->spi == (SPIName)NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_2) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/analogin_api.c index e35b893886..e2fdc6a513 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/analogin_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "analogin_api.h" #if DEVICE_ANALOGIN @@ -48,9 +49,7 @@ static const PinMap PinMap_ADC[] = { void analogin_init(analogin_t *obj, PinName pin) { obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); - if (obj->adc == (uint32_t)NC) { - error("ADC pin mapping failed"); - } + MBED_ASSERT(obj->adc != (uint32_t)NC); // ensure power is turned on RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN | RCC_AHB1ENR_GPIOBEN | diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c index e9cc039333..e35d1f2f68 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = (uint32_t) pin >> 4; // Enable GPIO peripheral clock @@ -27,9 +29,10 @@ uint32_t gpio_set(PinName pin) { } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); uint32_t port_index = (uint32_t) pin >> 4; @@ -46,8 +49,13 @@ void gpio_mode(gpio_t *obj, PinMode mode) { } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : pin_function(obj->pin, STM_PIN_DATA(0, 0)); break; - case PIN_OUTPUT: pin_function(obj->pin, STM_PIN_DATA(1, 0)); break; + case PIN_INPUT : + pin_function(obj->pin, STM_PIN_DATA(0, 0)); + break; + case PIN_OUTPUT: + pin_function(obj->pin, STM_PIN_DATA(1, 0)); + break; } } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_object.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_object.h index caaef02439..fcf499289e 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_object.h @@ -16,6 +16,8 @@ #ifndef MBED_GPIO_OBJECT_H #define MBED_GPIO_OBJECT_H +#include "mbed_assert.h" + #ifdef __cplusplus extern "C" { #endif @@ -32,6 +34,7 @@ typedef struct { } gpio_t; static inline void gpio_write(gpio_t *obj, int value) { + MBED_ASSERT(obj->pin != (PinName)NC); if (value) *obj->reg_set = obj->mask; else @@ -39,6 +42,7 @@ static inline void gpio_write(gpio_t *obj, int value) { } static inline int gpio_read(gpio_t *obj) { + MBED_ASSERT(obj->pin != (PinName)NC); return ((*obj->reg_in & obj->mask) ? 1 : 0); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/i2c_api.c index 2b930cf23e..b9e619bedc 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/i2c_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "i2c_api.h" #if DEVICE_I2C @@ -124,10 +125,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA); I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL); obj->i2c = (I2C_TypeDef *)pinmap_merge(i2c_sda, i2c_scl); - - if ((int)obj->i2c == NC) { - error("I2C pin mapping failed"); - } + MBED_ASSERT((int)obj->i2c != NC); // enable power i2c_power_enable(obj); diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/pinmap.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/pinmap.c index fce1147797..33a08966f8 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/pinmap.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/pinmap.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pinmap.h" #include "error.h" @@ -20,7 +21,7 @@ * Set the pin into input, output, alternate function or analog mode */ void pin_function(PinName pin, int data) { - if (pin == (uint32_t)NC) return; + MBED_ASSERT(pin != (PinName)NC); int mode = STM_PIN_MODE(data); int func = STM_PIN_FUNC(data); @@ -53,7 +54,7 @@ void pin_function(PinName pin, int data) { } void pin_mode(PinName pin, PinMode mode) { - if (pin == (uint32_t)NC) { return; } + MBED_ASSERT(pin != (PinName)NC); uint32_t pin_number = (uint32_t)pin; int port_index = pin_number >> 4; diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/spi_api.c index 9b2a4ac425..7617ead217 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/spi_api.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "spi_api.h" #if DEVICE_SPI @@ -20,7 +21,6 @@ #include "cmsis.h" #include "pinmap.h" -#include "error.h" static const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI_1, STM_PIN_DATA(2, 5)}, @@ -57,7 +57,7 @@ static const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI_3, STM_PIN_DATA(2, 6)}, {PA_15, SPI_1, STM_PIN_DATA(2, 5)}, {PA_15, SPI_3, STM_PIN_DATA(2, 6)}, - {PB_9, SPI_2, STM_PIN_DATA(2, 5)}, + {PB_9, SPI_2, STM_PIN_DATA(2, 5)}, {PB_12, SPI_2, STM_PIN_DATA(2, 5)}, {NC, NC, 0} }; @@ -75,9 +75,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso); SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPI_TypeDef*)pinmap_merge(spi_data, spi_cntl); - if ((int)obj->spi == NC) { - error("SPI pinout mapping failed"); - } + MBED_ASSERT((int)obj->spi != NC) // enable power and clocking switch ((int)obj->spi) { @@ -123,12 +121,8 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel void spi_free(spi_t *obj) {} void spi_format(spi_t *obj, int bits, int mode, int slave) { + MBED_ASSERT(((bits == 8) || (bits == 16)) && ((mode >= 0) && (mode <= 3))); ssp_disable(obj); - - if (!(bits == 8 || bits == 16) || !(mode >= 0 && mode <= 3)) { - error("SPI format error"); - } - int polarity = (mode & 0x2) ? 1 : 0; int phase = (mode & 0x1) ? 1 : 0; diff --git a/libraries/net/eth/lwip-eth/arch/TARGET_K64F/k64f_emac.c b/libraries/net/eth/lwip-eth/arch/TARGET_K64F/k64f_emac.c index 76a7fe4f1a..4e5a314e11 100644 --- a/libraries/net/eth/lwip-eth/arch/TARGET_K64F/k64f_emac.c +++ b/libraries/net/eth/lwip-eth/arch/TARGET_K64F/k64f_emac.c @@ -27,6 +27,7 @@ extern IRQn_Type enet_irq_ids[HW_ENET_INSTANCE_COUNT][FSL_FEATURE_ENET_INTERRUPT_COUNT]; extern uint8_t enetIntMap[kEnetIntNum]; +extern void *enetIfHandle; /******************************************************************************** * Internal data @@ -855,6 +856,22 @@ void eth_arch_disable_interrupts(void) { interrupt_disable(enet_irq_ids[BOARD_DEBUG_ENET_INSTANCE][enetIntMap[kEnetTxfInt]]); } +void ENET_Transmit_IRQHandler(void) +{ + enet_mac_tx_isr(enetIfHandle); +} + +void ENET_Receive_IRQHandler(void) +{ + enet_mac_rx_isr(enetIfHandle); +} + +#if FSL_FEATURE_ENET_SUPPORT_PTP +void ENET_1588_Timer_IRQHandler(void) +{ + enet_mac_ts_isr(enetIfHandle); +} +#endif /** * @} */ diff --git a/workspace_tools/build.py b/workspace_tools/build.py index 89534408cc..ab08e5596b 100755 --- a/workspace_tools/build.py +++ b/workspace_tools/build.py @@ -31,7 +31,8 @@ from workspace_tools.targets import TARGET_NAMES, TARGET_MAP from workspace_tools.options import get_default_options_parser from workspace_tools.build_api import build_mbed_libs, build_lib from workspace_tools.build_api import mcu_toolchain_matrix - +from workspace_tools.build_api import static_analysis_scan, static_analysis_scan_lib, static_analysis_scan_library +from workspace_tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT if __name__ == '__main__': start = time() @@ -50,21 +51,23 @@ if __name__ == '__main__': default=False, help="Compile the USB Device library") parser.add_option("-d", "--dsp", action="store_true", dest="dsp", default=False, help="Compile the DSP library") - parser.add_option("-v", "--verbose", action="store_true", dest="verbose", - default=False, help="Verbose diagnostic output") parser.add_option("-b", "--ublox", action="store_true", dest="ublox", default=False, help="Compile the u-blox library") parser.add_option("-D", "", action="append", dest="macros", help="Add a macro definition") parser.add_option("-S", "--supported-toolchains", action="store_true", dest="supported_toolchains", default=False, help="Displays supported matrix of MCUs and toolchains") + parser.add_option("", "--cppcheck", action="store_true", dest="cppcheck_validation", + default=False, help="Forces 'cppcheck' static code analysis") + parser.add_option("-v", "--verbose", action="store_true", dest="verbose", + default=False, help="Verbose diagnostic output") parser.add_option("-x", "--extra-verbose-notifications", action="store_true", dest="extra_verbose_notify", default=False, help="Makes compiler more verbose, CI friendly.") (options, args) = parser.parse_args() # Only prints matrix of supported toolchains if options.supported_toolchains: - mcu_toolchain_matrix() + print mcu_toolchain_matrix() exit(0) # Get target list @@ -106,41 +109,69 @@ if __name__ == '__main__': if options.ublox: libraries.extend(["rtx", "rtos", "usb_host", "ublox"]) - # Build + notify = print_notify_verbose if options.extra_verbose_notify else None # Special notify for CI (more verbose) + + # Build results failures = [] successes = [] - for toolchain in toolchains: - for target in targets: - id = "%s::%s" % (toolchain, target) - try: - mcu = TARGET_MAP[target] - notify = print_notify_verbose if options.extra_verbose_notify else None # Special notify for CI (more verbose) - build_mbed_libs(mcu, toolchain, options=options.options, - notify=notify, verbose=options.verbose, clean=options.clean, - macros=options.macros) - for lib_id in libraries: - notify = print_notify_verbose if options.extra_verbose_notify else None # Special notify for CI (more verbose) - build_lib(lib_id, mcu, toolchain, options=options.options, - notify=notify, verbose=options.verbose, clean=options.clean, - macros=options.macros) - successes.append(id) - except Exception, e: - if options.verbose: - import sys, traceback - traceback.print_exc(file=sys.stdout) - sys.exit(1) - failures.append(id) - print e + # CPPCHECK code validation + if options.cppcheck_validation: + for toolchain in toolchains: + for target in targets: + try: + mcu = TARGET_MAP[target] + # CMSIS and MBED libs analysis + static_analysis_scan(mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, verbose=options.verbose) + for lib_id in libraries: + # Static check for library + static_analysis_scan_lib(lib_id, mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, + options=options.options, + notify=notify, verbose=options.verbose, clean=options.clean, + macros=options.macros) + pass + except Exception, e: + if options.verbose: + import traceback + traceback.print_exc(file=sys.stdout) + sys.exit(1) + print e + else: + # Build + for toolchain in toolchains: + for target in targets: + tt_id = "%s::%s" % (toolchain, target) + try: + mcu = TARGET_MAP[target] + build_mbed_libs(mcu, toolchain, options=options.options, + notify=notify, verbose=options.verbose, clean=options.clean, + macros=options.macros) + + for lib_id in libraries: + notify = print_notify_verbose if options.extra_verbose_notify else None # Special notify for CI (more verbose) + build_lib(lib_id, mcu, toolchain, options=options.options, + notify=notify, verbose=options.verbose, clean=options.clean, + macros=options.macros) + successes.append(tt_id) + except Exception, e: + if options.verbose: + import traceback + traceback.print_exc(file=sys.stdout) + sys.exit(1) + failures.append(tt_id) + print e # Write summary of the builds - print "\n\nCompleted in: (%.2f)s" % (time() - start) + print "Completed in: (%.2f)s" % (time() - start) + print if successes: - print "\n\nBuild successes:" + print "Build successes:" + print print "\n".join([" * %s" % s for s in successes]) if failures: - print "\n\nBuild failures:" + print "Build failures:" + print print "\n".join([" * %s" % f for f in failures]) sys.exit(1) diff --git a/workspace_tools/build_api.py b/workspace_tools/build_api.py index 1c56b3afec..f09417217a 100644 --- a/workspace_tools/build_api.py +++ b/workspace_tools/build_api.py @@ -14,11 +14,14 @@ 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. """ + +import tempfile +import os from os.path import join, exists, basename from shutil import rmtree from types import ListType -from workspace_tools.utils import mkdir +from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext from workspace_tools.toolchains import TOOLCHAIN_CLASSES from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON from workspace_tools.libraries import Library @@ -212,9 +215,10 @@ def get_unique_supported_toolchains(): return unique_supported_toolchains -def mcu_toolchain_matrix(): +def mcu_toolchain_matrix(verbose_html=False): """ Shows target map using prettytable """ unique_supported_toolchains = get_unique_supported_toolchains() + from prettytable import PrettyTable # Only use it in this function so building works without extra modules # All tests status table print @@ -235,5 +239,201 @@ def mcu_toolchain_matrix(): perm_counter += 1 row.append(text); pt.add_row(row) - print pt - print "Total permutations: %d"% (perm_counter) + + result = pt.get_html_string() if verbose_html else pt.get_string() + result += "\n" + result += "Total permutations: %d"% (perm_counter) + return result + + +def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None): + # Toolchain + toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify) + toolchain.VERBOSE = verbose + toolchain.build_all = clean + + # Source and Build Paths + BUILD_TARGET = join(MBED_LIBRARIES, "TARGET_" + target.name) + BUILD_TOOLCHAIN = join(BUILD_TARGET, "TOOLCHAIN_" + toolchain.name) + mkdir(BUILD_TOOLCHAIN) + + TMP_PATH = join(MBED_LIBRARIES, '.temp', toolchain.obj_path) + mkdir(TMP_PATH) + + # CMSIS + toolchain.info(">>>> STATIC ANALYSIS FOR %s (%s, %s)" % ('CMSIS', target.name, toolchain_name)) + cmsis_src = join(MBED_TARGETS_PATH, "cmsis") + resources = toolchain.scan_resources(cmsis_src) + + # Copy files before analysis + toolchain.copy_files(resources.headers, BUILD_TARGET) + toolchain.copy_files(resources.linker_script, BUILD_TOOLCHAIN) + + # Gather include paths, c, cpp sources and macros to transfer to cppcheck command line + includes = ["-I%s" % i for i in resources.inc_dirs] + includes.append(" -I%s"% str(BUILD_TARGET)) + c_sources = " ".join(resources.c_sources) + cpp_sources = " ".join(resources.cpp_sources) + macros = ['-D%s' % s for s in toolchain.get_symbols() + toolchain.macros] + + includes = map(str.strip, includes) + macros = map(str.strip, macros) + + check_cmd = CPPCHECK_CMD + check_cmd += CPPCHECK_MSG_FORMAT + check_cmd += includes + check_cmd += macros + + # We need to pass some params via file to avoid "command line too long in some OSs" + tmp_file = tempfile.NamedTemporaryFile(delete=False) + tmp_file.writelines(line + '\n' for line in c_sources.split()) + tmp_file.writelines(line + '\n' for line in cpp_sources.split()) + tmp_file.close() + check_cmd += ["--file-list=%s"% tmp_file.name] + + _stdout, _stderr, _rc = run_cmd(check_cmd) + if verbose: + print _stdout + print _stderr + + # ========================================================================= + + # MBED + toolchain.info(">>> STATIC ANALYSIS FOR %s (%s, %s)" % ('MBED', target.name, toolchain_name)) + + # Common Headers + toolchain.copy_files(toolchain.scan_resources(MBED_API).headers, MBED_LIBRARIES) + toolchain.copy_files(toolchain.scan_resources(MBED_HAL).headers, MBED_LIBRARIES) + + # Target specific sources + HAL_SRC = join(MBED_TARGETS_PATH, "hal") + hal_implementation = toolchain.scan_resources(HAL_SRC) + + # Copy files before analysis + toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files, BUILD_TARGET, HAL_SRC) + incdirs = toolchain.scan_resources(BUILD_TARGET) + + target_includes = ["-I%s" % i for i in incdirs.inc_dirs] + target_includes.append("-I%s "% str(BUILD_TARGET)) + target_includes.append("-I%s "% str(HAL_SRC)) + target_c_sources = " ".join(incdirs.c_sources) + target_cpp_sources = " ".join(incdirs.cpp_sources) + target_macros = ['-D%s' % s for s in toolchain.get_symbols() + toolchain.macros] + + # Common Sources + mbed_resources = toolchain.scan_resources(MBED_COMMON) + + # Gather include paths, c, cpp sources and macros to transfer to cppcheck command line + mbed_includes = ["-I%s" % i for i in mbed_resources.inc_dirs] + mbed_includes.append("-I%s "% str(BUILD_TARGET)) + mbed_includes.append("-I%s "% str(MBED_COMMON)) + mbed_includes.append("-I%s "% str(MBED_API)) + mbed_includes.append("-I%s "% str(MBED_HAL)) + mbed_c_sources = " ".join(mbed_resources.c_sources) + mbed_cpp_sources = " ".join(mbed_resources.cpp_sources) + + target_includes = map(str.strip, target_includes) + mbed_includes = map(str.strip, mbed_includes) + target_macros = map(str.strip, target_macros) + + check_cmd = CPPCHECK_CMD + check_cmd += CPPCHECK_MSG_FORMAT + check_cmd += target_includes + check_cmd += mbed_includes + check_cmd += target_macros + + # We need to pass some parames via file to avoid "command line too long in some OSs" + tmp_file = tempfile.NamedTemporaryFile(delete=False) + tmp_file.writelines(line + '\n' for line in target_c_sources.split()) + tmp_file.writelines(line + '\n' for line in target_cpp_sources.split()) + tmp_file.writelines(line + '\n' for line in mbed_c_sources.split()) + tmp_file.writelines(line + '\n' for line in mbed_cpp_sources.split()) + tmp_file.close() + check_cmd += ["--file-list=%s"% tmp_file.name] + + _stdout, _stderr, _rc = run_cmd_ext(check_cmd) + if verbose: + print _stdout + print _stderr + + +def static_analysis_scan_lib(lib_id, target, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None): + lib = Library(lib_id) + if lib.is_supported(target, toolchain): + static_analysis_scan_library(lib.source_dir, lib.build_dir, target, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, + lib.dependencies, options, + verbose=verbose, clean=clean, macros=macros, notify=notify) + else: + print 'Library "%s" is not yet supported on target %s with toolchain %s' % (lib_id, target.name, toolchain) + + +def static_analysis_scan_library(src_paths, build_path, target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, + dependencies_paths=None, options=None, name=None, clean=False, + notify=None, verbose=False, macros=None): + if type(src_paths) != ListType: src_paths = [src_paths] + + for src_path in src_paths: + if not exists(src_path): + raise Exception("The library source folder does not exist: %s", src_path) + + + # Toolchain instance + toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify) + toolchain.VERBOSE = verbose + + # The first path will give the name to the library + name = basename(src_paths[0]) + toolchain.info(">>> STATIC ANALYSIS FOR LIBRARY %s (%s, %s)" % (name.upper(), target.name, toolchain_name)) + + # Scan Resources + resources = [] + for src_path in src_paths: + resources.append(toolchain.scan_resources(src_path)) + + # Dependencies Include Paths + dependencies_include_dir = [] + if dependencies_paths is not None: + for path in dependencies_paths: + lib_resources = toolchain.scan_resources(path) + dependencies_include_dir.extend(lib_resources.inc_dirs) + + # Create the desired build directory structure + bin_path = join(build_path, toolchain.obj_path) + mkdir(bin_path) + tmp_path = join(build_path, '.temp', toolchain.obj_path) + mkdir(tmp_path) + + # Gather include paths, c, cpp sources and macros to transfer to cppcheck command line + includes = ["-I%s" % i for i in dependencies_include_dir + src_paths] + c_sources = " " + cpp_sources = " " + macros = ['-D%s' % s for s in toolchain.get_symbols() + toolchain.macros] + + # Copy Headers + for resource in resources: + toolchain.copy_files(resource.headers, build_path, rel_path=resource.base_path) + includes += ["-I%s" % i for i in resource.inc_dirs] + c_sources += " ".join(resource.c_sources) + " " + cpp_sources += " ".join(resource.cpp_sources) + " " + + dependencies_include_dir.extend(toolchain.scan_resources(build_path).inc_dirs) + + includes = map(str.strip, includes) + macros = map(str.strip, macros) + + check_cmd = CPPCHECK_CMD + check_cmd += CPPCHECK_MSG_FORMAT + check_cmd += includes + check_cmd += macros + + # We need to pass some parames via file to avoid "command line too long in some OSs" + tmp_file = tempfile.NamedTemporaryFile(delete=False) + tmp_file.writelines(line + '\n' for line in c_sources.split()) + tmp_file.writelines(line + '\n' for line in cpp_sources.split()) + tmp_file.close() + check_cmd += ["--file-list=%s"% tmp_file.name] + + _stdout, _stderr, _rc = run_cmd_ext(check_cmd) + if verbose: + print _stdout + print _stderr diff --git a/workspace_tools/build_release.py b/workspace_tools/build_release.py index 49dffc099c..1b82df10a9 100644 --- a/workspace_tools/build_release.py +++ b/workspace_tools/build_release.py @@ -30,6 +30,7 @@ OFFICIAL_MBED_LIBRARY_BUILD = ( ('LPC11U24', ('ARM', 'uARM', 'GCC_ARM')), ('LPC1768', ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')), ('UBLOX_C027', ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')), + ('ARCH_PRO', ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')), ('LPC2368', ('ARM',)), ('LPC812', ('uARM',)), ('LPC1347', ('ARM',)), diff --git a/workspace_tools/export/codered.py b/workspace_tools/export/codered.py index 93acd2bff2..bcebd1b5db 100644 --- a/workspace_tools/export/codered.py +++ b/workspace_tools/export/codered.py @@ -29,6 +29,7 @@ class CodeRed(Exporter): 'LPC11U35_401', 'LPC11U35_501', 'UBLOX_C027', + 'ARCH_PRO', ] def generate(self): diff --git a/workspace_tools/export/codered_arch_pro_cproject.tmpl b/workspace_tools/export/codered_arch_pro_cproject.tmpl new file mode 100644 index 0000000000..e317bb125e --- /dev/null +++ b/workspace_tools/export/codered_arch_pro_cproject.tmpl @@ -0,0 +1,1925 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <?xml version="1.0" encoding="UTF-8"?> +<TargetConfig> +<Properties property_0="" property_1="" property_2="" property_3="NXP" property_4="LPC1768" property_count="5" version="1"/> +<infoList vendor="NXP"> +<info chip="LPC1768" match_id="0x00013f37,0x26013F37,0x26113F37" name="LPC1768" package="lpc17_lqfp100.xml"> +<chip> +<name>LPC1768</name> +<family>LPC17xx</family> +<vendor>NXP (formerly Philips)</vendor> +<reset board="None" core="Real" sys="Real"/> +<clock changeable="TRUE" freq="20MHz" is_accurate="TRUE"/> +<memory can_program="true" id="Flash" is_ro="true" type="Flash"/> +<memory id="RAM" type="RAM"/> +<memory id="Periph" is_volatile="true" type="Peripheral"/> +<memoryInstance derived_from="Flash" id="MFlash512" location="0x00000000" size="0x80000"/> +<memoryInstance derived_from="RAM" id="RamLoc32" location="0x10000000" size="0x8000"/> +<memoryInstance derived_from="RAM" id="RamAHB32" location="0x2007c000" size="0x8000"/> +<prog_flash blocksz="0x1000" location="0" maxprgbuff="0x1000" progwithcode="TRUE" size="0x10000"/> +<prog_flash blocksz="0x8000" location="0x10000" maxprgbuff="0x1000" progwithcode="TRUE" size="0x70000"/> +<peripheralInstance derived_from="LPC17_NVIC" determined="infoFile" id="NVIC" location="0xE000E000"/> +<peripheralInstance derived_from="TIMER" determined="infoFile" enable="SYSCTL.PCONP.PCTIM0&amp;0x1" id="TIMER0" location="0x40004000"/> +<peripheralInstance derived_from="TIMER" determined="infoFile" enable="SYSCTL.PCONP.PCTIM1&amp;0x1" id="TIMER1" location="0x40008000"/> +<peripheralInstance derived_from="TIMER" determined="infoFile" enable="SYSCTL.PCONP.PCTIM2&amp;0x1" id="TIMER2" location="0x40090000"/> +<peripheralInstance derived_from="TIMER" determined="infoFile" enable="SYSCTL.PCONP.PCTIM3&amp;0x1" id="TIMER3" location="0x40094000"/> +<peripheralInstance derived_from="LPC17_RIT" determined="infoFile" enable="SYSCTL.PCONP.PCRIT&amp;0x1" id="RIT" location="0x400B0000"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO0" location="0x2009C000"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO1" location="0x2009C020"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO2" location="0x2009C040"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO3" location="0x2009C060"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO4" location="0x2009C080"/> +<peripheralInstance derived_from="LPC17_I2S" determined="infoFile" enable="SYSCTL.PCONP&amp;0x08000000" id="I2S" location="0x400A8000"/> +<peripheralInstance derived_from="LPC17_SYSCTL" determined="infoFile" id="SYSCTL" location="0x400FC000"/> +<peripheralInstance derived_from="LPC17_DAC" determined="infoFile" enable="PCB.PINSEL1.P0_26&amp;0x2=2" id="DAC" location="0x4008C000"/> +<peripheralInstance derived_from="LPC17xx_UART" determined="infoFile" enable="SYSCTL.PCONP.PCUART0&amp;0x1" id="UART0" location="0x4000C000"/> +<peripheralInstance derived_from="LPC17xx_UART_MODEM" determined="infoFile" enable="SYSCTL.PCONP.PCUART1&amp;0x1" id="UART1" location="0x40010000"/> +<peripheralInstance derived_from="LPC17xx_UART" determined="infoFile" enable="SYSCTL.PCONP.PCUART2&amp;0x1" id="UART2" location="0x40098000"/> +<peripheralInstance derived_from="LPC17xx_UART" determined="infoFile" enable="SYSCTL.PCONP.PCUART3&amp;0x1" id="UART3" location="0x4009C000"/> +<peripheralInstance derived_from="SPI" determined="infoFile" enable="SYSCTL.PCONP.PCSPI&amp;0x1" id="SPI" location="0x40020000"/> +<peripheralInstance derived_from="LPC17_SSP" determined="infoFile" enable="SYSCTL.PCONP.PCSSP0&amp;0x1" id="SSP0" location="0x40088000"/> +<peripheralInstance derived_from="LPC17_SSP" determined="infoFile" enable="SYSCTL.PCONP.PCSSP1&amp;0x1" id="SSP1" location="0x40030000"/> +<peripheralInstance derived_from="LPC17_ADC" determined="infoFile" enable="SYSCTL.PCONP.PCAD&amp;0x1" id="ADC" location="0x40034000"/> +<peripheralInstance derived_from="LPC17_USBINTST" determined="infoFile" enable="USBCLKCTL.USBClkCtrl&amp;0x12" id="USBINTSTAT" location="0x400fc1c0"/> +<peripheralInstance derived_from="LPC17_USB_CLK_CTL" determined="infoFile" id="USBCLKCTL" location="0x5000cff4"/> +<peripheralInstance derived_from="LPC17_USBDEV" determined="infoFile" enable="USBCLKCTL.USBClkSt&amp;0x12=0x12" id="USBDEV" location="0x5000C200"/> +<peripheralInstance derived_from="LPC17_PWM" determined="infoFile" enable="SYSCTL.PCONP.PWM1&amp;0x1" id="PWM" location="0x40018000"/> +<peripheralInstance derived_from="LPC17_I2C" determined="infoFile" enable="SYSCTL.PCONP.PCI2C0&amp;0x1" id="I2C0" location="0x4001C000"/> +<peripheralInstance derived_from="LPC17_I2C" determined="infoFile" enable="SYSCTL.PCONP.PCI2C1&amp;0x1" id="I2C1" location="0x4005C000"/> +<peripheralInstance derived_from="LPC17_I2C" determined="infoFile" enable="SYSCTL.PCONP.PCI2C2&amp;0x1" id="I2C2" location="0x400A0000"/> +<peripheralInstance derived_from="LPC17_DMA" determined="infoFile" enable="SYSCTL.PCONP.PCGPDMA&amp;0x1" id="DMA" location="0x50004000"/> +<peripheralInstance derived_from="LPC17_ENET" determined="infoFile" enable="SYSCTL.PCONP.PCENET&amp;0x1" id="ENET" location="0x50000000"/> +<peripheralInstance derived_from="CM3_DCR" determined="infoFile" id="DCR" location="0xE000EDF0"/> +<peripheralInstance derived_from="LPC17_PCB" determined="infoFile" id="PCB" location="0x4002c000"/> +<peripheralInstance derived_from="LPC17_QEI" determined="infoFile" enable="SYSCTL.PCONP.PCQEI&amp;0x1" id="QEI" location="0x400bc000"/> +<peripheralInstance derived_from="LPC17_USBHOST" determined="infoFile" enable="USBCLKCTL.USBClkSt&amp;0x11=0x11" id="USBHOST" location="0x5000C000"/> +<peripheralInstance derived_from="LPC17_USBOTG" determined="infoFile" enable="USBCLKCTL.USBClkSt&amp;0x1c=0x1c" id="USBOTG" location="0x5000C000"/> +<peripheralInstance derived_from="LPC17_RTC" determined="infoFile" enable="SYSCTL.PCONP.PCRTC&amp;0x1" id="RTC" location="0x40024000"/> +<peripheralInstance derived_from="MPU" determined="infoFile" id="MPU" location="0xE000ED90"/> +<peripheralInstance derived_from="LPC1x_WDT" determined="infoFile" id="WDT" location="0x40000000"/> +<peripheralInstance derived_from="LPC17_FLASHCFG" determined="infoFile" id="FLASHACCEL" location="0x400FC000"/> +<peripheralInstance derived_from="GPIO_INT" determined="infoFile" id="GPIOINTMAP" location="0x40028080"/> +<peripheralInstance derived_from="LPC17_CANAFR" determined="infoFile" enable="SYSCTL.PCONP.PCCAN1&amp;0x1|SYSCTL.PCONP.PCCAN2&amp;0x1" id="CANAFR" location="0x4003C000"/> +<peripheralInstance derived_from="LPC17_CANCEN" determined="infoFile" enable="SYSCTL.PCONP.PCCAN1&amp;0x1|SYSCTL.PCONP.PCCAN2&amp;0x1" id="CANCEN" location="0x40040000"/> +<peripheralInstance derived_from="LPC17_CANWAKESLEEP" determined="infoFile" id="CANWAKESLEEP" location="0x400FC110"/> +<peripheralInstance derived_from="LPC17_CANCON" determined="infoFile" enable="SYSCTL.PCONP.PCCAN1&amp;0x1" id="CANCON1" location="0x40044000"/> +<peripheralInstance derived_from="LPC17_CANCON" determined="infoFile" enable="SYSCTL.PCONP.PCCAN2&amp;0x1" id="CANCON2" location="0x40048000"/> +<peripheralInstance derived_from="LPC17_MCPWM" determined="infoFile" enable="SYSCTL.PCONP.PCMCPWM&amp;0x1" id="MCPWM" location="0x400B8000"/> +</chip> +<processor> +<name gcc_name="cortex-m3">Cortex-M3</name> +<family>Cortex-M</family> +</processor> +<link href="nxp_lpcxxxx_peripheral.xme" show="embed" type="simple"/> +</info> +</infoList> +</TargetConfig> + + + diff --git a/workspace_tools/export/codered_arch_pro_project.tmpl b/workspace_tools/export/codered_arch_pro_project.tmpl new file mode 100644 index 0000000000..42ef4384de --- /dev/null +++ b/workspace_tools/export/codered_arch_pro_project.tmpl @@ -0,0 +1,84 @@ + + + {{name}} + This file was automagically generated by mbed.org. For more information, see http://mbed.org/handbook/Exporting-To-Code-Red + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/{{name}}/Debug} + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + diff --git a/workspace_tools/export/codered_lpc4088_cproject.tmpl b/workspace_tools/export/codered_lpc4088_cproject.tmpl index 9b05351086..173fea11f1 100644 --- a/workspace_tools/export/codered_lpc4088_cproject.tmpl +++ b/workspace_tools/export/codered_lpc4088_cproject.tmpl @@ -41,7 +41,7 @@ {% endfor %} - - -