You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
526 B
32 lines
526 B
/** |
|
* @copyright Copyright (c) 2021 Sagetech, Inc. All rights reserved. |
|
* |
|
* @file float2Buf.c |
|
* @author Jacob.Garrison |
|
* |
|
* @date Mar 2, 2021 |
|
* |
|
*/ |
|
|
|
#include "sgUtil.h" |
|
|
|
/* |
|
* Documented in the header file. |
|
*/ |
|
void float2Buf(uint8_t *bufferPos, float value) |
|
{ |
|
const uint16_t FLOAT_SIZE = 4; |
|
|
|
union |
|
{ |
|
float val; |
|
unsigned char bytes[FLOAT_SIZE]; |
|
} conversion; |
|
|
|
conversion.val = value; |
|
|
|
for (int i = 0; i < FLOAT_SIZE; ++i) |
|
{ |
|
bufferPos[i] = conversion.bytes[i]; |
|
} |
|
}
|
|
|