Skip to content

Commit

Permalink
Description refined. Added Basic-examples - but work on hold.
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Kaszubski committed Feb 12, 2019
1 parent 41a097e commit 1bfbd6c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 67 deletions.
65 changes: 65 additions & 0 deletions docs/d2d/basic-example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
*******************
D2D - Basic example
*******************

Library initialization
----------------------
This article tackles the bacis example of how to use **D2D** library.
The use case used in the example is very simple and can be a starter
point for building an **Application Layer** and communication between
devices.

.. note::

The code below shows how to use **D2D** libary with **ST Microelectronics**
**STM32** microcontrollers with support of **LL** and **HAL** drivers.

The basic setup of the library requires initialization of the **D2D** library
itself and its dependencies as well.

.. code-block:: C++
:linenos:

/* Includes ------------------------------------------------------------------*/
// Include Timer module (D2D dependency)
#include "timer.h"
// Include PRNG module (D2D dependency)
#include "prng.h"
// Include D2D library
#include "d2d_tl.h"
...



...

int main(void)
{
// Initilize D2D library and its dependencies
{
// Number of send attempts for D2D library
uint8_t sendAttemptsMax = 6;

// Initialize Timer module
timer_init();

// Initialize Pseugo Random Number Generator module
prng_init();

// Initialize D2D library
d2d_tl_init(sendAttemptsMax);
d2d_tl_register_cbs(&tlCbs);
}
}



What next
---------
..

**Footnote**

**kaeraz**, 2019/02
5 changes: 5 additions & 0 deletions docs/d2d/hw-setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ with the use of an **UART** microcontroller interface. In general the library
- Medium interface error detection
- Frame CRC calculation and verification

.. note::

Examplary code and hardware is based on UART microcontroller's
peripheral.

Hardware circuit
----------------
Example solution of **L1** uses standard **UART interface** for sending signals
Expand Down
32 changes: 29 additions & 3 deletions docs/d2d/sw-setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ Introduction
This chapter describes how to seput the **D2D** library. In general,
correct setup requires few actions:

- **Link Layer** setup to support used microcontroller
- setup of **Link Layer** to support used microcontroller
- **Pseudo Random Number Generator** setup
- **Timer** module setup

.. note::

The **D2D** library depends on two additional modules:
**Timer** module and **PSNG** module.

Layer 2: Link Layer overview
----------------------------
The **Link Layer** also called **Data Link Layer** is responsible for
Expand Down Expand Up @@ -209,7 +214,7 @@ in the **D2D** repository. The quick-and-dirty implementation for
**ST Microelectronis** **STM32** microcontrollers is shown below.

.. code-block:: C++
:lineos:
:linenos:

void prng_init_bit_generator(void)
{
Expand Down Expand Up @@ -273,10 +278,31 @@ The next section describes the **Timer** modules.

Dependencies: Timer setup
-------------------------
The **D2D** library depends on **Timer** module, which provides
a time counting facility. When **Timer** object is created
it registers user callback method that is called after time
expiration. There is little to setup in case of **Timer** module.
One has to set a maximum number of **Timer** objects in the
``timer_config.h`` file.

.. code-block:: C++
:linenos:

/**
* @brief Defines number of Timers used in the application.
*
*/
#define TIMER_NO_TIMERS (2) // Value of 2 is a minimum number of Timers
// for D2D library.
The **D2D** library requires at least two **Timer** objects for
proper operation.

What next
---------

After having an overview how to setup a **D2D** library, there
is a time to dig into an example code. The next article covers
this topic.


**Footnote**
Expand Down
64 changes: 0 additions & 64 deletions docs/d2d/transport_layer.rst

This file was deleted.

0 comments on commit 1bfbd6c

Please sign in to comment.