diff options
Diffstat (limited to 'os')
-rw-r--r-- | os/various/bswap.h | 29 | ||||
-rw-r--r-- | os/various/i2c_helpers.h | 16 |
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 |