Skip to content

Commit 4a85f87

Browse files
committed
NXP: Add support for MIMXRT1050_EVK
Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent 4d81ead commit 4a85f87

File tree

176 files changed

+108058
-1
lines changed

Some content is hidden

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

176 files changed

+108058
-1
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
17+
#ifndef MBED_PERIPHERALPINS_H
18+
#define MBED_PERIPHERALPINS_H
19+
20+
#include "pinmap.h"
21+
#include "PeripheralNames.h"
22+
23+
/************RTC***************/
24+
extern const PinMap PinMap_RTC[];
25+
26+
/************ADC***************/
27+
extern const PinMap PinMap_ADC[];
28+
29+
/************DAC***************/
30+
extern const PinMap PinMap_DAC[];
31+
32+
/************I2C***************/
33+
extern const PinMap PinMap_I2C_SDA[];
34+
extern const PinMap PinMap_I2C_SCL[];
35+
36+
/************UART***************/
37+
extern const PinMap PinMap_UART_TX[];
38+
extern const PinMap PinMap_UART_RX[];
39+
extern const PinMap PinMap_UART_CTS[];
40+
extern const PinMap PinMap_UART_RTS[];
41+
/************SPI***************/
42+
extern const PinMap PinMap_SPI_SCLK[];
43+
extern const PinMap PinMap_SPI_MOSI[];
44+
extern const PinMap PinMap_SPI_MISO[];
45+
extern const PinMap PinMap_SPI_SSEL[];
46+
47+
/************PWM***************/
48+
extern const PinMap PinMap_PWM[];
49+
50+
#endif
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
#ifndef MBED_PORTNAMES_H
17+
#define MBED_PORTNAMES_H
18+
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
23+
typedef enum {
24+
Gpio1 = 1,
25+
Gpio2 = 2,
26+
Gpio3 = 3,
27+
Gpio4 = 4,
28+
Gpio5 = 5
29+
} PortName;
30+
31+
#ifdef __cplusplus
32+
}
33+
#endif
34+
35+
#endif
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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
20+
21+
#include "cmsis.h"
22+
#include "pinmap.h"
23+
#include "PeripheralNames.h"
24+
#include "fsl_adc.h"
25+
#include "PeripheralPins.h"
26+
27+
/* Array of ADC peripheral base address. */
28+
static ADC_Type *const adc_addrs[] = ADC_BASE_PTRS;
29+
30+
void analogin_init(analogin_t *obj, PinName pin)
31+
{
32+
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
33+
MBED_ASSERT(obj->adc != (ADCName)NC);
34+
35+
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
36+
adc_config_t adc_config;
37+
38+
ADC_GetDefaultConfig(&adc_config);
39+
ADC_Init(adc_addrs[instance], &adc_config);
40+
#if !(defined(FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE) && FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE)
41+
ADC_EnableHardwareTrigger(adc_addrs[instance], false);
42+
#endif
43+
ADC_DoAutoCalibration(adc_addrs[instance]);
44+
}
45+
46+
uint16_t analogin_read_u16(analogin_t *obj)
47+
{
48+
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
49+
adc_channel_config_t adc_channel_config;
50+
51+
adc_channel_config.channelNumber = obj->adc & 0xF;
52+
adc_channel_config.enableInterruptOnConversionCompleted = false;
53+
54+
/*
55+
When in software trigger mode, each conversion would be launched once calling the "ADC_ChannelConfigure()"
56+
function, which works like writing a conversion command and executing it. For another channel's conversion,
57+
just to change the "channelNumber" field in channel configuration structure, and call the function
58+
"ADC_ChannelConfigure()"" again.
59+
Also, the "enableInterruptOnConversionCompleted" inside the channel configuration structure is a parameter
60+
for the conversion command. It takes affect just for the current conversion. If the interrupt is still required
61+
for the following conversion, it is necessary to assert the "enableInterruptOnConversionCompleted" every
62+
time for each command.
63+
*/
64+
ADC_SetChannelConfig(adc_addrs[instance], 0, &adc_channel_config);
65+
while (0U == ADC_GetChannelStatusFlags(adc_addrs[instance], 0))
66+
{
67+
}
68+
return ADC_GetChannelConversionValue(adc_addrs[instance], 0);
69+
}
70+
71+
float analogin_read(analogin_t *obj)
72+
{
73+
uint16_t value = analogin_read_u16(obj);
74+
return (float)value * (1.0f / (float)0xFFFF);
75+
}
76+
77+
#endif
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 "gpio_api.h"
18+
#include "pinmap.h"
19+
#include "fsl_gpio.h"
20+
21+
static GPIO_Type * const gpio_addrs[] = GPIO_BASE_PTRS;
22+
23+
uint32_t gpio_set(PinName pin)
24+
{
25+
MBED_ASSERT(pin != (PinName)NC);
26+
uint32_t pin_num = pin & 0xFF;
27+
28+
pin_function(pin, GPIO_MUX_PORT);
29+
return 1 << pin_num;
30+
}
31+
32+
void gpio_init(gpio_t *obj, PinName pin)
33+
{
34+
clock_ip_name_t gpio_clocks[] = GPIO_CLOCKS;
35+
36+
CLOCK_EnableClock(gpio_clocks[pin >> GPIO_PORT_SHIFT]);
37+
38+
obj->pin = pin;
39+
if (pin == (PinName)NC)
40+
return;
41+
42+
pin_function(pin, GPIO_MUX_PORT);
43+
}
44+
45+
void gpio_mode(gpio_t *obj, PinMode mode)
46+
{
47+
pin_mode(obj->pin, mode);
48+
}
49+
50+
void gpio_dir(gpio_t *obj, PinDirection direction)
51+
{
52+
MBED_ASSERT(obj->pin != (PinName)NC);
53+
uint32_t port = (obj->pin >> GPIO_PORT_SHIFT) & 0xF;
54+
uint32_t gpio_pin_num = obj->pin & 0xFF;
55+
GPIO_Type *base = gpio_addrs[port];
56+
57+
switch (direction) {
58+
case PIN_INPUT:
59+
base->GDIR &= ~(1U << gpio_pin_num);
60+
break;
61+
case PIN_OUTPUT:
62+
base->GDIR |= (1U << gpio_pin_num);
63+
break;
64+
}
65+
}
66+
67+
void gpio_write(gpio_t *obj, int value)
68+
{
69+
MBED_ASSERT(obj->pin != (PinName)NC);
70+
uint32_t port = (obj->pin >> GPIO_PORT_SHIFT) & 0xF;
71+
uint32_t gpio_pin_num = obj->pin & 0xFF;
72+
73+
GPIO_WritePinOutput(gpio_addrs[port], gpio_pin_num, value);
74+
}
75+
76+
int gpio_read(gpio_t *obj)
77+
{
78+
MBED_ASSERT(obj->pin != (PinName)NC);
79+
uint32_t port = (obj->pin >> GPIO_PORT_SHIFT) & 0xF;
80+
uint32_t gpio_pin_num = obj->pin & 0xFF;
81+
82+
return (int)GPIO_ReadPinInput(gpio_addrs[port], gpio_pin_num);
83+
}

0 commit comments

Comments
 (0)