Merge branch 'release/v16.1.0'
This commit is contained in:
2
.github/workflows/examples.yml
vendored
2
.github/workflows/examples.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
||||
- "examples/mbed-rtos-mesh-minimal"
|
||||
- "examples/mbed-rtos-serial"
|
||||
- "examples/mbed-rtos-usb-keyboard"
|
||||
- "examples/mbed-rtos-wifi"
|
||||
- "examples/mbed-rtos-sockets"
|
||||
- "examples/spl-blink"
|
||||
- "examples/stm32cube-hal-blink"
|
||||
- "examples/stm32cube-hal-eeprom-emulation"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"mcu": "stm32u575zit6q",
|
||||
"product_line": "STM32U575xx",
|
||||
"variant": "STM32U5xx/U575Z(G-I)TxQ_U585ZETxQ"
|
||||
"variant": "STM32U5xx/U575Z(G-I)TxQ_U585ZITxQ"
|
||||
},
|
||||
"connectivity": [
|
||||
"can"
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
"lpticker_lptim": {
|
||||
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
|
||||
"value": 1
|
||||
},
|
||||
"i2c_timing_value_algo": {
|
||||
"help": "If value was set to true I2C timing algorithm is enabled. Enabling may leads to performance issue. Keeping this false and changing system clock will trigger assert.)",
|
||||
"value": false
|
||||
}
|
||||
},
|
||||
"macros_add": [
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if("NUCLEO_L452RE_P" IN_LIST MBED_TARGET_LABELS)
|
||||
add_subdirectory(TARGET_NUCLEO_L452RE_P)
|
||||
endif()
|
||||
add_subdirectory(TARGET_NUCLEO_L452RE_P EXCLUDE_FROM_ALL)
|
||||
|
||||
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
|
||||
set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32l452xx.S)
|
||||
@@ -13,15 +11,20 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
|
||||
set(LINKER_FILE TOOLCHAIN_ARM/stm32l452xe.sct)
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
|
||||
add_library(mbed-stm32l452xe INTERFACE)
|
||||
|
||||
target_sources(mbed-core
|
||||
target_sources(mbed-stm32l452xe
|
||||
INTERFACE
|
||||
system_clock.c
|
||||
${STARTUP_FILE}
|
||||
)
|
||||
|
||||
target_include_directories(mbed-core
|
||||
target_include_directories(mbed-stm32l452xe
|
||||
INTERFACE
|
||||
.
|
||||
)
|
||||
|
||||
|
||||
mbed_set_linker_script(mbed-stm32l452xe ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
|
||||
|
||||
target_link_libraries(mbed-stm32l452xe INTERFACE mbed-stm32l4)
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
target_sources(mbed-core
|
||||
add_library(mbed-nucleo-l452re-p INTERFACE)
|
||||
|
||||
target_sources(mbed-nucleo-l452re-p
|
||||
INTERFACE
|
||||
PeripheralPins.c
|
||||
)
|
||||
|
||||
target_include_directories(mbed-core
|
||||
target_include_directories(mbed-nucleo-l452re-p
|
||||
INTERFACE
|
||||
.
|
||||
)
|
||||
|
||||
target_link_libraries(mbed-nucleo-l452re-p INTERFACE mbed-stm32l452xe)
|
||||
|
||||
@@ -124,44 +124,44 @@ MBED_WEAK const PinMap PinMap_I2C_SCL[] = {
|
||||
// You have to comment all PWM using TIM_MST defined in hal_tick.h file
|
||||
// or update python script (check TIM_MST_LIST) and re-run it
|
||||
MBED_WEAK const PinMap PinMap_PWM[] = {
|
||||
// {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // TIM2 used by us_ticker
|
||||
// {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // TIM2 used by us_ticker
|
||||
{PA_1_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 1)}, // TIM15_CH1N
|
||||
// {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // Connected to STDIO_UART_TX
|
||||
// {PA_2, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 0)}, // TIM15_CH1 // Connected to STDIO_UART_TX
|
||||
// {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // Connected to STDIO_UART_RX
|
||||
// {PA_3, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 2, 0)}, // TIM15_CH2 // Connected to STDIO_UART_RX
|
||||
// {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // Connected to SMPS_V1, TIM2 used by us_ticker
|
||||
{PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 // Connected to SMPS_PG [ADP5301ACBZ_OUTOK]
|
||||
{PA_6_ALT0, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1 // Connected to SMPS_PG [ADP5301ACBZ_OUTOK]
|
||||
{PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // Connected to SMPS_SW [TS3A44159PWR_IN1_2]
|
||||
{PA_7_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // Connected to SMPS_SW [TS3A44159PWR_IN1_2]
|
||||
{PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
|
||||
{PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
|
||||
{PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
|
||||
{PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
|
||||
// {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // TIM2 used by us_ticker
|
||||
{PB_0, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
{PB_0_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
|
||||
{PB_1, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
{PB_1_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
|
||||
// {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // TIM2 used by us_ticker
|
||||
{PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
{PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PB_6, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 1)}, // TIM16_CH1N
|
||||
{PB_8, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1
|
||||
// {PB_10, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // TIM2 used by usticker
|
||||
// {PB_11, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // TIM2 used by usticker
|
||||
{PB_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // Connected to LD4 [green Led]
|
||||
{PB_13_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 1)}, // TIM15_CH1N // Connected to LD4 [green Led]
|
||||
{PB_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
{PB_14_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 0)}, // TIM15_CH1
|
||||
{PB_15, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
{PB_15_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 2, 0)}, // TIM15_CH2
|
||||
{PC_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
{PC_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PC_8, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
|
||||
{PC_9, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
|
||||
// {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // TIM2 used by us_ticker
|
||||
// {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // TIM2 used by us_ticker
|
||||
{PA_1, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_TIM15, 1, 1)}, // TIM15_CH1N
|
||||
// {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // Connected to STDIO_UART_TX
|
||||
// {PA_2, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_TIM15, 1, 0)}, // TIM15_CH1 // Connected to STDIO_UART_TX
|
||||
// {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // Connected to STDIO_UART_RX
|
||||
// {PA_3, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_TIM15, 2, 0)}, // TIM15_CH2 // Connected to STDIO_UART_RX
|
||||
// {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // Connected to SMPS_V1, TIM2 used by us_ticker
|
||||
{PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 // Connected to SMPS_PG [ADP5301ACBZ_OUTOK]
|
||||
{PA_6_ALT0, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1 // Connected to SMPS_PG [ADP5301ACBZ_OUTOK]
|
||||
{PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // Connected to SMPS_SW [TS3A44159PWR_IN1_2]
|
||||
{PA_7_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // Connected to SMPS_SW [TS3A44159PWR_IN1_2]
|
||||
{PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
|
||||
{PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
|
||||
{PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
|
||||
{PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
|
||||
// {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // TIM2 used by us_ticker
|
||||
{PB_0, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
{PB_0_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
|
||||
{PB_1, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
{PB_1_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
|
||||
// {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // TIM2 used by us_ticker
|
||||
{PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
{PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PB_6, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_TIM16, 1, 1)}, // TIM16_CH1N
|
||||
{PB_8, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1
|
||||
// {PB_10, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // TIM2 used by usticker
|
||||
// {PB_11, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // TIM2 used by usticker
|
||||
{PB_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // Connected to LD4 [green Led]
|
||||
{PB_13_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_TIM15, 1, 1)}, // TIM15_CH1N // Connected to LD4 [green Led]
|
||||
{PB_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
{PB_14_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_TIM15, 1, 0)}, // TIM15_CH1
|
||||
{PB_15, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
{PB_15_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_TIM15, 2, 0)}, // TIM15_CH2
|
||||
{PC_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
{PC_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PC_8, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
|
||||
{PC_9, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
@@ -170,12 +170,12 @@ MBED_WEAK const PinMap PinMap_PWM[] = {
|
||||
MBED_WEAK const PinMap PinMap_UART_TX[] = {
|
||||
{PA_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to STDIO_UART_TX
|
||||
{PA_2_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to STDIO_UART_TX
|
||||
{PA_2_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to STDIO_UART_TX
|
||||
{PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PB_11, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_1, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_11, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_1, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_4, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PC_10_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
@@ -185,13 +185,13 @@ MBED_WEAK const PinMap PinMap_UART_TX[] = {
|
||||
MBED_WEAK const PinMap PinMap_UART_RX[] = {
|
||||
{PA_1, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to STDIO_UART_RX
|
||||
{PA_3_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to STDIO_UART_RX
|
||||
{PA_3_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to STDIO_UART_RX
|
||||
{PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PA_15, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART2)},
|
||||
{PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_10, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_10, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PC_0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PC_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PC_11_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{NC, NC, 0}
|
||||
@@ -203,9 +203,9 @@ MBED_WEAK const PinMap PinMap_UART_RTS[] = {
|
||||
{PA_15, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PA_15_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PB_1, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{PB_1_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_1_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_3, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_12, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_12, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
|
||||
{PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
@@ -213,12 +213,12 @@ MBED_WEAK const PinMap PinMap_UART_RTS[] = {
|
||||
MBED_WEAK const PinMap PinMap_UART_CTS[] = {
|
||||
{PA_0, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_6, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to SMPS_PG [ADP5301ACBZ_OUTOK]
|
||||
{PA_6_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to SMPS_PG [ADP5301ACBZ_OUTOK]
|
||||
{PA_6_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to SMPS_PG [ADP5301ACBZ_OUTOK]
|
||||
{PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_4, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_7, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
{PB_13, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to LD4 [green Led]
|
||||
{PB_13_ALT0, LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to LD4 [green Led]
|
||||
{PB_13_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to LD4 [green Led]
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,33 +1,22 @@
|
||||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2016-2021 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:
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.
|
||||
*******************************************************************************
|
||||
* Automatically generated from STM32CubeMX/db/mcu/STM32L452RETxP.xml
|
||||
*/
|
||||
|
||||
/* MBED TARGET LIST: NUCLEO_L452RE_P */
|
||||
|
||||
#ifndef MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
@@ -40,153 +29,127 @@ extern "C" {
|
||||
|
||||
typedef enum {
|
||||
ALT0 = 0x100,
|
||||
ALT1 = 0x200,
|
||||
ALT2 = 0x300,
|
||||
ALT3 = 0x400
|
||||
} ALTx;
|
||||
|
||||
typedef enum {
|
||||
PA_0 = 0x00,
|
||||
PA_1 = 0x01,
|
||||
PA_1_ALT0 = PA_1 | ALT0,
|
||||
PA_2 = 0x02,
|
||||
PA_2_ALT0 = PA_2 | ALT0,
|
||||
PA_3 = 0x03,
|
||||
PA_3_ALT0 = PA_3 | ALT0,
|
||||
PA_4 = 0x04,
|
||||
PA_4_ALT0 = PA_4 | ALT0,
|
||||
PA_5 = 0x05,
|
||||
PA_6 = 0x06,
|
||||
PA_6_ALT0 = PA_6 | ALT0,
|
||||
PA_7 = 0x07,
|
||||
PA_7_ALT0 = PA_7 | ALT0,
|
||||
PA_8 = 0x08,
|
||||
PA_9 = 0x09,
|
||||
PA_10 = 0x0A,
|
||||
PA_11 = 0x0B,
|
||||
PA_12 = 0x0C,
|
||||
PA_13 = 0x0D,
|
||||
PA_13_ALT0 = PA_13 | ALT0,
|
||||
PA_14 = 0x0E,
|
||||
PA_14_ALT0 = PA_14 | ALT0,
|
||||
PA_15 = 0x0F,
|
||||
PA_15_ALT0 = PA_15 | ALT0,
|
||||
PA_0 = 0x00,
|
||||
PA_1 = 0x01,
|
||||
PA_2 = 0x02,
|
||||
PA_2_ALT0 = PA_2 | ALT0, // same pin used for alternate HW
|
||||
PA_3 = 0x03,
|
||||
PA_3_ALT0 = PA_3 | ALT0, // same pin used for alternate HW
|
||||
PA_4 = 0x04,
|
||||
PA_4_ALT0 = PA_4 | ALT0, // same pin used for alternate HW
|
||||
PA_5 = 0x05,
|
||||
PA_6 = 0x06,
|
||||
PA_6_ALT0 = PA_6 | ALT0, // same pin used for alternate HW
|
||||
PA_7 = 0x07,
|
||||
PA_7_ALT0 = PA_7 | ALT0, // same pin used for alternate HW
|
||||
PA_8 = 0x08,
|
||||
PA_9 = 0x09,
|
||||
PA_10 = 0x0A,
|
||||
PA_11 = 0x0B,
|
||||
PA_12 = 0x0C,
|
||||
PA_13 = 0x0D,
|
||||
PA_14 = 0x0E,
|
||||
PA_15 = 0x0F,
|
||||
PA_15_ALT0 = PA_15 | ALT0, // same pin used for alternate HW
|
||||
PB_0 = 0x10,
|
||||
PB_0_ALT0 = PB_0 | ALT0, // same pin used for alternate HW
|
||||
PB_1 = 0x11,
|
||||
PB_1_ALT0 = PB_1 | ALT0, // same pin used for alternate HW
|
||||
PB_2 = 0x12,
|
||||
PB_3 = 0x13,
|
||||
PB_3_ALT0 = PB_3 | ALT0, // same pin used for alternate HW
|
||||
PB_4 = 0x14,
|
||||
PB_4_ALT0 = PB_4 | ALT0, // same pin used for alternate HW
|
||||
PB_5 = 0x15,
|
||||
PB_5_ALT0 = PB_5 | ALT0, // same pin used for alternate HW
|
||||
PB_6 = 0x16,
|
||||
PB_6_ALT0 = PB_6 | ALT0, // same pin used for alternate HW
|
||||
PB_7 = 0x17,
|
||||
PB_7_ALT0 = PB_7 | ALT0, // same pin used for alternate HW
|
||||
PB_8 = 0x18,
|
||||
PB_9 = 0x19,
|
||||
PB_10 = 0x1A,
|
||||
PB_10_ALT0 = PB_10 | ALT0, // same pin used for alternate HW
|
||||
PB_11 = 0x1B,
|
||||
PB_11_ALT0 = PB_11 | ALT0, // same pin used for alternate HW
|
||||
PB_12 = 0x1C,
|
||||
PB_13 = 0x1D,
|
||||
PB_13_ALT0 = PB_13 | ALT0, // same pin used for alternate HW
|
||||
PB_14 = 0x1E,
|
||||
PB_14_ALT0 = PB_14 | ALT0, // same pin used for alternate HW
|
||||
PB_15 = 0x1F,
|
||||
PB_15_ALT0 = PB_15 | ALT0, // same pin used for alternate HW
|
||||
PC_0 = 0x20,
|
||||
PC_0_ALT0 = PC_0 | ALT0, // same pin used for alternate HW
|
||||
PC_1 = 0x21,
|
||||
PC_1_ALT0 = PC_1 | ALT0, // same pin used for alternate HW
|
||||
PC_2 = 0x22,
|
||||
PC_3 = 0x23,
|
||||
PC_4 = 0x24,
|
||||
PC_6 = 0x26,
|
||||
PC_7 = 0x27,
|
||||
PC_8 = 0x28,
|
||||
PC_9 = 0x29,
|
||||
PC_10 = 0x2A,
|
||||
PC_10_ALT0 = PC_10 | ALT0, // same pin used for alternate HW
|
||||
PC_11 = 0x2B,
|
||||
PC_11_ALT0 = PC_11 | ALT0, // same pin used for alternate HW
|
||||
PC_12 = 0x2C,
|
||||
PC_13 = 0x2D,
|
||||
PC_14 = 0x2E,
|
||||
PC_15 = 0x2F,
|
||||
PH_0 = 0x70,
|
||||
PH_1 = 0x71,
|
||||
PH_3 = 0x73,
|
||||
|
||||
PB_0 = 0x10,
|
||||
PB_0_ALT0 = PB_0 | ALT0,
|
||||
PB_1 = 0x11,
|
||||
PB_1_ALT0 = PB_1 | ALT0,
|
||||
PB_2 = 0x12,
|
||||
PB_3 = 0x13,
|
||||
PB_3_ALT0 = PB_3 | ALT0,
|
||||
PB_4 = 0x14,
|
||||
PB_4_ALT0 = PB_4 | ALT0,
|
||||
PB_5 = 0x15,
|
||||
PB_5_ALT0 = PB_5 | ALT0,
|
||||
PB_6 = 0x16,
|
||||
PB_6_ALT0 = PB_6 | ALT0,
|
||||
PB_7 = 0x17,
|
||||
PB_7_ALT0 = PB_7 | ALT0,
|
||||
PB_8 = 0x18,
|
||||
PB_9 = 0x19,
|
||||
PB_10 = 0x1A,
|
||||
PB_10_ALT0 = PB_10 | ALT0,
|
||||
PB_11 = 0x1B,
|
||||
PB_11_ALT0 = PB_11 | ALT0,
|
||||
PB_12 = 0x1C,
|
||||
PB_13 = 0x1D,
|
||||
PB_13_ALT0 = PB_13 | ALT0,
|
||||
PB_14 = 0x1E,
|
||||
PB_14_ALT0 = PB_14 | ALT0,
|
||||
PB_15 = 0x1F,
|
||||
PB_15_ALT0 = PB_15 | ALT0,
|
||||
/**** ADC internal channels ****/
|
||||
|
||||
PC_0 = 0x20,
|
||||
PC_0_ALT0 = PC_0 | ALT0,
|
||||
PC_1 = 0x21,
|
||||
PC_1_ALT0 = PC_1 | ALT0,
|
||||
PC_2 = 0x22,
|
||||
PC_3 = 0x23,
|
||||
PC_4 = 0x24,
|
||||
// PC_5 = 0x25, // There is no PC_5 on an LQFP64 SMPS package (for the -P Nucleo)
|
||||
PC_6 = 0x26,
|
||||
PC_7 = 0x27,
|
||||
PC_8 = 0x28,
|
||||
PC_9 = 0x29,
|
||||
PC_10 = 0x2A,
|
||||
PC_10_ALT0 = PC_10 | ALT0,
|
||||
PC_11 = 0x2B,
|
||||
PC_11_ALT0 = PC_11 | ALT0,
|
||||
PC_12 = 0x2C,
|
||||
PC_13 = 0x2D,
|
||||
PC_14 = 0x2E,
|
||||
PC_15 = 0x2F,
|
||||
ADC_TEMP = 0xF0, // Internal pin virtual value
|
||||
ADC_VREF = 0xF1, // Internal pin virtual value
|
||||
ADC_VBAT = 0xF2, // Internal pin virtual value
|
||||
|
||||
PH_0 = 0x70,
|
||||
PH_1 = 0x71,
|
||||
#ifdef TARGET_FF_ARDUINO_UNO
|
||||
// Arduino Uno (Rev3) pins
|
||||
ARDUINO_UNO_A0 = PA_0,
|
||||
ARDUINO_UNO_A1 = PA_1,
|
||||
ARDUINO_UNO_A2 = PC_3,
|
||||
ARDUINO_UNO_A3 = PC_2,
|
||||
ARDUINO_UNO_A4 = PC_1,
|
||||
ARDUINO_UNO_A5 = PC_0,
|
||||
|
||||
PH_3 = 0x73,
|
||||
|
||||
// ADC internal channels
|
||||
ADC_TEMP = 0xF0,
|
||||
ADC_VREF = 0xF1,
|
||||
ADC_VBAT = 0xF2,
|
||||
|
||||
// Arduino connector namings
|
||||
A0 = PA_0,
|
||||
A1 = PA_1,
|
||||
A2 = PC_3,
|
||||
A3 = PC_2,
|
||||
A4 = PC_1,
|
||||
A5 = PC_0,
|
||||
D0 = PA_3,
|
||||
D1 = PA_2,
|
||||
D2 = PA_10,
|
||||
D3 = PB_3,
|
||||
D4 = PB_5,
|
||||
D5 = PA_15,
|
||||
D6 = PB_10,
|
||||
D7 = PC_7,
|
||||
D8 = PB_6,
|
||||
D9 = PA_8,
|
||||
D10 = PA_11,
|
||||
D11 = PB_15,
|
||||
D12 = PB_14,
|
||||
D13 = PB_13,
|
||||
D14 = PB_7,
|
||||
D15 = PB_8,
|
||||
ARDUINO_UNO_D0 = PA_3,
|
||||
ARDUINO_UNO_D1 = PA_2,
|
||||
ARDUINO_UNO_D2 = PA_10,
|
||||
ARDUINO_UNO_D3 = PB_3,
|
||||
ARDUINO_UNO_D4 = PB_5,
|
||||
ARDUINO_UNO_D5 = PA_15,
|
||||
ARDUINO_UNO_D6 = PB_10,
|
||||
ARDUINO_UNO_D7 = PC_7,
|
||||
ARDUINO_UNO_D8 = PB_6,
|
||||
ARDUINO_UNO_D9 = PA_8,
|
||||
ARDUINO_UNO_D10 = PA_11,
|
||||
ARDUINO_UNO_D11 = PB_15,
|
||||
ARDUINO_UNO_D12 = PB_14,
|
||||
ARDUINO_UNO_D13 = PB_13,
|
||||
ARDUINO_UNO_D14 = PB_7,
|
||||
ARDUINO_UNO_D15 = PB_8,
|
||||
#endif
|
||||
|
||||
// STDIO for console print
|
||||
#ifdef MBED_CONF_TARGET_STDIO_UART_TX
|
||||
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
|
||||
CONSOLE_TX = MBED_CONF_TARGET_STDIO_UART_TX,
|
||||
#else
|
||||
STDIO_UART_TX = PA_2,
|
||||
CONSOLE_TX = PA_2,
|
||||
#endif
|
||||
#ifdef MBED_CONF_TARGET_STDIO_UART_RX
|
||||
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
|
||||
CONSOLE_RX = MBED_CONF_TARGET_STDIO_UART_RX,
|
||||
#else
|
||||
STDIO_UART_RX = PA_3,
|
||||
CONSOLE_RX = PA_3,
|
||||
#endif
|
||||
|
||||
// Generic signals namings
|
||||
LED1 = PB_13,
|
||||
LED2 = PB_13,
|
||||
LED3 = PB_13,
|
||||
LED4 = PB_13,
|
||||
USER_BUTTON = PC_13,
|
||||
BUTTON1 = USER_BUTTON,
|
||||
SERIAL_TX = STDIO_UART_TX,
|
||||
SERIAL_RX = STDIO_UART_RX,
|
||||
USBTX = STDIO_UART_TX,
|
||||
USBRX = STDIO_UART_RX,
|
||||
I2C_SCL = PB_8,
|
||||
I2C_SDA = PB_7,
|
||||
SPI_MOSI = D11,
|
||||
SPI_MISO = D12,
|
||||
SPI_SCK = D13,
|
||||
SPI_CS = D10,
|
||||
PWM_OUT = D9,
|
||||
|
||||
/**** USB pins ****/
|
||||
USB_DM = PA_11,
|
||||
USB_DP = PA_12,
|
||||
@@ -217,6 +180,10 @@ typedef enum {
|
||||
NC = (int)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
// Standardized LED and button names
|
||||
#define LED1 PB_13 // LD4 [green Led]
|
||||
#define BUTTON1 PC_13 // B1 [Blue PushButton]
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,37 +1,31 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2016-2020 STMicroelectronics
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
******************************************************************************
|
||||
*
|
||||
* 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
|
||||
* Copyright (c) 2015-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file configures the system clock as follows:
|
||||
*=============================================================================
|
||||
* System clock source s | 1- PLL_HSE_EXTC | 3- PLL_HSI
|
||||
* | (external 8 MHz clock) | (internal 16 MHz)
|
||||
* | 2- PLL_HSE_XTAL | or PLL_MSI
|
||||
* | (external 8 MHz xtal) | (internal 4 MHz)
|
||||
* This file configures the system clock depending on config from targets.json:
|
||||
*-----------------------------------------------------------------------------
|
||||
* SYSCLK(MHz) | 48 | 80
|
||||
* System clock source | 1- USE_PLL_HSE_EXTC (external clock)
|
||||
* | 2- USE_PLL_HSE_XTAL (external xtal)
|
||||
* | 3- USE_PLL_HSI (internal 16 MHz)
|
||||
* | 4- USE_PLL_MSI (internal 100kHz to 48 MHz)
|
||||
*-----------------------------------------------------------------------------
|
||||
* AHBCLK (MHz) | 48 | 80
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB1CLK (MHz) | 48 | 80
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB2CLK (MHz) | 48 | 80
|
||||
*-----------------------------------------------------------------------------
|
||||
* USB capable (48 MHz precise clock) | YES | NO
|
||||
* SYSCLK(MHz) | 80
|
||||
* AHBCLK (MHz) | 80
|
||||
* APB1CLK (MHz) | 80
|
||||
* APB2CLK (MHz) | 80
|
||||
* USB capable | YES
|
||||
*-----------------------------------------------------------------------------
|
||||
**/
|
||||
|
||||
@@ -39,8 +33,8 @@
|
||||
#include "mbed_error.h"
|
||||
|
||||
// clock source is selected with CLOCK_SOURCE in json config
|
||||
#define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO - not enabled by default)
|
||||
#define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default)
|
||||
#define USE_PLL_HSE_EXTC 0x8 // Use external clock (OSC_IN)
|
||||
#define USE_PLL_HSE_XTAL 0x4 // Use external xtal (OSC_IN/OSC_OUT)
|
||||
#define USE_PLL_HSI 0x2 // Use HSI internal clock
|
||||
#define USE_PLL_MSI 0x1 // Use MSI internal clock
|
||||
|
||||
@@ -62,13 +56,13 @@ uint8_t SetSysClock_PLL_MSI(void);
|
||||
/**
|
||||
* @brief Configures the System clock source, PLL Multiplier and Divider factors,
|
||||
* AHB/APBx prescalers and Flash settings
|
||||
* @note This function should be called only once the RCC clock configuration
|
||||
* is reset to the default reset state (done in SystemInit() function).
|
||||
* @note This function is called in mbed_sdk_init() function (targets/TARGET_STM/mbed_overrides.c)
|
||||
* and after each deepsleep period in hal_deepsleep() (targets/TARGET_STM/sleep.c)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void SetSysClock(void)
|
||||
MBED_WEAK void SetSysClock(void)
|
||||
{
|
||||
#if ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC)
|
||||
/* 1- Try to start with HSE and external clock */
|
||||
@@ -117,17 +111,21 @@ MBED_WEAK uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
||||
// Enable HSE oscillator and activate PLL with HSE as source
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
if (bypass == 0) {
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External xtal on OSC_IN/OSC_OUT
|
||||
} else {
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External clock on OSC_IN
|
||||
}
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; // 8 MHz
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
#if HSE_VALUE==8000000
|
||||
RCC_OscInitStruct.PLL.PLLM = 1; // VCO input clock = 8 MHz (8 MHz / 1)
|
||||
#else
|
||||
#error Unsupported externall clock value, check HSE_VALUE define
|
||||
#endif
|
||||
RCC_OscInitStruct.PLL.PLLN = 20; // VCO output clock = 160 MHz (8 MHz * 20)
|
||||
RCC_OscInitStruct.PLL.PLLP = 7; // PLLSAI3 clock = 22 MHz (160 MHz / 7)
|
||||
RCC_OscInitStruct.PLL.PLLP = 7;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 2;
|
||||
RCC_OscInitStruct.PLL.PLLR = 2; // PLL clock = 80 MHz (160 MHz / 2)
|
||||
RCC_OscInitStruct.PLL.PLLR = 2; // PLL clock = 80 MHz (160 MHz / 2)
|
||||
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
@@ -135,10 +133,10 @@ MBED_WEAK uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
||||
|
||||
// Select PLL clock as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 80 MHz or 48 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 80 MHz or 48 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 80 MHz or 48 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 80 MHz or 48 MHz
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 80 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 80 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 80 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 80 MHz
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
}
|
||||
@@ -187,11 +185,11 @@ uint8_t SetSysClock_PLL_HSI(void)
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; // 16 MHz
|
||||
RCC_OscInitStruct.PLL.PLLM = 2; // VCO input clock = 8 MHz (16 MHz / 2)
|
||||
RCC_OscInitStruct.PLL.PLLM = 2; // VCO input clock = 8 MHz (16 MHz / 2)
|
||||
RCC_OscInitStruct.PLL.PLLN = 20; // VCO output clock = 160 MHz (8 MHz * 20)
|
||||
RCC_OscInitStruct.PLL.PLLP = 7; // PLLSAI3 clock = 22 MHz (160 MHz / 7)
|
||||
RCC_OscInitStruct.PLL.PLLP = 7;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 2;
|
||||
RCC_OscInitStruct.PLL.PLLR = 2; // PLL clock = 80 MHz (160 MHz / 2)
|
||||
RCC_OscInitStruct.PLL.PLLR = 2; // PLL clock = 80 MHz (160 MHz / 2)
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
}
|
||||
@@ -234,7 +232,7 @@ uint8_t SetSysClock_PLL_HSI(void)
|
||||
/******************************************************************************/
|
||||
/* PLL (clocked by MSI) used as System clock source */
|
||||
/******************************************************************************/
|
||||
uint8_t SetSysClock_PLL_MSI(void)
|
||||
MBED_WEAK uint8_t SetSysClock_PLL_MSI(void)
|
||||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
@@ -244,21 +242,15 @@ uint8_t SetSysClock_PLL_MSI(void)
|
||||
// Enable LSE Oscillator to automatically calibrate the MSI clock
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // No PLL update
|
||||
RCC_OscInitStruct.LSEState = RCC_LSE_ON; // External 32.768 kHz clock on OSC_IN/OSC_OUT
|
||||
RCC_OscInitStruct.LSEState = RCC_LSE_ON; // External 32.768 kHz clock on OSC32_IN/OSC32_OUT
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
}
|
||||
|
||||
/* Enable the CSS interrupt in case LSE signal is corrupted or not present */
|
||||
HAL_RCCEx_DisableLSECSS();
|
||||
#endif /* MBED_CONF_TARGET_LSE_AVAILABLE */
|
||||
|
||||
/* Enable MSI Oscillator and activate PLL with MSI as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
|
||||
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
|
||||
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
|
||||
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; /* 48 MHz */
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
|
||||
2
examples/mbed-rtos-ethernet-tls/.mbedignore
Normal file
2
examples/mbed-rtos-ethernet-tls/.mbedignore
Normal file
@@ -0,0 +1,2 @@
|
||||
mbed-os/features/*
|
||||
mbed-os/storage/*
|
||||
3
examples/mbed-rtos-events/.mbedignore
Normal file
3
examples/mbed-rtos-events/.mbedignore
Normal file
@@ -0,0 +1,3 @@
|
||||
mbed-os/connectivity/*
|
||||
mbed-os/features/*
|
||||
mbed-os/storage/*
|
||||
2
examples/mbed-rtos-filesystem/.mbedignore
Normal file
2
examples/mbed-rtos-filesystem/.mbedignore
Normal file
@@ -0,0 +1,2 @@
|
||||
mbed-os/connectivity/*
|
||||
mbed-os/features/*
|
||||
3
examples/mbed-rtos-serial/.mbedignore
Normal file
3
examples/mbed-rtos-serial/.mbedignore
Normal file
@@ -0,0 +1,3 @@
|
||||
mbed-os/connectivity/*
|
||||
mbed-os/features/*
|
||||
mbed-os/storage/*
|
||||
2
examples/mbed-rtos-sockets/.mbedignore
Normal file
2
examples/mbed-rtos-sockets/.mbedignore
Normal file
@@ -0,0 +1,2 @@
|
||||
mbed-os/features/*
|
||||
mbed-os/storage/*
|
||||
@@ -8,7 +8,7 @@ How to build PlatformIO based project
|
||||
|
||||
```shell
|
||||
# Change directory to example
|
||||
$ cd platform-ststm32/examples/mbed-rtos-wifi
|
||||
$ cd platform-ststm32/examples/mbed-rtos-sockets
|
||||
|
||||
# Build project
|
||||
$ pio run
|
||||
38
examples/mbed-rtos-sockets/include/root_ca_cert.h
Normal file
38
examples/mbed-rtos-sockets/include/root_ca_cert.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* Sockets Example
|
||||
* Copyright (c) 2020 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.
|
||||
*/
|
||||
|
||||
static const char root_ca_cert[] = \
|
||||
"-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n"
|
||||
"RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n"
|
||||
"VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n"
|
||||
"DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n"
|
||||
"ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n"
|
||||
"VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n"
|
||||
"mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n"
|
||||
"IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n"
|
||||
"mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n"
|
||||
"XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n"
|
||||
"dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n"
|
||||
"jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n"
|
||||
"BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n"
|
||||
"DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n"
|
||||
"9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n"
|
||||
"jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n"
|
||||
"Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n"
|
||||
"ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n"
|
||||
"R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n"
|
||||
"-----END CERTIFICATE-----";
|
||||
36
examples/mbed-rtos-sockets/include/wifi_helper.h
Normal file
36
examples/mbed-rtos-sockets/include/wifi_helper.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Sockets Example
|
||||
* Copyright (c) 2020 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.h"
|
||||
|
||||
static const char *get_security_string(nsapi_security_t sec)
|
||||
{
|
||||
switch (sec) {
|
||||
case NSAPI_SECURITY_NONE:
|
||||
return "None";
|
||||
case NSAPI_SECURITY_WEP:
|
||||
return "WEP";
|
||||
case NSAPI_SECURITY_WPA:
|
||||
return "WPA";
|
||||
case NSAPI_SECURITY_WPA2:
|
||||
return "WPA2";
|
||||
case NSAPI_SECURITY_WPA_WPA2:
|
||||
return "WPA/WPA2";
|
||||
case NSAPI_SECURITY_UNKNOWN:
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
34
examples/mbed-rtos-sockets/mbed_app.json
Normal file
34
examples/mbed-rtos-sockets/mbed_app.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"config": {
|
||||
"hostname": {
|
||||
"help": "The demo will try to connect to this web address on port 80 (or port 443 when using tls).",
|
||||
"value": "\"ifconfig.io\""
|
||||
},
|
||||
"use-tls-socket": {
|
||||
"value": false
|
||||
}
|
||||
},
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"nsapi.default-wifi-security": "WPA_WPA2",
|
||||
"nsapi.default-wifi-ssid": "\"YOUR_SSID\"",
|
||||
"nsapi.default-wifi-password": "\"YOUR_PASSWORD\"",
|
||||
"platform.stdio-baud-rate": 9600,
|
||||
"mbed-trace.enable": false,
|
||||
"mbed-trace.max-level": "TRACE_LEVEL_DEBUG",
|
||||
"rtos.main-thread-stack-size": 8192
|
||||
},
|
||||
"DISCO_F413ZH": {
|
||||
"target.components_add": ["ism43362"],
|
||||
"target.macros_add" : ["MBEDTLS_SHA1_C"]
|
||||
},
|
||||
"DISCO_L475VG_IOT01A": {
|
||||
"target.components_add": ["ism43362"],
|
||||
"target.network-default-interface-type": "WIFI",
|
||||
"target.macros_add" : ["MBEDTLS_SHA1_C"]
|
||||
},
|
||||
"K64F": {
|
||||
"target.macros_add" : ["MBEDTLS_SHA1_C"]
|
||||
}
|
||||
}
|
||||
}
|
||||
264
examples/mbed-rtos-sockets/src/main.cpp
Normal file
264
examples/mbed-rtos-sockets/src/main.cpp
Normal file
@@ -0,0 +1,264 @@
|
||||
/* Sockets Example
|
||||
* Copyright (c) 2016-2020 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.h"
|
||||
#include "wifi_helper.h"
|
||||
#include "mbed-trace/mbed_trace.h"
|
||||
|
||||
#if MBED_CONF_APP_USE_TLS_SOCKET
|
||||
#include "root_ca_cert.h"
|
||||
|
||||
#ifndef DEVICE_TRNG
|
||||
#error "mbed-os-example-tls-socket requires a device which supports TRNG"
|
||||
#endif
|
||||
#endif // MBED_CONF_APP_USE_TLS_SOCKET
|
||||
|
||||
class SocketDemo {
|
||||
static constexpr size_t MAX_NUMBER_OF_ACCESS_POINTS = 10;
|
||||
static constexpr size_t MAX_MESSAGE_RECEIVED_LENGTH = 100;
|
||||
|
||||
#if MBED_CONF_APP_USE_TLS_SOCKET
|
||||
static constexpr size_t REMOTE_PORT = 443; // tls port
|
||||
#else
|
||||
static constexpr size_t REMOTE_PORT = 80; // standard HTTP port
|
||||
#endif // MBED_CONF_APP_USE_TLS_SOCKET
|
||||
|
||||
public:
|
||||
SocketDemo() : _net(NetworkInterface::get_default_instance())
|
||||
{
|
||||
}
|
||||
|
||||
~SocketDemo()
|
||||
{
|
||||
if (_net) {
|
||||
_net->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
if (!_net) {
|
||||
printf("Error! No network interface found.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* if we're using a wifi interface run a quick scan */
|
||||
if (_net->wifiInterface()) {
|
||||
/* the scan is not required to connect and only serves to show visible access points */
|
||||
wifi_scan();
|
||||
|
||||
/* in this example we use credentials configured at compile time which are used by
|
||||
* NetworkInterface::connect() but it's possible to do this at runtime by using the
|
||||
* WiFiInterface::connect() which takes these parameters as arguments */
|
||||
}
|
||||
|
||||
/* connect will perform the action appropriate to the interface type to connect to the network */
|
||||
|
||||
printf("Connecting to the network...\r\n");
|
||||
|
||||
nsapi_size_or_error_t result = _net->connect();
|
||||
if (result != 0) {
|
||||
printf("Error! _net->connect() returned: %d\r\n", result);
|
||||
return;
|
||||
}
|
||||
|
||||
print_network_info();
|
||||
|
||||
/* opening the socket only allocates resources */
|
||||
result = _socket.open(_net);
|
||||
if (result != 0) {
|
||||
printf("Error! _socket.open() returned: %d\r\n", result);
|
||||
return;
|
||||
}
|
||||
|
||||
#if MBED_CONF_APP_USE_TLS_SOCKET
|
||||
result = _socket.set_root_ca_cert(root_ca_cert);
|
||||
if (result != NSAPI_ERROR_OK) {
|
||||
printf("Error: _socket.set_root_ca_cert() returned %d\n", result);
|
||||
return;
|
||||
}
|
||||
_socket.set_hostname(MBED_CONF_APP_HOSTNAME);
|
||||
#endif // MBED_CONF_APP_USE_TLS_SOCKET
|
||||
|
||||
/* now we have to find where to connect */
|
||||
|
||||
SocketAddress address;
|
||||
|
||||
if (!resolve_hostname(address)) {
|
||||
return;
|
||||
}
|
||||
|
||||
address.set_port(REMOTE_PORT);
|
||||
|
||||
/* we are connected to the network but since we're using a connection oriented
|
||||
* protocol we still need to open a connection on the socket */
|
||||
|
||||
printf("Opening connection to remote port %d\r\n", REMOTE_PORT);
|
||||
|
||||
result = _socket.connect(address);
|
||||
if (result != 0) {
|
||||
printf("Error! _socket.connect() returned: %d\r\n", result);
|
||||
return;
|
||||
}
|
||||
|
||||
/* exchange an HTTP request and response */
|
||||
|
||||
if (!send_http_request()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!receive_http_response()) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Demo concluded successfully \r\n");
|
||||
}
|
||||
|
||||
private:
|
||||
bool resolve_hostname(SocketAddress &address)
|
||||
{
|
||||
const char hostname[] = MBED_CONF_APP_HOSTNAME;
|
||||
|
||||
/* get the host address */
|
||||
printf("\nResolve hostname %s\r\n", hostname);
|
||||
nsapi_size_or_error_t result = _net->gethostbyname(hostname, &address);
|
||||
if (result != 0) {
|
||||
printf("Error! gethostbyname(%s) returned: %d\r\n", hostname, result);
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("%s address is %s\r\n", hostname, (address.get_ip_address() ? address.get_ip_address() : "None") );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool send_http_request()
|
||||
{
|
||||
/* loop until whole request sent */
|
||||
const char buffer[] = "GET / HTTP/1.1\r\n"
|
||||
"Host: ifconfig.io\r\n"
|
||||
"Connection: close\r\n"
|
||||
"\r\n";
|
||||
|
||||
nsapi_size_t bytes_to_send = strlen(buffer);
|
||||
nsapi_size_or_error_t bytes_sent = 0;
|
||||
|
||||
printf("\r\nSending message: \r\n%s", buffer);
|
||||
|
||||
while (bytes_to_send) {
|
||||
bytes_sent = _socket.send(buffer + bytes_sent, bytes_to_send);
|
||||
if (bytes_sent < 0) {
|
||||
printf("Error! _socket.send() returned: %d\r\n", bytes_sent);
|
||||
return false;
|
||||
} else {
|
||||
printf("sent %d bytes\r\n", bytes_sent);
|
||||
}
|
||||
|
||||
bytes_to_send -= bytes_sent;
|
||||
}
|
||||
|
||||
printf("Complete message sent\r\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool receive_http_response()
|
||||
{
|
||||
char buffer[MAX_MESSAGE_RECEIVED_LENGTH];
|
||||
int remaining_bytes = MAX_MESSAGE_RECEIVED_LENGTH;
|
||||
int received_bytes = 0;
|
||||
|
||||
/* loop until there is nothing received or we've ran out of buffer space */
|
||||
nsapi_size_or_error_t result = remaining_bytes;
|
||||
while (result > 0 && remaining_bytes > 0) {
|
||||
result = _socket.recv(buffer + received_bytes, remaining_bytes);
|
||||
if (result < 0) {
|
||||
printf("Error! _socket.recv() returned: %d\r\n", result);
|
||||
return false;
|
||||
}
|
||||
|
||||
received_bytes += result;
|
||||
remaining_bytes -= result;
|
||||
}
|
||||
|
||||
/* the message is likely larger but we only want the HTTP response code */
|
||||
|
||||
printf("received %d bytes:\r\n%.*s\r\n\r\n", received_bytes, strstr(buffer, "\n") - buffer, buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wifi_scan()
|
||||
{
|
||||
WiFiInterface *wifi = _net->wifiInterface();
|
||||
|
||||
WiFiAccessPoint ap[MAX_NUMBER_OF_ACCESS_POINTS];
|
||||
|
||||
/* scan call returns number of access points found */
|
||||
int result = wifi->scan(ap, MAX_NUMBER_OF_ACCESS_POINTS);
|
||||
|
||||
if (result <= 0) {
|
||||
printf("WiFiInterface::scan() failed with return value: %d\r\n", result);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%d networks available:\r\n", result);
|
||||
|
||||
for (int i = 0; i < result; i++) {
|
||||
printf("Network: %s secured: %s BSSID: %hhX:%hhX:%hhX:%hhx:%hhx:%hhx RSSI: %hhd Ch: %hhd\r\n",
|
||||
ap[i].get_ssid(), get_security_string(ap[i].get_security()),
|
||||
ap[i].get_bssid()[0], ap[i].get_bssid()[1], ap[i].get_bssid()[2],
|
||||
ap[i].get_bssid()[3], ap[i].get_bssid()[4], ap[i].get_bssid()[5],
|
||||
ap[i].get_rssi(), ap[i].get_channel());
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
|
||||
void print_network_info()
|
||||
{
|
||||
/* print the network info */
|
||||
SocketAddress a;
|
||||
_net->get_ip_address(&a);
|
||||
printf("IP address: %s\r\n", a.get_ip_address() ? a.get_ip_address() : "None");
|
||||
_net->get_netmask(&a);
|
||||
printf("Netmask: %s\r\n", a.get_ip_address() ? a.get_ip_address() : "None");
|
||||
_net->get_gateway(&a);
|
||||
printf("Gateway: %s\r\n", a.get_ip_address() ? a.get_ip_address() : "None");
|
||||
}
|
||||
|
||||
private:
|
||||
NetworkInterface *_net;
|
||||
|
||||
#if MBED_CONF_APP_USE_TLS_SOCKET
|
||||
TLSSocket _socket;
|
||||
#else
|
||||
TCPSocket _socket;
|
||||
#endif // MBED_CONF_APP_USE_TLS_SOCKET
|
||||
};
|
||||
|
||||
int main() {
|
||||
printf("\r\nStarting socket demo\r\n\r\n");
|
||||
|
||||
#ifdef MBED_CONF_MBED_TRACE_ENABLE
|
||||
mbed_trace_init();
|
||||
#endif
|
||||
|
||||
SocketDemo *example = new SocketDemo();
|
||||
MBED_ASSERT(example);
|
||||
example->run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
2
examples/mbed-rtos-usb-keyboard/.mbedignore
Normal file
2
examples/mbed-rtos-usb-keyboard/.mbedignore
Normal file
@@ -0,0 +1,2 @@
|
||||
mbed-os/connectivity/*
|
||||
mbed-os/features/*
|
||||
@@ -5,11 +5,6 @@
|
||||
#include "mbed.h"
|
||||
#include "USBMouseKeyboard.h"
|
||||
|
||||
//LED1: NUM_LOCK
|
||||
//LED2: CAPS_LOCK
|
||||
//LED3: SCROLL_LOCK
|
||||
BusOut leds(LED1, LED2, LED3);
|
||||
|
||||
//USBMouseKeyboard object
|
||||
USBMouseKeyboard key_mouse;
|
||||
|
||||
@@ -31,15 +26,12 @@ int main(void)
|
||||
key_mouse.move(x, y);
|
||||
//example of modifier key press
|
||||
key_mouse.key_code(KEY_CAPS_LOCK);
|
||||
leds = key_mouse.lock_status();
|
||||
ThisThread::sleep_for(50);
|
||||
key_mouse.media_control(KEY_VOLUME_UP);
|
||||
key_mouse.key_code(KEY_NUM_LOCK);
|
||||
leds = key_mouse.lock_status();
|
||||
ThisThread::sleep_for(50);
|
||||
angle += 10;
|
||||
key_mouse.key_code(KEY_SCROLL_LOCK);
|
||||
leds = key_mouse.lock_status();
|
||||
ThisThread::sleep_for(50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"config": {
|
||||
"wifi-ssid": {
|
||||
"help": "WiFi SSID",
|
||||
"value": "\"SSID\""
|
||||
},
|
||||
"wifi-password": {
|
||||
"help": "WiFi Password",
|
||||
"value": "\"PASSWORD\""
|
||||
}
|
||||
},
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"platform.stdio-convert-newlines": true,
|
||||
"esp8266.provide-default" : true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/* WiFi Example
|
||||
* Copyright (c) 2016 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.h"
|
||||
|
||||
WiFiInterface *wifi;
|
||||
|
||||
const char *sec2str(nsapi_security_t sec)
|
||||
{
|
||||
switch (sec) {
|
||||
case NSAPI_SECURITY_NONE:
|
||||
return "None";
|
||||
case NSAPI_SECURITY_WEP:
|
||||
return "WEP";
|
||||
case NSAPI_SECURITY_WPA:
|
||||
return "WPA";
|
||||
case NSAPI_SECURITY_WPA2:
|
||||
return "WPA2";
|
||||
case NSAPI_SECURITY_WPA_WPA2:
|
||||
return "WPA/WPA2";
|
||||
case NSAPI_SECURITY_UNKNOWN:
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
int scan_demo(WiFiInterface *wifi)
|
||||
{
|
||||
WiFiAccessPoint *ap;
|
||||
|
||||
printf("Scan:\n");
|
||||
|
||||
int count = wifi->scan(NULL,0);
|
||||
|
||||
if (count <= 0) {
|
||||
printf("scan() failed with return value: %d\n", count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Limit number of network arbitrary to 15 */
|
||||
count = count < 15 ? count : 15;
|
||||
|
||||
ap = new WiFiAccessPoint[count];
|
||||
count = wifi->scan(ap, count);
|
||||
|
||||
if (count <= 0) {
|
||||
printf("scan() failed with return value: %d\n", count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
printf("Network: %s secured: %s BSSID: %hhX:%hhX:%hhX:%hhx:%hhx:%hhx RSSI: %hhd Ch: %hhd\n", ap[i].get_ssid(),
|
||||
sec2str(ap[i].get_security()), ap[i].get_bssid()[0], ap[i].get_bssid()[1], ap[i].get_bssid()[2],
|
||||
ap[i].get_bssid()[3], ap[i].get_bssid()[4], ap[i].get_bssid()[5], ap[i].get_rssi(), ap[i].get_channel());
|
||||
}
|
||||
printf("%d networks available.\n", count);
|
||||
|
||||
delete[] ap;
|
||||
return count;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("WiFi example\n");
|
||||
|
||||
#ifdef MBED_MAJOR_VERSION
|
||||
printf("Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
|
||||
#endif
|
||||
|
||||
wifi = WiFiInterface::get_default_instance();
|
||||
if (!wifi) {
|
||||
printf("ERROR: No WiFiInterface found.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int count = scan_demo(wifi);
|
||||
if (count == 0) {
|
||||
printf("No WIFI APs found - can't continue further.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("\nConnecting to %s...\n", MBED_CONF_APP_WIFI_SSID);
|
||||
int ret = wifi->connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
|
||||
if (ret != 0) {
|
||||
printf("\nConnection error: %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Success\n\n");
|
||||
printf("MAC: %s\n", wifi->get_mac_address());
|
||||
SocketAddress a;
|
||||
wifi->get_ip_address(&a);
|
||||
printf("IP: %s\n", a.get_ip_address());
|
||||
wifi->get_netmask(&a);
|
||||
printf("Netmask: %s\n", a.get_ip_address());
|
||||
wifi->get_gateway(&a);
|
||||
printf("Gateway: %s\n", a.get_ip_address());
|
||||
printf("RSSI: %d\n\n", wifi->get_rssi());
|
||||
|
||||
wifi->disconnect();
|
||||
|
||||
printf("\nDone\n");
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/platformio/platform-ststm32.git"
|
||||
},
|
||||
"version": "16.0.0",
|
||||
"version": "16.1.0",
|
||||
"frameworks": {
|
||||
"mbed": {
|
||||
"package": "framework-mbed",
|
||||
@@ -85,7 +85,7 @@
|
||||
"type": "framework",
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "~6.60900.0"
|
||||
"version": "~6.61700.0"
|
||||
},
|
||||
"framework-cmsis": {
|
||||
"type": "framework",
|
||||
|
||||
Reference in New Issue
Block a user