Skip to content

Commit 17c7250

Browse files
committed
os_tick for iar
1 parent bd8c335 commit 17c7250

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF51822/analogin_api.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ uint16_t analogin_read_u16(analogin_t *obj)
6060
{
6161
nrf_adc_value_t adc_value;
6262

63-
nrf_drv_adc_channel_t adc_channel = NRF_DRV_ADC_DEFAULT_CHANNEL(obj->adc_pin);
63+
nrf_drv_adc_channel_t adc_channel;
64+
65+
66+
adc_channel.config.config.resolution = NRF_ADC_CONFIG_RES_10BIT;
67+
adc_channel.config.config.input = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE;
68+
adc_channel.config.config.reference = NRF_ADC_CONFIG_REF_VBG;
69+
adc_channel.config.config.ain = (obj->adc_pin);
70+
adc_channel.p_next = NULL;
6471

6572

6673
ret_code_t ret_code;

hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/os_tick.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,35 @@ __attribute__((naked)) void COMMON_RTC_IRQ_HANDLER(void)
142142
);
143143
}
144144

145+
#elif defined (__ICCARM__)//IAR
146+
void common_rtc_irq_handler(void);
147+
148+
__stackless __task void COMMON_RTC_IRQ_HANDLER(void)
149+
{
150+
uint32_t temp;
151+
152+
__asm volatile(
153+
" ldr %[temp], [%[reg2check]] \n"
154+
" cmp %[temp], #0 \n"
155+
" beq 1f \n"
156+
" bl.w OS_Tick_Handler \n"
157+
"1: \n"
158+
" push {r3, lr}\n"
159+
" blx %[rtc_irq] \n"
160+
" pop {r3, pc}\n"
161+
162+
: /* Outputs */
163+
[temp] "=&r"(temp)
164+
: /* Inputs */
165+
[reg2check] "r"(0x40011144),
166+
[rtc_irq] "r"(common_rtc_irq_handler)
167+
: /* Clobbers */
168+
"cc"
169+
);
170+
(void)temp;
171+
}
172+
173+
145174
#else
146175

147176
#error Compiler not supported.
@@ -345,7 +374,7 @@ uint32_t os_tick_val(void) {
345374
return clock_cycles_by_tick - ((current_counter - next_tick_cc_value) % clock_cycles_by_tick);
346375
}
347376

348-
return 0;
377+
//return 0;
349378
}
350379

351380
#endif // defined(TARGET_MCU_NRF51822)

0 commit comments

Comments
 (0)