|  | Dual Active Bridge Development Board (Part-No. ) |
Content |  |  |  |  |  |

Loading...
Searching...
No Matches
Useful Macros
Configuration Layer

Collection of macros that the user can utilize when converting physical quantities of parameters into binary (integer) numbers for registers and variables. More...

Collaboration diagram for Useful Macros:

#define | _rnd(a) ((int16_t)((a)+((a)<0?-0.5:0.5)))
#define | _min(a, b) (((a)>(b)) ? (b):(a))
#define | _max(a, b) (((a)>(b)) ? (a):(b))
#define | _rnd_int32_t(a) ((int32_t)((a)+((a)<0?-0.5:0.5)))
#define | WordLowByte(word) ((uint8_t) (word & 0x00FF))
#define | WordHighByte(word) ((uint8_t) (word >> 8))
#define | QFORMAT_SHIFT(value)
#define | TIME_TO_TICKS(time, tick_period) (_rnd(time/tick_period))
#define | RMS_TO_PEAK (1.414213562)
#define | AVG_TO_RMS (1.11)
#define | RMS_TO_AVG (1.0/AVG_TO_RMS)
#define | PWM_HR_EDGE_ALIGNED_PGxPER(freq_hz) ((uint16_t)(_rnd_int32_t((8.0*500.0e+6)/(float)freq_hz)-8.0))
#define | PWM_HR_EDGE_ALIGNED_PGxDC(PGxPER, duty_percent) ((uint16_t)(_rnd_int32_t((PGxPER+8)*(duty_percent/100.0))))
#define | PWM_HR_PGxTRIGy(trigger_offset) ((uint16_t)(_rnd_int32_t(8.0*500.0e+6*trigger_offset)))
#define | PWM_HR_PGxDTy(dead_time) ((uint16_t)(_rnd_int32_t(8.0*500.0e+6*dead_time)))
#define | UNITS_FROM_ENG_TO_ADC(threshold, gain, offset) (_rnd((((float)threshold*(float)gain) + (float)offset)/3.3*4095.0))
#define | UNITS_FROM_ADC_TO_ENG(AdcValue, Gain) (_rnd((((float)AdcValue /(float)Gain))/4095.0 * 3.3))

## Detailed Description

Collection of macros that the user can utilize when converting physical quantities of parameters into binary (integer) numbers for registers and variables.

## Macro Definition Documentation

## ◆ _max

#define _max | ( |  | a,
|  |  | b
| ) |  | (((a)>(b)) ? (a):(b))

Definition at line 15 of file useful_macros.h.

## ◆ _min

#define _min | ( |  | a,
|  |  | b
| ) |  | (((a)>(b)) ? (b):(a))

Definition at line 14 of file useful_macros.h.

## ◆ _rnd

#define _rnd | ( |  | a | ) | ((int16_t)((a)+((a)<0?-0.5:0.5)))

Definition at line 13 of file useful_macros.h.

## ◆ _rnd_int32_t

#define _rnd_int32_t | ( |  | a | ) | ((int32_t)((a)+((a)<0?-0.5:0.5)))

Definition at line 17 of file useful_macros.h.

## ◆ AVG_TO_RMS

#define AVG_TO_RMS (1.11)

Definition at line 48 of file useful_macros.h.

## ◆ PWM_HR_EDGE_ALIGNED_PGxDC

#define PWM_HR_EDGE_ALIGNED_PGxDC | ( |  | PGxPER,
|  |  | duty_percent
| ) |  | ((uint16_t)(_rnd_int32_t((PGxPER+8)*(duty_percent/100.0))))

Definition at line 59 of file useful_macros.h.

## ◆ PWM_HR_EDGE_ALIGNED_PGxPER

#define PWM_HR_EDGE_ALIGNED_PGxPER | ( |  | freq_hz | ) | ((uint16_t)(_rnd_int32_t((8.0*500.0e+6)/(float)freq_hz)-8.0))

Definition at line 55 of file useful_macros.h.

## ◆ PWM_HR_PGxDTy

#define PWM_HR_PGxDTy | ( |  | dead_time | ) | ((uint16_t)(_rnd_int32_t(8.0*500.0e+6*dead_time)))

Definition at line 65 of file useful_macros.h.

## ◆ PWM_HR_PGxTRIGy

#define PWM_HR_PGxTRIGy | ( |  | trigger_offset | ) | ((uint16_t)(_rnd_int32_t(8.0*500.0e+6*trigger_offset)))

Definition at line 62 of file useful_macros.h.

## ◆ QFORMAT_SHIFT

#define QFORMAT_SHIFT | ( |  | value | ) |

Value:
((value) < ((float)(1<<0)) ? (15) : \
((value) < ((float)(1<<1)) ? (14) : \
((value) < ((float)(1<<2)) ? (13) : \
((value) < ((float)(1<<3)) ? (12) : \
((value) < ((float)(1<<4)) ? (11) : \
((value) < ((float)(1<<5)) ? (10) : \
((value) < ((float)(1<<6)) ? (9) : \
((value) < ((float)(1<<7)) ? (8) : \
((value) < ((float)(1<<8)) ? (7) : \
((value) < ((float)(1<<9)) ? (6) : \
((value) < ((float)(1<<10)) ? (5) : \
((value) < ((float)(1<<11)) ? (4) : \
((value) < ((float)(1<<13)) ? (3) : \
((value) < ((float)(1<<13)) ? (2) : \
((value) < ((float)(1<<14)) ? (1) : (0))))))))))))))))

Definition at line 25 of file useful_macros.h.

## ◆ RMS_TO_AVG

#define RMS_TO_AVG (1.0/AVG_TO_RMS)

Definition at line 50 of file useful_macros.h.

## ◆ RMS_TO_PEAK

#define RMS_TO_PEAK (1.414213562)

Definition at line 45 of file useful_macros.h.

## ◆ TIME_TO_TICKS

#define TIME_TO_TICKS | ( |  | time,
|  |  | tick_period
| ) |  | (_rnd(time/tick_period))

Definition at line 42 of file useful_macros.h.

## ◆ UNITS_FROM_ADC_TO_ENG

#define UNITS_FROM_ADC_TO_ENG | ( |  | AdcValue,
|  |  | Gain
| ) |  | (_rnd((((float)AdcValue /(float)Gain))/4095.0 * 3.3))

Definition at line 72 of file useful_macros.h.

## ◆ UNITS_FROM_ENG_TO_ADC

#define UNITS_FROM_ENG_TO_ADC | ( |  | threshold,
|  |  | gain,
|  |  | offset
| ) |  | (_rnd((((float)threshold*(float)gain) + (float)offset)/3.3*4095.0))

Definition at line 70 of file useful_macros.h.

## ◆ WordHighByte

#define WordHighByte | ( |  | word | ) | ((uint8_t) (word >> 8))

Definition at line 21 of file useful_macros.h.

## ◆ WordLowByte

#define WordLowByte | ( |  | word | ) | ((uint8_t) (word & 0x00FF))

Definition at line 20 of file useful_macros.h.