Skip to content

Commit 0e532ba

Browse files
authored
Merge pull request #9910 from NXPmicro/Add_LPC55S69_TFM_mbed_master
Add support for LPC55S59
2 parents c609d63 + 862961c commit 0e532ba

File tree

167 files changed

+104204
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+104204
-292
lines changed

TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void test_isr_stack_in_range(void)
204204
{
205205
// MSP stack should be very near end (test using within 128 bytes)
206206
uint32_t msp = __get_MSP();
207-
bool result = inrange(msp, mbed_stack_isr_start + mbed_stack_isr_size - 128, 128);
207+
bool result = inrange(msp, mbed_stack_isr_start + mbed_stack_isr_size - 0x400, 0x400);
208208

209209
TEST_ASSERT_TRUE_MESSAGE(result, "Interrupt stack in wrong location");
210210
}

features/storage/kvstore/conf/global/mbed_lib.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
},
2929
"UBLOX_EVK_ODIN_W2": {
3030
"storage_type": "TDB_INTERNAL"
31+
},
32+
"LPC55S69_S": {
33+
"storage_type": "TDB_INTERNAL"
3134
}
3235
}
3336
}

features/storage/kvstore/conf/tdb_internal/mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"CY8CKIT_062_WIFI_BT_M0_PSA": {
1919
"internal_size": "0x8000",
2020
"internal_base_address": "0x10078000"
21+
},
22+
"LPC55S69_S": {
23+
"internal_size": "0x10000",
24+
"internal_base_address": "0x00030000"
2125
}
2226
}
2327
}

platform/mbed_wait_api_no_rtos.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ void wait_us(int us)
5151
// Cortex-M0 and Cortex-M1 take 6 cycles per iteration - SUBS = 1, 2xNOP = 2, BCS = 3
5252
#define LOOP_SCALER 6000
5353
#elif (__CORTEX_M == 0 && defined __CM0PLUS_REV) || __CORTEX_M == 3 || __CORTEX_M == 4 || \
54-
__CORTEX_M == 23 || __CORTEX_M == 33
55-
// Cortex-M0+, M3, M4, M23 and M33 take 5 cycles per iteration - SUBS = 1, 2xNOP = 2, BCS = 2
56-
// TODO - check M33
54+
__CORTEX_M == 23
55+
// Cortex-M0+, M3, M4 and M23 take 5 cycles per iteration - SUBS = 1, 2xNOP = 2, BCS = 2
5756
#define LOOP_SCALER 5000
57+
#elif __CORTEX_M == 33
58+
// Cortex-M33 can dual issue for 3 cycles per iteration (SUB,NOP) = 1, (NOP,BCS) = 2
59+
#define LOOP_SCALER 3000
5860
#elif __CORTEX_M == 7
5961
// Cortex-M7 manages to dual-issue for 2 cycles per iteration (SUB,NOP) = 1, (NOP,BCS) = 1
6062
// (The NOPs were added to stabilise this - with just the SUB and BCS, it seems that the

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/analogin_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "mbed_assert.h"
1717
#include "analogin_api.h"
1818

19-
#if DEVICE_ANALOGIN
19+
#if DEVICE_ANALOGIN && !defined(NXP_LPADC)
2020

2121
#include "cmsis.h"
2222
#include "pinmap.h"

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/gpio_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void gpio_write(gpio_t *obj, int value)
6262
uint32_t pin_number = obj->pin & 0x1F;
6363
uint8_t port_number = obj->pin / 32;
6464

65-
GPIO_WritePinOutput(GPIO, port_number, pin_number, value);
65+
GPIO_PinWrite(GPIO, port_number, pin_number, value);
6666
}
6767

6868
int gpio_read(gpio_t *obj)
@@ -71,5 +71,5 @@ int gpio_read(gpio_t *obj)
7171
uint32_t pin_number = obj->pin & 0x1F;
7272
uint8_t port_number = obj->pin / 32;
7373

74-
return (int)GPIO_ReadPinInput(GPIO, port_number, pin_number);
74+
return (int)GPIO_PinRead(GPIO, port_number, pin_number);
7575
}

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/i2c_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
6969
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM7);
7070
RESET_PeripheralReset(kFC7_RST_SHIFT_RSTn);
7171
break;
72-
#if (FSL_FEATURE_SOC_FLEXCOMM_COUNT > 8U)
72+
#if (FSL_FEATURE_SOC_I2C_COUNT > 8U)
7373
case 8:
7474
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM8);
7575
RESET_PeripheralReset(kFC8_RST_SHIFT_RSTn);
7676
break;
7777
#endif
78-
#if (FSL_FEATURE_SOC_FLEXCOMM_COUNT > 9U)
78+
#if (FSL_FEATURE_SOC_I2C_COUNT > 9U)
7979
case 9:
8080
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM9);
8181
RESET_PeripheralReset(kFC9_RST_SHIFT_RSTn);
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2013 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "mbed_assert.h"
17+
#include "analogin_api.h"
18+
19+
#if DEVICE_ANALOGIN && defined(NXP_LPADC)
20+
21+
#include "cmsis.h"
22+
#include "pinmap.h"
23+
#include "gpio_api.h"
24+
#include "PeripheralNames.h"
25+
#include "fsl_lpadc.h"
26+
#include "fsl_power.h"
27+
#include "PeripheralPins.h"
28+
29+
/* Array of ADC peripheral base address. */
30+
static ADC_Type *const adc_addrs[] = ADC_BASE_PTRS;
31+
extern void ADC_ClockPower_Configuration(void);
32+
33+
#define LPADC_USER_CMDID 1U /* CMD1 */
34+
35+
void analogin_init(analogin_t *obj, PinName pin)
36+
{
37+
gpio_t gpio;
38+
39+
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
40+
MBED_ASSERT(obj->adc != (ADCName)NC);
41+
42+
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
43+
lpadc_config_t adc_config;
44+
uint32_t reg;
45+
uint32_t pin_number = pin & 0x1F;
46+
uint8_t port_number = pin / 32;
47+
48+
ADC_ClockPower_Configuration();
49+
50+
LPADC_GetDefaultConfig(&adc_config);
51+
adc_config.enableAnalogPreliminary = true;
52+
#if defined(LPADC_VREF_SOURCE)
53+
adc_config.referenceVoltageSource = LPADC_VREF_SOURCE;
54+
#endif
55+
#if defined(FSL_FEATURE_LPADC_HAS_CTRL_CAL_AVGS) && FSL_FEATURE_LPADC_HAS_CTRL_CAL_AVGS
56+
adc_config.conversionAverageMode = kLPADC_ConversionAverage128;
57+
#endif /* FSL_FEATURE_LPADC_HAS_CTRL_CAL_AVGS */
58+
LPADC_Init(adc_addrs[instance], &adc_config);
59+
60+
#if defined(FSL_FEATURE_LPADC_HAS_CTRL_CALOFS) && FSL_FEATURE_LPADC_HAS_CTRL_CALOFS
61+
#if defined(FSL_FEATURE_LPADC_HAS_OFSTRIM) && FSL_FEATURE_LPADC_HAS_OFSTRIM
62+
/* Request offset calibration. */
63+
if (true == LPADC_DO_OFFSET_CALIBRATION) {
64+
LPADC_DoOffsetCalibration(adc_addrs[instance]);
65+
} else {
66+
LPADC_SetOffsetValue(adc_addrs[instance], LPADC_OFFSET_VALUE_A, LPADC_OFFSET_VALUE_B);
67+
}
68+
#endif /* FSL_FEATURE_LPADC_HAS_OFSTRIM */
69+
/* Request gain calibration. */
70+
LPADC_DoAutoCalibration(adc_addrs[instance]);
71+
#endif /* FSL_FEATURE_LPADC_HAS_CTRL_CALOFS */
72+
73+
#if (defined(FSL_FEATURE_LPADC_HAS_CFG_CALOFS) && FSL_FEATURE_LPADC_HAS_CFG_CALOFS)
74+
/* Do auto calibration. */
75+
LPADC_DoAutoCalibration(adc_addrs[instance]);
76+
#endif /* FSL_FEATURE_LPADC_HAS_CFG_CALOFS */
77+
78+
pinmap_pinout(pin, PinMap_ADC);
79+
80+
reg = IOCON->PIO[port_number][pin_number];
81+
/* Clear the DIGIMODE bit */
82+
reg &= ~IOCON_PIO_DIGIMODE_MASK;
83+
/* For pins PIO0_9, PIO0_11, PIO0_12, PIO0_15, PIO0_18, PIO0_31, PIO1_0 and
84+
PIO1_9, leave ASW bit at '0' in the related IOCON register. */
85+
if (((port_number == 0) && ((pin_number == 9) || (pin_number == 11) || (pin_number == 12) ||
86+
(pin_number == 15) || (pin_number == 18) || (pin_number == 31))) ||
87+
((port_number == 1) && ((pin_number == 0) || (pin_number == 9)))) {
88+
/* Disable Analog Switch Input control */
89+
reg &= ~IOCON_PIO_ASW_MASK;
90+
} else {
91+
/* Enable Analog Switch Input control */
92+
reg |= IOCON_PIO_ASW_MASK;
93+
}
94+
IOCON->PIO[port_number][pin_number] = reg;
95+
96+
/* Need to ensure the pin is in input mode */
97+
gpio_init(&gpio, pin);
98+
gpio_dir(&gpio, PIN_INPUT);
99+
}
100+
101+
uint16_t analogin_read_u16(analogin_t *obj)
102+
{
103+
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
104+
uint32_t channel = obj->adc & 0xF;
105+
lpadc_conv_trigger_config_t mLpadcTriggerConfigStruct;
106+
lpadc_conv_command_config_t mLpadcCommandConfigStruct;
107+
lpadc_conv_result_t mLpadcResultConfigStruct;
108+
109+
memset(&mLpadcTriggerConfigStruct, 0, sizeof(mLpadcTriggerConfigStruct));
110+
memset(&mLpadcCommandConfigStruct, 0, sizeof(mLpadcCommandConfigStruct));
111+
memset(&mLpadcResultConfigStruct, 0, sizeof(mLpadcResultConfigStruct));
112+
113+
/* Set conversion CMD configuration. */
114+
LPADC_GetDefaultConvCommandConfig(&mLpadcCommandConfigStruct);
115+
mLpadcCommandConfigStruct.channelNumber = channel;
116+
LPADC_SetConvCommandConfig(adc_addrs[instance], LPADC_USER_CMDID, &mLpadcCommandConfigStruct);
117+
118+
/* Set trigger configuration. */
119+
LPADC_GetDefaultConvTriggerConfig(&mLpadcTriggerConfigStruct);
120+
mLpadcTriggerConfigStruct.targetCommandId = LPADC_USER_CMDID;
121+
mLpadcTriggerConfigStruct.enableHardwareTrigger = false;
122+
LPADC_SetConvTriggerConfig(adc_addrs[instance], 0U, &mLpadcTriggerConfigStruct); /* Configurate the trigger0. */
123+
124+
LPADC_DoSoftwareTrigger(adc_addrs[instance], 1U); /* 1U is trigger0 mask. */
125+
126+
#if (defined(FSL_FEATURE_LPADC_FIFO_COUNT) && (FSL_FEATURE_LPADC_FIFO_COUNT == 2U))
127+
while (!LPADC_GetConvResult(adc_addrs[instance], &mLpadcResultConfigStruct, 0U)) {
128+
}
129+
#else
130+
while (!LPADC_GetConvResult(adc_addrs[instance], &mLpadcResultConfigStruct)) {
131+
}
132+
#endif /* FSL_FEATURE_LPADC_FIFO_COUNT */
133+
134+
return ((mLpadcResultConfigStruct.convValue) >> 3U);
135+
}
136+
137+
float analogin_read(analogin_t *obj)
138+
{
139+
uint16_t value = analogin_read_u16(obj);
140+
return (float)value * (1.0f / (float)0xFFFF);
141+
}
142+
143+
const PinMap *analogin_pinmap()
144+
{
145+
return PinMap_ADC;
146+
}
147+
148+
#endif

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct spi_s {
5959
uint8_t bits;
6060
};
6161

62-
#if DEVICE_FLASH
62+
#if DEVICE_FLASH && !defined(TARGET_FLASH_CMSIS_ALGO)
6363
struct flash_s {
6464
uint8_t dummy;
6565
};

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/pinmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void pin_function(PinName pin, int function)
3333
IOCON->PIO[port_number][pin_number] |= IOCON_PIO_DIGIMODE_MASK;
3434

3535
reg = IOCON->PIO[port_number][pin_number];
36-
reg = (reg & ~0x7) | (function & 0x7);
36+
reg = (reg & ~0x7) | (function & IOCON_PIO_FUNC_MASK);
3737
IOCON->PIO[port_number][pin_number] = reg;
3838
}
3939

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/port_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ void port_dir(port_t *obj, PinDirection dir)
7171

7272
void port_write(port_t *obj, int value)
7373
{
74-
GPIO_WriteMPort(GPIO, obj->port, value);
74+
GPIO_PortMaskedWrite(GPIO, obj->port, value);
7575
}
7676

7777
int port_read(port_t *obj)
7878
{
79-
return (int)(GPIO_ReadMPort(GPIO, obj->port));
79+
return (int)(GPIO_PortMaskedRead(GPIO, obj->port));
8080
}
8181

8282
#endif

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/serial_api.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
7979
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM7);
8080
RESET_PeripheralReset(kFC7_RST_SHIFT_RSTn);
8181
break;
82-
#if (FSL_FEATURE_SOC_FLEXCOMM_COUNT > 8U)
82+
#if (FSL_FEATURE_SOC_USART_COUNT > 8U)
8383
case 8:
8484
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM8);
8585
RESET_PeripheralReset(kFC8_RST_SHIFT_RSTn);
8686
break;
8787
#endif
88-
#if (FSL_FEATURE_SOC_FLEXCOMM_COUNT > 9U)
88+
#if (FSL_FEATURE_SOC_USART_COUNT > 9U)
8989
case 9:
9090
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM9);
9191
RESET_PeripheralReset(kFC9_RST_SHIFT_RSTn);
@@ -225,15 +225,15 @@ void uart7_irq()
225225
uart_irq((status_flags & kUSART_TxFifoEmptyFlag), (status_flags & kUSART_RxFifoNotEmptyFlag), 7);
226226
}
227227

228-
#if (FSL_FEATURE_SOC_FLEXCOMM_COUNT > 8U)
228+
#if (FSL_FEATURE_SOC_USART_COUNT > 8U)
229229
void uart8_irq()
230230
{
231231
uint32_t status_flags = USART8->FIFOSTAT;
232232
uart_irq((status_flags & kUSART_TxFifoEmptyFlag), (status_flags & kUSART_RxFifoNotEmptyFlag), 8);
233233
}
234234
#endif
235235

236-
#if (FSL_FEATURE_SOC_FLEXCOMM_COUNT > 9U)
236+
#if (FSL_FEATURE_SOC_USART_COUNT > 9U)
237237
void uart9_irq()
238238
{
239239
uint32_t status_flags = USART9->FIFOSTAT;
@@ -277,12 +277,12 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
277277
case 7:
278278
vector = (uint32_t)&uart7_irq;
279279
break;
280-
#if (FSL_FEATURE_SOC_FLEXCOMM_COUNT > 8U)
280+
#if (FSL_FEATURE_SOC_USART_COUNT > 8U)
281281
case 8:
282282
vector = (uint32_t)&uart8_irq;
283283
break;
284284
#endif
285-
#if (FSL_FEATURE_SOC_FLEXCOMM_COUNT > 9U)
285+
#if (FSL_FEATURE_SOC_USART_COUNT > 9U)
286286
case 9:
287287
vector = (uint32_t)&uart9_irq;
288288
break;

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC/sleep.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ void hal_sleep(void)
2727
void hal_deepsleep(void)
2828
{
2929
LPC_CLOCK_INTERNAL_IRC;
30+
3031
/* Enter Deep Sleep mode */
32+
#if (defined(FSL_FEATURE_POWERLIB_NIOBE4_EXTEND ) && FSL_FEATURE_POWERLIB_NIOBE4_EXTEND )
33+
POWER_EnterDeepSleep(APP_EXCLUDE_FROM_DEEPSLEEP, 0x0, WAKEUP_GPIO_INT0_0, 0x0);
34+
#else
3135
POWER_EnterDeepSleep(APP_EXCLUDE_FROM_DEEPSLEEP);
36+
#endif
37+
3238
LPC_CLOCK_RUN;
3339
}

0 commit comments

Comments
 (0)