Artemis Teensy Flight Software
The software on the Teensy in the Artemis cubesat.
bytelib.h
1 /********************************************************************
2 * Copyright (C) 2015 by Interstel Technologies, Inc.
3 * and Hawaii Space Flight Laboratory.
4 *
5 * This file is part of the COSMOS/core that is the central
6 * module for COSMOS. For more information on COSMOS go to
7 * <http://cosmos-project.com>
8 *
9 * The COSMOS/core software is licenced under the
10 * GNU Lesser General Public License (LGPL) version 3 licence.
11 *
12 * You should have received a copy of the
13 * GNU Lesser General Public License
14 * If not, go to <http://www.gnu.org/licenses/>
15 *
16 * COSMOS/core is free software: you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public License
18 * as published by the Free Software Foundation, either version 3 of
19 * the License, or (at your option) any later version.
20 *
21 * COSMOS/core is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * Refer to the "licences" folder for further information on the
27 * condititons and terms to use this software.
28 ********************************************************************/
29 
30 #ifndef _BYTELIB_H
31 #define _BYTELIB_H
32 
33 #include <vector>
34 #include "math/constants.h"
35 
36 ByteOrder local_byte_order();
37 
38 #if ((SIZE_WIDTH) == (UINT64_WIDTH))
39 uint64_t uintswap(uint8_t bits, uint64_t value, ByteOrder order=ByteOrder::LITTLEENDIAN);
40 #else
41 size_t uintswap(uint8_t bits, size_t value, ByteOrder order=ByteOrder::LITTLEENDIAN);
42 #endif
43 uint8_t uint8from(const uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
44 uint8_t uint8to(const uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
45 void uint8from(const vector<uint8_t> &src, vector<uint8_t> &dst, ByteOrder order=ByteOrder::LITTLEENDIAN);
46 void uint8to(const vector<uint8_t> &src, vector<uint8_t> dst, ByteOrder order=ByteOrder::LITTLEENDIAN);
47 uint16_t uint16from(uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
48 int16_t int16from(uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
49 uint32_t uint32from(const uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
50 int32_t int32from(uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
51 float floatfrom(uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
52 double doublefrom(uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
53 void uint32to(uint32_t value, uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
54 void int32to(int32_t value, uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
55 void uint16to(uint16_t value, uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
56 void int16to(int16_t value, uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
57 void floatto(float value, uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
58 void doubleto(double value, uint8_t *pointer, ByteOrder order=ByteOrder::LITTLEENDIAN);
59 vector<uint8_t> vector8invert(uint8_t* data, uint32_t count);
60 
61 
62 #endif
ByteOrder
Enumeration of possible byte orders.
Definition: constants.h:48
@ LITTLEENDIAN
Little Endian byte order.