60 #define PRINTF(...) printf(__VA_ARGS__) 65 #define RTC_INT1_PORT_BASE GPIO_PORT_TO_BASE(RTC_INT1_PORT) 66 #define RTC_INT1_PIN_MASK GPIO_PIN_MASK(RTC_INT1_PIN) 69 void (*rtcc_int1_callback)(uint8_t value);
71 static const char *ab080x_td_register_name[] =
83 static const char *ab080x_config_register_name[] =
106 bcd_to_dec(uint8_t val)
108 return (uint8_t)(((val >> 4) * 10) + (val % 16));
112 dec_to_bcd(uint8_t val)
114 return (uint8_t)(((val / 10) << 4) + (val % 10));
118 check_leap_year(uint8_t val)
120 return ((val % 4) && (val % 100)) || (val % 400);
124 ab08_read_reg(uint8_t reg, uint8_t *buf, uint8_t regnum)
136 ab08_write_reg(uint8_t reg, uint8_t *buf, uint8_t regnum)
138 uint8_t i, buff[INT_BUFF_SIZE];
140 if(regnum > (INT_BUFF_SIZE - 1)) {
147 for(i = 0; i < regnum; i++) {
148 buff[(i + 1)] = buf[i];
152 if(
i2c_burst_send(AB08XX_ADDR, buff, (regnum + 1)) == I2C_MASTER_ERR_NONE) {
160 write_default_config(
void)
162 const ab080x_register_config_t *settings;
163 settings = ab080x_default_setting;
164 uint8_t i, len = (
sizeof(ab080x_default_setting) /
sizeof(ab080x_register_config_t));
166 for(i = 0; i < len; i++) {
167 ab08_write_reg(settings[i].reg, (uint8_t *)&settings[i].val, 1);
172 ab08_key_reg(uint8_t unlock)
174 if((unlock != RTCC_CONFKEY_OSCONTROL) && (unlock != RTCC_CONFKEY_SWRESET) &&
175 (unlock != RTCC_CONFKEY_DEFREGS)) {
176 PRINTF(
"RTC: invalid confkey values\n");
180 if(ab08_write_reg((CONFIG_MAP_OFFSET + CONF_KEY_ADDR), &unlock, 1)) {
181 PRINTF(
"RTC: failed to write to confkey register\n");
189 ab08_read_status(uint8_t *buf)
191 return ab08_read_reg((STATUS_ADDR + CONFIG_MAP_OFFSET), buf, 1);
195 ab08_ctrl1_config(uint8_t cmd)
199 if(cmd >= RTCC_CMD_MAX) {
203 if(ab08_read_reg((CONFIG_MAP_OFFSET + CTRL_1_ADDR), &ctrl1, 1)) {
204 PRINTF(
"RTC: failed to retrieve CTRL1 register\n");
210 ctrl1 &= ~CTRL1_WRTC;
212 case RTCC_CMD_UNLOCK:
215 case RTCC_CMD_ENABLE:
216 ctrl1 &= ~CTRL1_STOP;
225 if(ab08_write_reg((CONFIG_MAP_OFFSET + CTRL_1_ADDR),
226 &ctrl1, 1) == AB08_ERROR) {
227 PRINTF(
"RTC: failed to write to the CTRL1 register\n");
235 ab08_check_td_format(simple_td_map *data, uint8_t alarm_state)
238 if((data->seconds > 59) || (data->minutes > 59) || (data->hours > 23)) {
242 if((data->months > 12) || (data->weekdays > 7) || (data->day > 31)) {
247 if(data->months == 2) {
248 if(check_leap_year(data->years)) {
262 if(data->years > 199) {
274 uint8_t rtc_buffer[RTCC_TD_MAP_SIZE];
276 if(ab08_check_td_format(data, 0) == AB08_ERROR) {
277 PRINTF(
"RTC: Invalid time/date values\n");
281 if(ab08_read_reg((CTRL_1_ADDR + CONFIG_MAP_OFFSET),
282 &aux, 1) == AB08_ERROR) {
283 PRINTF(
"RTC: failed to retrieve CONTROL1 register\n");
287 rtc_buffer[WEEKDAYLS_ADDR] = dec_to_bcd(data->weekdays);
288 rtc_buffer[YEAR_ADDR] = dec_to_bcd(data->years);
289 rtc_buffer[MONTHS_ADDR] = dec_to_bcd(data->months);
290 rtc_buffer[DAY_ADDR] = dec_to_bcd(data->day);
291 rtc_buffer[HOUR_ADDR] = dec_to_bcd(data->hours);
292 rtc_buffer[MIN_ADDR] = dec_to_bcd(data->minutes);
293 rtc_buffer[SEC_ADDR] = dec_to_bcd(data->seconds);
294 rtc_buffer[CENTHS_ADDR] = dec_to_bcd(data->miliseconds);
297 if(data->mode == RTCC_24H_MODE) {
300 if((data->hours == 0) || (data->hours > 12)) {
301 PRINTF(
"RTC: Invalid hour configuration (12h mode selected)\n");
305 if(data->mode == RTCC_12H_MODE_PM) {
307 rtc_buffer[HOUR_ADDR] |= RTCC_TOGGLE_PM_BIT;
309 PRINTF(
"RTC: Invalid time mode selected\n");
315 if(ab08_write_reg((CTRL_1_ADDR + CONFIG_MAP_OFFSET),
316 &aux, 1) == AB08_ERROR) {
317 PRINTF(
"RTC: failed to write 12h/24h configuration\n");
326 if(ab08_read_reg((STATUS_ADDR + CONFIG_MAP_OFFSET), &aux, 1) == AB08_ERROR) {
327 PRINTF(
"RTC: failed to retrieve STATUS register\n");
331 if(data->century == RTCC_CENTURY_20XX) {
333 }
else if(data->century == RTCC_CENTURY_19XX_21XX) {
336 PRINTF(
"RTC: invalid century value\n");
340 PRINTF(
"RTC: current STATUS value 0x%02X\n", aux);
342 if(ab08_write_reg((STATUS_ADDR + CONFIG_MAP_OFFSET), &aux, 1) == AB08_ERROR) {
343 PRINTF(
"RTC: failed to write century to STATUS register\n");
348 if(ab08_ctrl1_config(RTCC_CMD_UNLOCK) == AB08_ERROR) {
353 if(ab08_write_reg(CENTHS_ADDR, rtc_buffer,
354 RTCC_TD_MAP_SIZE) == AB08_ERROR) {
355 PRINTF(
"RTC: failed to write date configuration\n");
360 if(ab08_ctrl1_config(RTCC_CMD_LOCK) == AB08_ERROR) {
370 uint8_t rtc_buffer[RTCC_TD_MAP_SIZE];
372 if(ab08_read_reg(CENTHS_ADDR, rtc_buffer,
373 RTCC_TD_MAP_SIZE) == AB08_ERROR) {
374 PRINTF(
"RTC: failed to retrieve date and time values\n");
378 data->weekdays = bcd_to_dec(rtc_buffer[WEEKDAYLS_ADDR]);
379 data->years = bcd_to_dec(rtc_buffer[YEAR_ADDR]);
380 data->months = bcd_to_dec(rtc_buffer[MONTHS_ADDR]);
381 data->day = bcd_to_dec(rtc_buffer[DAY_ADDR]);
382 data->hours = bcd_to_dec(rtc_buffer[HOUR_ADDR]);
383 data->minutes = bcd_to_dec(rtc_buffer[MIN_ADDR]);
384 data->seconds = bcd_to_dec(rtc_buffer[SEC_ADDR]);
385 data->miliseconds = bcd_to_dec(rtc_buffer[CENTHS_ADDR]);
394 uint8_t aux[4], buf[RTCC_ALARM_MAP_SIZE];
396 if((trigger != RTCC_TRIGGER_INT2) && (trigger != RTCC_TRIGGER_INT1) &&
397 (trigger != RTCC_TRIGGER_BOTH)) {
398 PRINTF(
"RTC: invalid trigger pin\n");
402 if(state == RTCC_ALARM_OFF) {
403 if(ab08_read_reg((INT_MASK_ADDR + CONFIG_MAP_OFFSET),
404 &aux[0], 1) == AB08_ERROR) {
405 PRINTF(
"RTC: failed to retrieve INTMASK register\n");
409 aux[0] &= ~INTMASK_AIE;
411 if(ab08_write_reg((INT_MASK_ADDR + CONFIG_MAP_OFFSET),
412 &aux[0], 1) == AB08_ERROR) {
413 PRINTF(
"RTC: failed to clear the alarm config\n");
419 if((data == NULL) || (ab08_check_td_format(data, 1) == AB08_ERROR)) {
420 PRINTF(
"RTC: invalid alarm values\n");
424 if((state >= RTCC_ALARM_MAX) || (repeat >= RTCC_REPEAT_100THS)) {
425 PRINTF(
"RTC: invalid alarm config type or state\n");
430 ab08_ctrl1_config(RTCC_CMD_STOP);
432 buf[WEEKDAYS_ALARM_ADDR] = dec_to_bcd(data->weekdays);
433 buf[MONTHS_ALARM_ADDR] = dec_to_bcd(data->months);
434 buf[DAY_ALARMS_ADDR] = dec_to_bcd(data->day);
435 buf[HOURS_ALARM_ADDR] = dec_to_bcd(data->hours);
436 buf[MINUTES_ALARM_ADDR] = dec_to_bcd(data->minutes);
437 buf[SECONDS_ALARM_ADDR] = dec_to_bcd(data->seconds);
438 buf[HUNDREDTHS_ALARM_ADDR] = dec_to_bcd(data->miliseconds);
441 if(ab08_read_reg((CTRL_1_ADDR + CONFIG_MAP_OFFSET),
442 &aux[0], 1) == AB08_ERROR) {
443 PRINTF(
"RTC: failed to retrieve CONTROL1 register\n");
447 if(((aux[0] & CTRL1_1224) && (data->mode == RTCC_24H_MODE)) ||
448 (!(aux[0] & CTRL1_1224) && ((data->mode == RTCC_12H_MODE_AM) ||
449 (data->mode == RTCC_12H_MODE_PM)))) {
450 PRINTF(
"RTC: 12/24h mode and present date config mismatch\n");
454 if(data->mode != RTCC_24H_MODE) {
455 if((data->hours == 0) || (data->hours > 12)) {
456 PRINTF(
"RTC: Invalid hour configuration (12h mode selected)\n");
461 if(data->mode == RTCC_12H_MODE_PM) {
462 buf[HOURS_ALARM_ADDR] |= RTCC_TOGGLE_PM_BIT;
467 if(ab08_read_reg((TIMER_CONTROL_ADDR + CONFIG_MAP_OFFSET),
468 &aux[0], 1) == AB08_ERROR) {
469 PRINTF(
"RTC: failed to retrieve TIMER CTRL register\n");
473 aux[0] &= ~COUNTDOWN_TIMER_RPT_SECOND;
476 if(repeat == RTCC_REPEAT_10THS) {
477 buf[HUNDREDTHS_ALARM_ADDR] |= RTCC_FIX_10THS_HUNDRETHS;
478 repeat = RTCC_REPEAT_SECOND;
479 }
else if(repeat == RTCC_REPEAT_100THS) {
480 buf[HUNDREDTHS_ALARM_ADDR] |= RTCC_FIX_100THS_HUNDRETHS;
481 repeat = RTCC_REPEAT_SECOND;
484 if(repeat != RTCC_REPEAT_NONE) {
485 aux[0] |= (repeat << COUNTDOWN_TIMER_RPT_SHIFT);
490 aux[0] |= COUNTDOWN_TIMER_TM;
491 aux[0] &= ~COUNTDOWN_TIMER_TRPT;
493 if(ab08_write_reg((TIMER_CONTROL_ADDR + CONFIG_MAP_OFFSET),
494 &aux[0], 1) == AB08_ERROR) {
495 PRINTF(
"RTC: failed to clear the alarm config\n");
499 if(ab08_read_reg((STATUS_ADDR + CONFIG_MAP_OFFSET),
500 aux, 4) == AB08_ERROR) {
501 PRINTF(
"RTC: failed to read configuration registers\n");
506 aux[STATUS_ADDR] &= ~STATUS_ALM;
508 #if RTCC_CLEAR_INT_MANUALLY 509 aux[CTRL_1_ADDR] &= ~CTRL1_ARST;
513 aux[INT_MASK_ADDR] &= ~INTMASK_AIE;
520 if (trigger == RTCC_TRIGGER_INT2) {
521 aux[CTRL_2_ADDR] |= CTRL2_OUT2S_NAIRQ_OUTB;
529 if (trigger == RTCC_TRIGGER_INT1) {
530 aux[CTRL_2_ADDR] |= CTRL2_OUT1S_NIRQ_NAIRQ_OUT;
531 }
else if (trigger == RTCC_TRIGGER_BOTH) {
532 aux[CTRL_2_ADDR] |= (CTRL2_OUT1S_NIRQ_NAIRQ_OUT + CTRL2_OUT2S_NAIRQ_OUTB);
535 if(repeat != RTCC_REPEAT_NONE) {
536 aux[INT_MASK_ADDR] &= ~INTMASK_IM_LOW;
538 aux[INT_MASK_ADDR] |= INTMASK_IM_LOW;
541 if(ab08_write_reg((STATUS_ADDR + CONFIG_MAP_OFFSET), aux, 4) == AB08_ERROR) {
542 PRINTF(
"RTC: failed to clear alarm config\n");
547 if(ab08_write_reg((HUNDREDTHS_ALARM_ADDR + ALARM_MAP_OFFSET), buf,
548 RTCC_ALARM_MAP_SIZE) == AB08_ERROR) {
549 PRINTF(
"RTC: failed to set the alarm\n");
554 aux[INT_MASK_ADDR] |= INTMASK_AIE;
555 if(ab08_write_reg((INT_MASK_ADDR + CONFIG_MAP_OFFSET),
556 &aux[INT_MASK_ADDR], 1) == AB08_ERROR) {
557 PRINTF(
"RTC: failed to enable the alarm\n");
562 ab08_ctrl1_config(RTCC_CMD_ENABLE);
573 PRINTF(
"RTC: invalid argument\n");
586 aux = data->seconds + seconds;
587 data->seconds = (uint8_t)(aux % 60);
592 aux += data->minutes;
593 data->minutes = (uint8_t)(aux % 60);
600 data->hours = (uint8_t)(aux % 24);
607 if(data->months == 2) {
608 if(check_leap_year(data->years)) {
610 data->day = (uint8_t)(aux % 29);
613 }
else if(aux > 28) {
614 data->day = (uint8_t)(aux % 28);
617 }
else if((data->months == 4) || (data->months == 6) ||
618 (data->months == 9) || (data->months == 11)) {
620 data->day = (uint8_t)(aux % 30);
623 }
else if(aux > 31) {
624 data->day = (uint8_t)(aux % 31);
629 if(data->months > 12) {
630 data->months = data->months % 12;
636 PROCESS(rtcc_int_process,
"RTCC interruption process handler");
646 if(ab08_read_status(&buf) == AB08_ERROR) {
647 PRINTF(
"RTC: failed to retrieve ARST value\n");
652 if((buf & STATUS_ALM) && (rtcc_int1_callback != NULL)) {
653 #if RTCC_CLEAR_INT_MANUALLY 655 if(ab08_write_reg((STATUS_ADDR + CONFIG_MAP_OFFSET),
656 &buf, 1) == AB08_ERROR) {
657 PRINTF(
"RTC: failed to clear the alarm\n");
661 rtcc_int1_callback(0);
672 uint8_t rtc_buffer[RTCC_CONFIG_MAP_SIZE];
674 if(value >= RTCC_PRINT_MAX) {
679 case RTCC_PRINT_CONFIG:
680 len = (RTCC_CONFIG_MAP_SIZE - 1);
681 reg = STATUS_ADDR + CONFIG_MAP_OFFSET;
682 name = (
char **)ab080x_config_register_name;
684 case RTCC_PRINT_ALARM:
685 case RTCC_PRINT_ALARM_DEC:
686 len = RTCC_ALARM_MAP_SIZE;
687 reg = HUNDREDTHS_ALARM_ADDR + ALARM_MAP_OFFSET;
688 name = (
char **)ab080x_td_register_name;
690 case RTCC_PRINT_DATE:
691 case RTCC_PRINT_DATE_DEC:
692 len = RTCC_TD_MAP_SIZE;
694 name = (
char **)ab080x_td_register_name;
700 if(ab08_read_reg(reg, rtc_buffer, len) == AB08_ERROR) {
701 PRINTF(
"RTC: failed to retrieve values to print\n");
705 if(value == RTCC_PRINT_ALARM_DEC) {
706 printf(
"%02u/%02u (%02u) %02u:%02u:%02u/%02u\n",
707 bcd_to_dec(rtc_buffer[MONTHS_ALARM_ADDR]),
708 bcd_to_dec(rtc_buffer[DAY_ALARMS_ADDR]),
709 bcd_to_dec(rtc_buffer[WEEKDAYS_ALARM_ADDR]),
710 bcd_to_dec(rtc_buffer[HOURS_ALARM_ADDR]),
711 bcd_to_dec(rtc_buffer[MINUTES_ALARM_ADDR]),
712 bcd_to_dec(rtc_buffer[SECONDS_ALARM_ADDR]),
713 bcd_to_dec(rtc_buffer[HUNDREDTHS_ALARM_ADDR]));
717 if(value == RTCC_PRINT_DATE_DEC) {
718 printf(
"%02u/%02u/%02u (%02u) %02u:%02u:%02u/%02u\n",
719 bcd_to_dec(rtc_buffer[YEAR_ADDR]),
720 bcd_to_dec(rtc_buffer[MONTHS_ADDR]),
721 bcd_to_dec(rtc_buffer[DAY_ADDR]),
722 bcd_to_dec(rtc_buffer[WEEKDAYLS_ADDR]),
723 bcd_to_dec(rtc_buffer[HOUR_ADDR]),
724 bcd_to_dec(rtc_buffer[MIN_ADDR]),
725 bcd_to_dec(rtc_buffer[SEC_ADDR]),
726 bcd_to_dec(rtc_buffer[CENTHS_ADDR]));
730 for(i = 0; i < len; i++) {
731 printf(
"0x%02X <- %s\n", rtc_buffer[i], name[i]);
748 if(period > RTCC_AUTOCAL_9_MIN) {
749 PRINTF(
"RTC: invalid autocal value\n");
753 if(ab08_read_reg((OSC_CONTROL_ADDR + CONFIG_MAP_OFFSET),
754 &aux, 1) == AB08_ERROR) {
755 PRINTF(
"RTC: failed to read oscillator registers\n");
760 aux &= ~OSCONTROL_ACAL_9_MIN;
763 ab08_key_reg(RTCC_CONFKEY_OSCONTROL);
766 case RTCC_AUTOCAL_DISABLE:
768 case RTCC_AUTOCAL_ONCE:
769 case RTCC_AUTOCAL_17_MIN:
770 aux |= OSCONTROL_ACAL_17_MIN;
772 case RTCC_AUTOCAL_9_MIN:
773 aux |= OSCONTROL_ACAL_9_MIN;
779 if(ab08_write_reg((OSC_CONTROL_ADDR + CONFIG_MAP_OFFSET),
780 &aux, 1) == AB08_ERROR) {
781 PRINTF(
"RTC: failed to clear the autocalibration\n");
785 if(period == RTCC_AUTOCAL_ONCE) {
787 ab08_key_reg(RTCC_CONFKEY_OSCONTROL);
788 aux &= ~OSCONTROL_ACAL_9_MIN;
789 if(ab08_write_reg((OSC_CONTROL_ADDR + CONFIG_MAP_OFFSET),
790 &aux, 1) == AB08_ERROR) {
791 PRINTF(
"RTC: failed to clear the autocalibration\n");
806 if(mode > RTCC_CAL_RC_OSC) {
807 PRINTF(
"RTC: invalid calibration mode\n");
812 if((mode == RTCC_CAL_XT_OSC) && ((adjust <= -610) || (adjust >= 242))) {
813 PRINTF(
"RTC: invalid adjust value for XT oscillator\n");
817 if((mode == RTCC_CAL_RC_OSC) && ((adjust <= -65536) || (adjust >= 65520))) {
818 PRINTF(
"RTC: invalid adjust value for XT oscillator\n");
824 adjint = ((adjust) * 1000 - 953);
826 adjint = ((adjust) * 1000 + 953);
829 adjint = adjint / 1907;
831 if(mode == RTCC_CAL_XT_OSC) {
835 adjreg[0] = ((adjint >> 1) & 0x3F) | 0x80;
836 }
else if(adjint > -65) {
838 adjreg[0] = (adjint & 0x7F);
839 }
else if(adjint > -129) {
841 adjreg[0] = ((adjint + 64) & 0x7F);
842 }
else if(adjint > -193) {
844 adjreg[0] = ((adjint + 128) & 0x7F);
845 }
else if(adjint > -257) {
847 adjreg[0] = ((adjint + 192) & 0x7F);
850 adjreg[0] = ((adjint + 192) >> 1) & 0xFF;
853 if(ab08_write_reg((CAL_XT_ADDR + CONFIG_MAP_OFFSET),
854 &adjreg[0], 1) == AB08_ERROR) {
855 PRINTF(
"RTC: failed to clear the autocalibration\n");
859 if(ab08_read_reg((OSC_STATUS_ADDR + CONFIG_MAP_OFFSET),
860 &adjreg[0], 1) == AB08_ERROR) {
861 PRINTF(
"RTC: failed to read oscillator registers\n");
867 adjreg[0] |= (xtcal << 6);
869 if(ab08_write_reg((OSC_STATUS_ADDR + CONFIG_MAP_OFFSET),
870 &adjreg[0], 1) == AB08_ERROR) {
871 PRINTF(
"RTC: failed to clear the autocalibration\n");
874 }
else if(mode == RTCC_CAL_RC_OSC) {
876 adjreg[1] = ((adjint >> 3) & 0xFF);
877 adjreg[0] = ((adjint >> 11) | 0xC0);
878 }
else if(adjint > 16383) {
879 adjreg[1] = ((adjint >> 2) & 0xFF);
880 adjreg[0] = ((adjint >> 10) | 0x80);
881 }
else if(adjint > 8191) {
882 adjreg[1] = ((adjint >> 1) & 0xFF);
883 adjreg[0] = ((adjint >> 9) | 0x40);
884 }
else if(adjint >= 0) {
885 adjreg[1] = ((adjint) & 0xFF);
886 adjreg[0] = (adjint >> 8);
887 }
else if(adjint > -8193) {
888 adjreg[1] = ((adjint) & 0xFF);
889 adjreg[0] = (adjint >> 8) & 0x3F;
890 }
else if(adjint > -16385) {
891 adjreg[1] = ((adjint >> 1) & 0xFF);
892 adjreg[0] = (adjint >> 9) & 0x7F;
893 }
else if(adjint > -32769) {
894 adjreg[1] = ((adjint >> 2) & 0xFF);
895 adjreg[0] = (adjint >> 10) & 0xBF;
897 adjreg[1] = ((adjint >> 3) & 0xFF);
898 adjreg[0] = (adjint >> 11) & 0xFF;
901 if(ab08_write_reg((CAL_RC_HI_ADDR + CONFIG_MAP_OFFSET),
902 adjreg, 2) == AB08_ERROR) {
903 PRINTF(
"RTC: failed to set the RC calibration\n");
917 .handler = rtcc_interrupt_handler,
924 i2c_init(I2C_SDA_PORT, I2C_SDA_PIN, I2C_SCL_PORT, I2C_SCL_PIN,
925 I2C_SCL_NORMAL_BUS_SPEED);
927 #if RTCC_SET_DEFAULT_CONFIG 928 write_default_config();
936 rtcc_int1_callback = NULL;
Datatype for GPIO event handlers.
#define GPIO_ENABLE_INTERRUPT(PORT_BASE, PIN_MASK)
Enable interrupt triggering for pins with PIN_MASK of port with PORT_BASE.
#define PROCESS(name, strname)
Declare a process.
int8_t rtcc_date_increment_seconds(simple_td_map *data, uint16_t seconds)
Increments the current date by a number of seconds.
uint8_t i2c_burst_send(uint8_t slave_addr, uint8_t *data, uint8_t len)
Perform all operations to send multiple bytes to a slave.
#define PROCESS_YIELD_UNTIL(c)
Yield the currently running process until a condition occurs.
#define PROCESS_BEGIN()
Define the beginning of a process.
Header file with register and macro declarations for the cc2538 GPIO module.
#define GPIO_DETECT_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to detect edge.
#define PROCESS_END()
Define the end of a process.
int8_t rtcc_set_alarm_time_date(simple_td_map *data, uint8_t state, uint8_t repeat, uint8_t trigger)
Configure the RTCC to match an alarm counter.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
int8_t rtcc_set_autocalibration(uint8_t period)
Set the autocallibration period.
int8_t rtcc_get_time_date(simple_td_map *data)
Get the current time and date.
#define GPIO_DETECT_FALLING(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to trigger an interrupt on falling edge.
void gpio_hal_register_handler(gpio_hal_event_handler_t *handler)
Register a function to be called whenever a pin triggers an event.
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
Enable External Interrupt.
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK)
Configure the pin to be software controlled with PIN_MASK of port with PORT_BASE. ...
#define PROCESS_EXITHANDLER(handler)
Specify an action when a process exits.
void i2c_init(uint8_t port_sda, uint8_t pin_sda, uint8_t port_scl, uint8_t pin_scl, uint32_t bus_speed)
Initialize the I2C peripheral and pins.
void process_poll(struct process *p)
Request a process to be polled.
int8_t rtcc_init(void)
Initialize the RTCC, configures the I2C bus, interrupts and registers.
void ioc_set_over(uint8_t port, uint8_t pin, uint8_t over)
Set Port:Pin override function.
int8_t rtcc_print(uint8_t value)
Print data from the RTCC module, either from the memory map (values in BCD) or actual readable data (...
#define GPIO_SET_INPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to input.
Header file for the RE-Mote RF antenna switch.
uint8_t i2c_burst_receive(uint8_t slave_addr, uint8_t *data, uint8_t len)
Perform all operations to receive multiple bytes from a slave.
uint32_t gpio_hal_pin_mask_t
GPIO pin mask representation.
#define IOC_OVERRIDE_PUE
Pull Up Enable.
int8_t rtcc_set_calibration(uint8_t mode, int32_t adjust)
Manually calibrate the RTCC.
#define GPIO_TRIGGER_SINGLE_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to trigger an interrupt on single edge (controlled by G...
PROCESS_THREAD(cc2538_rf_process, ev, data)
Implementation of the cc2538 RF driver process.
#define gpio_hal_pin_to_mask(pin)
Convert a pin to a pin mask.
Header file for the LED HAL.
int8_t rtcc_set_time_date(simple_td_map *data)
Set the time and date.
uint8_t i2c_single_send(uint8_t slave_addr, uint8_t data)
Perform all operations to send a byte to a slave.
void process_start(struct process *p, process_data_t data)
Start a process.
void i2c_master_enable(void)
Enable master I2C module.
#define PROCESS_EXIT()
Exit the currently running process.