|
embclib
0.1
|
helper function More...
#include "stdint.h"
Go to the source code of this file.
Macros | |
| #define | __UTILS_VERSION (0x0001u) |
| Source file version tag. More... | |
| #define | Min(a, b) (((a) < (b)) ? (a) : (b)) |
| Find the smaller value. More... | |
| #define | Max(a, b) (((a) > (b)) ? (a) : (b)) |
| Find the greater value. More... | |
| #define | Abs(n) ((n < 0) ? (-n) : (n)) |
| convert negative value to non-negative value More... | |
| #define | Pow2(x) (1 << (x)) |
| Find the power of 2 of given value. More... | |
| #define | Swap(a, b) ((a) ^= (b) ^= (a) ^= (b)) |
| Swap/Exchange between the two values. More... | |
| #define | Limit(val, min, max) (Min( Max(val, (min) ), (max) )) |
| Limit value between maximum and minimum range. More... | |
Functions | |
| int16_t | UTILS_Rand_i16 (int16_t min_i16, int16_t max_i16) |
| Generate the random value between range. More... | |
| void | UTILS_RandSeed (uint16_t seed_i16) |
| Initialize the value to random number generator. More... | |
| int16_t | UTILS_Scale_i16 (int16_t in_value_i16, int16_t in_min_i16, int16_t in_max_i16, int16_t out_min_i16, int16_t out_max_i16) |
| Scale a number from one range to another. More... | |
helper function
| #define __UTILS_VERSION (0x0001u) |
Source file version tag.
version info: [15:8] main [7:0] beta
version: 0.1v
| #define Abs | ( | n | ) | ((n < 0) ? (-n) : (n)) |
convert negative value to non-negative value
Limit value between maximum and minimum range.
| #define Max | ( | a, | |
| b | |||
| ) | (((a) > (b)) ? (a) : (b)) |
Find the greater value.
| #define Min | ( | a, | |
| b | |||
| ) | (((a) < (b)) ? (a) : (b)) |
Find the smaller value.
| #define Pow2 | ( | x | ) | (1 << (x)) |
Find the power of 2 of given value.
| #define Swap | ( | a, | |
| b | |||
| ) | ((a) ^= (b) ^= (a) ^= (b)) |
Swap/Exchange between the two values.
Generate the random value between range.
| min_i16 | [in] Minimum limit of random number |
| max_i16 | [in] Maximum limit of random number |
| void UTILS_RandSeed | ( | uint16_t | seed_i16 | ) |
Initialize the value to random number generator.
| seed_i16 | initialize value |
| int16_t UTILS_Scale_i16 | ( | int16_t | in_value_i16, |
| int16_t | in_min_i16, | ||
| int16_t | in_max_i16, | ||
| int16_t | out_min_i16, | ||
| int16_t | out_max_i16 | ||
| ) |
Scale a number from one range to another.
| in_value_i16 | [in] Scaling value |
| in_min_i16 | [in] From range minimum value |
| in_max_i16 | [in] From range maximum value |
| out_min_i16 | [in] To range minimum value |
| out_max_i16 | [in] To range maximum value |
1.8.15