Skip to content

Commit d4c04e8

Browse files
committed
Merge pull request #230 from sg-/master
Create a platform specific file to override WEAK Handlers and pre-main hook mbed_sdk_init I thought about a better solution for this problem, but I couldn't find one, so this is fine. Just one comment: I wouldn't name that file 'platform_init.c'. First, it might contain other code than just initialization code (for example, mbed_die is also declared as a weak function and we'll need to override it for NRF51822). Second, it doesn't realy send the "this file is special and should be treated as such" message. I'd call it something like 'mbed_overrides.c'. But I'll make this change later. Thanks for the pull request!
2 parents 11c042f + ecad62a commit d4c04e8

File tree

8 files changed

+121
-29
lines changed

8 files changed

+121
-29
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/gpio_irq_api.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,3 @@ void gpio_irq_disable(gpio_irq_t *obj) {
173173
NVIC_DisableIRQ(PORTB_IRQn);
174174
}
175175
}
176-
177-
// Change the NMI pin to an input. This allows NMI pin to
178-
// be used as a low power mode wakeup. The application will
179-
// need to change the pin back to NMI_b or wakeup only occurs once!
180-
void NMI_Handler(void)
181-
{
182-
gpio_t gpio;
183-
gpio_init_in(&gpio, PTA4);
184-
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
// called before main - implement here if board needs it ortherwise, let
19+
// the application override this if necessary
20+
//void mbed_sdk_init()
21+
//{
22+
//
23+
//}
24+
25+
// Change the NMI pin to an input. This allows NMI pin to
26+
// be used as a low power mode wakeup. The application will
27+
// need to change the pin back to NMI_b or wakeup only occurs once!
28+
void NMI_Handler(void)
29+
{
30+
gpio_t gpio;
31+
gpio_init_in(&gpio, PTB5);
32+
}

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/gpio_irq_api.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,3 @@ void gpio_irq_disable(gpio_irq_t *obj) {
163163
NVIC_DisableIRQ(PORTD_IRQn);
164164
}
165165
}
166-
167-
// Change the NMI pin to an input. This allows NMI pin to
168-
// be used as a low power mode wakeup. The application will
169-
// need to change the pin back to NMI_b or wakeup only occurs once!
170-
void NMI_Handler(void)
171-
{
172-
gpio_t gpio;
173-
gpio_init_in(&gpio, PTA4);
174-
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
// called before main - implement here if board needs it ortherwise, let
19+
// the application override this if necessary
20+
//void mbed_sdk_init()
21+
//{
22+
//
23+
//}
24+
25+
// Change the NMI pin to an input. This allows NMI pin to
26+
// be used as a low power mode wakeup. The application will
27+
// need to change the pin back to NMI_b or wakeup only occurs once!
28+
void NMI_Handler(void)
29+
{
30+
gpio_t gpio;
31+
gpio_init_in(&gpio, PTA4);
32+
}

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/gpio_irq_api.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,3 @@ void gpio_irq_disable(gpio_irq_t *obj) {
183183
NVIC_DisableIRQ(PORTC_PORTD_IRQn);
184184
}
185185
}
186-
187-
// Change the NMI pin to an input. This allows NMI pin to
188-
// be used as a low power mode wakeup. The application will
189-
// need to change the pin back to NMI_b or wakeup only occurs once!
190-
void NMI_Handler(void)
191-
{
192-
gpio_t gpio;
193-
gpio_init_in(&gpio, PTA4);
194-
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
// called before main - implement here if board needs it ortherwise, let
19+
// the application override this if necessary
20+
//void mbed_sdk_init()
21+
//{
22+
//
23+
//}
24+
25+
// Change the NMI pin to an input. This allows NMI pin to
26+
// be used as a low power mode wakeup. The application will
27+
// need to change the pin back to NMI_b or wakeup only occurs once!
28+
void NMI_Handler(void)
29+
{
30+
gpio_t gpio;
31+
gpio_init_in(&gpio, PTA4);
32+
}

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/platform_init.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
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+
*/
216
#include "gpio_api.h"
317
#include "wait_api.h"
418

5-
// called before main
19+
// called before main
620
void mbed_sdk_init()
721
{
822
gpio_t modemEn, modemRst, modemPwrOn, modemLvlOe, modemILvlOe, modemUsbDet;

workspace_tools/build_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F
189189
if o.endswith('retarget.o'):
190190
retargeting = o
191191
objects.remove(retargeting)
192+
# We need to have a file that overrides weak delcatations on a per board basis and the
193+
# lesser evil is to pull in this file if it extist rather than add board specific
194+
# startup code in the /targets/cmsis directory
195+
platform_initialize = None
196+
for p in objects:
197+
if p.endswith('platform_init.o'):
198+
platform_initialize = p
199+
objects.remove(platform_initialize)
192200
toolchain.build_library(objects, BUILD_TOOLCHAIN, "mbed")
193201
toolchain.copy_files(retargeting, BUILD_TOOLCHAIN)
202+
toolchain.copy_files(platform_initialize, BUILD_TOOLCHAIN)
194203

0 commit comments

Comments
 (0)