root / proj / libs / utils / include / utils.h @ 324
History | View | Annotate | Download (2.21 KB)
1 |
#ifndef UTILS_H_INCLUDED
|
---|---|
2 |
#define UTILS_H_INCLUDED
|
3 |
|
4 |
#define BCD_FIRST(n) (n >> 4) /** @brief Get first digit (leftmost digit) of 8-bit BCD */ |
5 |
#define BCD_SECOND(n) (n & 0x0F) /** @brief Get second digit (rightmost digit) of 8-bit BCD */ |
6 |
|
7 |
/**
|
8 |
* @brief Gets the least significant byte of a 16-bit variable
|
9 |
* @param val 16-bit variable
|
10 |
* @param lsb Pointer to a 8-bit variable to store the value of the LSB
|
11 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
12 |
*/
|
13 |
int(util_get_LSB)(uint16_t val, uint8_t *lsb);
|
14 |
|
15 |
/**
|
16 |
* @brief Gets the most significant byte of a 16-bit variable
|
17 |
* @param val 16-bit variable
|
18 |
* @param msb Pointer to a 8-bit variable to store the value of the MSB
|
19 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
20 |
*/
|
21 |
int(util_get_MSB)(uint16_t val, uint8_t *msb);
|
22 |
|
23 |
/**
|
24 |
* @brief sys_inb wrapper
|
25 |
* @param port Port to read from
|
26 |
* @param value Pointer to byte to store value read
|
27 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
28 |
*/
|
29 |
int (util_sys_inb)(int port, uint8_t *value); |
30 |
|
31 |
/**
|
32 |
* @brief Unsubcribes Interrupts
|
33 |
* @param interrupt_id Interrupt ID, value via arguments on subscription of the interrupt_id
|
34 |
* @see subscribe_kbc_interrupt, subscribe_timer_interrupt
|
35 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
36 |
*/
|
37 |
int (unsubscribe_interrupt)(int *interrupt_id); |
38 |
|
39 |
/**
|
40 |
* @brief Gets the minimum value out of two values.
|
41 |
* @param a First value
|
42 |
* @param b Second value
|
43 |
* @return The minimum of the two values
|
44 |
*/
|
45 |
int16_t min16(int16_t a, int16_t b); |
46 |
uint16_t umin16(uint16_t a, uint16_t b); |
47 |
int32_t min32(int32_t a, int32_t b); |
48 |
double dmin (double a, double b); |
49 |
|
50 |
/**
|
51 |
* @brief Gets the maximum value out of two values.
|
52 |
* @param a First value
|
53 |
* @param b Second value
|
54 |
* @return The maximum of the two values
|
55 |
*/
|
56 |
int16_t max16(int16_t a, int16_t b); |
57 |
uint16_t umax16(uint16_t a, uint16_t b); |
58 |
int32_t max32(int32_t a, int32_t b); |
59 |
double dmax (double a, double b); |
60 |
|
61 |
double dabs(double a); |
62 |
|
63 |
int deq(double a, double b); |
64 |
|
65 |
#endif //UTILS_H_INCLUDED |