Merge pull request #1233 from adamdunkels/pr/26xx-13xx-fixes

CC26xx/CC13xx fixes
This commit is contained in:
George Oikonomou 2015-11-09 08:33:58 +00:00
commit a63efe947f
5 changed files with 46 additions and 17 deletions

View file

@ -120,31 +120,35 @@ clock_init(void)
((TIMER_CFG_B_ONE_SHOT >> 8) & 0xFF) | GPT_TBMR_TBPWMIE; ((TIMER_CFG_B_ONE_SHOT >> 8) & 0xFF) | GPT_TBMR_TBPWMIE;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void
update_clock_variable(void)
{
uint32_t aon_rtc_secs_now;
uint32_t aon_rtc_secs_now2;
uint16_t aon_rtc_ticks_now;
do {
aon_rtc_secs_now = HWREG(AON_RTC_BASE + AON_RTC_O_SEC);
aon_rtc_ticks_now = HWREG(AON_RTC_BASE + AON_RTC_O_SUBSEC) >> 16;
aon_rtc_secs_now2 = HWREG(AON_RTC_BASE + AON_RTC_O_SEC);
} while(aon_rtc_secs_now != aon_rtc_secs_now2);
/* Convert AON RTC ticks to clock tick counter */
count = (aon_rtc_secs_now * CLOCK_SECOND) + (aon_rtc_ticks_now >> 9);
}
/*---------------------------------------------------------------------------*/
CCIF clock_time_t CCIF clock_time_t
clock_time(void) clock_time(void)
{ {
update_clock_variable();
return (clock_time_t)(count & 0xFFFFFFFF); return (clock_time_t)(count & 0xFFFFFFFF);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
clock_update(void) clock_update(void)
{ {
bool interrupts_disabled; update_clock_variable();
uint32_t aon_rtc_secs_now;
uint16_t aon_rtc_ticks_now;
interrupts_disabled = ti_lib_int_master_disable();
aon_rtc_secs_now = HWREG(AON_RTC_BASE + AON_RTC_O_SEC);
aon_rtc_ticks_now = HWREG(AON_RTC_BASE + AON_RTC_O_SUBSEC) >> 16;
/* Convert AON RTC ticks to clock tick counter */
count = (aon_rtc_secs_now * CLOCK_SECOND) + (aon_rtc_ticks_now >> 9);
/* Re-enable interrupts */
if(!interrupts_disabled) {
ti_lib_int_master_enable();
}
if(etimer_pending()) { if(etimer_pending()) {
etimer_request_poll(); etimer_request_poll();

View file

@ -50,6 +50,8 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Prototype of a function in clock.c. Called every time the handler fires */ /* Prototype of a function in clock.c. Called every time the handler fires */
void clock_update(void); void clock_update(void);
static rtimer_clock_t last_isr_time;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define COMPARE_INCREMENT (RTIMER_SECOND / CLOCK_SECOND) #define COMPARE_INCREMENT (RTIMER_SECOND / CLOCK_SECOND)
#define MULTIPLE_512_MASK 0xFFFFFE00 #define MULTIPLE_512_MASK 0xFFFFFE00
@ -130,6 +132,12 @@ soc_rtc_schedule_one_shot(uint32_t channel, uint32_t ticks)
ti_lib_aon_rtc_channel_enable(channel); ti_lib_aon_rtc_channel_enable(channel);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
rtimer_clock_t
soc_rtc_last_isr_time(void)
{
return last_isr_time;
}
/*---------------------------------------------------------------------------*/
/* The AON RTC interrupt handler */ /* The AON RTC interrupt handler */
void void
soc_rtc_isr(void) soc_rtc_isr(void)
@ -138,6 +146,8 @@ soc_rtc_isr(void)
ENERGEST_ON(ENERGEST_TYPE_IRQ); ENERGEST_ON(ENERGEST_TYPE_IRQ);
last_isr_time = RTIMER_NOW();
now = ti_lib_aon_rtc_current_compare_value_get(); now = ti_lib_aon_rtc_current_compare_value_get();
/* Adjust the s/w tick counter irrespective of which event trigger this */ /* Adjust the s/w tick counter irrespective of which event trigger this */

View file

@ -92,6 +92,8 @@ rtimer_clock_t soc_rtc_get_next_trigger(void);
* instead use Contiki's timer-related libraries * instead use Contiki's timer-related libraries
*/ */
void soc_rtc_schedule_one_shot(uint32_t channel, uint32_t t); void soc_rtc_schedule_one_shot(uint32_t channel, uint32_t t);
rtimer_clock_t soc_rtc_last_isr_time(void);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#endif /* SOC_RTC_H_ */ #endif /* SOC_RTC_H_ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -281,7 +281,7 @@ lpm_drop()
if(next_event) { if(next_event) {
next_event = next_event - clock_time(); next_event = next_event - clock_time();
soc_rtc_schedule_one_shot(AON_RTC_CH1, RTIMER_NOW() + soc_rtc_schedule_one_shot(AON_RTC_CH1, soc_rtc_last_isr_time() +
(next_event * (RTIMER_SECOND / CLOCK_SECOND))); (next_event * (RTIMER_SECOND / CLOCK_SECOND)));
} }

View file

@ -853,6 +853,11 @@ transmit(unsigned short transmit_len)
*/ */
rf_core_cmd_done_dis(); rf_core_cmd_done_dis();
if(was_off) {
off();
}
return ret; return ret;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -1105,6 +1110,8 @@ off(void)
rx_off(); rx_off();
rf_core_power_down(); rf_core_power_down();
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
/* Switch HF clock source to the RCOSC to preserve power */ /* Switch HF clock source to the RCOSC to preserve power */
oscillators_switch_to_hf_rc(); oscillators_switch_to_hf_rc();
@ -1214,6 +1221,12 @@ set_value(radio_param_t param, radio_value_t value)
return RADIO_RESULT_INVALID_VALUE; return RADIO_RESULT_INVALID_VALUE;
} }
if(cmd->channel == (uint8_t)value) {
/* We already have that very same channel configured.
* Nothing to do here. */
return RADIO_RESULT_OK;
}
cmd->channel = (uint8_t)value; cmd->channel = (uint8_t)value;
break; break;
case RADIO_PARAM_PAN_ID: case RADIO_PARAM_PAN_ID: