Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Thu Oct 11 02:27:46 2018 +0000
Revision:
3:f3764f852aa8
Parent:
0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 /* mbed Microcontroller Library
kadonotakashi 0:8fdf9a60065b 2 * Copyright (c) 2015-2016 Nuvoton
kadonotakashi 0:8fdf9a60065b 3 *
kadonotakashi 0:8fdf9a60065b 4 * Licensed under the Apache License, Version 2.0 (the "License");
kadonotakashi 0:8fdf9a60065b 5 * you may not use this file except in compliance with the License.
kadonotakashi 0:8fdf9a60065b 6 * You may obtain a copy of the License at
kadonotakashi 0:8fdf9a60065b 7 *
kadonotakashi 0:8fdf9a60065b 8 * http://www.apache.org/licenses/LICENSE-2.0
kadonotakashi 0:8fdf9a60065b 9 *
kadonotakashi 0:8fdf9a60065b 10 * Unless required by applicable law or agreed to in writing, software
kadonotakashi 0:8fdf9a60065b 11 * distributed under the License is distributed on an "AS IS" BASIS,
kadonotakashi 0:8fdf9a60065b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kadonotakashi 0:8fdf9a60065b 13 * See the License for the specific language governing permissions and
kadonotakashi 0:8fdf9a60065b 14 * limitations under the License.
kadonotakashi 0:8fdf9a60065b 15 */
kadonotakashi 0:8fdf9a60065b 16
kadonotakashi 0:8fdf9a60065b 17 #ifndef NU_BIT_UTIL_H
kadonotakashi 0:8fdf9a60065b 18 #define NU_BIT_UTIL_H
kadonotakashi 0:8fdf9a60065b 19
kadonotakashi 0:8fdf9a60065b 20 #if defined(__ICCARM__) && ( defined(__CORTEX_M0) || defined(__CORTEX_M0P) || defined(__CORTEX_M23))
kadonotakashi 0:8fdf9a60065b 21 #include <arm_math.h>
kadonotakashi 0:8fdf9a60065b 22 #endif
kadonotakashi 0:8fdf9a60065b 23 #include "cmsis.h"
kadonotakashi 0:8fdf9a60065b 24
kadonotakashi 0:8fdf9a60065b 25 #ifdef __cplusplus
kadonotakashi 0:8fdf9a60065b 26 extern "C" {
kadonotakashi 0:8fdf9a60065b 27 #endif
kadonotakashi 0:8fdf9a60065b 28
kadonotakashi 0:8fdf9a60065b 29 __STATIC_INLINE int nu_clz(uint32_t x)
kadonotakashi 0:8fdf9a60065b 30 {
kadonotakashi 0:8fdf9a60065b 31 return __CLZ(x);
kadonotakashi 0:8fdf9a60065b 32 }
kadonotakashi 0:8fdf9a60065b 33
kadonotakashi 0:8fdf9a60065b 34 __STATIC_INLINE int nu_clo(uint32_t x)
kadonotakashi 0:8fdf9a60065b 35 {
kadonotakashi 0:8fdf9a60065b 36 return nu_clz(~x);
kadonotakashi 0:8fdf9a60065b 37 }
kadonotakashi 0:8fdf9a60065b 38
kadonotakashi 0:8fdf9a60065b 39 __STATIC_INLINE int nu_ctz(uint32_t x)
kadonotakashi 0:8fdf9a60065b 40 {
kadonotakashi 0:8fdf9a60065b 41 int c = __CLZ(x & -x);
kadonotakashi 0:8fdf9a60065b 42 return x ? 31 - c : c;
kadonotakashi 0:8fdf9a60065b 43 }
kadonotakashi 0:8fdf9a60065b 44
kadonotakashi 0:8fdf9a60065b 45 __STATIC_INLINE int nu_cto(uint32_t x)
kadonotakashi 0:8fdf9a60065b 46 {
kadonotakashi 0:8fdf9a60065b 47 return nu_ctz(~x);
kadonotakashi 0:8fdf9a60065b 48 }
kadonotakashi 0:8fdf9a60065b 49
kadonotakashi 0:8fdf9a60065b 50
kadonotakashi 0:8fdf9a60065b 51 __STATIC_INLINE uint16_t nu_get16_le(const uint8_t *pos)
kadonotakashi 0:8fdf9a60065b 52 {
kadonotakashi 0:8fdf9a60065b 53 uint16_t val;
kadonotakashi 0:8fdf9a60065b 54
kadonotakashi 0:8fdf9a60065b 55 val = *pos ++;
kadonotakashi 0:8fdf9a60065b 56 val += (*pos << 8);
kadonotakashi 0:8fdf9a60065b 57
kadonotakashi 0:8fdf9a60065b 58 return val;
kadonotakashi 0:8fdf9a60065b 59 }
kadonotakashi 0:8fdf9a60065b 60
kadonotakashi 0:8fdf9a60065b 61 __STATIC_INLINE void nu_set16_le(uint8_t *pos, uint16_t val)
kadonotakashi 0:8fdf9a60065b 62 {
kadonotakashi 0:8fdf9a60065b 63 *pos ++ = val & 0xFF;
kadonotakashi 0:8fdf9a60065b 64 *pos = val >> 8;
kadonotakashi 0:8fdf9a60065b 65 }
kadonotakashi 0:8fdf9a60065b 66
kadonotakashi 0:8fdf9a60065b 67 __STATIC_INLINE uint32_t nu_get32_le(const uint8_t *pos)
kadonotakashi 0:8fdf9a60065b 68 {
kadonotakashi 0:8fdf9a60065b 69 uint32_t val;
kadonotakashi 0:8fdf9a60065b 70
kadonotakashi 0:8fdf9a60065b 71 val = *pos ++;
kadonotakashi 0:8fdf9a60065b 72 val += (*pos ++ << 8);
kadonotakashi 0:8fdf9a60065b 73 val += (*pos ++ << 16);
kadonotakashi 0:8fdf9a60065b 74 val += (*pos ++ << 24);
kadonotakashi 0:8fdf9a60065b 75
kadonotakashi 0:8fdf9a60065b 76 return val;
kadonotakashi 0:8fdf9a60065b 77 }
kadonotakashi 0:8fdf9a60065b 78
kadonotakashi 0:8fdf9a60065b 79 __STATIC_INLINE void nu_set32_le(uint8_t *pos, uint32_t val)
kadonotakashi 0:8fdf9a60065b 80 {
kadonotakashi 0:8fdf9a60065b 81 *pos ++ = val & 0xFF;
kadonotakashi 0:8fdf9a60065b 82 *pos ++ = (val >> 8) & 0xFF;
kadonotakashi 0:8fdf9a60065b 83 *pos ++ = (val >> 16) & 0xFF;
kadonotakashi 0:8fdf9a60065b 84 *pos = (val >> 24) & 0xFF;
kadonotakashi 0:8fdf9a60065b 85 }
kadonotakashi 0:8fdf9a60065b 86
kadonotakashi 0:8fdf9a60065b 87 __STATIC_INLINE uint16_t nu_get16_be(const uint8_t *pos)
kadonotakashi 0:8fdf9a60065b 88 {
kadonotakashi 0:8fdf9a60065b 89 uint16_t val;
kadonotakashi 0:8fdf9a60065b 90
kadonotakashi 0:8fdf9a60065b 91 val = *pos ++;
kadonotakashi 0:8fdf9a60065b 92 val <<= 8;
kadonotakashi 0:8fdf9a60065b 93 val += *pos;
kadonotakashi 0:8fdf9a60065b 94
kadonotakashi 0:8fdf9a60065b 95 return val;
kadonotakashi 0:8fdf9a60065b 96 }
kadonotakashi 0:8fdf9a60065b 97
kadonotakashi 0:8fdf9a60065b 98 __STATIC_INLINE void nu_set16_be(uint8_t *pos, uint16_t val)
kadonotakashi 0:8fdf9a60065b 99 {
kadonotakashi 0:8fdf9a60065b 100 *pos ++ = val >> 8;
kadonotakashi 0:8fdf9a60065b 101 *pos = (val & 0xFF);
kadonotakashi 0:8fdf9a60065b 102 }
kadonotakashi 0:8fdf9a60065b 103
kadonotakashi 0:8fdf9a60065b 104 __STATIC_INLINE uint32_t nu_get32_be(const uint8_t *pos)
kadonotakashi 0:8fdf9a60065b 105 {
kadonotakashi 0:8fdf9a60065b 106 uint32_t val;
kadonotakashi 0:8fdf9a60065b 107
kadonotakashi 0:8fdf9a60065b 108 val = *pos ++;
kadonotakashi 0:8fdf9a60065b 109 val <<= 8;
kadonotakashi 0:8fdf9a60065b 110 val += *pos ++;
kadonotakashi 0:8fdf9a60065b 111 val <<= 8;
kadonotakashi 0:8fdf9a60065b 112 val += *pos ++;
kadonotakashi 0:8fdf9a60065b 113 val <<= 8;
kadonotakashi 0:8fdf9a60065b 114 val += *pos;
kadonotakashi 0:8fdf9a60065b 115
kadonotakashi 0:8fdf9a60065b 116 return val;
kadonotakashi 0:8fdf9a60065b 117 }
kadonotakashi 0:8fdf9a60065b 118
kadonotakashi 0:8fdf9a60065b 119 __STATIC_INLINE void nu_set32_be(uint8_t *pos, uint32_t val)
kadonotakashi 0:8fdf9a60065b 120 {
kadonotakashi 0:8fdf9a60065b 121 *pos ++ = val >> 24;
kadonotakashi 0:8fdf9a60065b 122 *pos ++ = val >> 16;
kadonotakashi 0:8fdf9a60065b 123 *pos ++ = val >> 8;
kadonotakashi 0:8fdf9a60065b 124 *pos ++ = (val & 0xFF);
kadonotakashi 0:8fdf9a60065b 125 }
kadonotakashi 0:8fdf9a60065b 126
kadonotakashi 0:8fdf9a60065b 127 #ifdef __cplusplus
kadonotakashi 0:8fdf9a60065b 128 }
kadonotakashi 0:8fdf9a60065b 129 #endif
kadonotakashi 0:8fdf9a60065b 130
kadonotakashi 0:8fdf9a60065b 131 #endif