Skip to content

Commit d5cf179

Browse files
committed
fixed lpc55 compilation
1 parent a9ca060 commit d5cf179

File tree

26 files changed

+848
-365
lines changed

26 files changed

+848
-365
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ M480_MCUS := M484
1010
CH32V_MCUS := CH32V307
1111
APM32_MCUS := APM32F407
1212
AT32_MCUS := AT32F405
13+
LPC55_MCUS := LPC5516
1314

1415
# Source files
1516
SRCS += \
@@ -85,6 +86,8 @@ include sdk/apm32/apm32_sdk.mk
8586
else ifneq (,$(filter $(strip $(MCU)),$(AT32_MCUS)))
8687
VENDOR_DIR := libs/vendor/artery
8788
include sdk/at32/at32_sdk.mk
89+
else ifneq (,$(filter $(strip $(MCU)),$(LPC55_MCUS)))
90+
include sdk/lpc55/lpc55_sdk.mk
8891
else
8992
$(error Unsupported MCU: $(MCU))
9093
endif

libs/tinyusb.mk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ else
6060
endif
6161

6262
ifeq (STM32F722, $(strip $(MCU)))
63-
SRCS += $(TINYUSB_DIR)/portable/st/synopsys/dcd_synopsys.c
63+
INCS +=$(TINYUSB_DIR)/portable/synopsys/dwc2
64+
SRCS += $(TINYUSB_DIR)/portable/synopsys/dwc2/dcd_dwc2.c
65+
#SRCS += $(TINYUSB_DIR)/portable/st/synopsys/dcd_synopsys.c
6466
endif
6567

6668
ifeq (ATSAMD21, $(strip $(MCU)))
@@ -72,7 +74,7 @@ else
7274
endif
7375

7476
ifeq (LPC5516, $(strip $(MCU)))
75-
SRCS += $(TINYUSB_DIR)/portable/nxp/lpc+ip3511/dcd_lpc3511.c
77+
SRCS += $(TINYUSB_DIR)/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
7678
endif
7779
endif #TINYUSB_USE_HAL
7880

main/amk/amk_gpio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@
183183
#include "gpio_apm32.h"
184184
#elif defined(AT32F405)
185185
#include "gpio_at32.h"
186+
#elif defined(LPC55xx)
187+
#include "gpio_lpc55.h"
186188
#else
187189
#error "MCU_TYPE not defined"
188190
#endif

main/amk/amk_hal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
#define system_core_clock SystemCoreClock
6666
#include "at32f402_405.h"
6767
#elif defined(LPC55xx)
68-
#include "peripherals.h"
68+
#include "fsl_conf.h"
6969
#else
7070
#error "unsupport platform"
7171
#endif

main/porting/wired.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,8 @@ endif
6161

6262
ifneq (,$(filter $(strip $(MCU)),$(AT32_MCUS)))
6363
include $(MAIN_DIR)/porting/wired/at32.mk
64+
endif
65+
66+
ifneq (,$(filter $(strip $(MCU)),$(LPC55_MCUS)))
67+
include $(MAIN_DIR)/porting/wired/lpc55.mk
6468
endif

main/porting/wired/lpc55.mk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
PLATFORM_PORTING_DIR := $(MAIN_DIR)/porting/wired/lpc55
2+
3+
SRCS += \
4+
$(PLATFORM_PORTING_DIR)/gpio_pin.c \
5+
$(PLATFORM_PORTING_DIR)/lpc55.c \
6+
$(MAIN_DIR)/porting/wired/common/cm_misc.c \
7+
8+
INCS += \
9+
$(PLATFORM_PORTING_DIR) \
10+
11+
ifeq (LPC5516, $(strip $(MCU)))
12+
SRCS += $(PLATFORM_PORTING_DIR)/lpc5516.c
13+
endif

main/porting/wired/lpc55/gpio_pin.c

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
#include "amk_hal.h"
99
#include "amk_gpio.h"
1010

11+
#define INPUT_FLOATING 0
12+
#define INPUT_PULL_DOWN 1
13+
#define INPUT_PULL_UP 2
14+
15+
#define OUTPUT_PUSHPULL 0
16+
#define OUTPUT_OPENDRAIN 1
17+
1118
int gpio_read_pin(pin_t pin)
1219
{
1320
return GPIO_PinRead(GPIO, GET_PORT(pin), GET_PIN(pin));
@@ -18,38 +25,48 @@ void gpio_write_pin(pin_t pin, int value)
1825
GPIO_PinWrite(GPIO,GET_PORT(pin), GET_PIN(pin), value);
1926
}
2027

21-
static void gpio_set_mode(pin_t pin, uint32_t mode, uint32_t strength, uint32_t otype, uint32_t pull)
28+
static void gpio_set_mode(pin_t pin, uint32_t mode, uint32_t otype, uint32_t pull)
2229
{
23-
gpio_init_type config = {0};
24-
config.gpio_pins = GET_PIN(pin);
25-
config.gpio_out_type = otype;
26-
config.gpio_pull = pull;
27-
config.gpio_mode = mode;
28-
config.gpio_drive_strength = strength;
29-
gpio_init(GET_PORT(pin), &config);
30+
// set direction
31+
gpio_pin_config_t config = {
32+
.pinDirection = mode,
33+
.outputLogic = 0U
34+
};
35+
uint32_t p_port = GET_PORT(pin);
36+
uint32_t p_pin = GET_PIN(pin);
37+
GPIO_PinInit(GPIO, p_port, p_pin, &config);
38+
39+
IOCON->PIO[p_port][p_pin] = ((IOCON->PIO[p_port][p_pin] & (~(IOCON_PIO_FUNC_MASK |
40+
IOCON_PIO_MODE_MASK |
41+
IOCON_PIO_DIGIMODE_MASK |
42+
IOCON_PIO_OD_MASK)))
43+
| IOCON_PIO_FUNC(IOCON_FUNC0)
44+
| IOCON_PIO_MODE(pull)
45+
| IOCON_PIO_DIGIMODE(1)
46+
| IOCON_PIO_OD(otype));
3047
}
3148

3249
void gpio_set_output_pushpull(pin_t pin)
3350
{
34-
gpio_set_mode(pin, GPIO_MODE_OUTPUT, GPIO_DRIVE_STRENGTH_STRONGER, GPIO_OUTPUT_PUSH_PULL, GPIO_PULL_NONE);
51+
gpio_set_mode(pin, kGPIO_DigitalOutput, OUTPUT_PUSHPULL, INPUT_FLOATING);
3552
}
3653

3754
void gpio_set_output_opendrain(pin_t pin)
3855
{
39-
gpio_set_mode(pin, GPIO_MODE_OUTPUT, GPIO_DRIVE_STRENGTH_STRONGER, GPIO_OUTPUT_OPEN_DRAIN, GPIO_PULL_NONE);
56+
gpio_set_mode(pin, kGPIO_DigitalOutput, OUTPUT_OPENDRAIN, INPUT_FLOATING);
4057
}
4158

4259
void gpio_set_input_floating(pin_t pin)
4360
{
44-
gpio_set_mode(pin, GPIO_MODE_INPUT, GPIO_DRIVE_STRENGTH_STRONGER, GPIO_OUTPUT_PUSH_PULL, GPIO_PULL_NONE);
61+
gpio_set_mode(pin, kGPIO_DigitalInput, OUTPUT_PUSHPULL, INPUT_FLOATING);
4562
}
4663

4764
void gpio_set_input_pullup(pin_t pin)
4865
{
49-
gpio_set_mode(pin, GPIO_MODE_INPUT, GPIO_DRIVE_STRENGTH_STRONGER, GPIO_OUTPUT_PUSH_PULL, GPIO_PULL_UP);
66+
gpio_set_mode(pin, kGPIO_DigitalInput, OUTPUT_PUSHPULL, INPUT_PULL_UP);
5067
}
5168

5269
void gpio_set_input_pulldown(pin_t pin)
5370
{
54-
gpio_set_mode(pin, GPIO_MODE_INPUT, GPIO_DRIVE_STRENGTH_STRONGER, GPIO_OUTPUT_PUSH_PULL, GPIO_PULL_DOWN);
71+
gpio_set_mode(pin, kGPIO_DigitalInput, OUTPUT_PUSHPULL, INPUT_PULL_DOWN);
5572
}

main/porting/wired/lpc55/lpc55.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ extern void system_clock_init(void);
1313

1414
void system_init(void)
1515
{
16-
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
17-
1816
system_clock_init();
1917

2018
#ifndef RTOS_ENABLE
@@ -41,30 +39,20 @@ static void fault_handler(void)
4139

4240
uint32_t magic_read(void)
4341
{
44-
crm_periph_clock_enable(CRM_PWC_PERIPH_CLOCK, TRUE);
45-
pwc_battery_powered_domain_access(TRUE);
46-
return ertc_bpr_data_read(ERTC_DT1);
42+
return 0;
4743
}
4844

4945
void magic_write(uint32_t magic)
5046
{
51-
crm_periph_clock_enable(CRM_PWC_PERIPH_CLOCK, TRUE);
52-
pwc_battery_powered_domain_access(TRUE);
53-
ertc_bpr_data_write(ERTC_DT1, magic);
5447
}
5548

5649
uint32_t reset_read(void)
5750
{
58-
crm_periph_clock_enable(CRM_PWC_PERIPH_CLOCK, TRUE);
59-
pwc_battery_powered_domain_access(TRUE);
60-
return ertc_bpr_data_read(ERTC_DT2);
51+
return 0;
6152
}
6253

6354
void reset_write(uint32_t reset)
6455
{
65-
crm_periph_clock_enable(CRM_PWC_PERIPH_CLOCK, TRUE);
66-
pwc_battery_powered_domain_access(TRUE);
67-
ertc_bpr_data_write(ERTC_DT2, reset);
6856
}
6957

7058
void NMI_Handler(void)

0 commit comments

Comments
 (0)