Skip to content

Commit d41b0ee

Browse files
committed
Merge remote-tracking branch 'upstream/master' into dev_target_k64f.
K64F gpio changed according to the latest mbed master. Conflicts: libraries/rtos/rtx/RTX_CM_lib.h workspace_tools/export/uvision4.py
2 parents 9c0a982 + e2574eb commit d41b0ee

File tree

152 files changed

+8254
-592
lines changed

Some content is hidden

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

152 files changed

+8254
-592
lines changed

libraries/mbed/api/DigitalIn.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,19 @@ class DigitalIn {
4949
/** Create a DigitalIn connected to the specified pin
5050
*
5151
* @param pin DigitalIn pin to connect to
52-
* @param name (optional) A string to identify the object
5352
*/
5453
DigitalIn(PinName pin) {
55-
gpio_init(&gpio, pin, PIN_INPUT);
54+
gpio_init_in(&gpio, pin);
5655
}
5756

57+
/** Create a DigitalIn connected to the specified pin
58+
*
59+
* @param pin DigitalIn pin to connect to
60+
* @param mode the initial mode of the pin
61+
*/
62+
DigitalIn(PinName pin, PinMode mode) {
63+
gpio_init_in_ex(&gpio, pin, mode);
64+
}
5865
/** Read the input, represented as 0 or 1 (int)
5966
*
6067
* @returns

libraries/mbed/api/DigitalInOut.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@ class DigitalInOut {
3232
* @param pin DigitalInOut pin to connect to
3333
*/
3434
DigitalInOut(PinName pin) {
35-
gpio_init(&gpio, pin, PIN_INPUT);
35+
gpio_init_in(&gpio, pin);
36+
}
37+
38+
/** Create a DigitalInOut connected to the specified pin
39+
*
40+
* @param pin DigitalInOut pin to connect to
41+
* @param direction the initial direction of the pin
42+
* @param mode the initial mode of the pin
43+
* @param value the initial value of the pin if is an output
44+
*/
45+
DigitalInOut(PinName pin, PinDirection direction, PinMode mode, int value) {
46+
gpio_init_inout(&gpio, pin, direction, mode, value);
3647
}
3748

3849
/** Set the output, specified as 0 or 1 (int)

libraries/mbed/api/DigitalOut.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,16 @@ class DigitalOut {
4646
* @param pin DigitalOut pin to connect to
4747
*/
4848
DigitalOut(PinName pin) {
49-
gpio_init(&gpio, pin, PIN_OUTPUT);
49+
gpio_init_out(&gpio, pin);
50+
}
51+
52+
/** Create a DigitalOut connected to the specified pin
53+
*
54+
* @param pin DigitalOut pin to connect to
55+
* @param value the initial pin value
56+
*/
57+
DigitalOut(PinName pin, int value){
58+
gpio_init_out_ex(&gpio, pin, value);
5059
}
5160

5261
/** Set the output, specified as 0 or 1 (int)

libraries/mbed/common/InterruptIn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace mbed {
2121

2222
InterruptIn::InterruptIn(PinName pin) {
2323
gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this);
24-
gpio_init(&gpio, pin, PIN_INPUT);
24+
gpio_init_in(&gpio, pin);
2525
}
2626

2727
InterruptIn::~InterruptIn() {

libraries/mbed/common/board.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
WEAK void mbed_die(void);
2121
WEAK void mbed_die(void) {
2222
__disable_irq(); // dont allow interrupts to disturb the flash pattern
23-
24-
#if (DEVICE_ERROR_RED == 1)
25-
gpio_t led_red; gpio_init(&led_red, LED_RED, PIN_OUTPUT);
2623

24+
#if (DEVICE_ERROR_RED == 1)
25+
gpio_t led_red; gpio_init_out(&led_red, LED_RED);
26+
2727
#elif (DEVICE_ERROR_PATTERN == 1)
28-
gpio_t led_1; gpio_init(&led_1, LED1, PIN_OUTPUT);
29-
gpio_t led_2; gpio_init(&led_2, LED2, PIN_OUTPUT);
30-
gpio_t led_3; gpio_init(&led_3, LED3, PIN_OUTPUT);
31-
gpio_t led_4; gpio_init(&led_4, LED4, PIN_OUTPUT);
28+
gpio_t led_1; gpio_init_out(&led_1, LED1);
29+
gpio_t led_2; gpio_init_out(&led_2, LED2);
30+
gpio_t led_3; gpio_init_out(&led_3, LED3);
31+
gpio_t led_4; gpio_init_out(&led_4, LED4);
3232
#endif
3333

3434
while (1) {

libraries/mbed/common/gpio.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 "gpio_api.h"
17+
18+
static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode)
19+
{
20+
gpio_init(gpio, pin);
21+
gpio_mode(gpio, mode);
22+
gpio_dir(gpio, PIN_INPUT);
23+
}
24+
25+
static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value)
26+
{
27+
gpio_init(gpio, pin);
28+
gpio_write(gpio, value);
29+
gpio_dir(gpio, PIN_OUTPUT);
30+
gpio_mode(gpio, mode);
31+
}
32+
33+
void gpio_init_in(gpio_t* gpio, PinName pin) {
34+
gpio_init_in_ex(gpio, pin, PullDefault);
35+
}
36+
37+
void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode) {
38+
_gpio_init_in(gpio, pin, mode);
39+
}
40+
41+
void gpio_init_out(gpio_t* gpio, PinName pin) {
42+
gpio_init_out_ex(gpio, pin, 0);
43+
}
44+
45+
void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) {
46+
_gpio_init_out(gpio, pin, PullNone, value);
47+
}
48+
49+
void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) {
50+
if (direction == PIN_INPUT) {
51+
_gpio_init_in(gpio, pin, mode);
52+
gpio_write(gpio, value); // we prepare the value in case it is switched later
53+
} else {
54+
_gpio_init_out(gpio, pin, mode, value);
55+
}
56+
}

libraries/mbed/hal/gpio_api.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,21 @@ extern "C" {
2929
uint32_t gpio_set(PinName pin);
3030

3131
/* GPIO object */
32-
void gpio_init (gpio_t *obj, PinName pin, PinDirection direction);
32+
void gpio_init(gpio_t *obj, PinName pin);
3333

3434
void gpio_mode (gpio_t *obj, PinMode mode);
3535
void gpio_dir (gpio_t *obj, PinDirection direction);
3636

3737
void gpio_write(gpio_t *obj, int value);
3838
int gpio_read (gpio_t *obj);
3939

40+
// the following set of functions are generic and are implemented in the common gpio.c file
41+
void gpio_init_in(gpio_t* gpio, PinName pin);
42+
void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode);
43+
void gpio_init_out(gpio_t* gpio, PinName pin);
44+
void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value);
45+
void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value);
46+
4047
#ifdef __cplusplus
4148
}
4249
#endif

libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401/LPC11U35.ld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ SECTIONS
4040
{
4141
KEEP(*(.isr_vector))
4242
*(.text.Reset_Handler)
43-
*(.text.SystemInit)
4443

4544
/* Only vectors and code running at reset are safe to be in first 512
4645
bytes since RAM can be mapped into this area for RAM based interrupt
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/* Linker script to configure memory regions. */
2+
MEMORY
3+
{
4+
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
5+
RAM (rwx) : ORIGIN = 0x100000C0, LENGTH = 0x1F40
6+
USB_RAM (rwx): ORIGIN = 0x20004000, LENGTH = 0x800
7+
}
8+
9+
/* Linker script to place sections and symbol values. Should be used together
10+
* with other linker script that defines memory regions FLASH and RAM.
11+
* It references following symbols, which must be defined in code:
12+
* Reset_Handler : Entry of reset handler
13+
*
14+
* It defines following symbols, which code can use without definition:
15+
* __exidx_start
16+
* __exidx_end
17+
* __etext
18+
* __data_start__
19+
* __preinit_array_start
20+
* __preinit_array_end
21+
* __init_array_start
22+
* __init_array_end
23+
* __fini_array_start
24+
* __fini_array_end
25+
* __data_end__
26+
* __bss_start__
27+
* __bss_end__
28+
* __end__
29+
* end
30+
* __HeapLimit
31+
* __StackLimit
32+
* __StackTop
33+
* __stack
34+
*/
35+
ENTRY(Reset_Handler)
36+
37+
SECTIONS
38+
{
39+
.text :
40+
{
41+
KEEP(*(.isr_vector))
42+
*(.text.Reset_Handler)
43+
44+
/* Only vectors and code running at reset are safe to be in first 512
45+
bytes since RAM can be mapped into this area for RAM based interrupt
46+
vectors. */
47+
. = 0x00000200;
48+
*(.text*)
49+
50+
KEEP(*(.init))
51+
KEEP(*(.fini))
52+
53+
/* .ctors */
54+
*crtbegin.o(.ctors)
55+
*crtbegin?.o(.ctors)
56+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
57+
*(SORT(.ctors.*))
58+
*(.ctors)
59+
60+
/* .dtors */
61+
*crtbegin.o(.dtors)
62+
*crtbegin?.o(.dtors)
63+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
64+
*(SORT(.dtors.*))
65+
*(.dtors)
66+
67+
*(.rodata*)
68+
69+
KEEP(*(.eh_frame*))
70+
} > FLASH
71+
72+
.ARM.extab :
73+
{
74+
*(.ARM.extab* .gnu.linkonce.armextab.*)
75+
} > FLASH
76+
77+
__exidx_start = .;
78+
.ARM.exidx :
79+
{
80+
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
81+
} > FLASH
82+
__exidx_end = .;
83+
84+
__etext = .;
85+
86+
.data : AT (__etext)
87+
{
88+
__data_start__ = .;
89+
*(vtable)
90+
*(.data*)
91+
92+
. = ALIGN(4);
93+
/* preinit data */
94+
PROVIDE (__preinit_array_start = .);
95+
KEEP(*(.preinit_array))
96+
PROVIDE (__preinit_array_end = .);
97+
98+
. = ALIGN(4);
99+
/* init data */
100+
PROVIDE (__init_array_start = .);
101+
KEEP(*(SORT(.init_array.*)))
102+
KEEP(*(.init_array))
103+
PROVIDE (__init_array_end = .);
104+
105+
106+
. = ALIGN(4);
107+
/* finit data */
108+
PROVIDE (__fini_array_start = .);
109+
KEEP(*(SORT(.fini_array.*)))
110+
KEEP(*(.fini_array))
111+
PROVIDE (__fini_array_end = .);
112+
113+
. = ALIGN(4);
114+
/* All data end */
115+
__data_end__ = .;
116+
117+
} > RAM
118+
119+
.bss :
120+
{
121+
__bss_start__ = .;
122+
*(.bss*)
123+
*(COMMON)
124+
__bss_end__ = .;
125+
} > RAM
126+
127+
.heap :
128+
{
129+
__end__ = .;
130+
end = __end__;
131+
*(.heap*)
132+
__HeapLimit = .;
133+
} > RAM
134+
135+
/* .stack_dummy section doesn't contains any symbols. It is only
136+
* used for linker to calculate size of stack sections, and assign
137+
* values to stack symbols later */
138+
.stack_dummy :
139+
{
140+
*(.stack)
141+
} > RAM
142+
143+
/* Set stack top to end of RAM, and stack limit move down by
144+
* size of stack_dummy section */
145+
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
146+
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
147+
PROVIDE(__stack = __StackTop);
148+
149+
/* Check if data + heap + stack exceeds RAM limit */
150+
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
151+
}

0 commit comments

Comments
 (0)