\section{Program description}
The program consists of two main parts: the setup part and the loop part.
The setup part does the things, that needs to be done once which are mostly initializations - clock prescaler, LCD, interrupts, SPI, pins and so on.

The loop part does the same thing all over again. This main cycle check, if there was a command received over a serial line, refreshes the time shown on the display, check if the button was pressed and then checks if some data are available from the RFID reader.

\subsection{UML activity diagram}

\begin{figure}[ht!]
\centering
\includegraphics[width=1\textwidth,angle=0]{activity_rfid_uml.jpg}
\caption{Activity diagram of the program in UML language}\label{uml:act}
\end{figure}

Activity diagram of the internal workings of the device's embedded system is shown in \ref{uml:act}. As we can see from the activity diagram shown above, the device itself (red) is responsible for storing the actual time and date and keeping track of it, checking and reading the file­system on the SD card for files and writing into them, providing the back­end for the device human interface and servicing the communication with RFID capable card working on Mifare protocol.


\subsection*{Actions}
\begin{itemize}
	\item Set time and date is done by the interface consisting of LCD display and pushbuttons
	\item Load SD card with meeting names is done on any device capable of creating files on the FAT filesystem
	\item Choose meeting to record into again, done on the device ­pushbuttons interface
	\item Try to read the ID tag is done automatically when the ISIC card is present in the magnetic field of reader
	\item Save RFID tag to the SD card is done automatically when the reading of the RFID tag is successful; tag is stored with actual time and date
\end{itemize}


­ 
\subsection*{Data sources}
\begin{itemize}
	\item Meeting names of the text files without extension on the SD card
	\item SD card contains the files (meeting names) that contains the meetings data (time, date, RFID tag) on the FAT filesystem
	\item RFID tag unique tag read wirelessly from ISIC card
\end{itemize}

\subsection*{Signals}
\begin{itemize}
	\item ­SD card error is displayed on the LCD display
	\item ­ISIC card error is displayed on the LCD display
\end{itemize}





\subsection{UML use-case diagram}

\begin{figure}[ht!]
\centering
\includegraphics[width=1\textwidth,angle=0]{usecase_rfid_uml.jpg}
\caption{Use-case diagram of the program in UML language}\label{uml:use}
\end{figure}

Unlike th activity diagram, in the Use case diagram, shown in \ref{uml:use}, the responsibilities of device users are depicted. From the diagram, it is clear that three systems are needed for whole concept. The main system (RFID reader) is the system embedded in the device. Two more subsystems are needed: one fro making sense of the data (statistics, analytics) and one for easy manipulation with SD card contents, since the human interface of the main system is very limited.

\subsection*{Meeting orgnizator (red actions)}
Organizator is responsible for preparing the reader by storing empty files, without extension on FAT filesystem formatted SD card on the device, which is capable of doing so. The file names are actually the meeting names. The data  are stored in these files. He is also responsible for setting up time and date, after each battery replacement. Before meeting start he chooses the file which data will be saved into. Viewing the data statistics and analytics is subject to further expansion of the system, for now, they are only available in raw format.

\subsection*{Meting visitor (blue actions)}
When the reader is fully prepared by the organizator. meeting visitor's only responsibility is to firmly put his ISIC card on the reader for brief period of time (until beep is sound is played). Data are wirelessly transmitted into the reader and processed there. When this happens, the visitor's presence on the meeting is recorded and stored on the SD card for further analysis.





\newpage
\section{Program compilation}
The program can be compiled with the use of Eclipse IDE, when opened as a project right out of the box. Manual compilation is possible, but is really complicated and should not be used. Versions of compilation tools:

\begin{itemize}
	\item \texttt{avrdude-5.11.1}
	\item \texttt{avr-libc-1.8.0}
	\item \texttt{binutils-avr\_2.20.1-2}
	\item \texttt{gcc-avr\_4.7.2-2}
\end{itemize}










%The Contactless Attendance Logger is a device constructed as a result of this work. The requirements for this device was detailed in sections 3 and 4. This section explains, how and why individual components, depicted in those sections were chosen. The fully assembled device, inside a case is shown at \ref{dev:full}, with part labelled at \ref{dev:ilu}.
%
%\begin{figure}[ht!]
%\centering
%\includegraphics[width=.6\textwidth,angle=0]{device_full.png}
%\caption{Full assembled device - Contactless Attendance Logger}\label{dev:full}
%\end{figure}
%
%\subsection{Firmware}
%For the firmware\cite{toulson2012fast} side, the Arduino platform\cite{monk2013programming} will be used. The reason behind this decision is global community support and free software libraries for almost any possible component including most of the components suggested for this device. This will greatly reduce the software development time over plain C programming.
%
%\subsection{Power supplies and battery level}
%Four 1.5V AA type batteries in series will produce slightly more than 6V when fully charged. Together with low drop-out linear regulator LP2985-33\cite{DS:LP2985-33} will provide steady 3.3V over full operable batteries voltage range. This setup will eliminate the need to incorporate a DC converter, which will make the design far simpler.
%
%The device will be operable also without the main power supply, the batteries. Linear Technology LTC4412\cite{DS:LTC4412} chip will take care of switching between battery and USB supply, choosing the USB when provided. Two external diodes will provide further protection. To preserve battery voltage range, the low drop-out Schottky diode BAT42 is used on the batteries side.
%
%The power supply part of the device is able to provide information about which power supply is active at given time, however it is not able to determine the current battery charge level. For this purpose small custom circuitry will be made to handle this task and to protect the MCU from over-voltage, since it cannot measure voltage level of the batteries at their full potential.
%
%\begin{figure}[ht!]
%\centering
%\includegraphics[width=.4\textwidth,angle=0]{device_pcb.png}
%\caption{Disassembled device showing the main board, exposing components}\label{dev:pcb}
%\end{figure}
%
%\subsection{Microcontroller}
%As a brain for the device is chosen the Atmel microcontroller, ATmega328P\cite{DS:ATmega328P}. This MCU is fully compatible with the Arduino platform, so no further modifications are needed. It has 32kB of flash program memory, which gives us a reasonable amount of memory reserve, since estimations shows, that around 20kB of program memory space will be used.
%
%
%\subsection{Communication}
%The FTDI device FT321X\cite{DS:FT231X} will be used for providing communication between microcontroller and the PC over an USB connection. It communicates with a MCU over an UART protocol, which needs precise clock source on both sides. This device has it's own precise clock already integrated. This chip is also cheaper, smaller and more reliable than a lot of other similar solutions on the market.
%
%Since the device will use a fully compliant USB-to-UART bridge, the user will be able to reprogram the microcontroller over the USB without the need of any external device. This will help introducing further firmware updated to the end device. The USB side of the bridge will appear on host computer as Virtual COM Port\cite{axelson2007serial}.
%
%\subsection{Clock source}
%The microcontroller will use small compact 16MHz resonator with integrated run-up capacitors with 0.5\% accuracy. Since the MCU cannot reliably operate clocked to 16MHz at 3.3V, clock prescaler, integrated inside the MCU, with a factor of 2 will be used to drop the clock frequency to 8MHz. This frequency is fully compatible with the Arduino platform, so no further code modifications will be needed. Lower frequency also help to preserve the batteries. The external clock source will reduce the errors over the UART communication.
%
%\subsection{Display}
%User will be able to read the information and menu from the chosen 24x48 dot matrix LCD with PCD8544 controller, known for presence in some popular Nokia mobile phones like 3310 or 5110 models. The reasons for this was really low power consumption, communication in SPI protocol, price and ability to easily display simple images, for example a battery level indication. 
%Since the display has its own controller, if there is no actual need for updating the displayed data, microcontroller can go to sleep mode to preserve the battery energy. This is not possible in displays directly controlled by MCU, i.e. multiplexed 7-segment displays.
%
%\subsection{User interface}
%The minimalist design of this device was requiring at least 3 user inputs. For this purpose, re branded rotary encoder from old Sony Ericsson mobile phone is used. Now the device can be controlled with only one finger or thumb.
%The encoder will provide two rotation directions and also acts as a push-button. This will help scrolling the device menu.
%   
%Audio feedback for used will be handled by small speaker used commonly in hand-held devices to provide an audible feedback for user, indicating some events, i.e. successful card read operation.
%
%\subsection{Time and date tracking}
%For this task, the Maxim DS1302\cite{DS:DS1302} chip is used. The precise clock source, watch crystal with 32.768kHz, that is fed directly into the chip. The chip is also backed by a small replaceable non-rechargeable 3V battery CR1220. This will make sure that the device will be fully operable without main battery, only with the USB connection active.
%
%\subsection{RFID reader module}
%The suggested RFID reader module from China manufacturers, with NXP's chip MFRC522 will be used for RFID communication. It handles all the Mifare protocol communication and also is able to communicate over SPI protocol. This plays nicely with the LCD display, since it is also communicating over SPI.
%
%\subsection{MicroSD card slot}
%MicroSD card will be pushed into standard MicroSD card slot. No module will be used, since they provide no real advantage and take precious space in hand-held devices. The card also communicates with MCU over the SPI protocol, which needs some surrounding electronics shared with other SPI related components.
%
%\begin{figure}[ht!]
%\centering
%\includegraphics[width=.6\textwidth,angle=0]{device_illustration.jpg}
%\caption{Illustration of the fully assembled device with labelled individual parts}\label{dev:ilu}
%\end{figure}
%
%\newpage
%\section{User interface operation instructions}
%This section is devoted to instructions for proper operation of the device. The manual and all other information provided by the device is available only in English language.
%
%\subsection{MicroSD card preparation and usage}
%The device supports MicroSD cards up to 2 GB of storage space. The card itself has to be formatted with the FAT16 filesystem\cite{solomon2011computer}. Consult your operating system help center for instructions. The device itself cannot do this task alone. Properly prepared card is then inserted with a gentle push into MicroSD slot near the top right corner of the device. This operation is possible only when the device is out of its case, since there is no dedicated hole in the case. Pull the card firmly to take it out of the device. When the card is inserted after the device was powered, or the card is broken or not supported, the CARD INIT ERROR\ref{disp:1} error is displayed.
%\begin{figure}[ht!]
%\centering
%\includegraphics[width=.4\textwidth,angle=0]{display_error_card.jpg}
%\caption{Illustration of the LCD display, when the device is unable to recognize the MicroSD card}\label{disp:1}
%\end{figure}
%When this happens, please ensure that the card is fully inserted inside it's slot, power-down and power-up the device again, or try another card, if the error persists.
%
%
%If the card is supported, but is formatted unproperly, the FAT16 INIT ERROR \ref{disp:2} is displayed.
%\begin{figure}[ht!]
%\centering
%\includegraphics[width=.4\textwidth,angle=0]{display_error_fat16.jpg}
%\caption{Illustration of the LCD display, when the MicroSD card is recognized, but is not formatted with FAT16 file system}\label{disp:2}
%\end{figure}
%Without the working MicroSD card, the device will not be operable.
%
%\subsection{Basic operation}
%The device starts itself as soon, as the power source is present. When inserted into the dedicated plastic case with no USB cable attached, the device is powered from the four contained AA batteries. This fact, along with the current battery level is indicated in the top left corner of the LCD display, in the power source indicator area. With battery mode active, the LCD display looks similar to illustration \ref{disp:3}. Other information displayed on the LCD are current time in the right-top corner and actual storage file. The storage files are explained in advanced operation. 
%\begin{figure}[ht!]
%\centering
%\includegraphics[width=.4\textwidth,angle=0]{display_battery.jpg}
%\caption{Illustration of the LCD display, when the device is in battery power supply mode}\label{disp:3}
%\end{figure}
%The indicator has four stages, indicating battery level of circa 100, 75, 50, 25\%. When the batteries re too too low for device to operate, it will not start, nor display anything on the LCD.
%
%For the operation in the USB mode, connect the Mini-B USB connector to he bottom-right corner or the device. Connect the other side to some USB charger or PC. When connected to the PC, device acts as a Virtual COM Port, that is supported by most OS. You should be able to see it in your operating system device manager. Note that on Windows machines, it may take a while for device driver to install itself via Windows Update service. If this is not the case, you can use included CD to install the driver manually.
%
%When the device is plugged into USB power source, it will immediately switch to the USB mode. This mode does not drain the battery and is indicated with a small USB standard icon in the top-left corner of the display, as illustrated on \ref{disp:4}.
%
%\begin{figure}[ht!]
%\centering
%\includegraphics[width=.4\textwidth,angle=0]{display_usb.jpg}
%\caption{Illustration of the LCD display, when the device is in USB power supply mode}\label{disp:4}
%\end{figure}
%
%\subsection{Menu and advanced operation}
%A main menu is accessed by push of the rotary button, which is the only manually operable element. The button is situated in the top-right corner of the device. When in menu, navigation is achieved by a rotation of the rotary button. The current selected menu entry is indicated by the black arrow on the left side of the display. The menu entry is selected by one more push of the button. The main menu itself is simple and contains only 4 entries \ref{disp:5}: Storage, New file, Date/time and an Exit for return to the main screen, when the device is active. This means, that the device records RFID data and responds to Serial commands. Both this concepts will be explained later.
%\begin{figure}[ht!]
%\centering
%\includegraphics[width=.4\textwidth,angle=0]{display_menu.jpg}
%\caption{Illustration of the LCD display, the main menu is active}\label{disp:5}
%\end{figure}
%
%When for some reason, i.e. the MicroSD card is empty or the selected storage file was deleted, the "Please select a storage file" sign \ref{disp:6} will be sown on the display.
%
%The purpose of the storage menu entry is to choose the file, where the data will be stored, the storage file. Navigation in this submenu is identical to the navigation of the of the main menu. When the file is selected, the device returns to the main screen.
%\begin{figure}[ht!]
%\centering
%\includegraphics[width=.4\textwidth,angle=0]{display_error_storage.jpg}
%\caption{Illustration of the LCD display, the storage file is not selected}\label{disp:6}
%\end{figure}
%
%
%If again, the card is empty, the storage submenu will be empty too. This can be solved by accessing the second entry of the main menu - New file. The entry has no visible submenu and will return to the main screen when accessed. However, the empty storage file will be created. The file naming scheme is FILE1, FILE2, FILE3 and so on. The created file will then be shown on the Storage submenu, where can be selected and activated.
%
%The third entry in the main menu is Date/time. When accessed, the current time and date is shown and can be changed. The actual changed value is indicated by continual blinking. The values are accessed by successive pushes of the button and can be changed by rotation of the rotary button. When the button is pushed on the last, year value, the menu is left to the main screen and the changes to date and time are saved.
%
%\subsection{Data recording and Serial commands}
%The device is active when there is no error or sign displayed and is out of menu, on the main screen - illustrated previously on \ref{disp:3} and \ref{disp:4}. The screen contains the sign "Saving to:" and the storage file name beneath the sign. Now, when an RFID active ISIC card is resent in the blue device reader area, the actual date, time and the card's RFID tag is stored on inside the active storage file on the MicroSD card. Success is signalized by a short beep sound. Note that copy of the data that are stored are also sent over the USB cable, through the serial connection.
%
%Serial connection in established by opening a serial terminal application i.e. HyperTerminal, PuTTy or similar one on the PC, to which the device is connected by USB. After choosing the correct port assigned to the device, the baud rate of 38400 is selected. Flow control should be turned off. The other parameters should be left in default state. This includes 8 bit mode, no parity bit and 1 stop bit. The notation for this configuration is 8N1. Consult the application manual for correct settings.
%
%When the serial connection is active, the more advanced commands become available. The commands are typed into the terminal. No special characters are involved. If the command has one or more parameters, they are separated a by space character. When the inserted command is not recognized by the device, the brief help, containing list of possible commands is shown. For easier understanding, the command's arguments are CAPITALIZED. For convention, commands has similar structure as commands used in a Linux/UNIX environment. If the command has one or more arguments, they are all required. Note that file names must be 8 or less characters long. Longer file names may not work. The list of possible commands:
%\begin{itemize}
%	\item \texttt{ls} - list all storage files
%	\item \texttt{touch FILE} - create a storage file named FILE
%	\item \texttt{rm FILE} - remove a storage file named FILE
%	\item \texttt{rmall} - remove all storage files
%	\item \texttt{mv FILE1 FILE2} - rename storage file FILE1 to FILE2
%	\item \texttt{read FILE} - read the contents of the storage file FILE
%	\item \texttt{readall} - read the contents of all storage files
%	\item \texttt{date D M Y} - set current date to DD:MM:YYYY
%	\item \texttt{time H I S} - set current time to HH:II:SS
%\end{itemize}
%
%\subsection{Manual manipulation with MicroSD card contents}
%User is able to manipulate the files directly by inserting the MicroSD card root destination from the device into the dedicated device or a slot in a computer. This way, user is gaining tools provided by the operating system to manipulate the files. Such a functionality is useful in example, when only specific files needs to be deleted, or some special naming convention is used. However, few restrictions still apply, otherwise the device will not work as expected. The maximum of 8 characters long names rule has to be preserved. Another important factor is not to change the .CSV file extension of the existing files and also adding this extension to files created. It is not advised to create any sub-folders on the MicroSD card.
%
%\newpage
%\section{Technical details}
%This section covers some details of the inner workings of the device and also explains some design decisions. All the information contained here are meant to be read by the expert users. 
%
%\subsection{Circuit explaination}
%The device circuit is shown on \ref{cir:1}. It was created in the DipTrace electronics CAD software. The voltage regulator U5 is connected according to its datasheet\cite{DS:LP2985-33}. So do the USB-to-UART bridge U4\cite{DS:FT231X}, the bus powered configuration is used. Apart from TX and RX lines, the only connection is the DTR line, which connects over a capacitor to the main microcontroller U1 reset line\cite{arduino:pro_mini}. This allows firmware uploading over the serial port, so no external programmer is needed. Microcontroller gains this capability by running the Optiboot\cite{anderson2013pro} bootloader\cite{susnea2006microcontrollers}. The RTC chip U2\cite{DS:DS1302} is also connected according to it's datasheet. Since the microcontroller does not have the hardware support for the Three line serial interface, communication is implemented purely in software on separate pins.
%
%\begin{figure}
%\centering
%\includegraphics[width=1\textwidth,angle=0]{schematic.pdf}
%\caption{The device's schematic created in DipTrace}\label{cir:1}
%\end{figure}
%
%The PowerPath controller U3\cite{DS:LTC4412} has a special configuration. It's control CTL line is pulled-down by R10 and the GATE pin turns the P-channel MOSFET into On-state, so the current from from battery through Schottky diode D2. This diode is low drop-out, so together with a low drop-out voltage regulator, a minimum battery voltage for device operation can be as low as approximately 3.35V. This diode also stops current, that could flow from the USB bus through MOSFET substrate diode back to the batteries, when their voltage drops below the 5V. This could make batteries explode. The last function of this diode is to protect the whole circuit from situations, when a battery is inserted with wrong polarity. 
%
%The U3 CTL line is pulled up by the USB bus. This shuts-down the MOSFET, so even when the battery voltage is higher than 5V, the current flows only from the USB bus through a normal junction diode D1. This diode also protects against wrong polarity, however this is unlikely in the USB bus, due to standardised connectors. It's main purpose is to stop the current flow from the batteries, when higher than 5V, to the USB bus. Also, the CTL line is protected, without the diode, it will be always pulled-up. Lastly, it leaves the U4 without power, when powered from batteries. This helps protects batteries, since there is no for the bridge without the USB connection.
%
%Since the microcontroller provides two pins, that acts only as analog input, without the interrupt capability, we can utilize on of them to sense, which power source is active. This is achieved by connecting the U3 STAT line to ADC7, along with external pull-up resistor to 3.3V, since this analog inputs have no in-built ones. The other one is used for real analog sensing of the battery voltage. This is done by bringing the PC5 high. The transistor Q2 is then fully saturated, so the analog pin ADC6 can sense battery voltage through a voltage divider with the ratio of 1:1. This means that safe maximum battery voltage is 2 x 3.3 - around 6.6V. The capacitor C13 blocks DC current from battery through the transistor's base. After the measurement is done, the PC5 is brought down. This approach makes sure that no microcontroller pin connected to constant voltage higher than 3.3V and also that a battery isn't constantly drained by the voltage divider.
%
%\tabcolsep=8pt
%\begin{table}[!ht]
%\centering
%\caption{Bill of materials used in the circuit}\label{t:bom}
%\begin{tabular}{lllr}
%\hline
%\textbf{RefDes}        & \textbf{Value} & \textbf{Pattern} & \textbf{Qty} \\
%B1                     & CR1220         &                  & 1            \\
%C1 - C8, C12, C14      & 0.1uF          & CAP\_0805        & 10           \\
%C9                     & 4.7uF          & CAP\_0805        & 1            \\
%C10, C11               & 10uF           & TC\_0805         & 2            \\
%C13                    & 10uF           & CAP\_0805        & 1            \\
%C15, C16               & 47pF           & CAP\_0805        & 2            \\
%D1                     & 1N4148         & CAP\_0805        & 1            \\
%D2                     & BAT42          & MINIMELF         & 1            \\
%J1 – J6                & connectors     &                  & 1            \\
%LS1                    & Piezo          &                  & 1            \\
%Q1                     & AP2309GN       & SOT23            & 1            \\
%Q2                     & BC807          & SOT23            & 1            \\
%R1, R2, R3, R5, R6, R7 & 22k            & RES\_0805        & 6            \\
%R4, R11, R12, R15, R16 & 10k            & RES\_0805        & 5            \\
%R8                     & 100R           & RES\_0805        & 1            \\
%R9                     & 470k           & RES\_0805        & 1            \\
%R10                    & 100k           & RES\_0805        & 1            \\
%R13, R14               & 27R            & RES\_0805        & 2            \\
%U1                     & ATmega328      & QFP-32/9x9x0.8   & 1            \\
%U2                     & DS1302Z        & SOIC-8/150mil    & 1            \\
%U3                     & LTC4412ES6     & SOT23-6          & 1            \\
%U4                     & FT321X         & QSOP-20          & 1            \\
%U5                     & LP2985-33      & SOT23-5          & 1            \\
%Y1                     & 16.0           & CSTCE16M0V53-R0  & 1            \\
%Y2                     & 0.032768       &                  & 1           
%\end{tabular}
%\end{table}
%
%The only other microcontroller's inputs being the two rotary encoder lines, the button line and the RFID reader module IRQ, which is host interrupt request. All of this inputs needs a I/O pin that is capable of  interrupt. Since all normal pins on the microcontroller are capable of pin change interrupt, they could be connected almost anywhere. However, the button and the IRQ are connected to PD2 and PD3, which are the external interrupt pins. Only this two pins can wake-up the MCU from sleep when the card is present or the button is pressed. Sleep helps to reduce the power consumption, thus preserve batteries. Whole action is invisible to the user.
%
%Hardware encoder and button debouncing is done by the C5 - C7 along with MCU internal pull-up resistors activated on selected lines. R8 helps protect the pin driving the speaker, so it will not exceed it's rated 20mA maximum current source. Both the RTC watch crystal and the MCU resonator does not need a drive capacitors. They are built-in corresponding packages.
% 
%The last thing is SPI\cite{susnea2006microcontrollers} communication. All lines has an external pull-up resistor. MCU built-in pull-up resistors should not be used for this purpose, since they are not active when the MCU in in reset - they are tri-stated. The communication lines pull-up resistors R1, R5 and R6 protects the slave SPI devices from any possible noise on these lines, when MCU is in the reset. They are also required by some MicroSD cards. The slave-select resistors R2, R3 and R7 are keeping all SPI slaves inactive, unless explicitly driven low by the MCU. This makes external MCU programming through the SPI possible.
%
%
%
%\subsection{Printed circuit board}
%The PCB schematic \ref{pcb:schem} is dual-layer was created in the DipTrace software as well. The main design aim was to have a bottom side of PCB without the components to minimize the device height. It is also a good practice to have one layer of the PCB with as much ground plane, as possible\cite{hara1998emc}. The the PCB design had to be done in the way, that it is possible to create the PCB in amateur, home environment.
%
%The process included application of dry photo-resist, which after exposed to UV light, covered by the actual PCB mask on transparent foil creates a etchant immune paths. For the etchant, the Hydrogen Peroxide with Hydrochlorid Acid was used. The drilling, vias and soldering was done manually.
%
%\begin{figure}
%\centering
%\includegraphics[width=1\textwidth,angle=0]{pcb_schematic.jpg}
%\caption{The device's PCB schematic created in DipTrace}\label{pcb:schem}
%\end{figure}
%
%\subsection{Firmware algorithm}
%There should be a general idea of the device inner operation after the Circuit explanation section was read. The firmware consists of some separate Arduino files and libraries for operating the SPI, LCD, SD, RFID reader, RTC, clock prescaler and the rotary encoder. The strings for a serial communication and bitmaps for a LCD are stored in MCU flash memory, to preserve a precious RAM.
%
%After the MCU is started, prescaler is activated, to make 8Mhz clock from 16MHz resonator for a safe 3.3V operation. Then the pull-ups are activated, the interrupts are initiated and the SPI communication is initialized. After that, LCD and RFID reader are initiated. In the end, the MicroSD card is tested. When everything is ready, the global interrupts are enabled and the program goes into the main loop, which goes over and over.
%
%The main loop handles the received serial commands, refreshes the time,power indicator and storage file information, handles the received RFID data and shows menu, when the button was pressed. The menus and submenus are just endless loops again, that reacts on the button press or rotary encoder activity. 
%
%
%
%%
%%Začnime rovnicou
%%
%%\begin{equation}\label{r:2}
%%\frac{\ud^2y}{\ud t^2}+\frac{\ud y}{\ud t}+y =0, \qquad y(0)=1, \quad
%%y\,'(0)=15.
%%\end{equation}
%%
%%Grafický priebeh riešenia tejto rovnice vidíme na Obrázku \ref{o:2}.
%%
%%\begin{figure}[ht!]
%%\centering
%%\includegraphics[width=.6\textwidth,angle=0]{relaxcas.pdf}
%%\caption{Teplotná závislosť\/ spinovo-mriežkového relaxačného
%%času}\label{o:3}
%%\end{figure}
%%
%%%\tabcolsep=3pt % sirka stlpcov
%%%\renewcommand{\arraystretch}{1.2} % riadkovanie
%%\begin{table}[ht!]
%%\centering
%%\caption{Parametre získané z~meraní spinovo-mriežkových relaxačných
%%časov $T_1$}\label{t:2}
%%\medskip
%%\newcolumntype{d}{D{,}{,}{-1}}
%%\begin{tabular}{||c||d|d|d|d|d||}
%%\hhline{|t:==t:==:==:t|}
%%\multicolumn{1}{||c||}{}&\multicolumn{1}{c|}{PP --
%%01}&\multicolumn{1}{c|}{PP -- 05}&\multicolumn{1}{c|}{PP --
%%10}&\multicolumn{1}{c|}{PP -- 16}&\multicolumn{1}{c||}{PP -- 22} \\
%%\hhline{|:==:==:==:|}
%%C $\cdot 10^8$~(s$^{-2}$) & 10,1 & 10,0 & 11,0 & 9,2 & 8  \\
%%\hhline{||-|-|-|-|-|-||}
%%$\tau_0 \cdot 10^{-14}$~(s) & 2,63 & 1,44 & 0,95 & 2,21 & 10,83  \\
%%\hhline{||-|-|-|-|-|-||}
%%$E_{\text a}$~(kJ) & 34,26 & 8,33 & 39,76 & 37,31 & 31,86  \\
%%\hhline{||-|-|-|-|-|-||}
%%$T_{\min}$~(K) & 354 & 367 & 367 & 369 & 367  \\
%%\hhline{||-|-|-|-|-|-||}
%%$T_{1\min}$~(ms) & 141 & 160 & 157 & 175 & 181  \\
%%\hhline{||-|-|-|-|-|-||}
%%$\Delta M_2$~(Gs$^2$) & 5,49 & 5,66 & 5,16 & 5,09 & 5,02  \\
%%\hhline{|b:==b:==:==:b|}
%%\end{tabular}
%%\end{table}
%
