lpc55s69 is mounted as lpc55boot
This commit is contained in:
parent
e94e346d97
commit
f250eddd3d
8 changed files with 123 additions and 25 deletions
2
lib/nxp
2
lib/nxp
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6ef798460290c33da4cec1a52063cacb58a31879
|
Subproject commit e649af36e724d9a8a6cd35b81a37d434a7b3d378
|
||||||
|
|
@ -31,6 +31,7 @@ CFLAGS += -Wno-error=unused-parameter -Wno-error=float-equal
|
||||||
PORT_SRC_C += \
|
PORT_SRC_C += \
|
||||||
$(addprefix $(CURRENT_PATH)/, $(wildcard *.c)) \
|
$(addprefix $(CURRENT_PATH)/, $(wildcard *.c)) \
|
||||||
$(MCU_DIR)/system_$(MCU)_cm33_core0.c \
|
$(MCU_DIR)/system_$(MCU)_cm33_core0.c \
|
||||||
|
$(MCU_DIR)/project_template/clock_config.c \
|
||||||
$(MCU_DIR)/drivers/fsl_clock.c \
|
$(MCU_DIR)/drivers/fsl_clock.c \
|
||||||
$(MCU_DIR)/drivers/fsl_gpio.c \
|
$(MCU_DIR)/drivers/fsl_gpio.c \
|
||||||
$(MCU_DIR)/drivers/fsl_power.c \
|
$(MCU_DIR)/drivers/fsl_power.c \
|
||||||
|
|
@ -48,7 +49,8 @@ LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_hardabi.a
|
||||||
INC += \
|
INC += \
|
||||||
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||||
$(TOP)/$(MCU_DIR) \
|
$(TOP)/$(MCU_DIR) \
|
||||||
$(TOP)/$(MCU_DIR)/drivers
|
$(TOP)/$(MCU_DIR)/drivers \
|
||||||
|
$(TOP)/$(MCU_DIR)/project_template
|
||||||
|
|
||||||
include ../rules.mk
|
include ../rules.mk
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,24 +25,107 @@
|
||||||
#include "board_api.h"
|
#include "board_api.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
|
#include "fsl_device_registers.h"
|
||||||
|
#include "fsl_gpio.h"
|
||||||
|
#include "fsl_power.h"
|
||||||
|
#include "fsl_iocon.h"
|
||||||
|
|
||||||
|
#include "clock_config.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
#define IOCON_PIO_ASW_DIS_EN 0x00u /*!<@brief Analog switch is closed (enabled), only for A0 version */
|
||||||
|
#define IOCON_PIO_ASW_EN 0x0400u /*!<@brief Analog switch is closed (enabled) */
|
||||||
|
#define IOCON_PIO_DIGITAL_EN 0x0100u /*!<@brief Enables digital function */
|
||||||
|
#define IOCON_PIO_FUNC0 0x00u /*!<@brief Selects pin function 0 */
|
||||||
|
#define IOCON_PIO_FUNC1 0x01u /*!<@brief Selects pin function 1 */
|
||||||
|
#define IOCON_PIO_FUNC7 0x07u /*!<@brief Selects pin function 7 */
|
||||||
|
#define IOCON_PIO_INV_DI 0x00u /*!<@brief Input function is not inverted */
|
||||||
|
#define IOCON_PIO_MODE_INACT 0x00u /*!<@brief No addition pin function */
|
||||||
|
#define IOCON_PIO_MODE_PULLUP 0x20u /*!<@brief Selects pull-up function */
|
||||||
|
#define IOCON_PIO_OPENDRAIN_DI 0x00u /*!<@brief Open drain is disabled */
|
||||||
|
#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */
|
||||||
|
|
||||||
void board_init(void)
|
void board_init(void)
|
||||||
{
|
{
|
||||||
|
// Enable IOCON clock
|
||||||
|
CLOCK_EnableClock(kCLOCK_Iocon);
|
||||||
|
|
||||||
|
// Init 96 MHz clock
|
||||||
|
BOARD_BootClockFROHF96M();
|
||||||
|
|
||||||
|
// disable systick
|
||||||
|
board_timer_stop();
|
||||||
|
|
||||||
|
// GPIO_PortInit(GPIO, BUTTON_PORT);
|
||||||
|
|
||||||
|
// LED
|
||||||
|
GPIO_PortInit(GPIO, LED_PORT);
|
||||||
|
gpio_pin_config_t const led_config = { kGPIO_DigitalOutput, 0};
|
||||||
|
GPIO_PinInit(GPIO, LED_PORT, LED_PIN, &led_config);
|
||||||
|
board_led_write(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_dfu_init(void)
|
void board_dfu_init(void)
|
||||||
{
|
{
|
||||||
|
// USB VBUS
|
||||||
|
const uint32_t port0_pin22_config = (
|
||||||
|
IOCON_PIO_FUNC7 | /* Pin is configured as USB0_VBUS */
|
||||||
|
IOCON_PIO_MODE_INACT | /* No addition pin function */
|
||||||
|
IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
|
||||||
|
IOCON_PIO_INV_DI | /* Input function is not inverted */
|
||||||
|
IOCON_PIO_DIGITAL_EN | /* Enables digital function */
|
||||||
|
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
|
||||||
|
);
|
||||||
|
/* PORT0 PIN22 (coords: 78) is configured as USB0_VBUS */
|
||||||
|
IOCON_PinMuxSet(IOCON, 0U, 22U, port0_pin22_config);
|
||||||
|
|
||||||
|
// USB Controller
|
||||||
|
POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB0 Phy */
|
||||||
|
POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY); /*< Turn on USB1 Phy */
|
||||||
|
|
||||||
|
/* reset the IP to make sure it's in reset state. */
|
||||||
|
RESET_PeripheralReset(kUSB0D_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB0HSL_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB0HMR_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB1H_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB1D_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB1_RST_SHIFT_RSTn);
|
||||||
|
RESET_PeripheralReset(kUSB1RAM_RST_SHIFT_RSTn);
|
||||||
|
|
||||||
|
#if (defined USB_DEVICE_CONFIG_LPCIP3511HS) && (USB_DEVICE_CONFIG_LPCIP3511HS)
|
||||||
|
CLOCK_EnableClock(kCLOCK_Usbh1);
|
||||||
|
/* Put PHY powerdown under software control */
|
||||||
|
*((uint32_t *)(USBHSH_BASE + 0x50)) = USBHSH_PORTMODE_SW_PDCOM_MASK;
|
||||||
|
/* According to reference mannual, device mode setting has to be set by access usb host register */
|
||||||
|
*((uint32_t *)(USBHSH_BASE + 0x50)) |= USBHSH_PORTMODE_DEV_ENABLE_MASK;
|
||||||
|
/* enable usb1 host clock */
|
||||||
|
CLOCK_DisableClock(kCLOCK_Usbh1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 || (defined USB_DEVICE_CONFIG_LPCIP3511FS) && (USB_DEVICE_CONFIG_LPCIP3511FS)
|
||||||
|
CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
|
||||||
|
CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
|
||||||
|
/* enable usb0 host clock */
|
||||||
|
CLOCK_EnableClock(kCLOCK_Usbhsl0);
|
||||||
|
/*According to reference mannual, device mode setting has to be set by access usb host register */
|
||||||
|
*((uint32_t *)(USBFSH_BASE + 0x5C)) |= USBFSH_PORTMODE_DEV_ENABLE_MASK;
|
||||||
|
/* disable usb0 host clock */
|
||||||
|
CLOCK_DisableClock(kCLOCK_Usbhsl0);
|
||||||
|
CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbfsSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB Device clock */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_dfu_complete(void)
|
void board_dfu_complete(void)
|
||||||
{
|
{
|
||||||
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool board_app_valid(void)
|
bool board_app_valid(void)
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_app_jump(void)
|
void board_app_jump(void)
|
||||||
|
|
@ -61,7 +144,8 @@ uint8_t board_usb_get_serial(uint8_t serial_id[16])
|
||||||
|
|
||||||
void board_led_write(uint32_t state)
|
void board_led_write(uint32_t state)
|
||||||
{
|
{
|
||||||
(void) state;
|
// TODO PWM for fading
|
||||||
|
GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_rgb_write(uint8_t const rgb[])
|
void board_rgb_write(uint8_t const rgb[])
|
||||||
|
|
@ -75,17 +159,17 @@ void board_rgb_write(uint8_t const rgb[])
|
||||||
|
|
||||||
void board_timer_start(uint32_t ms)
|
void board_timer_start(uint32_t ms)
|
||||||
{
|
{
|
||||||
(void) ms;
|
SysTick_Config( (SystemCoreClock/1000) * ms );
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_timer_stop(void)
|
void board_timer_stop(void)
|
||||||
{
|
{
|
||||||
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysTick_Handler (void)
|
void SysTick_Handler (void)
|
||||||
{
|
{
|
||||||
|
board_timer_handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -95,12 +179,17 @@ int board_uart_write(void const * buf, int len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||||
#ifndef TINYUF2_SELF_UPDATE
|
#ifndef TINYUF2_SELF_UPDATE
|
||||||
|
|
||||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
void USB0_IRQHandler(void)
|
||||||
void OTG_FS_IRQHandler(void)
|
|
||||||
{
|
{
|
||||||
tud_int_handler(0);
|
tud_int_handler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void USB1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
tud_int_handler(1);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
#define USE_DFU_DOUBLE_TAP 1
|
#define USE_DFU_DOUBLE_TAP 0
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,10 @@
|
||||||
// LED
|
// LED
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
#define LED_PORT GPIOC
|
// RGB pins are P1_6, P1_7, P1_4
|
||||||
#define LED_PIN GPIO_PIN_1
|
#define LED_PORT 1
|
||||||
#define LED_STATE_ON 1
|
#define LED_PIN 6
|
||||||
|
#define LED_STATE_ON 0
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Neopixel
|
// Neopixel
|
||||||
|
|
@ -50,15 +51,15 @@
|
||||||
// USB UF2
|
// USB UF2
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
#define USB_VID 0x0000
|
#define USB_VID 0x1fc9
|
||||||
#define USB_PID 0x0000
|
#define USB_PID 0x0094
|
||||||
#define USB_MANUFACTURER "Adafruit"
|
#define USB_MANUFACTURER "NXP"
|
||||||
#define USB_PRODUCT "Dummy"
|
#define USB_PRODUCT "LPCXpresso 55s69"
|
||||||
|
|
||||||
#define UF2_PRODUCT_NAME USB_MANUFACTURER " " USB_PRODUCT
|
#define UF2_PRODUCT_NAME USB_MANUFACTURER " " USB_PRODUCT
|
||||||
#define UF2_BOARD_ID "Dummy"
|
#define UF2_BOARD_ID "LPC55S69-Xpresso-revA"
|
||||||
#define UF2_VOLUME_LABEL "DUMMYBOOT"
|
#define UF2_VOLUME_LABEL "LPC5569BOOT"
|
||||||
#define UF2_INDEX_URL "https://www.adafruit.com"
|
#define UF2_INDEX_URL "https://www.nxp.com/design/development-boards/lpcxpresso-boards/lpcxpresso55s69-development-board:LPC55S69-EVK"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// UART
|
// UART
|
||||||
|
|
|
||||||
|
|
@ -34,19 +34,23 @@ void board_init(void)
|
||||||
|
|
||||||
void board_dfu_init(void)
|
void board_dfu_init(void)
|
||||||
{
|
{
|
||||||
|
// Init USB for DFU
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_dfu_complete(void)
|
void board_dfu_complete(void)
|
||||||
{
|
{
|
||||||
|
// Mostly reset
|
||||||
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool board_app_valid(void)
|
bool board_app_valid(void)
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_app_jump(void)
|
void board_app_jump(void)
|
||||||
{
|
{
|
||||||
|
// Jump to application code
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t board_usb_get_serial(uint8_t serial_id[16])
|
uint8_t board_usb_get_serial(uint8_t serial_id[16])
|
||||||
|
|
@ -75,17 +79,17 @@ void board_rgb_write(uint8_t const rgb[])
|
||||||
|
|
||||||
void board_timer_start(uint32_t ms)
|
void board_timer_start(uint32_t ms)
|
||||||
{
|
{
|
||||||
(void) ms;
|
SysTick_Config( (SystemCoreClock/1000) * ms );
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_timer_stop(void)
|
void board_timer_stop(void)
|
||||||
{
|
{
|
||||||
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysTick_Handler (void)
|
void SysTick_Handler (void)
|
||||||
{
|
{
|
||||||
|
board_timer_handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
|
#define USE_DFU_DOUBLE_TAP 0
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ void board_timer_handler(void)
|
||||||
case STATE_USB_UNPLUGGED:
|
case STATE_USB_UNPLUGGED:
|
||||||
case STATE_USB_PLUGGED:
|
case STATE_USB_PLUGGED:
|
||||||
{
|
{
|
||||||
// Fading with LED
|
// Fading with LED TODO option to skip for unsupported MCUs
|
||||||
uint8_t duty = _timer_count & 0xff;
|
uint8_t duty = _timer_count & 0xff;
|
||||||
if ( _timer_count & 0x100 ) duty = 255 - duty;
|
if ( _timer_count & 0x100 ) duty = 255 - duty;
|
||||||
board_led_write(duty);
|
board_led_write(duty);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue