Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions os/common/startup/ARMCMx/compilers/GCC/mk/startup_ch579m.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# CH579M startup files (ARM Cortex-M0, ARMv6-M).
#
# Uses the generic ChibiOS ARMv6-M startup (crt0_v6m.S + vectors.S)
# with WCH's CH579M CMSIS device header for the vector table layout.
#
# The system_ch579m.c provides SystemInit() which is called from crt0;
# our hal_lld_init() then does the PLL switch in __early_init().

STARTUPSRC = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/crt1.c

STARTUPASM = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/crt0_v6m.S \
$(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/vectors.S

STARTUPINC = $(CHIBIOS)/os/common/portability/GCC \
$(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC \
$(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/ld \
$(CHIBIOS)/os/common/ext/ARM/CMSIS/Core/Include \
$(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/devices/CH579 \
$(CHIBIOS_CONTRIB)/os/hal/ports/WCH/CH579 \
$(KEYBOARD_PATH_1)/ld

STARTUPLD = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/ld
STARTUPLD_CONTRIB = $(KEYBOARD_PATH_1)/ld

LDFLAGS += -L$(KEYBOARD_PATH_1)/ld

# Shared variables
ALLXASMSRC += $(STARTUPASM)
ALLCSRC += $(STARTUPSRC)
ALLINC += $(STARTUPINC)
48 changes: 48 additions & 0 deletions os/common/startup/ARMCMx/devices/CH579/cmparams.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* ChibiOS - CH579M Cortex-M0 CMSIS parameters
*
* CH579M interrupt vector count: 26 external IRQs from the datasheet,
* rounded up to the next multiple of 8 → 32.
*/

#ifndef CMPARAMS_H
#define CMPARAMS_H

/** @brief Cortex core model: 0 = Cortex-M0. */
#define CORTEX_MODEL 0

/** @brief No FPU on Cortex-M0. */
#define CORTEX_HAS_FPU 0

/**
* @brief Number of bits in priority masks.
* @note Cortex-M0 only implements the top 2 bits of the priority field.
*/
#define CORTEX_PRIORITY_BITS 2

/**
* @brief Number of interrupt vectors.
* @note Does NOT include the 16 system vectors. Must be a multiple of 8.
* CH579M has 26 external IRQs → rounded to 32.
*/
#define CORTEX_NUM_VECTORS 32

#if !defined(_FROM_ASM_)

#include "board.h"

/* Pull in the device register header solely to verify parameters match. */
#include "CH579.h"

#if CORTEX_MODEL != __CORTEX_M
#error "CMSIS __CORTEX_M mismatch — verify CH579.h defines __CORTEX_M 0"
#endif

#if CORTEX_PRIORITY_BITS != __NVIC_PRIO_BITS
#error \
"CMSIS __NVIC_PRIO_BITS mismatch — verify CH579.h defines __NVIC_PRIO_BITS 2"
#endif

#endif /* !defined(_FROM_ASM_) */

#endif /* CMPARAMS_H */
Loading