<p>laforge <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/14390">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved; Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ASF: add related RTC files<br><br>this add the documentation and (yet unused) RTC definitions so to<br>by in sync with the ASFv4 upstream library<br><br>Change-Id: If3e24ede24b4e8cc2724a796756a5a2aa81119de<br>---<br>A sysmoOCTSIM/hal/documentation/calendar.rst<br>A sysmoOCTSIM/hpl/rtc/hpl_rtc_base.h<br>2 files changed, 124 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/sysmoOCTSIM/hal/documentation/calendar.rst b/sysmoOCTSIM/hal/documentation/calendar.rst</span><br><span>new file mode 100644</span><br><span>index 0000000..8a3de6e</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/hal/documentation/calendar.rst</span><br><span>@@ -0,0 +1,72 @@</span><br><span style="color: hsl(120, 100%, 40%);">+===============================</span><br><span style="color: hsl(120, 100%, 40%);">+The Calendar driver (bare-bone)</span><br><span style="color: hsl(120, 100%, 40%);">+===============================</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The Calendar driver provides means to set and get current date and time.</span><br><span style="color: hsl(120, 100%, 40%);">+After enabling, an instance of the driver starts counting time from the base date with</span><br><span style="color: hsl(120, 100%, 40%);">+the resolution of one second. The default base date is 00:00:00 1st of January 1970.</span><br><span style="color: hsl(120, 100%, 40%);">+Only the base year of the base date can be changed via the driver API.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The current date and time is kept internally in a relative form as the difference between</span><br><span style="color: hsl(120, 100%, 40%);">+current date and time and the base date and time. This means that changing the base year changes</span><br><span style="color: hsl(120, 100%, 40%);">+current date.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The base date and time defines time "zero" or the earliest possible point in time that the calender driver can describe,</span><br><span style="color: hsl(120, 100%, 40%);">+this means that current time and alarms can not be set to anything earlier than this time.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The Calendar driver provides alarm functionality.</span><br><span style="color: hsl(120, 100%, 40%);">+An alarm is a software trigger which fires on particular date and time with particular periodicity.</span><br><span style="color: hsl(120, 100%, 40%);">+Upon firing the given callback function is called.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+An alarm can be in single-shot mode, firing only once at matching time; or in repeating mode, meaning that it will</span><br><span style="color: hsl(120, 100%, 40%);">+reschedule a new alarm automatically based on repeating mode configuration.</span><br><span style="color: hsl(120, 100%, 40%);">+In single-shot mode an alarm is removed from the alarm queue before its callback is called. It allows an application to</span><br><span style="color: hsl(120, 100%, 40%);">+reuse the memory of expired alarm in the callback.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+An alarm can be triggered on the following events: match on second, minute, hour, day, month or year.</span><br><span style="color: hsl(120, 100%, 40%);">+Matching on second means that the alarm is triggered when the value of seconds of the current time is equal to</span><br><span style="color: hsl(120, 100%, 40%);">+the alarm's value of seconds. This means repeating alarm with match on seconds is triggered with the period of a minute.</span><br><span style="color: hsl(120, 100%, 40%);">+Matching on minute means that the calendars minute and seconds values has to match the alarms, the rest of the date-time</span><br><span style="color: hsl(120, 100%, 40%);">+value is ignored. In repeating mode this means a new alarm every hour.</span><br><span style="color: hsl(120, 100%, 40%);">+The same logic is applied to match on hour, day, month and year.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Each instance of the Calendar driver supports infinite amount of software alarms, only limited by the amount of RAM available.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Features</span><br><span style="color: hsl(120, 100%, 40%);">+--------</span><br><span style="color: hsl(120, 100%, 40%);">+* Initialization and de-initialization</span><br><span style="color: hsl(120, 100%, 40%);">+* Enabling and disabling</span><br><span style="color: hsl(120, 100%, 40%);">+* Date and time operations</span><br><span style="color: hsl(120, 100%, 40%);">+* Software alarms</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Applications</span><br><span style="color: hsl(120, 100%, 40%);">+------------</span><br><span style="color: hsl(120, 100%, 40%);">+* A source of current date and time for an embedded system.</span><br><span style="color: hsl(120, 100%, 40%);">+* Periodical functionality in low-power applications since the driver is designed to use 1Hz clock.</span><br><span style="color: hsl(120, 100%, 40%);">+* Periodical function calls in case if it is more convenient to operate with absolute time.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Dependencies</span><br><span style="color: hsl(120, 100%, 40%);">+------------</span><br><span style="color: hsl(120, 100%, 40%);">+* This driver expects a counter to be increased by one every second to count date and time correctly.</span><br><span style="color: hsl(120, 100%, 40%);">+* Each instance of the driver requires separate hardware timer.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Concurrency</span><br><span style="color: hsl(120, 100%, 40%);">+-----------</span><br><span style="color: hsl(120, 100%, 40%);">+The Calendar driver is an interrupt driven driver.This means that the interrupt that triggers an alarm may occur during</span><br><span style="color: hsl(120, 100%, 40%);">+the process of adding or removing an alarm via the driver's API. In such case the interrupt processing is postponed</span><br><span style="color: hsl(120, 100%, 40%);">+until the alarm adding or removing is complete.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The alarm queue is not protected from the access by interrupts not used by the driver. Due to this</span><br><span style="color: hsl(120, 100%, 40%);">+it is not recommended to add or remove an alarm from such interrupts: in case if a higher priority interrupt supersedes</span><br><span style="color: hsl(120, 100%, 40%);">+the driver's interrupt, adding or removing an alarm may cause unpredictable behavior of the driver.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Limitations</span><br><span style="color: hsl(120, 100%, 40%);">+-----------</span><br><span style="color: hsl(120, 100%, 40%);">+* Only years divisible by 4 are deemed a leap year, this gives a correct result between the years 1901 to 2099.</span><br><span style="color: hsl(120, 100%, 40%);">+* The driver is designed to work outside of an operating system environment, the software alarm queue is therefore processed in interrupt context which may delay execution of other interrupts.</span><br><span style="color: hsl(120, 100%, 40%);">+* If there are a lot of frequently called interrupts with the priority higher than the driver's one, it may cause delay in alarm's triggering.</span><br><span style="color: hsl(120, 100%, 40%);">+* Changing the base year or setting current date or time does not shift alarms' date and time accordingly or expires alarms.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Knows issues and workarounds</span><br><span style="color: hsl(120, 100%, 40%);">+----------------------------</span><br><span style="color: hsl(120, 100%, 40%);">+Not applicable</span><br><span>diff --git a/sysmoOCTSIM/hpl/rtc/hpl_rtc_base.h b/sysmoOCTSIM/hpl/rtc/hpl_rtc_base.h</span><br><span>new file mode 100644</span><br><span>index 0000000..06e3bd7</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/hpl/rtc/hpl_rtc_base.h</span><br><span>@@ -0,0 +1,52 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief RTC</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_start</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \page License</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Subject to your compliance with these terms, you may use Microchip</span><br><span style="color: hsl(120, 100%, 40%);">+ * software and any derivatives exclusively with Microchip products.</span><br><span style="color: hsl(120, 100%, 40%);">+ * It is your responsibility to comply with third party license terms applicable</span><br><span style="color: hsl(120, 100%, 40%);">+ * to your use of third party software (including open source software) that</span><br><span style="color: hsl(120, 100%, 40%);">+ * may accompany Microchip software.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span style="color: hsl(120, 100%, 40%);">+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT</span><br><span style="color: hsl(120, 100%, 40%);">+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY</span><br><span style="color: hsl(120, 100%, 40%);">+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_stop</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef _HPL_RTC2_V200_H_INCLUDED</span><br><span style="color: hsl(120, 100%, 40%);">+#define _HPL_RTC2_V200_H_INCLUDED</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <hpl_timer.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef __cplusplus</span><br><span style="color: hsl(120, 100%, 40%);">+extern "C" {</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Retrieve timer helper functions</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return A pointer to set of timer helper functions</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+struct _timer_hpl_interface *_rtc_get_timer(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef __cplusplus</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* _HPL_RTC2_V200_H_INCLUDED */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/14390">change 14390</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/14390"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-ccid-firmware </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: If3e24ede24b4e8cc2724a796756a5a2aa81119de </div>
<div style="display:none"> Gerrit-Change-Number: 14390 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kévin Redon <kredon@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>