Skip to content

Commit

Permalink
Merge pull request #366 from hftsai256/upstream-v21.11.3
Browse files Browse the repository at this point in the history
Add a generic board for lpc11u35
  • Loading branch information
fpoussin committed Jul 17, 2023
2 parents d7e99ac + ac24055 commit 553b773
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 11 deletions.
13 changes: 6 additions & 7 deletions os/common/ext/CMSIS/LPC/LPC11Uxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,26 +719,25 @@ typedef struct { /*!< (@ 0x40080000) USB Structure
// ----- GPIO_PORT -----
// ------------------------------------------------------------------------------------------------


/**
* @brief Product name title=UM10462 Chapter title=LPC11U1x GPIO Modification date=3/17/2011 Major revision=0 Minor revision=3 (GPIO_PORT)
*/

typedef struct {
union {
struct {
__IO uint8_t B0[32]; /*!< (@ 0x50000000) Byte pin registers port 0; pins PIO0_0 to PIO0_31 */
__IO uint8_t B1[32]; /*!< (@ 0x50000020) Byte pin registers port 1 */
__IO uint8_t BP0[32]; /*!< (@ 0x50000000) Byte pin registers port 0; pins PIO0_0 to PIO0_31 */
__IO uint8_t BP1[32]; /*!< (@ 0x50000020) Byte pin registers port 1 */
};
__IO uint8_t B[64]; /*!< (@ 0x50000000) Byte pin registers port 0/1 */
__IO uint8_t BP[64]; /*!< (@ 0x50000000) Byte pin registers port 0/1 */
};
__I uint32_t RESERVED0[1008];
union {
struct {
__IO uint32_t W0[32]; /*!< (@ 0x50001000) Word pin registers port 0 */
__IO uint32_t W1[32]; /*!< (@ 0x50001080) Word pin registers port 1 */
__IO uint32_t WP0[32]; /*!< (@ 0x50001000) Word pin registers port 0 */
__IO uint32_t WP1[32]; /*!< (@ 0x50001080) Word pin registers port 1 */
};
__IO uint32_t W[64]; /*!< (@ 0x50001000) Word pin registers port 0/1 */
__IO uint32_t WP[64]; /*!< (@ 0x50001000) Word pin registers port 0/1 */
};
uint32_t RESERVED1[960];
__IO uint32_t DIR[2]; /* 0x2000 */
Expand Down
31 changes: 31 additions & 0 deletions os/hal/boards/LPC11U35_GENERIC/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright (C) 2020 Yaotian Feng, Codetector<codetector@codetector.cn>
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 "board.h"
#include "quantum.h"

__attribute__((weak)) void __chibios_override___early_init(void) {
// Reset / Debug Select Input
palSetLineMode(LINE_RESET , MODE_DIR_IN | MODE_MODE_PULL_UP | MODE_AD_DIGITAL);
// ISP TP
palSetLineMode(LINE_USBISP, MODE_DIR_IN | MODE_MODE_PULL_UP | MODE_AD_DIGITAL);
// USB
palSetLineMode(LINE_USBVBUS, MODE_FUNC_ALT1 | MODE_MODE_PULL_UP | MODE_AD_DIGITAL);
palSetLineMode(LINE_USBCONN, MODE_FUNC_ALT1);
}

__attribute__((weak)) void __chibios_override_boardInit(void) {}

66 changes: 66 additions & 0 deletions os/hal/boards/LPC11U35_GENERIC/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio
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.
*/

/*
* This file has been automatically generated using ChibiStudio board
* generator plugin. Do not edit manually.
*/

#ifndef _BOARD_H_
#define _BOARD_H_

/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/

/*
* Setup for LPC11U35 board.
*/

/*
* Board identifier.
*/
#define BOARD_LPC11U35_GENERIC
#define BOARD_NAME "LPC11U35_GENERIC"

#define LPC11U35

/*
* IO pins assignments.
*
* Define ST/SN GPIO convensions so that we could use A1..B31 shorthands as
* defined in chibios: platforms/chibios/_pin_defs.h
*/
#define GPIOA IOPORT0
#define GPIOB IOPORT1


#define LINE_RESET PAL_LINE(IOPORT0, 0)
#define LINE_USBISP PAL_LINE(IOPORT0, 1)
#define LINE_USBCONN PAL_LINE(IOPORT0, 6)
#define LINE_USBVBUS PAL_LINE(IOPORT0, 3)

#if !defined(_FROM_ASM_)
#ifdef __cplusplus
extern "C" {
#endif
void boardInit(void);
#ifdef __cplusplus
}
#endif
#endif /* _FROM_ASM_ */

#endif /* _BOARD_H_ */
10 changes: 10 additions & 0 deletions os/hal/boards/LPC11U35_GENERIC/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# List of all the board related files.
BOARDSRC = $(CHIBIOS_CONTRIB)/os/hal/boards/LPC11U35_GENERIC/board.c

# Required include directories
BOARDINC = $(CHIBIOS_CONTRIB)/os/hal/boards/LPC11U35_GENERIC

# Shared variables
ALLCSRC += $(BOARDSRC)
ALLINC += $(BOARDINC)

23 changes: 20 additions & 3 deletions os/hal/ports/LPC/LLD/GPIO/hal_pal_lld.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@
be updated to the new style.*/
#define PAL_NEW_INIT

/*===========================================================================*/
/* Unsupported modes and specific modes */
/*===========================================================================*/

#undef PAL_MODE_RESET
#undef PAL_MODE_UNCONNECTED
#undef PAL_MODE_INPUT
#undef PAL_MODE_INPUT_PULLUP
#undef PAL_MODE_INPUT_PULLDOWN
#undef PAL_MODE_INPUT_ANALOG
#undef PAL_MODE_OUTPUT_PUSHPULL
#undef PAL_MODE_OUTPUT_OPENDRAIN

#define PAL_MODE_INPUT_PULLUP (MODE_DIR_IN | MODE_MODE_PULL_UP | MODE_AD_DIGITAL)
#define PAL_MODE_INPUT_PULLDOWN (MODE_DIR_IN | MODE_MODE_PULL_DOWN | MODE_AD_DIGITAL)
#define PAL_MODE_OUTPUT_OPENDRAIN (MODE_DIR_OUT | MODE_OD_ENABLE | MODE_AD_DIGITAL)

/*===========================================================================*/
/* I/O Ports Types and constants. */
/*===========================================================================*/
Expand Down Expand Up @@ -136,7 +153,7 @@ typedef uint32_t iomode_t;
#define MODE_INV_DISABLE (0x0U << MODE_INV_POS)
#define MODE_INV_ENABLE (0x1U << MODE_INV_POS)

#define MODE_AD_POS (7U)
#define MODE_AD_POS 7U
#define MODE_AD_MASK (1U << MODE_AD_POS)
#define MODE_AD_ANALOG (0U << MODE_AD_POS)
#define MODE_AD_DIGITAL (1U << MODE_AD_POS)
Expand Down Expand Up @@ -310,7 +327,7 @@ typedef uint32_t iopadid_t;
* @notapi
*/
#define pal_lld_readpad(port, pad) \
(LPC_GPIO->B[(PAL_IOPORTS_WIDTH * LPC_IOPORT_NUM(port)) + pad])
(LPC_GPIO->BP[(PAL_IOPORTS_WIDTH * LPC_IOPORT_NUM(port)) + pad])

/**
* @brief Writes a logical state on an output pad.
Expand All @@ -329,7 +346,7 @@ typedef uint32_t iopadid_t;
*/
#define pal_lld_writepad(port, pad, bit) \
do { \
(LPC_GPIO->B[(PAL_IOPORTS_WIDTH * LPC_IOPORT_NUM(port)) + pad]) = bit; \ \
(LPC_GPIO->BP[(PAL_IOPORTS_WIDTH * LPC_IOPORT_NUM(port)) + pad]) = bit; \ \
} while (false)


Expand Down
1 change: 1 addition & 0 deletions os/hal/ports/LPC/LPC11Uxx/hal_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ void hal_lld_init(void) {
lpc_clock_init();
}


/** @} */
38 changes: 37 additions & 1 deletion os/hal/ports/LPC/LPC11Uxx/hal_lld.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@
#define LPC_IRC_FREQUENCY 12000000UL // 12MHz
/** @} */

/* set_pll mode options */
#define CPU_FREQ_EQU 0
#define CPU_FREQ_LTE 1
#define CPU_FREQ_GTE 2
#define CPU_FREQ_APPROX 3

/* set_pll result0 options */
#define PLL_CMD_SUCCESS 0
#define PLL_INVALID_FREQ 1
#define PLL_INVALID_MODE 2
#define PLL_FREQ_NOT_FOUND 3
#define PLL_NOT_LOCKED 4

/* set_power mode options */
#define PWR_DEFAULT 0
#define PWR_CPU_PERFORMANCE 1
#define PWR_EFFICIENCY 2
#define PWR_LOW_CURRENT 3

/* set_power result0 options */
#define PWR_CMD_SUCCESS 0
#define PWR_INVALID_FREQ 1
#define PWR_INVALID_MODE 2

/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
Expand Down Expand Up @@ -130,6 +154,18 @@ SYSCON_MAINCLKSEL_PLLIN, SYSCON_MAINCLKSEL_WATCHDOG, SYSCON_MAINCLKSEL_PLLOUT"
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
typedef struct _PWRD {
void (*set_pll)(unsigned int cmd[], unsigned int resp[]);
void (*set_power)(unsigned int cmd[], unsigned int resp[]);
} PWRD;

typedef struct _ROM {
const void *drv000;
const void *drv001;
const void *drv002;
const PWRD *pWRD;
} ROM;


/*===========================================================================*/
/* Driver macros. */
Expand All @@ -138,7 +174,7 @@ SYSCON_MAINCLKSEL_PLLIN, SYSCON_MAINCLKSEL_WATCHDOG, SYSCON_MAINCLKSEL_PLLOUT"
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/

#define CPU_CLOCK LPC_SYS_FREQUENCY

/*===========================================================================*/
/* External declarations. */
Expand Down

0 comments on commit 553b773

Please sign in to comment.