diff --git a/os/common/ext/CMSIS/LPC/LPC11Uxx.h b/os/common/ext/CMSIS/LPC/LPC11Uxx.h index 317ca8852f..54ec4c335f 100644 --- a/os/common/ext/CMSIS/LPC/LPC11Uxx.h +++ b/os/common/ext/CMSIS/LPC/LPC11Uxx.h @@ -719,7 +719,6 @@ 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) */ @@ -727,18 +726,18 @@ typedef struct { /*!< (@ 0x40080000) USB Structure 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 */ diff --git a/os/hal/boards/LPC11U35_GENERIC/board.c b/os/hal/boards/LPC11U35_GENERIC/board.c new file mode 100644 index 0000000000..b57ea4e7da --- /dev/null +++ b/os/hal/boards/LPC11U35_GENERIC/board.c @@ -0,0 +1,31 @@ +/* + Copyright (C) 2020 Yaotian Feng, Codetector + + 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) {} + diff --git a/os/hal/boards/LPC11U35_GENERIC/board.h b/os/hal/boards/LPC11U35_GENERIC/board.h new file mode 100644 index 0000000000..dbb1acae77 --- /dev/null +++ b/os/hal/boards/LPC11U35_GENERIC/board.h @@ -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_ */ diff --git a/os/hal/boards/LPC11U35_GENERIC/board.mk b/os/hal/boards/LPC11U35_GENERIC/board.mk new file mode 100644 index 0000000000..f35568b742 --- /dev/null +++ b/os/hal/boards/LPC11U35_GENERIC/board.mk @@ -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) + diff --git a/os/hal/ports/LPC/LLD/GPIO/hal_pal_lld.h b/os/hal/ports/LPC/LLD/GPIO/hal_pal_lld.h index 44c60d1d4f..595ac4bbca 100644 --- a/os/hal/ports/LPC/LLD/GPIO/hal_pal_lld.h +++ b/os/hal/ports/LPC/LLD/GPIO/hal_pal_lld.h @@ -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. */ /*===========================================================================*/ @@ -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) @@ -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. @@ -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) diff --git a/os/hal/ports/LPC/LPC11Uxx/hal_lld.c b/os/hal/ports/LPC/LPC11Uxx/hal_lld.c index f3e35d485f..4dc931dc49 100644 --- a/os/hal/ports/LPC/LPC11Uxx/hal_lld.c +++ b/os/hal/ports/LPC/LPC11Uxx/hal_lld.c @@ -99,4 +99,5 @@ void hal_lld_init(void) { lpc_clock_init(); } + /** @} */ diff --git a/os/hal/ports/LPC/LPC11Uxx/hal_lld.h b/os/hal/ports/LPC/LPC11Uxx/hal_lld.h index 9ed343e3e4..886c141afd 100644 --- a/os/hal/ports/LPC/LPC11Uxx/hal_lld.h +++ b/os/hal/ports/LPC/LPC11Uxx/hal_lld.h @@ -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. */ /*===========================================================================*/ @@ -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. */ @@ -138,7 +174,7 @@ SYSCON_MAINCLKSEL_PLLIN, SYSCON_MAINCLKSEL_WATCHDOG, SYSCON_MAINCLKSEL_PLLOUT" /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ - +#define CPU_CLOCK LPC_SYS_FREQUENCY /*===========================================================================*/ /* External declarations. */