Skip to content

Commit

Permalink
Merge pull request #2943 from nvlsianpu/nrf_nvic_set_vector_func_trzy
Browse files Browse the repository at this point in the history
[NRF5] NVIC_SetVector functionality
  • Loading branch information
0xc0170 authored Oct 25, 2016
2 parents 26bf6eb + 9204c6f commit 4ec2f2e
Show file tree
Hide file tree
Showing 30 changed files with 742 additions and 1,355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ extern "C" {
#include "nRF5xServiceDiscovery.h"
#include "nRF5xCharacteristicDescriptorDiscoverer.h"


bool isEventsSignaled = false;

extern "C" void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name);
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name);
extern "C" void SD_EVT_IRQHandler(void); // export the softdevice event handler for registration by nvic-set-vector.


static void btle_handler(ble_evt_t *p_ble_evt);

Expand Down Expand Up @@ -112,10 +115,14 @@ static uint32_t signalEvent()
return NRF_SUCCESS;
}


error_t btle_init(void)
{
nrf_clock_lf_cfg_t clockConfiguration;

// register softdevice handler vector
NVIC_SetVector(SD_EVT_IRQn, (uint32_t) SD_EVT_IRQHandler);

// Configure the LF clock according to values provided by btle_clock.h.
// It is input from the chain of the yotta configuration system.
clockConfiguration.source = LFCLK_CONF_SOURCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static const PinMap PinMap_ADC[] = {
{NC, NC, 0}
};

void ADC_IRQHandler(void); // export IRQ handler from nrf_drv_adc.c

void analogin_init(analogin_t *obj, PinName pin)
{
Expand All @@ -50,6 +51,8 @@ void analogin_init(analogin_t *obj, PinName pin)

obj->adc_pin = pinFunc;

NVIC_SetVector(ADC_IRQn, (uint32_t)ADC_IRQHandler);

ret_code_t ret_code;
// p_config, event_handler
ret_code = nrf_drv_adc_init(NULL , NULL); // select blocking mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@ __Vectors DCD __initial_sp ; Top of Stack
; External Interrupts
DCD POWER_CLOCK_IRQHandler ;POWER_CLOCK
DCD RADIO_IRQHandler ;RADIO
DCD UART0_IRQHandler ;UART0
DCD SPI0_TWI0_IRQHandler ;SPI0_TWI0
DCD SPI1_TWI1_IRQHandler ;SPI1_TWI1
DCD UART0_IRQHandler_v ;UART0
DCD SPI0_TWI0_IRQHandler_v ;SPI0_TWI0
DCD SPI1_TWI1_IRQHandler_v ;SPI1_TWI1
DCD 0 ;Reserved
DCD GPIOTE_IRQHandler ;GPIOTE
DCD ADC_IRQHandler ;ADC
DCD GPIOTE_IRQHandler_v ;GPIOTE
DCD ADC_IRQHandler_v ;ADC
DCD TIMER0_IRQHandler ;TIMER0
DCD TIMER1_IRQHandler ;TIMER1
DCD TIMER2_IRQHandler ;TIMER2
DCD TIMER1_IRQHandler_v ;TIMER1
DCD TIMER2_IRQHandler_v ;TIMER2
DCD RTC0_IRQHandler ;RTC0
DCD TEMP_IRQHandler ;TEMP
DCD RNG_IRQHandler ;RNG
DCD ECB_IRQHandler ;ECB
DCD CCM_AAR_IRQHandler ;CCM_AAR
DCD WDT_IRQHandler ;WDT
DCD RTC1_IRQHandler ;RTC1
DCD QDEC_IRQHandler ;QDEC
DCD LPCOMP_COMP_IRQHandler ;LPCOMP_COMP
DCD SWI0_IRQHandler ;SWI0
DCD SWI1_IRQHandler ;SWI1
DCD SWI2_IRQHandler ;SWI2
DCD SWI3_IRQHandler ;SWI3
DCD WDT_IRQHandler_v ;WDT
DCD RTC1_IRQHandler_v ;RTC1
DCD QDEC_IRQHandler_v ;QDEC
DCD LPCOMP_IRQHandler_v ;LPCOMP_COMP
DCD SWI0_IRQHandler_v ;SWI0
DCD SWI1_IRQHandler_v ;SWI1
DCD SWI2_IRQHandler_v ;SWI2
DCD SWI3_IRQHandler_v ;SWI3
DCD SWI4_IRQHandler ;SWI4
DCD SWI5_IRQHandler ;SWI5
DCD 0 ;Reserved
Expand All @@ -92,13 +92,16 @@ Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
IMPORT nrf_reloc_vector_table
LDR R0, =NRF_POWER_RAMON_ADDRESS
LDR R2, [R0]
MOVS R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
ORRS R2, R2, R1
STR R2, [R0]
LDR R0, =SystemInit
BLX R0
LDR R0, =nrf_reloc_vector_table
BLX R0
LDR R0, =__main
BX R0
ENDP
Expand Down Expand Up @@ -131,52 +134,52 @@ Default_Handler PROC

EXPORT POWER_CLOCK_IRQHandler [WEAK]
EXPORT RADIO_IRQHandler [WEAK]
EXPORT UART0_IRQHandler [WEAK]
EXPORT SPI0_TWI0_IRQHandler [WEAK]
EXPORT SPI1_TWI1_IRQHandler [WEAK]
EXPORT GPIOTE_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT UART0_IRQHandler_v [WEAK]
EXPORT SPI0_TWI0_IRQHandler_v [WEAK]
EXPORT SPI1_TWI1_IRQHandler_v [WEAK]
EXPORT GPIOTE_IRQHandler_v [WEAK]
EXPORT ADC_IRQHandler_v [WEAK]
EXPORT TIMER0_IRQHandler [WEAK]
EXPORT TIMER1_IRQHandler [WEAK]
EXPORT TIMER2_IRQHandler [WEAK]
EXPORT TIMER1_IRQHandler_v [WEAK]
EXPORT TIMER2_IRQHandler_v [WEAK]
EXPORT RTC0_IRQHandler [WEAK]
EXPORT TEMP_IRQHandler [WEAK]
EXPORT RNG_IRQHandler [WEAK]
EXPORT ECB_IRQHandler [WEAK]
EXPORT CCM_AAR_IRQHandler [WEAK]
EXPORT WDT_IRQHandler [WEAK]
EXPORT RTC1_IRQHandler [WEAK]
EXPORT QDEC_IRQHandler [WEAK]
EXPORT LPCOMP_COMP_IRQHandler [WEAK]
EXPORT SWI0_IRQHandler [WEAK]
EXPORT SWI1_IRQHandler [WEAK]
EXPORT SWI2_IRQHandler [WEAK]
EXPORT SWI3_IRQHandler [WEAK]
EXPORT WDT_IRQHandler_v [WEAK]
EXPORT RTC1_IRQHandler_v [WEAK]
EXPORT QDEC_IRQHandler_v [WEAK]
EXPORT LPCOMP_IRQHandler_v [WEAK]
EXPORT SWI0_IRQHandler_v [WEAK]
EXPORT SWI1_IRQHandler_v [WEAK]
EXPORT SWI2_IRQHandler_v [WEAK]
EXPORT SWI3_IRQHandler_v [WEAK]
EXPORT SWI4_IRQHandler [WEAK]
EXPORT SWI5_IRQHandler [WEAK]
POWER_CLOCK_IRQHandler
RADIO_IRQHandler
UART0_IRQHandler
SPI0_TWI0_IRQHandler
SPI1_TWI1_IRQHandler
GPIOTE_IRQHandler
ADC_IRQHandler
UART0_IRQHandler_v
SPI0_TWI0_IRQHandler_v
SPI1_TWI1_IRQHandler_v
GPIOTE_IRQHandler_v
ADC_IRQHandler_v
TIMER0_IRQHandler
TIMER1_IRQHandler
TIMER2_IRQHandler
TIMER1_IRQHandler_v
TIMER2_IRQHandler_v
RTC0_IRQHandler
TEMP_IRQHandler
RNG_IRQHandler
ECB_IRQHandler
CCM_AAR_IRQHandler
WDT_IRQHandler
RTC1_IRQHandler
QDEC_IRQHandler
LPCOMP_COMP_IRQHandler
SWI0_IRQHandler
SWI1_IRQHandler
SWI2_IRQHandler
SWI3_IRQHandler
WDT_IRQHandler_v
RTC1_IRQHandler_v
QDEC_IRQHandler_v
LPCOMP_IRQHandler_v
SWI0_IRQHandler_v
SWI1_IRQHandler_v
SWI2_IRQHandler_v
SWI3_IRQHandler_v
SWI4_IRQHandler
SWI5_IRQHandler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
;
;WITH SOFTDEVICE:

LR_IROM1 0x0001B000 0x0025000 {
ER_IROM1 0x0001B000 0x0025000 {
LR_IROM1 0x1B000 0x0025000 {
ER_IROM1 0x1B000 0x0025000 {
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20002ef8 0x5108 {
RW_IRAM0 0x20002ef8 UNINIT 0x000000c0 { ;no init section
*(noinit)
}
RW_IRAM1 0x20002FB8 0x00005048 {
.ANY (+RW +ZI)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@ __Vectors DCD __initial_sp ; Top of Stack
; External Interrupts
DCD POWER_CLOCK_IRQHandler ;POWER_CLOCK
DCD RADIO_IRQHandler ;RADIO
DCD UART0_IRQHandler ;UART0
DCD SPI0_TWI0_IRQHandler ;SPI0_TWI0
DCD SPI1_TWI1_IRQHandler ;SPI1_TWI1
DCD UART0_IRQHandler_v ;UART0
DCD SPI0_TWI0_IRQHandler_v ;SPI0_TWI0
DCD SPI1_TWI1_IRQHandler_v ;SPI1_TWI1
DCD 0 ;Reserved
DCD GPIOTE_IRQHandler ;GPIOTE
DCD ADC_IRQHandler ;ADC
DCD GPIOTE_IRQHandler_v ;GPIOTE
DCD ADC_IRQHandler_v ;ADC
DCD TIMER0_IRQHandler ;TIMER0
DCD TIMER1_IRQHandler ;TIMER1
DCD TIMER2_IRQHandler ;TIMER2
DCD TIMER1_IRQHandler_v ;TIMER1
DCD TIMER2_IRQHandler_v ;TIMER2
DCD RTC0_IRQHandler ;RTC0
DCD TEMP_IRQHandler ;TEMP
DCD RNG_IRQHandler ;RNG
DCD ECB_IRQHandler ;ECB
DCD CCM_AAR_IRQHandler ;CCM_AAR
DCD WDT_IRQHandler ;WDT
DCD RTC1_IRQHandler ;RTC1
DCD QDEC_IRQHandler ;QDEC
DCD LPCOMP_IRQHandler ;LPCOMP
DCD SWI0_IRQHandler ;SWI0
DCD SWI1_IRQHandler ;SWI1
DCD SWI2_IRQHandler ;SWI2
DCD SWI3_IRQHandler ;SWI3
DCD WDT_IRQHandler_v ;WDT
DCD RTC1_IRQHandler_v ;RTC1
DCD QDEC_IRQHandler_v ;QDEC
DCD LPCOMP_IRQHandler_v ;LPCOMP_COMP
DCD SWI0_IRQHandler_v ;SWI0
DCD SWI1_IRQHandler_v ;SWI1
DCD SWI2_IRQHandler_v ;SWI2
DCD SWI3_IRQHandler_v ;SWI3
DCD SWI4_IRQHandler ;SWI4
DCD SWI5_IRQHandler ;SWI5
DCD 0 ;Reserved
Expand All @@ -93,6 +93,7 @@ Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
IMPORT nrf_reloc_vector_table

MOVS R1, #NRF_POWER_RAMONx_RAMxON_ONMODE_Msk

Expand All @@ -108,6 +109,8 @@ Reset_Handler PROC

LDR R0, =SystemInit
BLX R0
LDR R0, =nrf_reloc_vector_table
BLX R0
LDR R0, =__main
BX R0
ENDP
Expand Down Expand Up @@ -140,52 +143,52 @@ Default_Handler PROC

EXPORT POWER_CLOCK_IRQHandler [WEAK]
EXPORT RADIO_IRQHandler [WEAK]
EXPORT UART0_IRQHandler [WEAK]
EXPORT SPI0_TWI0_IRQHandler [WEAK]
EXPORT SPI1_TWI1_IRQHandler [WEAK]
EXPORT GPIOTE_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT UART0_IRQHandler_v [WEAK]
EXPORT SPI0_TWI0_IRQHandler_v [WEAK]
EXPORT SPI1_TWI1_IRQHandler_v [WEAK]
EXPORT GPIOTE_IRQHandler_v [WEAK]
EXPORT ADC_IRQHandler_v [WEAK]
EXPORT TIMER0_IRQHandler [WEAK]
EXPORT TIMER1_IRQHandler [WEAK]
EXPORT TIMER2_IRQHandler [WEAK]
EXPORT TIMER1_IRQHandler_v [WEAK]
EXPORT TIMER2_IRQHandler_v [WEAK]
EXPORT RTC0_IRQHandler [WEAK]
EXPORT TEMP_IRQHandler [WEAK]
EXPORT RNG_IRQHandler [WEAK]
EXPORT ECB_IRQHandler [WEAK]
EXPORT CCM_AAR_IRQHandler [WEAK]
EXPORT WDT_IRQHandler [WEAK]
EXPORT RTC1_IRQHandler [WEAK]
EXPORT QDEC_IRQHandler [WEAK]
EXPORT LPCOMP_IRQHandler [WEAK]
EXPORT SWI0_IRQHandler [WEAK]
EXPORT SWI1_IRQHandler [WEAK]
EXPORT SWI2_IRQHandler [WEAK]
EXPORT SWI3_IRQHandler [WEAK]
EXPORT WDT_IRQHandler_v [WEAK]
EXPORT RTC1_IRQHandler_v [WEAK]
EXPORT QDEC_IRQHandler_v [WEAK]
EXPORT LPCOMP_IRQHandler_v [WEAK]
EXPORT SWI0_IRQHandler_v [WEAK]
EXPORT SWI1_IRQHandler_v [WEAK]
EXPORT SWI2_IRQHandler_v [WEAK]
EXPORT SWI3_IRQHandler_v [WEAK]
EXPORT SWI4_IRQHandler [WEAK]
EXPORT SWI5_IRQHandler [WEAK]
POWER_CLOCK_IRQHandler
RADIO_IRQHandler
UART0_IRQHandler
SPI0_TWI0_IRQHandler
SPI1_TWI1_IRQHandler
GPIOTE_IRQHandler
ADC_IRQHandler
UART0_IRQHandler_v
SPI0_TWI0_IRQHandler_v
SPI1_TWI1_IRQHandler_v
GPIOTE_IRQHandler_v
ADC_IRQHandler_v
TIMER0_IRQHandler
TIMER1_IRQHandler
TIMER2_IRQHandler
TIMER1_IRQHandler_v
TIMER2_IRQHandler_v
RTC0_IRQHandler
TEMP_IRQHandler
RNG_IRQHandler
ECB_IRQHandler
CCM_AAR_IRQHandler
WDT_IRQHandler
RTC1_IRQHandler
QDEC_IRQHandler
LPCOMP_IRQHandler
SWI0_IRQHandler
SWI1_IRQHandler
SWI2_IRQHandler
SWI3_IRQHandler
WDT_IRQHandler_v
RTC1_IRQHandler_v
QDEC_IRQHandler_v
LPCOMP_IRQHandler_v
SWI0_IRQHandler_v
SWI1_IRQHandler_v
SWI2_IRQHandler_v
SWI3_IRQHandler_v
SWI4_IRQHandler
SWI5_IRQHandler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
;
;WITH SOFTDEVICE:

LR_IROM1 0x0001B000 0x0025000 {
ER_IROM1 0x0001B000 0x0025000 {
LR_IROM1 0x18000 0x0028000 {
ER_IROM1 0x18000 0x0028000 {
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20002ef8 0x1108 {
RW_IRAM0 0x20002000 UNINIT 0x000000c0 { ;no init section
*(noinit)
}
RW_IRAM1 0x200020C0 0x00001F40 {
.ANY (+RW +ZI)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ LR_IROM1 0x0001B000 0x0025000 {
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20002ef8 0x1108 {
RW_IRAM0 0x20002ef8 UNINIT 0x000000c0 { ;no init section
*(noinit)
}
RW_IRAM1 0x20002FB8 0x00001048 {
.ANY (+RW +ZI)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ SECTIONS
} > RAM

__edata = .;

.noinit :
{
PROVIDE(__start_noinit = .);
KEEP(*(.noinit))
PROVIDE(__stop_noinit = .);
} > RAM

.bss :
{
Expand Down
Loading

0 comments on commit 4ec2f2e

Please sign in to comment.