boards/nucleo-wl55jc: add new board

This patch includes bare minimum support for nucleo-wl55jc board.
It compiles and nsh shell is working properly on virtual com port
over USB. 3 onboard leds with userled driver are working.

Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
This commit is contained in:
Michał Łyszczek 2022-06-07 12:00:00 +02:00 committed by Xiang Xiao
parent e54fe68bbf
commit f643edbe41
12 changed files with 1050 additions and 0 deletions

View File

@ -1397,6 +1397,15 @@ config ARCH_BOARD_NUCLEO_L552ZE
---help---
STMicro Nucleo STM32L552 board based on the STMicro STM32L552ZET6 MCU.
config ARCH_BOARD_NUCLEO_WL55JC
bool "STM32WL55 Nucleo WL55JC"
depends on ARCH_CHIP_STM32WL55JC_CPU1 || ARCH_CHIP_STM32WL55JC_CPU2
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
select ARCH_HAVE_IRQBUTTONS
---help---
STMicro Nucleo STM32WL55 board based on the STMicro STM32WL55JC MCU.
config ARCH_BOARD_QEMU_I486
bool "Qemu i486 Mode"
depends on ARCH_CHIP_QEMU_I486
@ -2525,6 +2534,7 @@ config ARCH_BOARD
default "nucleo-l476rg" if ARCH_BOARD_NUCLEO_L476RG
default "nucleo-l496zg" if ARCH_BOARD_NUCLEO_L496ZG
default "nucleo-l552ze" if ARCH_BOARD_NUCLEO_L552ZE
default "nucleo-wl55jc" if ARCH_BOARD_NUCLEO_WL55JC
default "nutiny-nuc120" if ARCH_BOARD_NUTINY_NUC120
default "olimex-efm32g880f128-stk" if ARCH_BOARD_OLIMEX_EFM32G880F128_STK
default "olimex-lpc1766stk" if ARCH_BOARD_LPC1766STK
@ -3031,6 +3041,9 @@ endif
if ARCH_BOARD_NUCLEO_L552ZE
source "boards/arm/stm32l5/nucleo-l552ze/Kconfig"
endif
if ARCH_BOARD_NUCLEO_WL55JC
source "boards/arm/stm32wl5/nucleo-wl55jc/Kconfig"
endif
if ARCH_BOARD_STM32L476_MDK
source "boards/arm/stm32l4/stm32l476-mdk/Kconfig"
endif

View File

@ -0,0 +1,10 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_BOARD_NUCLEO_WL55JC
comment "empty"
endif # ARCH_BOARD_NUCLEO_WL55JC

View File

@ -0,0 +1,75 @@
Nucleo-WL55JC README
====================
This README file discusses the port of NuttX to the STMicro Nucleo-WL55JC
board. That board features the STM32WL55JCI7 MCU with 256KiB of FLASH and
64KiB of SRAM. This is dual CPU (not core) chip. There is integrated LORA
hardware on board which is only available via CPU0.
Contents
========
- Status
- LEDs
- Buttons
- Serial Console
- Configurations
- Flashing
Status
======
2022.06.07: Board boots and nsh works without problems. Both arduino and
virtual com port UARTs work.
LEDs
====
There are user controlled 3 LEDs. Blue (PB15), Green(PB9) and Red(PB11).
To turn on the LED, GPIO has to be driven to HIGH state.
Green and Red LEDs are used by the system at boot to show system state.
Once system is booted these LEDs are for user to control. When
CONFIG_ARCH_LEDS is set, Blue LED is reserved by OS for reporting system
status. When CONFIG_ARCH_LEDS is not set, OS state won't be reported on
any of the LEDs and all 3 LEDs are available for user right from the start.
Buttons
=======
There are 3 buttons that are available for the user to program, and one
reset button.
Serial Console
==============
There are 2 serial ports - USART1 and LPUART1.
USART1 is connected to arduino D0/D1 pin and LPUART is connected to
stlink that provides virtual serial port.
NSH is configured to use LPUART and virtual serial port. After flashing
you can open /dev/ttyACM0 (may change depending on your system) and nsh
prompt will be waiting for you there. Serial device does not disapear
when flashing and reseting board - it can be left opened and flashing
will work without problems.
Configuration
=============
Configuration sub-directories
-----------------------------
nsh:
Configures the NuttShell (nsh) located at examples/nsh. NSH is will
work on virtual serial port over usb.
Flashing
========
Easiest way to flash nucleo is to use openocd tool. Openocd supports
stlink v3 which is on the board. It's as easy as running:
openocd -f interface/stlink.cfg -f target/stm32wlx.cfg \
-c "program nuttx.bin exit 0x08000000"

View File

@ -0,0 +1,23 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="nucleo-wl55jc"
CONFIG_ARCH_BOARD_NUCLEO_WL55JC=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_CHIP="stm32wl5"
CONFIG_ARCH_CHIP_STM32WL55JC_CPU1=y
CONFIG_ARCH_CHIP_STM32WL5=y
CONFIG_INIT_ENTRYNAME="main"
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_LPUART1_SERIAL_CONSOLE=y
CONFIG_RAM_SIZE=32768
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_STM32WL5_LPUART1=y
CONFIG_SYSTEM_NSH=y

View File

@ -0,0 +1,221 @@
/****************************************************************************
* boards/arm/stm32wl5/nucleo-wl55jc/include/board.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_STM32WL5_NUCLEO_WL55JC_INCLUDE_BOARD_H
#define __BOARDS_ARM_STM32WL5_NUCLEO_WL55JC_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
/* Clocking *****************************************************************/
/* nucleo-wl55jc has installed 32Mhz HSE oscillator */
#define STM32WL5_XTAL_FREQ 32000000ul
/* Use the HSE */
#define STM32WL5_BOARD_USEHSE 1
/* HSE source is a TCXO crystal which needs to be first powered on */
#define STM32WL5_BOARD_USETCXO
/* Prescaler common to all PLL inputs */
#define STM32WL5_PLLCFG_PLLM RCC_PLLCFG_PLLM(2) /* 32MHz / 2 = 16MHz */
/* 'main' PLL config; we use this to generate our system clock */
/* disable unused pll clocks */
#define STM32WL5_PLLCFG_PLLP 0
#undef STM32WL5_PLLCFG_PLLP_ENABLED
#define STM32WL5_PLLCFG_PLLQ 0
#undef STM32WL5_PLLCFG_PLLQ_ENABLED
/* further multiplicate source for system clock */
#define STM32WL5_PLLCFG_PLLN RCC_PLLCFG_PLLN(6) /* 16MHz * 6 = 96MHz */
#define STM32WL5_PLLCFG_PLLR RCC_PLLCFG_PLLR(2) /* 96MHz / 2 = 48MHz */
#define STM32WL5_PLLCFG_PLLR_ENABLED
/* Resulting system clock is 48MHz */
#define STM32WL5_SYSCLK_FREQUENCY 48000000ul
/* Configure the HCLK divisor (for the AHB bus, core, memory, and DMA */
#define STM32WL5_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */
#define STM32WL5_HCLK_FREQUENCY STM32WL5_SYSCLK_FREQUENCY
/* Configure the HCLK3 divisor (for flash and sram2) */
#define STM32WL5_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK3 = SYSCLK / 1 */
#define STM32WL5_HCLK3_FREQUENCY STM32WL5_SYSCLK_FREQUENCY
/* Configure the APB1 prescaler */
#define STM32WL5_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLK /* PCLK1 = HCLK / 1 */
#define STM32WL5_PCLK1_FREQUENCY (STM32WL5_HCLK_FREQUENCY / 1)
/* The timer clock frequencies are automatically defined by hardware.
* If the APB prescaler equals 1, the timer clock frequencies are set to the
* same frequency as that of the APB domain. Otherwise they are set to twice.
*/
#define STM32WL5_APB1_TIM2_CLKIN (STM32WL5_PCLK1_FREQUENCY)
/* Configure the APB2 prescaler */
#define STM32WL5_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK /* PCLK2 = HCLK / 1 */
#define STM32WL5_PCLK2_FREQUENCY (STM32WL5_HCLK_FREQUENCY / 1)
/* The timer clock frequencies are automatically defined by hardware.
* If the APB prescaler equals 1, the timer clock frequencies are set to the
* same frequency as that of the APB domain. Otherwise they are set to twice.
*/
#define STM32WL5_APB2_TIM1_CLKIN STM32WL5_PCLK2_FREQUENCY
#define STM32WL5_APB2_TIM16_CLKIN STM32WL5_PCLK2_FREQUENCY
#define STM32WL5_APB2_TIM17_CLKIN STM32WL5_PCLK2_FREQUENCY
/* The timer clock frequencies are automatically defined by hardware. If the
* APB prescaler equals 1, the timer clock frequencies are set to the same
* frequency as that of the APB domain. Otherwise they are set to twice.
* Note: TIM1,15,16 are on APB2, others on APB1
*/
#define BOARD_TIM1_FREQUENCY STM32WL5_HCLK_FREQUENCY
#define BOARD_TIM2_FREQUENCY STM32WL5_HCLK_FREQUENCY
#define BOARD_TIM16_FREQUENCY STM32WL5_HCLK_FREQUENCY
#define BOARD_TIM17_FREQUENCY STM32WL5_HCLK_FREQUENCY
#define BOARD_LPTIM1_FREQUENCY STM32WL5_HCLK_FREQUENCY
#define BOARD_LPTIM2_FREQUENCY STM32WL5_HCLK_FREQUENCY
#define BOARD_LPTIM3_FREQUENCY STM32WL5_HCLK_FREQUENCY
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Alternate function pin selections ****************************************/
/* USART1:
* RXD: PB7 (D0 on arduino pinout)
* TXD: PB6 (D1 on arduino pinout)
*/
#define GPIO_USART1_RX GPIO_USART1_RX_2 /* PB7 */
#define GPIO_USART1_TX GPIO_USART1_TX_2 /* PB6 */
/* LPUART1
* Connected to virtual com port
*/
#define GPIO_LPUART1_RX GPIO_LPUART1_RX_1 /* PA3 */
#define GPIO_LPUART1_TX GPIO_LPUART1_TX_1 /* PA2 */
/* LEDs
*
* The Nucleo wl55jc board provides 3 user leds
* PB15 - blue LED
* PB11 - red LED
* PB9 - green LED
*
* - When the I/O is HIGH value, the LED is on.
* - When the I/O is LOW, the LED is off.
*/
/* LED index values for use with board_userled() */
#define BOARD_LED_BLUE 0
#define BOARD_LED_GREEN 1
#define BOARD_LED_RED 2
#define BOARD_NLEDS 3
/* LED bits for use with board_userled_all() */
#define BOARD_LED_BLUE_BIT (1 << BOARD_LED_BLUE)
#define BOARD_LED_GREEN_BIT (1 << BOARD_LED_GREEN)
#define BOARD_LED_RED_BIT (1 << BOARD_LED_RED)
/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/stm32_autoleds.c. The LEDs are used to encode
* OS-related events as follows:
*
* SYMBOL Val Meaning LED state
* BLUE GREEN RED
* ----------------- --- ----------------------- ---- ----- ----
*/
#define LED_STARTED 1 /* NuttX has been started ON OFF OFF */
#define LED_HEAPALLOCATE 2 /* Heap has been allocated OFF ON OFF */
#define LED_IRQSENABLED 3 /* Interrupts enabled ON ON OFF */
#define LED_STACKCREATED 4 /* Idle stack created OFF OFF ON */
#define LED_INIRQ 5 /* In an interrupt GLOW N/C N/C */
#define LED_SIGNAL 6 /* In a signal handler GLOW N/C N/C */
#define LED_ASSERTION 7 /* An assertion failed GLOW N/C N/C */
#define LED_PANIC 8 /* The system has crashed ON ON ON */
#undef LED_IDLE /* MCU is is sleep mode Not used */
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: stm32wl5_board_initialize
*
* Description:
* All STM32WL5 architectures must provide the following entry point.
* This entry point is called early in the initialization -- after all
* memory has been configured and mapped but before any devices have been
* initialized.
*
****************************************************************************/
void stm32wl5_board_initialize(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_STM32WL5_NUCLEO_WL55JC_INCLUDE_BOARD_H */

View File

@ -0,0 +1,39 @@
############################################################################
# boards/arm/stm32wl5/nucleo-wl55jc/scripts/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
LDSCRIPT = wl55jc.ld
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

View File

@ -0,0 +1,105 @@
/****************************************************************************
* boards/arm/stm32wl5/nucleo-wl55jc/scripts/wl55jc.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The STM32WL55JC has 256KiB of FLASH beginning at address 0x0800:0000 and
* 32KiB of SRAM beginning at address 0x2000:0000. When booting from FLASH,
* FLASH memory is aliased to address 0x0000:0000 where the code expects to
* begin execution by jumping to the entry point in the 0x0800:0000 address
* range.
*/
MEMORY
{
flash (rx) : ORIGIN = 0x08000000, LENGTH = 256K
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
}
OUTPUT_ARCH(arm)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab : {
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
/* The STM32WL55JC has 32KiB of SRAM beginning at the following address */
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > sram AT > flash
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View File

@ -0,0 +1,29 @@
############################################################################
# boards/arm/stm32wl5/nucleo-wl55jc/src/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/Make.defs
CSRCS = stm32_boot.c stm32_leds.c
ifeq ($(CONFIG_BOARDCTL),y)
CSRCS += stm32_appinit.c
endif
include $(TOPDIR)/boards/Board.mk

View File

@ -0,0 +1,72 @@
/****************************************************************************
* boards/arm/stm32wl5/nucleo-wl55jc/src/nucleo-wl55jc.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_STM32WL5_NUCLEO_WL55JC_SRC_NUCLEO_WL55JC_H
#define __BOARDS_ARM_STM32WL5_NUCLEO_WL55JC_SRC_NUCLEO_WL55JC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#define HAVE_PROC 1
#if !defined(CONFIG_FS_PROCFS)
# undef HAVE_PROC
#endif
#if defined(HAVE_PROC) && defined(CONFIG_DISABLE_MOUNTPOINT)
# warning Mountpoints disabled. No procfs support
# undef HAVE_PROC
#endif
#define GPIO_LED_GREEN (GPIO_PORTB|GPIO_PIN9 |GPIO_OUTPUT|GPIO_PULLUP|GPIO_SPEED_50MHz)
#define GPIO_LED_RED (GPIO_PORTB|GPIO_PIN11|GPIO_OUTPUT|GPIO_PULLUP|GPIO_SPEED_50MHz)
#define GPIO_LED_BLUE (GPIO_PORTB|GPIO_PIN15|GPIO_OUTPUT|GPIO_PULLUP|GPIO_SPEED_50MHz)
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Functions Prototypes
****************************************************************************/
/****************************************************************************
* Name: board_leds_initialize
*
* Description:
* Initialize LEDs
*
****************************************************************************/
void board_leds_initialize(void);
#endif /* __BOARDS_ARM_STM32WL5_NUCLEO_WL55JC_SRC_NUCLEO_WL55JC_H */

View File

@ -0,0 +1,129 @@
/****************************************************************************
* boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_appinit.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/fs/fs.h>
#include <nuttx/leds/userled.h>
#include <stm32wl5.h>
#include <stm32wl5_uart.h>
#include <arch/board/board.h>
#include "nucleo-wl55jc.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform application specific initialization. This function is never
* called directly from application code, but only indirectly via the
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initialization logic and the
* matching application logic. The value could be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
int board_app_initialize(uintptr_t arg)
{
int ret = OK;
(void)arg;
#ifdef HAVE_PROC
/* Mount the proc filesystem */
syslog(LOG_INFO, "Mounting procfs to /proc\n");
ret = nx_mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to mount the PROC filesystem: %d\n",
ret);
return ret;
}
#endif
#if defined(CONFIG_USERLED_LOWER)
/* Register the LED driver */
ret = userled_lower_initialize("/dev/userleds");
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
}
#endif
return ret;
}
#ifdef CONFIG_BOARDCTL_IOCTL
int board_ioctl(unsigned int cmd, uintptr_t arg)
{
return -ENOTTY;
}
#endif
#if defined(CONFIG_BOARDCTL_UNIQUEID)
int board_uniqueid(uint8_t *uniqueid)
{
if (uniqueid == 0)
{
return -EINVAL;
}
stm32wl5_get_uniqueid(uniqueid);
return OK;
}
#endif

View File

@ -0,0 +1,93 @@
/****************************************************************************
* boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_boot.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
#include <arch/board/board.h>
#include "arm_internal.h"
#include "nucleo-wl55jc.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32wl5_board_initialize
*
* Description:
* All STM32WL5 architectures must provide the following entry point.
* This entry point is called early in the initialization -- after all
* memory has been configured and mapped but before any devices have been
* initialized.
*
****************************************************************************/
void stm32wl5_board_initialize(void)
{
/* Configure on-board LEDs, which are always enabled */
board_leds_initialize();
}
/****************************************************************************
* Name: board_late_initialize
*
* Description:
* If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_late_initialize(). board_late_initialize() will be
* called immediately after up_initialize() is called and just before the
* initial application is started. This additional initialization phase
* may be used, for example, to initialize board-specific device drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_LATE_INITIALIZE
void board_late_initialize(void)
{
/* Perform NSH initialization here instead of from the NSH. This
* alternative NSH initialization is necessary when NSH is ran in
* user-space but the initialization function must run in kernel space.
*/
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT)
board_app_initialize(0);
#endif
}
#endif

View File

@ -0,0 +1,241 @@
/****************************************************************************
* boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_leds.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "chip.h"
#include "arm_internal.h"
#include "stm32wl5.h"
#include "nucleo-wl55jc.h"
/****************************************************************************
* Private Types
****************************************************************************/
/* Identifies led state */
#define LED_OFF 0
#define LED_ON 1
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: led_state
*
* Description:
* Sets pack of leds to given state
****************************************************************************/
static void led_state(int state, unsigned int leds)
{
if (leds & BOARD_LED_BLUE_BIT)
{
stm32wl5_gpiowrite(GPIO_LED_BLUE, state);
}
if (leds & BOARD_LED_RED_BIT)
{
stm32wl5_gpiowrite(GPIO_LED_RED, state);
}
if (leds & BOARD_LED_GREEN_BIT)
{
stm32wl5_gpiowrite(GPIO_LED_GREEN, state);
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_leds_initialize
****************************************************************************/
void board_leds_initialize(void)
{
stm32wl5_configgpio(GPIO_LED_BLUE);
stm32wl5_configgpio(GPIO_LED_RED);
stm32wl5_configgpio(GPIO_LED_GREEN);
}
/****************************************************************************
* Name: board_leds_on
*
* Description:
* Drives board leds when specific RTOS state led occurs.
*
* Input Parameters:
* state - RTOS state
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void board_autoled_on(int state)
{
switch (state)
{
case LED_STARTED:
led_state(LED_OFF, (unsigned int)-1);
led_state(LED_ON, BOARD_LED_BLUE_BIT);
break;
case LED_HEAPALLOCATE:
led_state(LED_OFF, (unsigned int)-1);
led_state(LED_ON, BOARD_LED_GREEN_BIT);
break;
case LED_IRQSENABLED:
led_state(LED_OFF, (unsigned int)-1);
led_state(LED_ON, BOARD_LED_BLUE_BIT | BOARD_LED_GREEN_BIT);
break;
case LED_STACKCREATED:
led_state(LED_OFF, (unsigned int)-1);
led_state(LED_ON, BOARD_LED_RED_BIT);
break;
case LED_INIRQ:
case LED_SIGNAL:
case LED_ASSERTION:
case LED_PANIC:
led_state(LED_ON, BOARD_LED_BLUE_BIT);
break;
}
}
#endif /* CONFIG_ARCH_LEDS */
/****************************************************************************
* Name: board_leds_off
*
* Description:
* Drives board leds when specific RTOS state led occurs.
*
* Input Parameters:
* state - RTOS state
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void board_autoled_off(int state)
{
switch (state)
{
case LED_HEAPALLOCATE:
led_state(LED_OFF, BOARD_LED_GREEN_BIT);
break;
case LED_IRQSENABLED:
led_state(LED_OFF, BOARD_LED_BLUE_BIT | BOARD_LED_GREEN_BIT);
break;
case LED_STACKCREATED:
led_state(LED_OFF, BOARD_LED_RED_BIT);
break;
case LED_STARTED:
case LED_INIRQ:
case LED_SIGNAL:
case LED_ASSERTION:
case LED_PANIC:
led_state(LED_OFF, BOARD_LED_BLUE_BIT);
break;
}
}
#endif /* CONFIG_ARCH_LEDS */
/****************************************************************************
* Name: board_userled_initialize
*
* Description:
* This function should initialize leds for user use, but on RTOS start we
* initialize every led for use by RTOS and at end, when RTOS is fully
* booted up, we give control of these specific leds for user. So that's
* why this function is empty.
****************************************************************************/
uint32_t board_userled_initialize(void)
{
/* Already initialized by stm32_led_initialize. */
return BOARD_NLEDS;
}
/****************************************************************************
* Name: board_userled
*
* Description:
* Sets led to ledon state.
*
* Input Parameters:
* led - Led to be set, indexed from 0
* ledon - new state for the led.
****************************************************************************/
void board_userled(int led, bool ledon)
{
unsigned int ledbit;
#ifndef CONFIG_ARCH_LEDS
if (led == BOARD_BLUE)
{
return;
}
#endif
ledbit = 1 << led;
led_state(ledon, ledbit);
}
/****************************************************************************
* Name: board_userled_all
*
* Description:
* Sets whole ledset to given state.
*
* Input Parameters:
* ledset - Led bits to be set on or off
****************************************************************************/
void board_userled_all(uint32_t ledset)
{
#ifdef CONFIG_ARCH_LEDS
led_state(LED_ON, ledset & ~BOARD_LED_BLUE_BIT);
led_state(LED_OFF, ~(ledset | BOARD_LED_BLUE_BIT));
#else
led_state(LED_ON, ledset);
led_state(LED_OFF, ~ledset);
#endif
}