In `dac_util_map(...)` the expression `((value - min) * UINT16_MAX)` was
cast to a 16 bit unsigned, then divided by `(max - min)`. This means
that anytime `(value - min) != 0` the numerator was truncated prior to
being divided and then returned.
This patch modifies the expression so that the downcast to 16 bits is
performed as the last operation.
Change the API to use int32_t instead of int, to allow for greater
flexibility on 8- and 16-bit platforms. Removed limitation on input
arguments that min < max. Times where it can be useful to have min > max
is when measuring a sensor where a higher measured voltage means a lower
physical value. For example a thermistor can be connected so that the
measured voltage goes down when the temperature goes up.