STM32F411: use arduino.h for UART pinout.

delete 11 mbed-files
    SIZES          ARM...     stm32f411
    FLASH  :  3124 bytes           1%
    RAM    :   212 bytes           1%
    EEPROM :     0 bytes           0%
This commit is contained in:
Nico Tonnhofer 2015-11-12 22:13:32 +01:00
parent 73df1be2d2
commit a890fecc6d
16 changed files with 35 additions and 1216 deletions

View File

@ -119,15 +119,13 @@ TARGET = $(PROGRAM).hex
SOURCES = $(wildcard *.c)
ifeq ($(MCU), stm32f411)
SOURCES += mbed-pinmap_stm32.c
SOURCES += mbed-system_stm32f4xx.c
SOURCES += mbed-cmsis_nvic_stm32.c
SOURCES += mbed-stm32f4xx_hal.c
SOURCES += mbed-stm32f4xx_hal_cortex.c
SOURCES += mbed-stm32f4xx_hal_gpio.c
SOURCES += mbed-stm32f4xx_hal_rcc.c
SOURCES += mbed-stm32f4xx_hal_tim.c
SOURCES += mbed-ticker_api.c
SOURCES += mbed-cmsis_nvic_stm32.c
SOURCES += mbed-hal_tick_stm32.c
endif

View File

@ -20,6 +20,13 @@
#include "mbed-stm32f4xx.h"
/** Pins for UART, the serial port.
*/
#define RXD_PORT PIOA_3_PORT
#define RXD_PIN PIOA_3_PIN
#define TXD_PORT PIOA_2_PORT
#define TXD_PIN PIOA_2_PIN
/**
We define only pins available on the Nucleo F411RE here.
Use alphas for PORT and numerics for PIN, close to the design.

View File

@ -1,94 +0,0 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, STMicroelectronics
* All rights reserved.
*
* 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.
*******************************************************************************
*/
/*
Notes for Teacup:
Copied from $(MBED)/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/PeripheralNames.h.
Used only to get things running quickly. Without serial it's almost
impossible to see wether code changes work. Should go away soon, because
all this MBED stuff is too bloated for Teacup's purposes.
- Prefixed names of #include files with mbed- to match the names of the
copies in the Teacup repo.
*/
#ifndef MBED_PERIPHERALNAMES_H
#define MBED_PERIPHERALNAMES_H
#include "mbed-cmsis_stm32.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
ADC_1 = (int)ADC1_BASE
} ADCName;
typedef enum {
UART_1 = (int)USART1_BASE,
UART_2 = (int)USART2_BASE,
UART_6 = (int)USART6_BASE
} UARTName;
#define STDIO_UART_TX PA_2
#define STDIO_UART_RX PA_3
#define STDIO_UART UART_2
typedef enum {
SPI_1 = (int)SPI1_BASE,
SPI_2 = (int)SPI2_BASE,
SPI_3 = (int)SPI3_BASE,
SPI_4 = (int)SPI4_BASE,
SPI_5 = (int)SPI5_BASE
} SPIName;
typedef enum {
I2C_1 = (int)I2C1_BASE,
I2C_2 = (int)I2C2_BASE,
I2C_3 = (int)I2C3_BASE
} I2CName;
typedef enum {
PWM_1 = (int)TIM1_BASE,
PWM_2 = (int)TIM2_BASE,
PWM_3 = (int)TIM3_BASE,
PWM_4 = (int)TIM4_BASE,
PWM_5 = (int)TIM5_BASE,
PWM_9 = (int)TIM9_BASE,
PWM_10 = (int)TIM10_BASE,
PWM_11 = (int)TIM11_BASE
} PWMName;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,197 +0,0 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, STMicroelectronics
* All rights reserved.
*
* 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.
*******************************************************************************
*/
/*
Notes for Teacup:
Copied from $(MBED)/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/PinNames.h.
Used only to get things running quickly. Without serial it's almost
impossible to see wether code changes work. Should go away soon, because
all this MBED stuff is too bloated for Teacup's purposes.
- Prefixed names of #include files with mbed- to match the names of the
copies in the Teacup repo.
*/
#ifndef MBED_PINNAMES_H
#define MBED_PINNAMES_H
#include "mbed-cmsis_stm32.h"
#ifdef __cplusplus
extern "C" {
#endif
// See stm32f4xx_hal_gpio.h and stm32f4xx_hal_gpio_ex.h for values of MODE, PUPD and AFNUM
#define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((AFNUM) << 7) | ((PUPD) << 4) | ((MODE) << 0)))
#define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((INVERTED & 0x01) << 15) | ((CHANNEL & 0x0F) << 11) | ((AFNUM & 0x0F) << 7) | ((PUPD & 0x07) << 4) | ((MODE & 0x0F) << 0)))
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
#define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x0F)
#define STM_PIN_INVERTED(X) (((X) >> 15) & 0x01)
#define STM_MODE_INPUT (0)
#define STM_MODE_OUTPUT_PP (1)
#define STM_MODE_OUTPUT_OD (2)
#define STM_MODE_AF_PP (3)
#define STM_MODE_AF_OD (4)
#define STM_MODE_ANALOG (5)
#define STM_MODE_IT_RISING (6)
#define STM_MODE_IT_FALLING (7)
#define STM_MODE_IT_RISING_FALLING (8)
#define STM_MODE_EVT_RISING (9)
#define STM_MODE_EVT_FALLING (10)
#define STM_MODE_EVT_RISING_FALLING (11)
#define STM_MODE_IT_EVT_RESET (12)
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
// Low nibble = pin number
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
typedef enum {
PIN_INPUT,
PIN_OUTPUT
} PinDirection;
typedef enum {
PA_0 = 0x00,
PA_1 = 0x01,
PA_2 = 0x02,
PA_3 = 0x03,
PA_4 = 0x04,
PA_5 = 0x05,
PA_6 = 0x06,
PA_7 = 0x07,
PA_8 = 0x08,
PA_9 = 0x09,
PA_10 = 0x0A,
PA_11 = 0x0B,
PA_12 = 0x0C,
PA_13 = 0x0D,
PA_14 = 0x0E,
PA_15 = 0x0F,
PB_0 = 0x10,
PB_1 = 0x11,
PB_2 = 0x12,
PB_3 = 0x13,
PB_4 = 0x14,
PB_5 = 0x15,
PB_6 = 0x16,
PB_7 = 0x17,
PB_8 = 0x18,
PB_9 = 0x19,
PB_10 = 0x1A,
PB_12 = 0x1C,
PB_13 = 0x1D,
PB_14 = 0x1E,
PB_15 = 0x1F,
PC_0 = 0x20,
PC_1 = 0x21,
PC_2 = 0x22,
PC_3 = 0x23,
PC_4 = 0x24,
PC_5 = 0x25,
PC_6 = 0x26,
PC_7 = 0x27,
PC_8 = 0x28,
PC_9 = 0x29,
PC_10 = 0x2A,
PC_11 = 0x2B,
PC_12 = 0x2C,
PC_13 = 0x2D,
PC_14 = 0x2E,
PC_15 = 0x2F,
PD_2 = 0x32,
PH_0 = 0x70,
PH_1 = 0x71,
// Arduino connector namings
A0 = PA_0,
A1 = PA_1,
A2 = PA_4,
A3 = PB_0,
A4 = PC_1,
A5 = PC_0,
D0 = PA_3,
D1 = PA_2,
D2 = PA_10,
D3 = PB_3,
D4 = PB_5,
D5 = PB_4,
D6 = PB_10,
D7 = PA_8,
D8 = PA_9,
D9 = PC_7,
D10 = PB_6,
D11 = PA_7,
D12 = PA_6,
D13 = PA_5,
D14 = PB_9,
D15 = PB_8,
// Generic signals namings
LED1 = PA_5,
LED2 = PA_5,
LED3 = PA_5,
LED4 = PA_5,
USER_BUTTON = PC_13,
SERIAL_TX = PA_2,
SERIAL_RX = PA_3,
USBTX = PA_2,
USBRX = PA_3,
I2C_SCL = PB_8,
I2C_SDA = PB_9,
SPI_MOSI = PA_7,
SPI_MISO = PA_6,
SPI_SCK = PA_5,
SPI_CS = PB_6,
PWM_OUT = PB_3,
// Not connected
NC = (int)0xFFFFFFFF
} PinName;
typedef enum {
PullNone = 0,
PullUp = 1,
PullDown = 2,
OpenDrain = 3,
PullDefault = PullNone
} PinMode;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,58 +0,0 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, STMicroelectronics
* All rights reserved.
*
* 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.
*******************************************************************************
*/
/*
Notes for Teacup:
Copied from $(MBED)/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/PortNames.h.
Used only to get things running quickly. Without serial it's almost
impossible to see wether code changes work. Should go away soon, because
all this MBED stuff is too bloated for Teacup's purposes.
*/
#ifndef MBED_PORTNAMES_H
#define MBED_PORTNAMES_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
PortA = 0,
PortB = 1,
PortC = 2,
PortD = 3,
PortE = 4,
PortH = 7
} PortName;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,83 +0,0 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2015, STMicroelectronics
* All rights reserved.
*
* 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.
*******************************************************************************
*/
/*
Notes for Teacup:
Copied from $(MBED)/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/device.h
Used only to get things running quickly. Without serial it's almost
impossible to see wether code changes work. Should go away soon, because
all this MBED stuff is too bloated for Teacup's purposes.
- Prefixed names of #include files with mbed- to match the names of the
copies in the Teacup repo.
*/
#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 0 // Not present on this device
#define DEVICE_SERIAL 1
#define DEVICE_I2C 1
#define DEVICE_I2CSLAVE 1
#define DEVICE_SPI 1
#define DEVICE_SPISLAVE 1
#define DEVICE_RTC 1
#define DEVICE_PWMOUT 1
#define DEVICE_SLEEP 1
//=======================================
#define DEVICE_SEMIHOST 0
#define DEVICE_LOCALFILESYSTEM 0
#define DEVICE_ID_LENGTH 24
#define DEVICE_DEBUG_AWARENESS 0
#define DEVICE_STDIO_MESSAGES 1
#define DEVICE_ERROR_RED 1
#define LED_RED LED1
#include "mbed-objects_stm32.h"
#endif

View File

@ -1,83 +0,0 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, STMicroelectronics
* All rights reserved.
*
* 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.
*******************************************************************************
*/
/*
Notes for Teacup:
Copied from $(MBED)/mbed/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/gpio_object.h.
Used only to get things running quickly. Without serial it's almost
impossible to see wether code changes work. Should go away soon, because
all this MBED stuff is too bloated for Teacup's purposes.
- Prefixed names of #include files with mbed- to match the names of the
copies in the Teacup repo.
*/
#ifndef MBED_GPIO_OBJECT_H
#define MBED_GPIO_OBJECT_H
#include "mbed-cmsis_stm32.h"
#include "mbed-PortNames_stm32.h"
#include "mbed-PeripheralNames_stm32.h"
#include "mbed-PinNames_stm32.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PinName pin;
uint32_t mask;
__IO uint32_t *reg_in;
__IO uint32_t *reg_set_clr;
} gpio_t;
static inline void gpio_write(gpio_t *obj, int value)
{
if (value) {
*obj->reg_set_clr = obj->mask;
} else {
*obj->reg_set_clr = obj->mask << 16;
}
}
static inline int gpio_read(gpio_t *obj)
{
return ((*obj->reg_in & obj->mask) ? 1 : 0);
}
static inline int gpio_is_connected(const gpio_t *obj) {
return obj->pin != (PinName)NC;
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,120 +0,0 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, STMicroelectronics
* All rights reserved.
*
* 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.
*******************************************************************************
*/
/*
Notes for Teacup:
Copied from $(MBED)/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/objects.h.
Used only to get things running quickly. Without serial it's almost
impossible to see wether code changes work. Should go away soon, because
all this MBED stuff is too bloated for Teacup's purposes.
- Prefixed names of #include files with mbed- to match the names of the
copies in the Teacup repo.
*/
#ifndef MBED_OBJECTS_H
#define MBED_OBJECTS_H
#include "mbed-cmsis_stm32.h"
#include "mbed-PortNames_stm32.h"
#include "mbed-PeripheralNames_stm32.h"
#include "mbed-PinNames_stm32.h"
#ifdef __cplusplus
extern "C" {
#endif
struct gpio_irq_s {
IRQn_Type irq_n;
uint32_t irq_index;
uint32_t event;
PinName pin;
};
struct port_s {
PortName port;
uint32_t mask;
PinDirection direction;
__IO uint32_t *reg_in;
__IO uint32_t *reg_out;
};
struct analogin_s {
ADCName adc;
PinName pin;
uint8_t channel;
};
struct serial_s {
UARTName uart;
int index; // Used by irq
uint32_t baudrate;
uint32_t databits;
uint32_t stopbits;
uint32_t parity;
PinName pin_tx;
PinName pin_rx;
};
struct spi_s {
SPIName spi;
uint32_t bits;
uint32_t cpol;
uint32_t cpha;
uint32_t mode;
uint32_t nss;
uint32_t br_presc;
PinName pin_miso;
PinName pin_mosi;
PinName pin_sclk;
PinName pin_ssel;
};
struct i2c_s {
I2CName i2c;
uint32_t slave;
};
struct pwmout_s {
PWMName pwm;
PinName pin;
uint32_t period;
uint32_t pulse;
uint8_t channel;
uint8_t inverted;
};
#include "mbed-gpio_object_stm32.h"
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,59 +0,0 @@
/* 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.
*/
/*
Notes for Teacup:
Copied from $(MBED)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pinmap.c.
Used only to get things running quickly. Without serial it's almost
impossible to see wether code changes work. Should go away soon, because
all this MBED stuff is too bloated for Teacup's purposes.
- Prefixed names of #include files with mbed- to match the names of the
copies in the Teacup repo.
- Wrapped the whole file in #ifdef __ARMEL__ to not cause conflicts with
AVR builds.
*/
#ifdef __ARM_LPC1114__
#include "mbed-mbed_assert.h"
#include "mbed-pinmap.h"
void pin_function(PinName pin, int function) {
uint32_t offset = (uint32_t)pin & 0xff;
__IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + offset);
// pin function bits: [2:0] -> 111 = (0x7)
*reg = (*reg & ~0x7) | (function & 0x7);
}
void pin_mode(PinName pin, PinMode mode) {
uint32_t offset = (uint32_t)pin & 0xff;
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;
// pin mode bits: [4:3] -> 11000 = (0x3 << 3)
tmp &= ~(0x3 << 3);
tmp |= (mode & 0x3) << 3;
// drain
tmp &= ~(0x1 << 10);
tmp |= drain << 10;
*reg = tmp;
}
#endif /* __ARMEL__ */

View File

@ -1,56 +0,0 @@
/* 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.
*/
/*
Notes for Teacup:
Copied from $(MBED)/libraries/mbed/hal/pinmap.h.
Used only to get things running quickly. Without serial it's almost
impossible to see wether code changes work. Should go away soon, because
all this MBED stuff is too bloated for Teacup's purposes.
- Prefixed names of #include files with mbed- to match the names of the
copies in the Teacup repo.
- Different PinNames.h for STM32 and LPC
*/
#ifndef MBED_PINMAP_H
#define MBED_PINMAP_H
#ifdef __ARM_LPC1114__
#include "mbed-PinNames.h"
#elif __ARM_STM32F411__
#include "mbed-PinNames_stm32.h"
#include "mbed-stm32f4xx_hal.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PinName pin;
int peripheral;
int function;
} PinMap;
void pin_function(PinName pin, int function);
void pin_mode (PinName pin, PinMode mode);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,192 +0,0 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, STMicroelectronics
* All rights reserved.
*
* 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.
*******************************************************************************
*/
/*
Notes for Teacup:
Copied from $(MBED)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pinmap.c.
Used only to get things running quickly. Without serial it's almost
impossible to see wether code changes work. Should go away soon, because
all this MBED stuff is too bloated for Teacup's purposes.
- Prefixed names of #include files with mbed- to match the names of the
copies in the Teacup repo.
- Wrapped the whole file in #ifdef __ARMEL__ to not cause conflicts with
AVR builds.
*/
#ifdef __ARM_STM32F411__
#include "mbed-pinmap.h"
#include "mbed-PortNames_stm32.h"
// GPIO mode look-up table
static const uint32_t gpio_mode[13] = {
0x00000000, // 0 = GPIO_MODE_INPUT
0x00000001, // 1 = GPIO_MODE_OUTPUT_PP
0x00000011, // 2 = GPIO_MODE_OUTPUT_OD
0x00000002, // 3 = GPIO_MODE_AF_PP
0x00000012, // 4 = GPIO_MODE_AF_OD
0x00000003, // 5 = GPIO_MODE_ANALOG
0x10110000, // 6 = GPIO_MODE_IT_RISING
0x10210000, // 7 = GPIO_MODE_IT_FALLING
0x10310000, // 8 = GPIO_MODE_IT_RISING_FALLING
0x10120000, // 9 = GPIO_MODE_EVT_RISING
0x10220000, // 10 = GPIO_MODE_EVT_FALLING
0x10320000, // 11 = GPIO_MODE_EVT_RISING_FALLING
0x10000000 // 12 = Reset GPIO_MODE_IT_EVT
};
// Enable GPIO clock and return GPIO base address
uint32_t Set_GPIO_Clock(uint32_t port_idx)
{
uint32_t gpio_add = 0;
switch (port_idx) {
case PortA:
gpio_add = GPIOA_BASE;
__GPIOA_CLK_ENABLE();
break;
case PortB:
gpio_add = GPIOB_BASE;
__GPIOB_CLK_ENABLE();
break;
case PortC:
gpio_add = GPIOC_BASE;
__GPIOC_CLK_ENABLE();
break;
#if defined GPIOD_BASE
case PortD:
gpio_add = GPIOD_BASE;
__GPIOD_CLK_ENABLE();
break;
#endif
#if defined GPIOE_BASE
case PortE:
gpio_add = GPIOE_BASE;
__GPIOE_CLK_ENABLE();
break;
#endif
#if defined GPIOF_BASE
case PortF:
gpio_add = GPIOF_BASE;
__GPIOF_CLK_ENABLE();
break;
#endif
#if defined GPIOG_BASE
case PortG:
gpio_add = GPIOG_BASE;
__GPIOG_CLK_ENABLE();
break;
#endif
#if defined GPIOH_BASE
case PortH:
gpio_add = GPIOH_BASE;
__GPIOH_CLK_ENABLE();
break;
#endif
#if defined GPIOI_BASE
case PortI:
gpio_add = GPIOI_BASE;
__GPIOI_CLK_ENABLE();
break;
#endif
#if defined GPIOJ_BASE
case PortJ:
gpio_add = GPIOJ_BASE;
__GPIOJ_CLK_ENABLE();
break;
#endif
#if defined GPIOK_BASE
case PortK:
gpio_add = GPIOK_BASE;
__GPIOK_CLK_ENABLE();
break;
#endif
default:
break;
}
return gpio_add;
}
/**
* Configure pin (mode, speed, output type and pull-up/pull-down)
*/
void pin_function(PinName pin, int data)
{
// Get the pin informations
uint32_t mode = STM_PIN_MODE(data);
uint32_t pupd = STM_PIN_PUPD(data);
uint32_t afnum = STM_PIN_AFNUM(data);
uint32_t port_index = STM_PORT(pin);
uint32_t pin_index = STM_PIN(pin);
// Enable GPIO clock
uint32_t gpio_add = Set_GPIO_Clock(port_index);
GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add;
// Configure GPIO
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Pin = (uint32_t)(1 << pin_index);
GPIO_InitStructure.Mode = gpio_mode[mode];
GPIO_InitStructure.Pull = pupd;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
GPIO_InitStructure.Alternate = afnum;
HAL_GPIO_Init(gpio, &GPIO_InitStructure);
// [TODO] Disconnect JTAG-DP + SW-DP signals.
// Warning: Need to reconnect under reset
//if ((pin == PA_13) || (pin == PA_14)) {
//
//}
//if ((pin == PA_15) || (pin == PB_3) || (pin == PB_4)) {
//
//}
}
/**
* Configure pin pull-up/pull-down
*/
void pin_mode(PinName pin, PinMode mode)
{
uint32_t port_index = STM_PORT(pin);
uint32_t pin_index = STM_PIN(pin);
// Enable GPIO clock
uint32_t gpio_add = Set_GPIO_Clock(port_index);
GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add;
// 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
gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2)));
gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2));
}
#endif

View File

@ -95,7 +95,6 @@
#ifdef __ARM_STM32F411__
#include "mbed-stm32f4xx.h"
#include "mbed-hal_tick_stm32.h"
#include "mbed-stm32f4xx_hal.h"
#if !defined (HSE_VALUE)
@ -243,17 +242,10 @@ void SystemInit(void)
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#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;
}
/**

View File

@ -1,135 +0,0 @@
/* mbed Microcontroller Library
* Copyright (c) 2015 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 <stddef.h>
#include "mbed-ticker_api.h"
#include "mbed-cmsis_stm32.h"
void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler) {
data->interface->init();
data->queue->event_handler = handler;
}
void ticker_irq_handler(const ticker_data_t *const data) {
data->interface->clear_interrupt();
/* Go through all the pending TimerEvents */
while (1) {
if (data->queue->head == NULL) {
// There are no more TimerEvents left, so disable matches.
data->interface->disable_interrupt();
return;
}
if ((int)(data->queue->head->timestamp - data->interface->read()) <= 0) {
// This event was in the past:
// point to the following one and execute its handler
ticker_event_t *p = data->queue->head;
data->queue->head = data->queue->head->next;
if (data->queue->event_handler != NULL) {
(*data->queue->event_handler)(p->id); // NOTE: the handler can set new events
}
/* Note: We continue back to examining the head because calling the
* event handler may have altered the chain of pending events. */
} else {
// This event and the following ones in the list are in the future:
// set it as next interrupt and return
data->interface->set_interrupt(data->queue->head->timestamp);
return;
}
}
}
void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, timestamp_t timestamp, uint32_t id) {
/* disable interrupts for the duration of the function */
__disable_irq();
// initialise our data
obj->timestamp = timestamp;
obj->id = id;
/* Go through the list until we either reach the end, or find
an element this should come before (which is possibly the
head). */
ticker_event_t *prev = NULL, *p = data->queue->head;
while (p != NULL) {
/* check if we come before p */
if ((int)(timestamp - p->timestamp) < 0) {
break;
}
/* go to the next element */
prev = p;
p = p->next;
}
/* if prev is NULL we're at the head */
if (prev == NULL) {
data->queue->head = obj;
data->interface->set_interrupt(timestamp);
} else {
prev->next = obj;
}
/* if we're at the end p will be NULL, which is correct */
obj->next = p;
__enable_irq();
}
void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj) {
__disable_irq();
// remove this object from the list
if (data->queue->head == obj) {
// first in the list, so just drop me
data->queue->head = obj->next;
if (data->queue->head == NULL) {
data->interface->disable_interrupt();
} else {
data->interface->set_interrupt(data->queue->head->timestamp);
}
} else {
// find the object before me, then drop me
ticker_event_t* p = data->queue->head;
while (p != NULL) {
if (p->next == obj) {
p->next = obj->next;
break;
}
p = p->next;
}
}
__enable_irq();
}
timestamp_t ticker_read(const ticker_data_t *const data)
{
return data->interface->read();
}
int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *timestamp)
{
int ret = 0;
/* if head is NULL, there are no pending events */
__disable_irq();
if (data->queue->head != NULL) {
*timestamp = data->queue->head->timestamp;
ret = 1;
}
__enable_irq();
return ret;
}

View File

@ -1,108 +0,0 @@
/* mbed Microcontroller Library
* Copyright (c) 2015 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_TICKER_API_H
#define MBED_TICKER_API_H
#include "mbed-device_stm32.h"
typedef uint32_t timestamp_t;
/** Ticker's event structure
*/
typedef struct ticker_event_s {
timestamp_t timestamp; /**< Event's timestamp */
uint32_t id; /**< TimerEvent object */
struct ticker_event_s *next; /**< Next event in the queue */
} ticker_event_t;
typedef void (*ticker_event_handler)(uint32_t id);
/** Ticker's interface structure - required API for a ticker
*/
typedef struct {
void (*init)(void); /**< Init function */
uint32_t (*read)(void); /**< Read function */
void (*disable_interrupt)(void); /**< Disable interrupt function */
void (*clear_interrupt)(void); /**< Clear interrupt function */
void (*set_interrupt)(timestamp_t timestamp); /**< Set interrupt function */
} ticker_interface_t;
/** Tickers events queue structure
*/
typedef struct {
ticker_event_handler event_handler; /**< Event handler */
ticker_event_t *head; /**< A pointer to head */
} ticker_event_queue_t;
/** Tickers data structure
*/
typedef struct {
const ticker_interface_t *interface; /**< Ticker's interface */
ticker_event_queue_t *queue; /**< Ticker's events queue */
} ticker_data_t;
#ifdef __cplusplus
extern "C" {
#endif
/** Initialize a ticker and sets the event handler
*
* @param data The ticker's data
* @param handler A handler to be set
*/
void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler);
/** Irq handler which goes through the events to trigger events in the past.
*
* @param data The ticker's data
*/
void ticker_irq_handler(const ticker_data_t *const data);
/** Remove an event from the queue
*
* @param data The ticker's data
* @param obj The event's queue to be removed
*/
void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj);
/** Insert an event from the queue
*
* @param data The ticker's data
* @param obj The event's queue to be removed
* @param timestamp The event's timestamp
* @param id The event object
*/
void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, timestamp_t timestamp, uint32_t id);
/** Read the current ticker's timestamp
*
* @param data The ticker's data
* @return The current timestamp
*/
timestamp_t ticker_read(const ticker_data_t *const data);
/** Read the next event's timestamp
*
* @param data The ticker's data
* @return 1 if timestamp is pending event, 0 if there's no event pending
*/
int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *timestamp);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -161,12 +161,12 @@
#define _PULLUP_ON(IO) \
do { \
IO ## _PORT->PUPDR &= ~(3 << ((IO ## _PIN) << 1)); \
IO ## _PORT->PUPDR |= (1 << ((IO ## _PIN) << 1)) * 0x1; \
IO ## _PORT->PUPDR |= (1 << ((IO ## _PIN) << 1)); \
} while (0)
/// Disable pullup resistor.
#define _PULLUP_OFF(IO) \
do { \
IO ## _PORT->PUPDR &= ~(1 << ((IO ## _PIN) << 1)) * 0x1; \
IO ## _PORT->PUPDR &= ~(3 << ((IO ## _PIN) << 1)); \
} while (0)
#elif defined SIMULATOR

View File

@ -12,7 +12,6 @@
#if defined TEACUP_C_INCLUDE && defined __ARM_STM32F411__
#include "arduino.h"
#include "mbed-pinmap.h"
#ifdef XONXOFF
#error XON/XOFF protocol not yet implemented for ARM. \
@ -23,18 +22,26 @@ USART_TypeDef *port = USART2;
void serial_init()
{
// Enable USART clock
volatile uint32_t tmpreg;
SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);
/* Delay after an RCC peripheral clock enabling */
tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);
(void)(tmpreg);
// Enable TX/RX clock (GPIOA)
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
// Enable USART2 clock
RCC->APB1ENR |= RCC_APB1ENR_USART2EN;
// Configure the UART pins
pin_function(USBTX, 0x393);
pin_mode(USBTX, PullUp);
pin_function(USBRX, 0x393);
pin_mode(USBRX, PullUp);
// AF 4bits per channel
// Alternate functions from DM00115249.pdf datasheet (page 47; table 9)
TXD_PORT->AFR[0] |= (GPIO_AF7_USART2 << ((TXD_PIN) << 2));
RXD_PORT->AFR[0] |= (GPIO_AF7_USART2 << ((RXD_PIN) << 2));
// MODER 2bits per channel
TXD_PORT->MODER |= (GPIO_MODE_AF_PP << ((TXD_PIN) << 1)); // set bit2: alternate function
RXD_PORT->MODER |= (GPIO_MODE_AF_PP << ((RXD_PIN) << 1));
TXD_PORT->OSPEEDR |= GPIO_SPEED_HIGH << ((TXD_PIN) << 1);
RXD_PORT->OSPEEDR |= GPIO_SPEED_HIGH << ((RXD_PIN) << 1);
TXD_PORT->PUPDR |= (GPIO_PULLUP << ((TXD_PIN) << 1)); //Pullup
RXD_PORT->PUPDR |= (GPIO_PULLUP << ((RXD_PIN) << 1)); //Pullup? LPC has No Pull-up or Pull-down activation
/* Disable the peripheral */
port->CR1 &= ~USART_CR1_UE;
@ -42,26 +49,26 @@ void serial_init()
/* Set the UART Communication parameters */
/*-------------------------- USART CR2 Configuration -----------------------*/
/* Clear STOP[13:12] bits */
port->CR2 &= (uint32_t)~((uint32_t)USART_CR2_STOP);
port->CR2 &= ~(USART_CR2_STOP);
/* Configure the UART Stop Bits: Set STOP[13:12] bits according to huart->Init.StopBits value */
port->CR2 |= (uint32_t)UART_STOPBITS_1;
port->CR2 |= UART_STOPBITS_1;
/*-------------------------- USART CR1 Configuration -----------------------*/
/* Clear M, PCE, PS, TE and RE bits */
port->CR1 &= (uint32_t)~((uint32_t)(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | \
USART_CR1_RE | USART_CR1_OVER8));
port->CR1 &= ~(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | \
USART_CR1_RE | USART_CR1_OVER8);
/* Configure the UART Word Length, Parity and mode:
Set the M bits according to huart->Init.WordLength value
Set PCE and PS bits according to huart->Init.Parity value
Set TE and RE bits according to huart->Init.Mode value
Set OVER8 bit according to huart->Init.OverSampling value */
port->CR1 |= (uint32_t)UART_WORDLENGTH_8B | UART_PARITY_NONE | UART_MODE_TX_RX | UART_OVERSAMPLING_16;
port->CR1 |= UART_WORDLENGTH_8B | UART_PARITY_NONE | UART_MODE_TX_RX | UART_OVERSAMPLING_16;
/*-------------------------- USART CR3 Configuration -----------------------*/
/* Clear CTSE and RTSE bits */
port->CR3 &= (uint32_t)~((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE));
port->CR3 &= ~(USART_CR3_RTSE | USART_CR3_CTSE);
/* Configure the UART HFC: Set CTSE and RTSE bits according to huart->Init.HwFlowCtl value */
port->CR3 |= UART_HWCONTROL_NONE;