Skip to content

Commit 511e24e

Browse files
nRF51822 mbed SDK with working GPIO, RawSerial, and timer
1 parent ea7ee81 commit 511e24e

23 files changed

+9210
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; *************************************************************
2+
; *** Scatter-Loading Description File generated by uVision ***
3+
; *************************************************************
4+
5+
LR_IROM1 0x00000000 0x00040000 {
6+
ER_IROM1 0x00000000 0x00040000 {
7+
*.o (RESET, +First)
8+
*(InRoot$$Sections)
9+
.ANY (+RO)
10+
}
11+
RW_IRAM1 0x20000000 0x00004000 {
12+
.ANY (+RW +ZI)
13+
}
14+
}
15+
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
; Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
2+
;
3+
; The information contained herein is property of Nordic Semiconductor ASA.
4+
; Terms and conditions of usage are described in detail in NORDIC
5+
; SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
6+
;
7+
; Licensees are granted free, non-transferable use of the information. NO
8+
; WARRANTY of ANY KIND is provided. This heading must NOT be removed from
9+
; the file.
10+
11+
; NOTE: Template files (including this one) are application specific and therefore
12+
; expected to be copied into the application project folder prior to its use!
13+
14+
; Description message
15+
16+
Stack_Size EQU 2048
17+
AREA STACK, NOINIT, READWRITE, ALIGN=3
18+
Stack_Mem SPACE Stack_Size
19+
__initial_sp
20+
21+
Heap_Size EQU 2048
22+
23+
AREA HEAP, NOINIT, READWRITE, ALIGN=3
24+
__heap_base
25+
Heap_Mem SPACE Heap_Size
26+
__heap_limit
27+
28+
PRESERVE8
29+
THUMB
30+
31+
; Vector Table Mapped to Address 0 at Reset
32+
33+
AREA RESET, DATA, READONLY
34+
EXPORT __Vectors
35+
EXPORT __Vectors_End
36+
EXPORT __Vectors_Size
37+
38+
__Vectors DCD __initial_sp ; Top of Stack
39+
DCD Reset_Handler ; Reset Handler
40+
DCD NMI_Handler ; NMI Handler
41+
DCD HardFault_Handler ; Hard Fault Handler
42+
DCD 0 ; Reserved
43+
DCD 0 ; Reserved
44+
DCD 0 ; Reserved
45+
DCD 0 ; Reserved
46+
DCD 0 ; Reserved
47+
DCD 0 ; Reserved
48+
DCD 0 ; Reserved
49+
DCD SVC_Handler ; SVCall Handler
50+
DCD 0 ; Reserved
51+
DCD 0 ; Reserved
52+
DCD PendSV_Handler ; PendSV Handler
53+
DCD SysTick_Handler ; SysTick Handler
54+
55+
; External Interrupts
56+
DCD POWER_CLOCK_IRQHandler ;POWER_CLOCK
57+
DCD RADIO_IRQHandler ;RADIO
58+
DCD UART0_IRQHandler ;UART0
59+
DCD SPI0_TWI0_IRQHandler ;SPI0_TWI0
60+
DCD SPI1_TWI1_IRQHandler ;SPI1_TWI1
61+
DCD 0 ;Reserved
62+
DCD GPIOTE_IRQHandler ;GPIOTE
63+
DCD ADC_IRQHandler ;ADC
64+
DCD TIMER0_IRQHandler ;TIMER0
65+
DCD TIMER1_IRQHandler ;TIMER1
66+
DCD TIMER2_IRQHandler ;TIMER2
67+
DCD RTC0_IRQHandler ;RTC0
68+
DCD TEMP_IRQHandler ;TEMP
69+
DCD RNG_IRQHandler ;RNG
70+
DCD ECB_IRQHandler ;ECB
71+
DCD CCM_AAR_IRQHandler ;CCM_AAR
72+
DCD WDT_IRQHandler ;WDT
73+
DCD RTC1_IRQHandler ;RTC1
74+
DCD QDEC_IRQHandler ;QDEC
75+
DCD LPCOMP_COMP_IRQHandler ;LPCOMP_COMP
76+
DCD SWI0_IRQHandler ;SWI0
77+
DCD SWI1_IRQHandler ;SWI1
78+
DCD SWI2_IRQHandler ;SWI2
79+
DCD SWI3_IRQHandler ;SWI3
80+
DCD SWI4_IRQHandler ;SWI4
81+
DCD SWI5_IRQHandler ;SWI5
82+
DCD 0 ;Reserved
83+
DCD 0 ;Reserved
84+
DCD 0 ;Reserved
85+
DCD 0 ;Reserved
86+
DCD 0 ;Reserved
87+
DCD 0 ;Reserved
88+
89+
90+
__Vectors_End
91+
92+
__Vectors_Size EQU __Vectors_End - __Vectors
93+
94+
AREA |.text|, CODE, READONLY
95+
96+
; Reset Handler
97+
98+
NRF_POWER_RAMON_ADDRESS EQU 0x40000524 ; NRF_POWER->RAMON address
99+
NRF_POWER_RAMON_RAMxON_ONMODE_Msk EQU 0xF ; All RAM blocks on in onmode bit mask
100+
101+
Reset_Handler PROC
102+
EXPORT Reset_Handler [WEAK]
103+
IMPORT SystemInit
104+
IMPORT __main
105+
LDR R0, =NRF_POWER_RAMON_ADDRESS
106+
LDR R2, [R0]
107+
MOVS R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
108+
ORRS R2, R2, R1
109+
STR R2, [R0]
110+
LDR R0, =SystemInit
111+
BLX R0
112+
LDR R0, =__main
113+
BX R0
114+
ENDP
115+
116+
; Dummy Exception Handlers (infinite loops which can be modified)
117+
118+
NMI_Handler PROC
119+
EXPORT NMI_Handler [WEAK]
120+
B .
121+
ENDP
122+
HardFault_Handler\
123+
PROC
124+
EXPORT HardFault_Handler [WEAK]
125+
B .
126+
ENDP
127+
SVC_Handler PROC
128+
EXPORT SVC_Handler [WEAK]
129+
B .
130+
ENDP
131+
PendSV_Handler PROC
132+
EXPORT PendSV_Handler [WEAK]
133+
B .
134+
ENDP
135+
SysTick_Handler PROC
136+
EXPORT SysTick_Handler [WEAK]
137+
B .
138+
ENDP
139+
140+
Default_Handler PROC
141+
142+
EXPORT POWER_CLOCK_IRQHandler [WEAK]
143+
EXPORT RADIO_IRQHandler [WEAK]
144+
EXPORT UART0_IRQHandler [WEAK]
145+
EXPORT SPI0_TWI0_IRQHandler [WEAK]
146+
EXPORT SPI1_TWI1_IRQHandler [WEAK]
147+
EXPORT GPIOTE_IRQHandler [WEAK]
148+
EXPORT ADC_IRQHandler [WEAK]
149+
EXPORT TIMER0_IRQHandler [WEAK]
150+
EXPORT TIMER1_IRQHandler [WEAK]
151+
EXPORT TIMER2_IRQHandler [WEAK]
152+
EXPORT RTC0_IRQHandler [WEAK]
153+
EXPORT TEMP_IRQHandler [WEAK]
154+
EXPORT RNG_IRQHandler [WEAK]
155+
EXPORT ECB_IRQHandler [WEAK]
156+
EXPORT CCM_AAR_IRQHandler [WEAK]
157+
EXPORT WDT_IRQHandler [WEAK]
158+
EXPORT RTC1_IRQHandler [WEAK]
159+
EXPORT QDEC_IRQHandler [WEAK]
160+
EXPORT LPCOMP_COMP_IRQHandler [WEAK]
161+
EXPORT SWI0_IRQHandler [WEAK]
162+
EXPORT SWI1_IRQHandler [WEAK]
163+
EXPORT SWI2_IRQHandler [WEAK]
164+
EXPORT SWI3_IRQHandler [WEAK]
165+
EXPORT SWI4_IRQHandler [WEAK]
166+
EXPORT SWI5_IRQHandler [WEAK]
167+
POWER_CLOCK_IRQHandler
168+
RADIO_IRQHandler
169+
UART0_IRQHandler
170+
SPI0_TWI0_IRQHandler
171+
SPI1_TWI1_IRQHandler
172+
GPIOTE_IRQHandler
173+
ADC_IRQHandler
174+
TIMER0_IRQHandler
175+
TIMER1_IRQHandler
176+
TIMER2_IRQHandler
177+
RTC0_IRQHandler
178+
TEMP_IRQHandler
179+
RNG_IRQHandler
180+
ECB_IRQHandler
181+
CCM_AAR_IRQHandler
182+
WDT_IRQHandler
183+
RTC1_IRQHandler
184+
QDEC_IRQHandler
185+
LPCOMP_COMP_IRQHandler
186+
SWI0_IRQHandler
187+
SWI1_IRQHandler
188+
SWI2_IRQHandler
189+
SWI3_IRQHandler
190+
SWI4_IRQHandler
191+
SWI5_IRQHandler
192+
193+
B .
194+
ENDP
195+
ALIGN
196+
197+
; User Initial Stack & Heap
198+
199+
IF :DEF:__MICROLIB
200+
201+
EXPORT __initial_sp
202+
EXPORT __heap_base
203+
EXPORT __heap_limit
204+
205+
ELSE
206+
207+
IMPORT __use_two_region_memory
208+
EXPORT __user_initial_stackheap
209+
__user_initial_stackheap
210+
211+
LDR R0, = Heap_Mem
212+
LDR R1, = (Stack_Mem + Stack_Size)
213+
LDR R2, = (Heap_Mem + Heap_Size)
214+
LDR R3, = Stack_Mem
215+
BX LR
216+
217+
ALIGN
218+
219+
ENDIF
220+
221+
END
222+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* mbed Microcontroller Library - stackheap
2+
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
3+
*
4+
* Setup a fixed single stack/heap memory model,
5+
* between the top of the RW/ZI region and the stackpointer
6+
*/
7+
8+
#ifdef __cplusplus
9+
extern "C" {
10+
#endif
11+
12+
#include <rt_misc.h>
13+
#include <stdint.h>
14+
15+
extern char Image$$RW_IRAM1$$ZI$$Limit[];
16+
17+
extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {
18+
uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit;
19+
uint32_t sp_limit = __current_sp();
20+
21+
zi_limit = (zi_limit + 7) & ~0x7; // ensure zi_limit is 8-byte aligned
22+
23+
struct __initial_stackheap r;
24+
r.heap_base = zi_limit;
25+
r.heap_limit = sp_limit;
26+
return r;
27+
}
28+
29+
#ifdef __cplusplus
30+
}
31+
#endif
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
2+
*
3+
* The information contained herein is property of Nordic Semiconductor ASA.
4+
* Terms and conditions of usage are described in detail in NORDIC
5+
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
6+
*
7+
* Licensees are granted free, non-transferable use of the information. NO
8+
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
9+
* the file.
10+
*
11+
*/
12+
13+
14+
15+
/* Template files (including this one) are application specific and therefore expected to
16+
be copied into the application project folder prior to its use! */
17+
18+
#ifndef _UICR_CONFIG_H
19+
#define _UICR_CONFIG_H
20+
21+
/*lint ++flb "Enter library region" */
22+
23+
#include <stdint.h>
24+
25+
/*
26+
* Include this file in your project if you want to include in your compiled code files data
27+
* for the User Information Configuration Registers (UICR) area; see nRF51 Series Reference
28+
* Manual chapter User Information Configuration Registers. This file declares one variable
29+
* per register of the UICR area and informs the linker where to place them. To include
30+
* the desired value in the desired address, uncomment the variable with the proper address
31+
* at the target area and update the assignment value.
32+
*
33+
* Please note that UICR values are stored in a reserved area of the flash and should only be
34+
* stored into when downloading a hex file. Do not use these defined variables to store data
35+
* at run time.
36+
*
37+
* Note as well that this file uses one non-standard attribute ("at"). It will only function
38+
* with the ARMCC compiler toolset.
39+
*
40+
* Note that the hex file generated when this file is included will fail to download when using
41+
* the standard download algorithm provided by Nordic. See example project "uicr_config_example"
42+
* in any of the board example folders for an example of the recommended download method as well
43+
* as the documentation that follows with the SDK. nrfjprog can be used as normal.
44+
*
45+
* Please note as well that if you are using a SoftDevice the UICR_CLENR0 address will
46+
* already be in use. Do not uncomment that line.
47+
*/
48+
49+
// const uint32_t UICR_CLENR0 __attribute__((at(0x10001000))) __attribute__((used)) = 0xFFFFFFFF; // WARNING: This address might be used by the SoftDevice. Use with care.
50+
// const uint32_t UICR_RBPCONF __attribute__((at(0x10001004))) __attribute__((used)) = 0xFFFFFFFF;
51+
// const uint32_t UICR_XTALFREQ __attribute__((at(0x10001008))) __attribute__((used)) = 0xFFFFFFFF;
52+
53+
// const uint32_t UICR_ADDR_0x80 __attribute__((at(0x10001080))) __attribute__((used)) = 0xFFFFFFFF;
54+
// const uint32_t UICR_ADDR_0x84 __attribute__((at(0x10001084))) __attribute__((used)) = 0xFFFFFFFF;
55+
// const uint32_t UICR_ADDR_0x88 __attribute__((at(0x10001088))) __attribute__((used)) = 0xFFFFFFFF;
56+
// const uint32_t UICR_ADDR_0x8C __attribute__((at(0x1000108C))) __attribute__((used)) = 0xFFFFFFFF;
57+
// const uint32_t UICR_ADDR_0x90 __attribute__((at(0x10001090))) __attribute__((used)) = 0xFFFFFFFF;
58+
// const uint32_t UICR_ADDR_0x94 __attribute__((at(0x10001094))) __attribute__((used)) = 0xFFFFFFFF;
59+
// const uint32_t UICR_ADDR_0x98 __attribute__((at(0x10001098))) __attribute__((used)) = 0xFFFFFFFF;
60+
// const uint32_t UICR_ADDR_0x9C __attribute__((at(0x1000109C))) __attribute__((used)) = 0xFFFFFFFF;
61+
// const uint32_t UICR_ADDR_0xA0 __attribute__((at(0x100010A0))) __attribute__((used)) = 0xFFFFFFFF;
62+
// const uint32_t UICR_ADDR_0xA4 __attribute__((at(0x100010A4))) __attribute__((used)) = 0xFFFFFFFF;
63+
// const uint32_t UICR_ADDR_0xA8 __attribute__((at(0x100010A8))) __attribute__((used)) = 0xFFFFFFFF;
64+
// const uint32_t UICR_ADDR_0xAC __attribute__((at(0x100010AC))) __attribute__((used)) = 0xFFFFFFFF;
65+
// const uint32_t UICR_ADDR_0xB0 __attribute__((at(0x100010B0))) __attribute__((used)) = 0xFFFFFFFF;
66+
// const uint32_t UICR_ADDR_0xB4 __attribute__((at(0x100010B4))) __attribute__((used)) = 0xFFFFFFFF;
67+
// const uint32_t UICR_ADDR_0xB8 __attribute__((at(0x100010B8))) __attribute__((used)) = 0xFFFFFFFF;
68+
// const uint32_t UICR_ADDR_0xBC __attribute__((at(0x100010BC))) __attribute__((used)) = 0xFFFFFFFF;
69+
// const uint32_t UICR_ADDR_0xC0 __attribute__((at(0x100010C0))) __attribute__((used)) = 0xFFFFFFFF;
70+
// const uint32_t UICR_ADDR_0xC4 __attribute__((at(0x100010C4))) __attribute__((used)) = 0xFFFFFFFF;
71+
// const uint32_t UICR_ADDR_0xC8 __attribute__((at(0x100010C8))) __attribute__((used)) = 0xFFFFFFFF;
72+
// const uint32_t UICR_ADDR_0xCC __attribute__((at(0x100010CC))) __attribute__((used)) = 0xFFFFFFFF;
73+
// const uint32_t UICR_ADDR_0xD0 __attribute__((at(0x100010D0))) __attribute__((used)) = 0xFFFFFFFF;
74+
// const uint32_t UICR_ADDR_0xD4 __attribute__((at(0x100010D4))) __attribute__((used)) = 0xFFFFFFFF;
75+
// const uint32_t UICR_ADDR_0xD8 __attribute__((at(0x100010D8))) __attribute__((used)) = 0xFFFFFFFF;
76+
// const uint32_t UICR_ADDR_0xDC __attribute__((at(0x100010DC))) __attribute__((used)) = 0xFFFFFFFF;
77+
// const uint32_t UICR_ADDR_0xE0 __attribute__((at(0x100010E0))) __attribute__((used)) = 0xFFFFFFFF;
78+
// const uint32_t UICR_ADDR_0xE4 __attribute__((at(0x100010E4))) __attribute__((used)) = 0xFFFFFFFF;
79+
// const uint32_t UICR_ADDR_0xE8 __attribute__((at(0x100010E8))) __attribute__((used)) = 0xFFFFFFFF;
80+
// const uint32_t UICR_ADDR_0xEC __attribute__((at(0x100010EC))) __attribute__((used)) = 0xFFFFFFFF;
81+
// const uint32_t UICR_ADDR_0xF0 __attribute__((at(0x100010F0))) __attribute__((used)) = 0xFFFFFFFF;
82+
// const uint32_t UICR_ADDR_0xF4 __attribute__((at(0x100010F4))) __attribute__((used)) = 0xFFFFFFFF;
83+
// const uint32_t UICR_ADDR_0xF8 __attribute__((at(0x100010F8))) __attribute__((used)) = 0xFFFFFFFF;
84+
// const uint32_t UICR_ADDR_0xFC __attribute__((at(0x100010FC))) __attribute__((used)) = 0xFFFFFFFF;
85+
86+
/*lint --flb "Leave library region" */
87+
88+
#endif //_UICR_CONFIG_H
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* mbed Microcontroller Library - CMSIS
2+
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
3+
*
4+
* A generic CMSIS include header, pulling in LPC407x_8x specifics
5+
*/
6+
7+
#ifndef MBED_CMSIS_H
8+
#define MBED_CMSIS_H
9+
10+
#include "nRF51822.h"
11+
#include "cmsis_nvic.h"
12+
13+
#endif

0 commit comments

Comments
 (0)