summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-01-23 17:10:01 +0700
committerhathach <[email protected]>2025-01-23 17:10:48 +0700
commit31071ccf0e27cc8b77ddb41417665ea82b2b9b35 (patch)
treeb57770b93a442a7cebc0ce9a2d4a5ef268c8dce9 /hw
parent6080f89f3daae50344e21accf972061240f55ccd (diff)
kind of work with zephyr with pca10056 with cmake -DBUILD_ZEPHYR
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/family_support.cmake18
-rw-r--r--hw/bsp/nrf/boards/pca10095/board.cmake2
-rw-r--r--hw/bsp/nrf/family.c29
-rw-r--r--hw/bsp/nrf/family.cmake47
-rw-r--r--hw/bsp/nrf/family.mk32
-rw-r--r--hw/bsp/nrf/nrfx_config/nrfx_config.h (renamed from hw/bsp/nrf/nrfx_config.h)0
-rw-r--r--hw/bsp/nrf/nrfx_config/nrfx_glue.h (renamed from hw/bsp/nrf/nrfx_glue.h)0
-rw-r--r--hw/bsp/nrf/nrfx_config/nrfx_log.h (renamed from hw/bsp/nrf/nrfx_log.h)0
8 files changed, 62 insertions, 66 deletions
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake
index 15baf0294..e32bb1689 100644
--- a/hw/bsp/family_support.cmake
+++ b/hw/bsp/family_support.cmake
@@ -170,7 +170,7 @@ function(family_add_rtos TARGET RTOS)
elseif (RTOS STREQUAL "zephyr")
target_compile_definitions(${TARGET} PUBLIC CFG_TUSB_OS=OPT_OS_ZEPHYR)
target_include_directories(${TARGET} PUBLIC ${ZEPHYR_BASE}/include)
- target_link_libraries(${TARGET} PUBLIC zephyr_interface kernel)
+# target_link_libraries(${TARGET} PUBLIC kernel)
endif ()
endfunction()
@@ -201,12 +201,9 @@ function(family_configure_common TARGET RTOS)
target_compile_definitions(${TARGET} PUBLIC LOGGER_${LOGGER})
# Add segger rtt to example
if(LOGGER STREQUAL "RTT" OR LOGGER STREQUAL "rtt")
- if (NOT TARGET segger_rtt)
- add_library(segger_rtt STATIC ${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c)
- target_include_directories(segger_rtt PUBLIC ${TOP}/lib/SEGGER_RTT/RTT)
-# target_compile_definitions(segger_rtt PUBLIC SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL)
- endif()
- target_link_libraries(${TARGET} PUBLIC segger_rtt)
+ target_sources(${TARGET} PUBLIC ${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c)
+ target_include_directories(${TARGET} PUBLIC ${TOP}/lib/SEGGER_RTT/RTT)
+# target_compile_definitions(${TARGET} PUBLIC SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL)
endif ()
endif ()
@@ -239,7 +236,8 @@ function(family_configure_common TARGET RTOS)
-Wmissing-prototypes
)
target_link_options(${TARGET} PUBLIC "LINKER:-Map=$<TARGET_FILE:${TARGET}>.map")
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0 AND NO_WARN_RWX_SEGMENTS_SUPPORTED)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0
+ AND NO_WARN_RWX_SEGMENTS_SUPPORTED AND (NOT BUILD_ZEPHYR))
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
endif ()
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
@@ -255,7 +253,7 @@ function(family_configure_common TARGET RTOS)
# endif ()
endfunction()
-# Add tinyusb to target with RTOS
+# Add tinyusb to target (TODO remove RTOS)
function(family_add_tinyusb TARGET OPT_MCU RTOS)
# tinyusb's CMakeList.txt
add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
@@ -364,7 +362,7 @@ function(family_add_default_example_warnings TARGET)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0 AND NO_WARN_RWX_SEGMENTS_SUPPORTED)
-# target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
+ target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
endif()
# GCC 10
diff --git a/hw/bsp/nrf/boards/pca10095/board.cmake b/hw/bsp/nrf/boards/pca10095/board.cmake
index 95dd30969..6d183dde6 100644
--- a/hw/bsp/nrf/boards/pca10095/board.cmake
+++ b/hw/bsp/nrf/boards/pca10095/board.cmake
@@ -2,6 +2,6 @@ set(MCU_VARIANT nrf5340_application)
function(update_board TARGET)
target_sources(${TARGET} PRIVATE
- ${NRFX_DIR}/drivers/src/nrfx_usbreg.c
+ ${NRFX_PATH}/drivers/src/nrfx_usbreg.c
)
endfunction()
diff --git a/hw/bsp/nrf/family.c b/hw/bsp/nrf/family.c
index 2c3413b9e..298ca2302 100644
--- a/hw/bsp/nrf/family.c
+++ b/hw/bsp/nrf/family.c
@@ -44,10 +44,10 @@
#include "nrfx.h"
#include "hal/nrf_gpio.h"
-#include "drivers/include/nrfx_gpiote.h"
-#include "drivers/include/nrfx_power.h"
-#include "drivers/include/nrfx_uarte.h"
-#include "drivers/include/nrfx_spim.h"
+#include "nrfx_gpiote.h"
+#include "nrfx_power.h"
+#include "nrfx_uarte.h"
+#include "nrfx_spim.h"
#ifdef SOFTDEVICE_PRESENT
#include "nrf_sdm.h"
@@ -67,8 +67,6 @@
#define NRFX_VER 3
#endif
-extern void nrfx_isr(const void *irq_handler);
-
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
@@ -148,12 +146,10 @@ void board_init(void) {
// irq_enable(USBREGULATOR_IRQn);
#endif
- // IRQ_CONNECT(CLOCK_POWER_IRQn, 0, nrfx_isr, nrfx_power_irq_handler, 0);
-
/* USB device controller access from devicetree */
- // #define DT_DRV_COMPAT nordic_nrf_usbd
- // IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), nrfx_isr, nrf_usbd_common_irq_handler, 0);
-
+ #define DT_DRV_COMPAT nordic_nrf_usbd
+ IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), nrfx_isr, USBD_IRQHandler, 0);
+ irq_enable(DT_INST_IRQN(0));
#endif
// UART
@@ -187,7 +183,7 @@ void board_init(void) {
};
#endif
- nrfx_uarte_init(&_uart_id, &uart_cfg, NULL); //uart_handler);
+ nrfx_uarte_init(&_uart_id, &uart_cfg, NULL);
//------------- USB -------------//
#if CFG_TUD_ENABLED
@@ -231,8 +227,12 @@ void board_init(void) {
#endif
}
- if ( usb_reg & VBUSDETECT_Msk ) tusb_hal_nrf_power_event(USB_EVT_DETECTED);
- if ( usb_reg & OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(USB_EVT_READY);
+ if ( usb_reg & VBUSDETECT_Msk ) {
+ tusb_hal_nrf_power_event(USB_EVT_DETECTED);
+ }
+ if ( usb_reg & OUTPUTRDY_Msk ) {
+ tusb_hal_nrf_power_event(USB_EVT_READY);
+ }
#endif
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
@@ -244,7 +244,6 @@ void board_init(void) {
//--------------------------------------------------------------------+
// Board porting API
//--------------------------------------------------------------------+
-
void board_led_write(bool state) {
nrf_gpio_pin_write(LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
}
diff --git a/hw/bsp/nrf/family.cmake b/hw/bsp/nrf/family.cmake
index 30561cdf5..1e7a4fe82 100644
--- a/hw/bsp/nrf/family.cmake
+++ b/hw/bsp/nrf/family.cmake
@@ -1,6 +1,6 @@
include_guard()
-set(NRFX_DIR ${TOP}/hw/mcu/nordic/nrfx)
+set(NRFX_PATH ${TOP}/hw/mcu/nordic/nrfx)
set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
# include board specific
@@ -25,6 +25,10 @@ set(FAMILY_MCUS NRF5X CACHE INTERNAL "")
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
+ if (BUILD_ZEPHYR)
+ return()
+ endif ()
+
if (TARGET ${BOARD_TARGET})
return()
endif ()
@@ -40,18 +44,18 @@ function(add_board_target BOARD_TARGET)
endif ()
if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S)
+ set(STARTUP_FILE_GNU ${NRFX_PATH}/mdk/gcc_startup_${MCU_VARIANT}.S)
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
endif ()
add_library(${BOARD_TARGET} STATIC
- ${NRFX_DIR}/helpers/nrfx_flag32_allocator.c
- ${NRFX_DIR}/drivers/src/nrfx_gpiote.c
- ${NRFX_DIR}/drivers/src/nrfx_power.c
- ${NRFX_DIR}/drivers/src/nrfx_spim.c
- ${NRFX_DIR}/drivers/src/nrfx_uarte.c
- ${NRFX_DIR}/mdk/system_${MCU_VARIANT}.c
- ${NRFX_DIR}/soc/nrfx_atomic.c
+ ${NRFX_PATH}/helpers/nrfx_flag32_allocator.c
+ ${NRFX_PATH}/drivers/src/nrfx_gpiote.c
+ ${NRFX_PATH}/drivers/src/nrfx_power.c
+ ${NRFX_PATH}/drivers/src/nrfx_spim.c
+ ${NRFX_PATH}/drivers/src/nrfx_uarte.c
+ ${NRFX_PATH}/mdk/system_${MCU_VARIANT}.c
+ ${NRFX_PATH}/soc/nrfx_atomic.c
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
string(TOUPPER "${MCU_VARIANT_XXAA}" MCU_VARIANT_XXAA_UPPER)
@@ -67,12 +71,10 @@ function(add_board_target BOARD_TARGET)
endif ()
target_include_directories(${BOARD_TARGET} PUBLIC
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
- ${NRFX_DIR}
- ${NRFX_DIR}/mdk
- ${NRFX_DIR}/hal
- ${NRFX_DIR}/drivers/include
- ${NRFX_DIR}/drivers/src
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/nrfx_config
+ ${NRFX_PATH}
+ ${NRFX_PATH}/mdk
+ ${NRFX_PATH}/drivers/include
${CMSIS_DIR}/CMSIS/Core/Include
)
@@ -81,14 +83,14 @@ function(add_board_target BOARD_TARGET)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
- -L${NRFX_DIR}/mdk
+ -L${NRFX_PATH}/mdk
--specs=nosys.specs --specs=nano.specs
-nostartfiles
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
- -L${NRFX_DIR}/mdk
+ -L${NRFX_PATH}/mdk
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
@@ -113,6 +115,9 @@ endfunction()
function(family_configure_example TARGET RTOS)
# Board target
add_board_target(board_${BOARD})
+ if (NOT BUILD_ZEPHYR)
+ target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ endif ()
family_configure_common(${TARGET} ${RTOS})
@@ -132,16 +137,10 @@ function(family_configure_example TARGET RTOS)
# Add TinyUSB target and port source
family_add_tinyusb(${TARGET} OPT_MCU_NRF5X ${RTOS})
- target_sources(${TARGET} PUBLIC
+ target_sources(${TARGET} PRIVATE
${TOP}/src/portable/nordic/nrf5x/dcd_nrf5x.c
)
-# if (BUILD_ZEPHYR)
-# target_link_libraries(${TARGET} PUBLIC zephyr_interface kernel)
-# elseif ()
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-# endif ()
-
# Flashing
# family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/nrf/family.mk b/hw/bsp/nrf/family.mk
index b3c05e6db..f5a3f5c45 100644
--- a/hw/bsp/nrf/family.mk
+++ b/hw/bsp/nrf/family.mk
@@ -1,6 +1,6 @@
UF2_FAMILY_ID = 0xADA52840
-NRFX_DIR = hw/mcu/nordic/nrfx
+NRFX_PATH = hw/mcu/nordic/nrfx
include $(TOP)/$(BOARD_PATH)/board.mk
@@ -28,31 +28,31 @@ CFLAGS_GCC += \
LDFLAGS_GCC += \
-nostartfiles \
--specs=nosys.specs --specs=nano.specs \
- -L$(TOP)/${NRFX_DIR}/mdk
+ -L$(TOP)/${NRFX_PATH}/mdk
LDFLAGS_CLANG += \
- -L$(TOP)/${NRFX_DIR}/mdk \
+ -L$(TOP)/${NRFX_PATH}/mdk \
SRC_C += \
src/portable/nordic/nrf5x/dcd_nrf5x.c \
- ${NRFX_DIR}/helpers/nrfx_flag32_allocator.c \
- ${NRFX_DIR}/drivers/src/nrfx_gpiote.c \
- ${NRFX_DIR}/drivers/src/nrfx_power.c \
- ${NRFX_DIR}/drivers/src/nrfx_spim.c \
- ${NRFX_DIR}/drivers/src/nrfx_uarte.c \
- ${NRFX_DIR}/mdk/system_$(MCU_VARIANT).c \
- ${NRFX_DIR}/soc/nrfx_atomic.c
+ ${NRFX_PATH}/helpers/nrfx_flag32_allocator.c \
+ ${NRFX_PATH}/drivers/src/nrfx_gpiote.c \
+ ${NRFX_PATH}/drivers/src/nrfx_power.c \
+ ${NRFX_PATH}/drivers/src/nrfx_spim.c \
+ ${NRFX_PATH}/drivers/src/nrfx_uarte.c \
+ ${NRFX_PATH}/mdk/system_$(MCU_VARIANT).c \
+ ${NRFX_PATH}/soc/nrfx_atomic.c
INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
- $(TOP)/${NRFX_DIR} \
- $(TOP)/${NRFX_DIR}/mdk \
- $(TOP)/${NRFX_DIR}/hal \
- $(TOP)/${NRFX_DIR}/drivers/include \
- $(TOP)/${NRFX_DIR}/drivers/src \
+ $(TOP)/${NRFX_PATH} \
+ $(TOP)/${NRFX_PATH}/mdk \
+ $(TOP)/${NRFX_PATH}/hal \
+ $(TOP)/${NRFX_PATH}/drivers/include \
+ $(TOP)/${NRFX_PATH}/drivers/src \
-SRC_S += ${NRFX_DIR}/mdk/gcc_startup_$(MCU_VARIANT).S
+SRC_S += ${NRFX_PATH}/mdk/gcc_startup_$(MCU_VARIANT).S
ASFLAGS += -D__HEAP_SIZE=0
diff --git a/hw/bsp/nrf/nrfx_config.h b/hw/bsp/nrf/nrfx_config/nrfx_config.h
index fbec4192b..fbec4192b 100644
--- a/hw/bsp/nrf/nrfx_config.h
+++ b/hw/bsp/nrf/nrfx_config/nrfx_config.h
diff --git a/hw/bsp/nrf/nrfx_glue.h b/hw/bsp/nrf/nrfx_config/nrfx_glue.h
index bc3b3689b..bc3b3689b 100644
--- a/hw/bsp/nrf/nrfx_glue.h
+++ b/hw/bsp/nrf/nrfx_config/nrfx_glue.h
diff --git a/hw/bsp/nrf/nrfx_log.h b/hw/bsp/nrf/nrfx_config/nrfx_log.h
index 3bc1b424e..3bc1b424e 100644
--- a/hw/bsp/nrf/nrfx_log.h
+++ b/hw/bsp/nrf/nrfx_config/nrfx_log.h