mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
Diff: targets/hal/TARGET_ARM_SSG/TARGET_MPS2/us_ticker.c
- Revision:
- 80:bdf1132a57cf
- Parent:
- 0:9b334a45a8ff
- Child:
- 144:ef7eb2e8f9f7
--- a/targets/hal/TARGET_ARM_SSG/TARGET_MPS2/us_ticker.c Wed Mar 02 10:15:13 2016 +0000 +++ b/targets/hal/TARGET_ARM_SSG/TARGET_MPS2/us_ticker.c Wed Mar 02 14:30:11 2016 +0000 @@ -19,7 +19,7 @@ #define US_TICKER_TIMER1 CMSDK_DUALTIMER1 #define US_TICKER_TIMER2 CMSDK_DUALTIMER2 -#define US_TICKER_TIMER_IRQn DUALTIMER_IRQn +#define US_TICKER_TIMER_IRQn DUALTIMER_IRQn int us_ticker_inited = 0; @@ -29,9 +29,9 @@ US_TICKER_TIMER1->TimerControl = 0x0; // disable timer US_TICKER_TIMER2->TimerControl = 0x00; // disable timer - US_TICKER_TIMER1->TimerLoad = 0xFFFFFFFF; - US_TICKER_TIMER2->TimerLoad = 0xFFFFFFFF; - + US_TICKER_TIMER1->TimerLoad = 0xFFFFFFFF; + US_TICKER_TIMER2->TimerLoad = 0xFFFFFFFF; + US_TICKER_TIMER1->TimerControl = 0x62; // enable interrupt and set to 32 bit counter and set to periodic mode US_TICKER_TIMER2->TimerControl = 0x42; // enable interrupt and set to 32 bit counter @@ -47,11 +47,10 @@ if (!us_ticker_inited) us_ticker_init(); return_value = ((~US_TICKER_TIMER2->TimerValue)/25); - return return_value; + return return_value; } void us_ticker_set_interrupt(timestamp_t timestamp) { -uint32_t timer_value = 0; int delta = 0; if (!us_ticker_inited) us_ticker_init(); @@ -61,24 +60,23 @@ us_ticker_irq_handler(); return; } - timer_value = (delta)*25; - // enable interrupt + // enable interrupt US_TICKER_TIMER1->TimerControl = 0x0; // disable timer US_TICKER_TIMER1->TimerControl = 0x62; // enable interrupt and set to 32 bit counter and set to periodic mode - US_TICKER_TIMER1->TimerLoad = (delta)*25; //initialise the timer value - US_TICKER_TIMER1->TimerControl |= 0x80; //enable timer + US_TICKER_TIMER1->TimerLoad = (delta)*25; //initialise the timer value + US_TICKER_TIMER1->TimerControl |= 0x80; //enable timer } void us_ticker_disable_interrupt(void) { - US_TICKER_TIMER1->TimerControl &= 0xDF; - US_TICKER_TIMER2->TimerControl &= 0xDF; + US_TICKER_TIMER1->TimerControl &= 0xDF; + US_TICKER_TIMER2->TimerControl &= 0xDF; } void us_ticker_clear_interrupt(void) { - US_TICKER_TIMER1->TimerIntClr = 0x1; - US_TICKER_TIMER2->TimerIntClr = 0x1; + US_TICKER_TIMER1->TimerIntClr = 0x1; + US_TICKER_TIMER2->TimerIntClr = 0x1; }