Skip to content

Commit

Permalink
Change all config (settings) from _CONFIG to _OPT prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Jun 27, 2020
1 parent 655cdd1 commit 71a94fe
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 82 deletions.
24 changes: 10 additions & 14 deletions dev/VisualStudio/ow_config.h → dev/VisualStudio/ow_opts.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* \file ow.h
* \brief OneWire-UART main include file
* \file ow_opts.h
* \brief OW application options
*/

/*
Expand Down Expand Up @@ -31,19 +31,15 @@
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.0.0
*/
#ifndef OW_HDR_CONFIG_H
#define OW_HDR_CONFIG_H
#ifndef OW_HDR_OPTS_H
#define OW_HDR_OPTS_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Rename this file to "ow_opts.h" for your application */

/*
* Open "include/ow/ow_opt.h" and
* copy & replace here settings you want to change values
*/
#define OW_CFG_OS 1

#include "ow/ow_config_default.h"

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* OW_HDR_CONFIG_H */
#endif /* OW_HDR_OPTS_H */
6 changes: 3 additions & 3 deletions docs/api-reference/config.rst → docs/api-reference/opt.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.. _api_ow_config:
.. _api_ow_opt:

OW Configuration
================

This is the default configuration of the middleware.
When any of the settings shall be modified, it shall be done in dedicated application config ``ow_config.h`` file.
When any of the settings shall be modified, it shall be done in dedicated application config ``ow_opts.h`` file.

.. note::
Check :ref:`getting_started` to create configuration file.

.. doxygengroup:: OW_CONFIG
.. doxygengroup:: OW_OPT
8 changes: 4 additions & 4 deletions docs/get-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ At this point it is assumed that you have successfully download library, either
* Copy ``onewire_uart`` folder to your project
* Add ``onewire_uart/src/include`` folder to `include path` of your toolchain
* Add source files from ``onewire_uart/src/`` folder to toolchain build
* Copy ``onewire_uart/src/include/ow/ow_config_template.h`` to project folder and rename it to ``ow_config.h``
* Copy ``onewire_uart/src/include/ow/ow_opts_template.h`` to project folder and rename it to ``ow_opts.h``
* Implement device drivers for UART hardware
* Build the project

Configuration file
^^^^^^^^^^^^^^^^^^

Library comes with template config file, which can be modified according to needs.
This file shall be named ``ow_config.h`` and its default template looks like the one below:
This file shall be named ``ow_opts.h`` and its default template looks like the one below:

.. tip::
Check :ref:`api_ow_config` section for possible configuration settings
Check :ref:`api_ow_opt` section for possible configuration settings

.. literalinclude:: ../../onewire_uart/src/include/ow/ow_config_template.h
.. literalinclude:: ../../onewire_uart/src/include/ow/ow_opts_template.h
:language: c
:linenos:
:caption: Config template file
2 changes: 1 addition & 1 deletion docs/user-manual/porting-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ System function must only support OS mutex management and has to provide:

.. warning::
Application must define :c:macro:`OW_CFG_OS_MUTEX_HANDLE` for mutex type.
This shall be done in ``ow_config.h`` file.
This shall be done in ``ow_opts.h`` file.

.. tip::
Check :ref:`api_ow_sys` for function prototypes.
Expand Down
4 changes: 2 additions & 2 deletions docs/user-manual/thread-safety.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Library has locking mechanism support for thread safety, which needs to be enabl

.. tip::
To enable thread-safety support, parameter ``OW_CFG_OS`` must be set to ``1``.
Please check :ref:`api_ow_config` for more information about other options.
Please check :ref:`api_ow_opt` for more information about other options.

After thread-safety features has been enabled, it is necessary to implement
``4`` low-level system functions.
Expand All @@ -20,7 +20,7 @@ After thread-safety features has been enabled, it is necessary to implement

Example code for ``CMSIS-OS V2``

.. note::
.. note::
Check :ref:`api_ow_sys` section for function description

.. literalinclude:: ../../onewire_uart/src/system/ow_sys_cmsis_os.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* \file ow_config.h
* \brief Configuration for OW
* \file ow_opts.h
* \brief OW application options
*/

/*
Expand Down Expand Up @@ -31,18 +31,18 @@
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.0.0
*/
#ifndef OW_HDR_CONFIG_H
#define OW_HDR_CONFIG_H
#ifndef OW_HDR_OPTS_H
#define OW_HDR_OPTS_H

/* Rename this file to "ow_opts.h" for your application */

#include "cmsis_os.h"

/*
* User specific config which overwrites setup from ow_config_default.h file
* Open "include/ow/ow_opt.h" and
* copy & replace here settings you want to change values
*/
#define OW_CFG_OS 1
#define OW_CFG_OS_MUTEX_HANDLE osMutexId_t

/* Include default configuration setup */
#include "ow/ow_config_default.h"

#endif /* OW_HDR_CONFIG_H */
#endif /* OW_HDR_OPTS_H */
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* \file ow_config.h
* \brief Configuration for OW
* \file ow_opts.h
* \brief OW application options
*/

/*
Expand Down Expand Up @@ -31,16 +31,18 @@
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.0.0
*/
#ifndef OW_HDR_CONFIG_H
#define OW_HDR_CONFIG_H
#ifndef OW_HDR_OPTS_H
#define OW_HDR_OPTS_H

/* Rename this file to "ow_opts.h" for your application */

#include "cmsis_os.h"

/* User specific config which overwrites setup from ow_config_default.h file */
/*
* Open "include/ow/ow_opt.h" and
* copy & replace here settings you want to change values
*/
#define OW_CFG_OS 1
#define OW_CFG_OS_MUTEX_HANDLE osMutexId_t

/* Include default configuration setup */
#include "ow/ow_config_default.h"

#endif /* OW_HDR_CONFIG_H */
#endif /* OW_HDR_OPTS_H */
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* \file ow_config.h
* \brief Configuration for OW
* \file ow_opts.h
* \brief OW application options
*/

/*
Expand Down Expand Up @@ -31,16 +31,18 @@
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.0.0
*/
#ifndef OW_HDR_CONFIG_H
#define OW_HDR_CONFIG_H
#ifndef OW_HDR_OPTS_H
#define OW_HDR_OPTS_H

/* Rename this file to "ow_opts.h" for your application */

#include "cmsis_os.h"

/* User specific config which overwrites setup from ow_config_default.h file */
/*
* Open "include/ow/ow_opt.h" and
* copy & replace here settings you want to change values
*/
#define OW_CFG_OS 1
#define OW_CFG_OS_MUTEX_HANDLE osMutexId_t

/* Include default configuration setup */
#include "ow/ow_config_default.h"

#endif /* OW_HDR_CONFIG_H */
#endif /* OW_HDR_OPTS_H */
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* \file ow_config.h
* \brief Configuration for OW
* \file ow_opts.h
* \brief OW application options
*/

/*
Expand Down Expand Up @@ -31,15 +31,15 @@
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.0.0
*/
#ifndef OW_HDR_CONFIG_H
#define OW_HDR_CONFIG_H
#ifndef OW_HDR_OPTS_H
#define OW_HDR_OPTS_H

/* Rename this file to "ow_opts.h" for your application */

/*
* User specific config which overwrites setup from ow_config_default.h file
* Open "include/ow/ow_opt.h" and
* copy & replace here settings you want to change values
*/
#define OW_CFG_OS 0

/* Include default configuration setup */
#include "ow/ow_config_default.h"

#endif /* OW_HDR_CONFIG_H */
#endif /* OW_HDR_OPTS_H */
2 changes: 1 addition & 1 deletion onewire_uart/src/include/ow/ow.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include <stdint.h>
#include <stddef.h>
#include "ow_config.h"
#include "ow/ow_opt.h"

#ifdef __cplusplus
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* \file ow_config_default.h
* \brief OneWire default config
* \file ow_opt.h
* \brief OneWire options
*/

/*
Expand Down Expand Up @@ -31,16 +31,19 @@
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.0.0
*/
#ifndef OW_HDR_CONFIG_DEFAULT_H
#define OW_HDR_CONFIG_DEFAULT_H
#ifndef OW_HDR_OPT_H
#define OW_HDR_OPT_H

/* Include application options */
#include "ow_opts.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/**
* \defgroup OW_CONFIG Configuration
* \brief Configuration for OneWire library
* \defgroup OW_OPT Configuration
* \brief OW options
* \{
*/

Expand Down Expand Up @@ -72,4 +75,4 @@ extern "C" {
}
#endif /* __cplusplus */

#endif /* OW_HDR_CONFIG_DEFAULT_H */
#endif /* OW_HDR_OPT_H */
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* \file ow_config_template.h
* \file ow_opts_template.h
* \brief OneWire configuration file
*/

Expand Down Expand Up @@ -31,17 +31,14 @@
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v2.0.0
*/
#ifndef OW_HDR_CONFIG_H
#define OW_HDR_CONFIG_H
#ifndef OW_HDR_OPTS_H
#define OW_HDR_OPTS_H

/* Rename this file to "ow_config.h" for your application */
/* Rename this file to "ow_opts.h" for your application */

/*
* Open "include/ow/ow_config_default.h" and
* copy & replace here settings you want to change values
*/

/* After user configuration, call default config to merge config together */
#include "ow/ow_config_default.h"

#endif /* OW_HDR_CONFIG_H */
#endif /* OW_HDR_OPTS_H */
11 changes: 5 additions & 6 deletions onewire_uart/src/ow/ow.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,18 +595,17 @@ ow_skip_rom(ow_t* const ow) {
*/
uint8_t
ow_crc(const void* in, const size_t len) {
size_t i;
uint8_t crc = 0, inbyte, mix;
uint8_t crc = 0;
const uint8_t* d = in;

if (in == NULL || len == 0) {
return 0;
}

for (i = 0; i < len; ++i, ++d) {
inbyte = *d;
for (uint8_t i = 8; i > 0; --i) {
mix = (crc ^ inbyte) & 0x01;
for (size_t i = 0; i < len; ++i, ++d) {
uint8_t inbyte = *d;
for (uint8_t j = 8; j > 0; --j) {
uint8_t mix = (crc ^ inbyte) & 0x01;
crc >>= 1;
if (mix > 0) {
crc ^= 0x8C;
Expand Down

0 comments on commit 71a94fe

Please sign in to comment.