Skip to content

Commit

Permalink
hw/mcu: Add LPC55xx family MCU from NXP
Browse files Browse the repository at this point in the history
This adds basic support for NXP LPC55xx family.
Currently watchdog, flash, uart, gpio is suported.
No I2C, SPI, timers.
  • Loading branch information
kasjer committed Aug 20, 2024
1 parent 84248a5 commit 6c5542f
Show file tree
Hide file tree
Showing 21 changed files with 3,091 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .style_ignored_dirs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ hw/mcu/stm/stm32_common/src/stm32_driver_mod_i2c_v2.c
hw/mcu/stm/stm32_common/src/stm32_driver_mod_timer.c
hw/mcu/stm/stm32_common/src/stm32_driver_mod_spi.c

hw/mcu/nxp/lpc55xx/src/clock_config.c

# Nordic preserved code style
hw/mcu/nordic/nrf52xxx/src/system_nrf52.c
hw/mcu/nordic/nrf51xxx/src/system_nrf51.c
Expand Down
167 changes: 167 additions & 0 deletions hw/mcu/nxp/lpc55xx/include/clock_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
* Copyright 2017-2019 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/***********************************************************************************************************************
* This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
* will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
**********************************************************************************************************************/

#ifndef _CLOCK_CONFIG_H_
#define _CLOCK_CONFIG_H_

#include "fsl_common.h"

/*******************************************************************************
* Definitions
******************************************************************************/
#define BOARD_XTAL0_CLK_HZ 16000000U /*!< Board xtal frequency in Hz */
#define BOARD_XTAL32K_CLK_HZ 32768U /*!< Board xtal32K frequency in Hz */

/*******************************************************************************
************************ BOARD_InitBootClocks function ************************
******************************************************************************/

#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus*/

/*!
* @brief This function executes default configuration of clocks.
*
*/
void BOARD_InitBootClocks(void);

#if defined(__cplusplus)
}
#endif /* __cplusplus*/

/*******************************************************************************
******************** Configuration BOARD_BootClockFRO12M **********************
******************************************************************************/
/*******************************************************************************
* Definitions for BOARD_BootClockFRO12M configuration
******************************************************************************/
#define BOARD_BOOTCLOCKFRO12M_CORE_CLOCK 12000000U /*!< Core clock frequency: 12000000Hz */

/*******************************************************************************
* API for BOARD_BootClockFRO12M configuration
******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus*/

/*!
* @brief This function executes configuration of clocks.
*
*/
void BOARD_BootClockFRO12M(void);

#if defined(__cplusplus)
}
#endif /* __cplusplus*/

/*******************************************************************************
******************* Configuration BOARD_BootClockFROHF96M *********************
******************************************************************************/
/*******************************************************************************
* Definitions for BOARD_BootClockFROHF96M configuration
******************************************************************************/
#define BOARD_BOOTCLOCKFROHF96M_CORE_CLOCK 96000000U /*!< Core clock frequency: 96000000Hz */

/*******************************************************************************
* API for BOARD_BootClockFROHF96M configuration
******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus*/

/*!
* @brief This function executes configuration of clocks.
*
*/
void BOARD_BootClockFROHF96M(void);

#if defined(__cplusplus)
}
#endif /* __cplusplus*/

/*******************************************************************************
******************** Configuration BOARD_BootClockPLL100M *********************
******************************************************************************/
/*******************************************************************************
* Definitions for BOARD_BootClockPLL100M configuration
******************************************************************************/
#define BOARD_BOOTCLOCKPLL100M_CORE_CLOCK 100000000U /*!< Core clock frequency: 100000000Hz */

/*******************************************************************************
* API for BOARD_BootClockPLL100M configuration
******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus*/

/*!
* @brief This function executes configuration of clocks.
*
*/
void BOARD_BootClockPLL100M(void);

#if defined(__cplusplus)
}
#endif /* __cplusplus*/

/*******************************************************************************
******************** Configuration BOARD_BootClockPLL150M *********************
******************************************************************************/
/*******************************************************************************
* Definitions for BOARD_BootClockPLL150M configuration
******************************************************************************/
#define BOARD_BOOTCLOCKPLL150M_CORE_CLOCK 150000000U /*!< Core clock frequency: 150000000Hz */

/*******************************************************************************
* API for BOARD_BootClockPLL150M configuration
******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus*/

/*!
* @brief This function executes configuration of clocks.
*
*/
void BOARD_BootClockPLL150M(void);

#if defined(__cplusplus)
}
#endif /* __cplusplus*/

/*******************************************************************************
******************* Configuration BOARD_BootClockPLL1_150M ********************
******************************************************************************/
/*******************************************************************************
* Definitions for BOARD_BootClockPLL1_150M configuration
******************************************************************************/
#define BOARD_BOOTCLOCKPLL1_150M_CORE_CLOCK 150000000U /*!< Core clock frequency: 150000000Hz */


/*******************************************************************************
* API for BOARD_BootClockPLL1_150M configuration
******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus*/

/*!
* @brief This function executes configuration of clocks.
*
*/
void BOARD_BootClockPLL1_150M(void);

#if defined(__cplusplus)
}
#endif /* __cplusplus*/

#endif /* _CLOCK_CONFIG_H_ */
29 changes: 29 additions & 0 deletions hw/mcu/nxp/lpc55xx/include/mcu/cmsis_nvic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* mbed Microcontroller Library - cmsis_nvic
* Copyright (c) 2009-2011 ARM Limited. All rights reserved.
*
* CMSIS-style functionality to support dynamic vectors
*/

#ifndef MBED_CMSIS_NVIC_H
#define MBED_CMSIS_NVIC_H

#include <stdint.h>

#define NVIC_NUM_VECTORS (16 + 59) // CORE + MCU Peripherals
#define NVIC_USER_IRQ_OFFSET 16

#include <fsl_device_registers.h>

#ifdef __cplusplus
extern "C" {
#endif

void NVIC_Relocate(void);
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
uint32_t NVIC_GetVector(IRQn_Type IRQn);

#ifdef __cplusplus
}
#endif

#endif
40 changes: 40 additions & 0 deletions hw/mcu/nxp/lpc55xx/include/mcu/cortex_m33.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 __MCU_CORTEX_M33_H__
#define __MCU_CORTEX_M33_H__

#include <mcu/mcu.h>
#include <cmsis_gcc.h>

#ifdef __cplusplus
extern "C" {
#endif

static inline void
hal_debug_break(void)
{
__BKPT(1);
}

#ifdef __cplusplus
}
#endif

#endif /* __MCU_CORTEX_M33_H__ */
41 changes: 41 additions & 0 deletions hw/mcu/nxp/lpc55xx/include/mcu/mcu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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 __MCU_MCU_H_
#define __MCU_MCU_H_

#include <fsl_device_registers.h>

#ifdef __cplusplus
extern "C" {
#endif

#define SVC_IRQ_NUMBER SVC_IRQn

/*
* Defines for naming GPIOs.
*/
#define MCU_GPIO_PORT0(pin) ((0 * 32) + (pin))
#define MCU_GPIO_PORT1(pin) ((1 * 32) + (pin))

#ifdef __cplusplus
}
#endif

#endif /* __MCU_MCU_H_ */
24 changes: 24 additions & 0 deletions hw/mcu/nxp/lpc55xx/include/mcu/mcu_vectors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.
*/

#if (defined(CPU_LPC55S28JBD100) || defined(CPU_LPC55S28JBD64) || defined(CPU_LPC55S28JEV98))
#include "vectors/lpc55s28_vectors.h"
#else
#error "Please select first the target LPC55 device used in your application"
#endif
64 changes: 64 additions & 0 deletions hw/mcu/nxp/lpc55xx/include/mcu/mcux_hal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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 __MCUX_HAL_H_
#define __MCUX_HAL_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Helper functions to enable/disable interrupts. */
#define __HAL_DISABLE_INTERRUPTS(x) \
do { \
x = __get_PRIMASK(); \
__disable_irq(); \
} while(0);

#define __HAL_ENABLE_INTERRUPTS(x) \
do { \
if (!x) { \
__enable_irq(); \
} \
} while(0);

struct nxp_hal_i2c_cfg {
int8_t pin_scl;
int8_t pin_sda;
uint32_t frequency;
};

struct nxp_hal_spi_cfg {
uint32_t clk_pin;
uint32_t pcs_pin;
uint32_t sout_pin;
uint32_t sin_pin;
};

struct hal_flash;
extern const struct hal_flash mcux_flash_dev;
extern const struct hal_flash mcux_qspi_dev;

#ifdef __cplusplus
}
#endif

#endif /* __MCUX_HAL_H_ */
Loading

0 comments on commit 6c5542f

Please sign in to comment.