aboutsummaryrefslogtreecommitdiffstats
path: root/os/various
diff options
context:
space:
mode:
authorStephane D'Alu <sdalu@sdalu.com>2016-02-15 21:42:16 +0100
committerStephane D'Alu <sdalu@sdalu.com>2016-02-15 21:42:16 +0100
commit7b5ddf1928e900fc0a0647e24cc0d4b8c49c1f42 (patch)
tree318e0a2a75c6d060ca9c777084fff6e373b9efb4 /os/various
parent260a9edc325b2083901aa591874aa50bd0e5be25 (diff)
downloadChibiOS-Contrib-7b5ddf1928e900fc0a0647e24cc0d4b8c49c1f42.tar.gz
ChibiOS-Contrib-7b5ddf1928e900fc0a0647e24cc0d4b8c49c1f42.tar.bz2
ChibiOS-Contrib-7b5ddf1928e900fc0a0647e24cc0d4b8c49c1f42.zip
included copyright
Diffstat (limited to 'os/various')
-rw-r--r--os/various/bswap.h29
-rw-r--r--os/various/i2c_helpers.h16
2 files changed, 39 insertions, 6 deletions
diff --git a/os/various/bswap.h b/os/various/bswap.h
index b99034e..30ae1d6 100644
--- a/os/various/bswap.h
+++ b/os/various/bswap.h
@@ -1,3 +1,19 @@
+/*
+ Copyright (C) 2016 Stephane D'Alu
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
#ifndef BSWAP_H
#define BSWAP_H
@@ -6,16 +22,17 @@ extern "C" {
#endif
#if !(defined(ARCH_BIG_ENDIAN) || defined(ARCH_LITTLE_ENDIAN))
-#error "ARCH_BIG_ENDIAN or ARCH_LITTLE_ENDIAN not set."
+#error "Need to define one: ARCH_BIG_ENDIAN or ARCH_LITTLE_ENDIAN"
#endif
#if defined(ARCH_BIG_ENDIAN) && defined(ARCH_LITTLE_ENDIAN)
-#error "ARCH_BIG_ENDIAN and ARCH_LITTLE_ENDIAN are both set."
+#error "ARCH_BIG_ENDIAN and ARCH_LITTLE_ENDIAN are both set"
#endif
#define BSWAP_16(x) \
- (uint16_t)((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
+ (uint16_t)((((x) & 0xFF00) >> 8) | \
+ (((x) & 0x00FF) << 8))
#define BSWAP_32(x) \
(uint32_t)((((x) & 0xFF000000UL) >> 24UL) | \
(((x) & 0x00FF0000UL) >> 8UL) | \
@@ -61,7 +78,7 @@ extern "C" {
#define CPU_TO_BE16(x) BSWAP_16(x)
#define CPU_TO_BE32(x) BSWAP_32(x)
#endif
-
+
static inline uint16_t bswap_16(const uint16_t x)
__attribute__ ((warn_unused_result))
@@ -114,8 +131,8 @@ static inline void bswap_n(void* const data, uint8_t len) {
uint8_t* ptr = (uint8_t*)data;
for ( ; len > 1 ; ptr++, len -= 2 ) {
- uint8_t tmp = *ptr;
- *ptr = *(ptr + len - 1);
+ uint8_t tmp = *ptr;
+ *ptr = *(ptr + len - 1);
*(ptr + len - 1) = tmp;
}
}
diff --git a/os/various/i2c_helpers.h b/os/various/i2c_helpers.h
index 56f9be6..4b57174 100644
--- a/os/various/i2c_helpers.h
+++ b/os/various/i2c_helpers.h
@@ -1,3 +1,19 @@
+/*
+ Copyright (C) 2016 Stephane D'Alu
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
#ifndef I2C_HELPERS_H
#define I2C_HELPERS_H