Updated RTCC driver with selectable INT1/INT2 trigger
This commit is contained in:
parent
980de99472
commit
d1a7740a2c
|
@ -159,8 +159,8 @@ PROCESS_THREAD(test_remote_rtcc_process, ev, data)
|
|||
* minute. In case we would want to trigger the alarm on a specific time,
|
||||
* then we would want to set a daily repeat interval
|
||||
*/
|
||||
if(rtcc_set_alarm_time_date(simple_td, RTCC_ALARM_ON,
|
||||
RTCC_REPEAT_MINUTE) == AB08_ERROR) {
|
||||
if(rtcc_set_alarm_time_date(simple_td, RTCC_ALARM_ON, RTCC_REPEAT_MINUTE,
|
||||
RTCC_TRIGGER_INT1) == AB08_ERROR) {
|
||||
printf("Fail: couldn't set the alarm\n");
|
||||
PROCESS_EXIT();
|
||||
}
|
||||
|
|
|
@ -100,4 +100,3 @@ static const ab080x_register_config_t ab080x_default_setting[] =
|
|||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
|
|
@ -388,10 +388,17 @@ rtcc_get_time_date(simple_td_map *data)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int8_t
|
||||
rtcc_set_alarm_time_date(simple_td_map *data, uint8_t state, uint8_t repeat)
|
||||
rtcc_set_alarm_time_date(simple_td_map *data, uint8_t state, uint8_t repeat,
|
||||
uint8_t trigger)
|
||||
{
|
||||
uint8_t aux[4], buf[RTCC_ALARM_MAP_SIZE];
|
||||
|
||||
if((trigger != RTCC_TRIGGER_INT2) && (trigger != RTCC_TRIGGER_INT1) &&
|
||||
(trigger != RTCC_TRIGGER_BOTH)) {
|
||||
PRINTF("RTC: invalid trigger pin\n");
|
||||
return AB08_ERROR;
|
||||
}
|
||||
|
||||
if(state == RTCC_ALARM_OFF) {
|
||||
if(ab08_read_reg((INT_MASK_ADDR + CONFIG_MAP_OFFSET),
|
||||
&aux[0], 1) == AB08_ERROR) {
|
||||
|
@ -505,12 +512,25 @@ rtcc_set_alarm_time_date(simple_td_map *data, uint8_t state, uint8_t repeat)
|
|||
/* Clear the AIE alarm bit */
|
||||
aux[INT_MASK_ADDR] &= ~INTMASK_AIE;
|
||||
|
||||
/* Configure Interrupt parameters for Alarm Interrupt Mode in nIRQ pin,
|
||||
* and fixed level until interrupt flag is cleared
|
||||
/* Configure Interrupt parameters for Alarm Interrupt Mode in nIRQ
|
||||
* or nAIRQ pins and fixed level until interrupt flag is cleared
|
||||
* RTC_INT1 is connected to the CC2538
|
||||
* RTC_INT2 is connected to the power management PIC in revision B
|
||||
*/
|
||||
if (trigger == RTCC_TRIGGER_INT2) {
|
||||
aux[CTRL_2_ADDR] |= CTRL2_OUT2S_NAIRQ_OUTB;
|
||||
/* Only options left enable the INT1 interrupt pin */
|
||||
} else {
|
||||
GPIO_ENABLE_INTERRUPT(RTC_INT1_PORT_BASE, RTC_INT1_PIN_MASK);
|
||||
ioc_set_over(RTC_INT1_PORT, RTC_INT1_PIN, IOC_OVERRIDE_PUE);
|
||||
nvic_interrupt_enable(RTC_INT1_VECTOR);
|
||||
}
|
||||
|
||||
/* Enable nIRQ if at least one interrupt is enabled */
|
||||
if (trigger == RTCC_TRIGGER_INT1) {
|
||||
aux[CTRL_2_ADDR] |= CTRL2_OUT1S_NIRQ_NAIRQ_OUT;
|
||||
} else if (trigger == RTCC_TRIGGER_BOTH) {
|
||||
aux[CTRL_2_ADDR] |= (CTRL2_OUT1S_NIRQ_NAIRQ_OUT + CTRL2_OUT2S_NAIRQ_OUTB);
|
||||
}
|
||||
|
||||
if(repeat != RTCC_REPEAT_NONE) {
|
||||
aux[INT_MASK_ADDR] &= ~INTMASK_IM_LOW;
|
||||
|
@ -523,11 +543,6 @@ rtcc_set_alarm_time_date(simple_td_map *data, uint8_t state, uint8_t repeat)
|
|||
return AB08_ERROR;
|
||||
}
|
||||
|
||||
/* Enable interrupts */
|
||||
GPIO_ENABLE_INTERRUPT(RTC_INT1_PORT_BASE, RTC_INT1_PIN_MASK);
|
||||
ioc_set_over(RTC_INT1_PORT, RTC_INT1_PIN, IOC_OVERRIDE_PUE);
|
||||
nvic_interrupt_enable(RTC_INT1_VECTOR);
|
||||
|
||||
/* Write to the alarm counters */
|
||||
if(ab08_write_reg((HUNDREDTHS_ALARM_ADDR + ALARM_MAP_OFFSET), buf,
|
||||
RTCC_ALARM_MAP_SIZE) == AB08_ERROR) {
|
||||
|
|
|
@ -275,6 +275,13 @@ enum {
|
|||
RTCC_AUTOCAL_17_MIN,
|
||||
RTCC_AUTOCAL_9_MIN,
|
||||
};
|
||||
/* -------------------------------------------------------------------------- */
|
||||
enum {
|
||||
RTCC_TRIGGER_INT1 = 0,
|
||||
RTCC_TRIGGER_INT2,
|
||||
RTCC_TRIGGER_BOTH,
|
||||
};
|
||||
|
||||
/** @} */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/** \name Readable Date and time memory map implementation
|
||||
|
@ -337,12 +344,13 @@ int8_t rtcc_print(uint8_t value);
|
|||
* \param data date and time values (in decimal) to match against
|
||||
* \param state set on/off the alarm interruption
|
||||
* \param repeat set the frequency of the alarm (minute, hourly, daily, etc.)
|
||||
* \param trigger interrupt trigger (INT1, INT2 or both)
|
||||
* \return
|
||||
* \ AB08_SUCCESS date/time set
|
||||
* \ AB08_ERROR failed to set time/date (enable DEBUG for more info)
|
||||
*/
|
||||
int8_t rtcc_set_alarm_time_date(simple_td_map *data, uint8_t state,
|
||||
uint8_t repeat);
|
||||
uint8_t repeat, uint8_t trigger);
|
||||
|
||||
/**
|
||||
* \brief Manually calibrate the RTCC
|
||||
|
|
Loading…
Reference in a new issue