Jens Altenburg
/
Fachbuch_Initialisierungen
Initialisation Nucleo-F446 by Jens Altenburg
Revision 0:9b6fbe273511, committed 2021-03-17
- Comitter:
- prof_al
- Date:
- Wed Mar 17 13:55:03 2021 +0000
- Commit message:
- Hardware Abstraction Layer (HAL) Nucleo-F446
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/font6_8.h Wed Mar 17 13:55:03 2021 +0000 @@ -0,0 +1,118 @@ +/** + * SSD1306xLED - Library for the SSD1306 based OLED/PLED 128x64 displays + * + * @author Neven Boyanov + * + * This is part of the Tinusaur/SSD1306xLED project. + * + * Copyright (c) 2018 Neven Boyanov, The Tinusaur Team. All Rights Reserved. + * Distributed as open source software under MIT License, see LICENSE.txt file. + * Retain in your source code the link http://tinusaur.org to the Tinusaur project. + * + * Source code available at: https://bitbucket.org/tinusaur/ssd1306xled + * + */ + +// ============================================================================ + +#include "main.h" + +// ---------------------------------------------------------------------------- + +/* Standard ASCII 6x8 font */ +const byte ssd1306xled_font6x8data[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sp + 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // ! + 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, // " + 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14, // # + 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12, // $ + 0x00, 0x62, 0x64, 0x08, 0x13, 0x23, // % + 0x00, 0x36, 0x49, 0x55, 0x22, 0x50, // & + 0x00, 0x00, 0x05, 0x03, 0x00, 0x00, // ' + 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00, // ( + 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00, // ) + 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14, // * + 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, // + + 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00, // , + 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, // - + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, // . + 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, // / + 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0 + 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, // 1 + 0x00, 0x42, 0x61, 0x51, 0x49, 0x46, // 2 + 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31, // 3 + 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, // 4 + 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, // 5 + 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, // 6 + 0x00, 0x01, 0x71, 0x09, 0x05, 0x03, // 7 + 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, // 8 + 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, // 9 + 0x00, 0x00, 0x36, 0x36, 0x00, 0x00, // : + 0x00, 0x00, 0x56, 0x36, 0x00, 0x00, // ; + 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, // < + 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, // = + 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, // > + 0x00, 0x02, 0x01, 0x51, 0x09, 0x06, // ? + 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E, // @ + 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, // A + 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, // B + 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, // C + 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C, // D + 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, // E + 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, // F + 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A, // G + 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, // H + 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, // I + 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, // J + 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, // K + 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, // L + 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F, // M + 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, // N + 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, // O + 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, // P + 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, // Q + 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, // R + 0x00, 0x46, 0x49, 0x49, 0x49, 0x31, // S + 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, // T + 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, // U + 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, // V + 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, // W + 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, // X + 0x00, 0x07, 0x08, 0x70, 0x08, 0x07, // Y + 0x00, 0x61, 0x51, 0x49, 0x45, 0x43, // Z + 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, // [ + 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55, // 55 + 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00, // ] + 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, // ^ + 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, // _ + 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, // ' + 0x00, 0x20, 0x54, 0x54, 0x54, 0x78, // a + 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38, // b + 0x00, 0x38, 0x44, 0x44, 0x44, 0x20, // c + 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F, // d + 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, // e + 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02, // f + 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C, // g + 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, // h + 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, // i + 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00, // j + 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, // k + 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, // l + 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, // m + 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, // n + 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, // o + 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18, // p + 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, // q + 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, // r + 0x00, 0x48, 0x54, 0x54, 0x54, 0x20, // s + 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20, // t + 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, // u + 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, // v + 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, // w + 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, // x + 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, // y + 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, // z + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, // horiz lines +}; + +// ============================================================================ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/font8_16.h Wed Mar 17 13:55:03 2021 +0000 @@ -0,0 +1,122 @@ +/** + * SSD1306xLED - Library for the SSD1306 based OLED/PLED 128x64 displays + * + * @author Neven Boyanov + * + * This is part of the Tinusaur/SSD1306xLED project. + * + * Copyright (c) 2018 Neven Boyanov, The Tinusaur Team. All Rights Reserved. + * Distributed as open source software under MIT License, see LICENSE.txt file. + * Retain in your source code the link http://tinusaur.org to the Tinusaur project. + * + * Source code available at: https://bitbucket.org/tinusaur/ssd1306xled + * + */ + +// ============================================================================ + +#include "main.h" + +// ---------------------------------------------------------------------------- + +/* Standard ASCII 8x16 font */ +const byte ssd1306xled_font8x16data[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 0 + //0xf0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00, // 0 + 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00, // ! 1 + 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // " 2 + 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00, // # 3 + 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00, // $ 4 + 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00, // % 5 + 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10, // & 6 + 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ' 7 + 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00, // ( 8 + 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00, // ) 9 + 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00, // * 10 + 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00, // + 11 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00, // , 12 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01, // - 13 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00, // . 14 + 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00, // / 15 + 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, // 0 16 + 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // 1 17 + 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, // 2 18 + 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00, // 3 19 + 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00, // 4 20 + 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00, // 5 21 + 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00, // 6 22 + 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, // 7 23 + 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00, // 8 24 + 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00, // 9 25 + 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, // : 26 + 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00, // ; 27 + 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00, // < 28 + 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00, // = 29 + 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00, // > 30 + 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00, // ? 31 + 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00, // @ 32 + 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20, // A 33 + 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00, // B 34 + 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00, // C 35 + 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00, // D 36 + 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00, // E 37 + 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00, // F 38 + 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00, // G 39 + 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20, // H 40 + 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // I 41 + 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00, // J 42 + 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00, // K 43 + 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00, // L 44 + 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00, // M 45 + 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00, // N 46 + 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00, // O 47 + 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00, // P 48 + 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00, // Q 49 + 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20, // R 50 + 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00, // S 51 + 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00, // T 52 + 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00, // U 53 + 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00, // V 54 + 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00, // W 55 + 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20, // X 56 + 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00, // Y 57 + 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00, // Z 58 + 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00, // [ 59 + 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00, // \ 60 + 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00, // ] 61 + 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ^ 62 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, // _ 63 + 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ` 64 + 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20, // a 65 + 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00, // b 66 + 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00, // c 67 + 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20, // d 68 + 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00, // e 69 + 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // f 70 + 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00, // g 71 + 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, // h 72 + 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // i 73 + 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00, // j 74 + 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00, // k 75 + 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // l 76 + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F, // m 77 + 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, // n 78 + 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00, // o 79 + 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00, // p 80 + 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80, // q 81 + 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00, // r 82 + 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00, // s 83 + 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00, // t 84 + 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20, // u 85 + 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00, // v 86 + 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00, // w 87 + 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00, // x 88 + 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00, // y 89 + 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00, // z 90 + 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40, // { 91 + 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00, // | 92 + 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00, // } 93 + 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ~ 94 +}; + +// ============================================================================ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/i2c.cpp Wed Mar 17 13:55:03 2021 +0000 @@ -0,0 +1,233 @@ +#if 0 + +/*************************************************************************** +* Titel : I2C.C +* +* Beschreibung : IIC - Interface +* +* Kategorie : +* +* Verantwortlich : Jens Altenburg +* +* Modulhistory : +* + ---------------------------------------------------------------------------- + Date | Author | Change + ---------------------------------------------------------------------------- + 28.09.03 | J. Altenburg | Ersterstellung + ---------------------------------------------------------------------------- + +****************************************************************************/ + +/*************************************************************************** +* HEADER-FILES (Only those that are needed in this file) +****************************************************************************/ +/* Own headerfiles */ +#include "i2c.h" /* */ + + + +/*************************************************************************** +* FILE LOCAL DEFINITIONS +* +* In this section define +* - all file local macros +* - all file local define-constants +* - all file local ROM-constants (static) +* - all file local type definitions +* - all file local variables (static) +****************************************************************************/ +#define nShortDelay 20 /* Verzögerungszeit für I2C */ + + +/*************************************************************************** +* Variablendefinitionen +****************************************************************************/ + + +/*************************************************************************** +* Definition der einzelnen I2C-Befehle +****************************************************************************/ +#define _0 0xb0 +#define _1 0xb1 +#define _2 0xb2 +#define _3 0xb3 +#define _4 0xb4 +#define _5 0xb5 +#define _6 0xb6 +#define _7 0xb7 +#define _8 0xb8 +#define _9 0xb9 + +const byte abInit[] = {0x74, 0x00, 0x25, 0x06, 0x24, 0x0f, 0x84}; +const byte abCls[] = {0x74, 0x00, 0x84}; +const byte abText1[] = {0x74, 0x40, 0xe3, 0xa7, 0xf4, 0xad, 0xd2, 0xef, 0xe2}; +const byte abZeile2[] = {0x74, 0x00, 0xc4}; +const byte abNr0[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _0}; +const byte abNr1[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _1}; +const byte abNr2[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _2}; +const byte abNr3[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _3}; +const byte abNr4[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _4}; +const byte abNr5[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _5}; +const byte abNr6[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _6}; +const byte abNr7[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _7}; +const byte abNr8[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _8}; +const byte abNr9[] = {0x74, 0x40, 0xd3, 0xf4, 0xe1, 0xf4, 0xe5, 0xa0, _9}; + + +/***************************************************************************** + Name: vStarti2c() + Parameters: none + Returns: nothing + Description: Generiert das Startsignal für I2C-Bus + +******************************************************************************/ +void vStarti2c(void){ + vDelay(nShortDelay); + SDA(); /* data high */ + vDelay(nShortDelay); + SCL(); /* clk high */ + vDelay(nShortDelay); + _SDA(); /* data low */ + vDelay(nShortDelay); + _SCL(); /* clk low */ + vDelay(nShortDelay); + } + +/***************************************************************************** + Name: vStopi2c() + Parameters: none + Returns: nothing + Description: Generiert das Stopsignal für I2C-Bus + +******************************************************************************/ +void vStopi2c(void){ + vDelay(nShortDelay); + _SDA(); /* data low */ + vDelay(nShortDelay); + SCL(); /* clk high */ + vDelay(nShortDelay); + SDA(); /* data high */ + vDelay(nShortDelay); + } + + +/***************************************************************************** + Name: vWriteBi2c() + Parameters: Byte + Returns: nothing + Description: Schreibt in Byte auf den I2C-Bus + +******************************************************************************/ +void vWriteBi2c(byte bData){ + byte i = 0; + vDelay(nShortDelay); + _SCL(); + vDelay(nShortDelay); + for ( i = 0; i < 8; i++){ + if ((bData & 0x80) == 0x80){ + SDA(); /* Bit := 1 */ + } + else{ + _SDA(); /* Bit := 0 */ + } + bData <<= 1; + vDelay(nShortDelay); + SCL(); + vDelay(nShortDelay); + _SCL(); + vDelay(nShortDelay); + } + _SDA(); + vDelay(nShortDelay); + SCL(); + vDelay(nShortDelay); + _SCL(); + vDelay(nShortDelay); + } + +/***************************************************************************** + Name: vDelay() + Parameters: Byte + Returns: nothing + Description: Laufzeitschleife + +******************************************************************************/ +void vDelay(byte bTime){ + while(bTime){ + bTime--; + } + } + +/***************************************************************************** + Name: vSendI2C() + Parameters: Zeichenanzahl, String + Returns: nothing + Description: Schickt den String zum I2C Bus + +******************************************************************************/ +void vSendI2C(byte bLen, byte *pStr){ + word w = 500; + while(w--); + vStarti2c(); + while(bLen){ + vWriteBi2c(*pStr); + pStr++; + bLen--; + } + vStopi2c(); + } + +/*************************************************************************** +* Kurzbeschreibung : OV6620 (OV6630) initialisieren +* Uebergabeparameter : -- +* Return Value : -- +* Author : Jens Altenburg +****************************************************************************/ +void I2C_vInit( void ){ + vSendI2C(sizeof(abInit), (byte *) &abInit[0]); + vSendI2C(sizeof(abCls), (byte *) &abCls[0]); + vSendI2C(sizeof(abText1), (byte *) &abText1[0]); + vSendI2C(sizeof(abZeile2), (byte *) &abZeile2[0]); + vSendI2C(sizeof(abNr0), (byte *) &abNr0[0]); + } + +void I2C_vState(byte bState){ + vSendI2C(sizeof(abZeile2), (byte *) &abZeile2[0]); + switch(bState){ + case 0: + vSendI2C(sizeof(abNr0), (byte *) &abNr0[0]); + break; + case 1: + vSendI2C(sizeof(abNr1), (byte *) &abNr1[0]); + break; + case 2: + vSendI2C(sizeof(abNr2), (byte *) &abNr2[0]); + break; + case 3: + vSendI2C(sizeof(abNr3), (byte *) &abNr3[0]); + break; + case 4: + vSendI2C(sizeof(abNr4), (byte *) &abNr4[0]); + break; + case 5: + vSendI2C(sizeof(abNr5), (byte *) &abNr5[0]); + break; + case 6: + vSendI2C(sizeof(abNr6), (byte *) &abNr6[0]); + break; + case 7: + vSendI2C(sizeof(abNr7), (byte *) &abNr7[0]); + break; + case 8: + vSendI2C(sizeof(abNr8), (byte *) &abNr8[0]); + break; + case 9: + vSendI2C(sizeof(abNr9), (byte *) &abNr9[0]); + break; + } + } +/*************************************************************************** +* EOF: SWMODxC1.C +****************************************************************************/ +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 17 13:55:03 2021 +0000 @@ -0,0 +1,394 @@ +/******************************************************************** + * + * Name: main.cpp + * Beschreibung: HAL für "Embedded Systems Engineering" + * Autor: + * Erstellung: 29.05.2020 + * + * Revisionsliste + * Datum | Autor | Änderung + * ------------+---------------+-------------------------- + * 29.05.2020 | Altenburg | Ersterstellung + * ------------+---------------+-------------------------- + * 04.02.2021 | Altenburg | syntaktische Korrekturen + * ------------+---------------+-------------------------- + * + ********************************************************************/ +#include "mbed.h" +#include "main.h" +#include "oled.h" + +DigitalOut pinLed4(PC_0); /* SCL - I2C; rote LED2 */ +DigitalInOut pinLed2(PC_2); /* SDA - I2C; grüne LED */ + +DigitalOut pinLed3(PC_7); /* rote LED1 */ + +/* Interruptprioritäten */ +#define nSystickLevel 31 /* niedrigste Priorität */ +#define nMillisecLevel 30 /* aufsteigende Priorität */ +#define nSbusTimerLevel 29 +#define nSbusUartLevel 28 + +/* Interrupts global freigeben/sperren */ +#define mcIntEnable() \ + { __asm(" cpsie i\n"); } +#define mcIntDisable() \ + { __asm(" cpsid i\n"); } + +void vWaitFast( void ); /* 200 ms Warten */ +void vWaitSlow( void ); /* 1 Sekunde warten */ + +volatile word wTimer;/* +* Description : +*/ +Def_fFunc afFuncList[] = { vWaitFast, vWaitSlow };/* +* Description : Liste mit Funktionen +*/ +Def_fFunc *pafFuncList;/* +* Description : Zeiger auf Funktionspointerliste +*/ + +/**************************************************************************** + * Init Systemclock * +PLLCFGR 0b00100010010000100010110100000100 +Reserved: 0 +PLLR: 010 = 2 +PLLQ: 0010 = 2 +Reserved: 0 +PLLSRC: 1 = HSE +Reserved: 00 00 +PLLP: 10 = 6 +PLLN: 0010110100 = 180 +PLLM: 000100 = 4 + +CFGR 0b00000000000000001011010000001111 +PPRE: 101 = AHB2 clock divided by 4 +PPRE: 101 = AHB1 clock divided by 4 +Reserved: 00 = +HPRE: 0000 = AHB prescaler divided by 1 +SWS: 11 = PLL_R used as the system clock +SW: 11 = PLL_R selected as system clock + + * Author : J. Altenburg (based on C. Hilgert) * + * Revison : 17.07.17 * + * Parameters * + * Input : Nothing * + * Output : Nothing * + ****************************************************************************/ +void vSysClockInit(void) { + volatile dword dw; + RCC->APB1ENR |= RCC_APB1ENR_PWREN; /* __PWR_CLK_ENABLE(); */ + PWR->CR |= 0x0000C000; /* VOS[1:0] Scale 1 = 0b11 */ + dw = RCC->PLLCFGR; + dw = 0x22422d04; /* PLLCFG-Register einstellen */ + RCC->PLLCFGR = dw; + PWR->CR |= PWR_CR_ODEN; /* overdrive enable */ + while ((PWR->CSR & PWR_CSR_ODRDY) == 0);/* wait until overdrive is ready */ + PWR->CR |= PWR_CR_ODSWEN; + RCC->CR |= RCC_CR_HSEON; /* 1. Clocking the controller from external HSC crystal (8 MHz) */ + while ((RCC->CR & RCC_CR_HSERDY) == 0); /* wait until the HSE is ready */ + RCC->CR |= RCC_CR_PLLON; /* 2. PLL on */ + while ((RCC->CR & RCC_CR_PLLRDY) == 0); /* wait until PLL is locked */ + FLASH->ACR = FLASH_ACR_LATENCY_5WS; /* Zugriffsverz?gerung */ + dw = RCC->CFGR; + dw |= (RCC_CFGR_PPRE2_DIV4 | RCC_CFGR_PPRE1_DIV4 | RCC_CFGR_HPRE_DIV1 | RCC_CFGR_SW_PLLR); + RCC->CFGR = dw; /* APB2 = 45 MHz, APB1 = 45 MHz */ + } + +/**************************************************************************** + * Init-Port - A * + * Author : J. Altenburg (based on C. Hilgert) * + * Revison : 17.07.17 * + * Parameters * + * Input : Nothing * + * Output : Nothing * + * Hinweis : Beschreibung GPIO_AFR[x] Table 11 im Datasheet * + ****************************************************************************/ +void vPortAInit(void) { + dword dw; + RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; /* GPIO-Port A initialisieren */ + dw = GPIOA->MODER; + dw &= ~(GPIO_MODER_MODE15_Msk /* PA15 maskieren */ + | GPIO_MODER_MODE0_Msk /* PA0 - UART4 TX */ + | GPIO_MODER_MODE1_Msk /* PA1 - UART4 RX */ + | GPIO_MODER_MODE2_Msk /* PA2 - UART2 TX */ + | GPIO_MODER_MODE3_Msk /* PA3 - UART2 RX */ + | GPIO_MODER_MODE4_Msk /* PA4 - SPI1_CS */ + | GPIO_MODER_MODE5_Msk /* PA5 - SPI1 SCK */ + | GPIO_MODER_MODE6_Msk /* PA6 - SPI1 MISO */ + | GPIO_MODER_MODE7_Msk /* PA7 - SPI1 MOSI */ + | GPIO_MODER_MODE9_Msk /* PA9 - UART1 TX */ + | GPIO_MODER_MODE10_Msk /* PA10- UART1 RX */ + ); + dw |= (GPIO_MODER_MODE15_0 /* PA15- output */ + | GPIO_MODER_MODE0_1 /* PA0 - alternate output */ + | GPIO_MODER_MODE1_1 /* PA1 - alternate output */ + | GPIO_MODER_MODE2_1 /* PA2 - alternate output */ + | GPIO_MODER_MODE3_1 /* PA3 - alternate output */ + | GPIO_MODER_MODE4_0 /* PA4 - output */ + | GPIO_MODER_MODE5_1 /* PA5 - alternate output */ + | GPIO_MODER_MODE6_1 /* PA6 - alternate output */ + | GPIO_MODER_MODE7_1 /* PA7 - alternate output */ + | GPIO_MODER_MODE9_1 /* PA9 - alternate output */ + | GPIO_MODER_MODE10_1 /* PA10- alternate output */ + ); + GPIOA->MODER = dw; + dw = GPIOA->OTYPER; + dw |= GPIO_OTYPER_OT15; /* open drain */ + //GPIOA->OTYPER = dw; + dw = GPIOA->OSPEEDR; + dw |= GPIO_OSPEEDR_OSPEED15_1; + + GPIOA->AFR[0] = 0x55507788; + GPIOA->AFR[1] = 0x00000770; + //vCS1High(); /* CS BME280 inaktiv */ +} + +/*************************************************************************** +* Init Systemticker +* Author : J. Altenburg +* Revison : 17.07.17 +* Parameters – alle 15 Millisekunden einen Interrupt +***************************************************************************/ +void vSystickInit( void ) { + NVIC_SetPriority(SysTick_IRQn, nSystickLevel); /* INT freigeben */ + /* 15m/180MHz^-1 set reload register = 15 Millisekunden */ + SysTick->LOAD = (2700000 - 1); + SysTick->VAL = 0; /* Init Counter */ + SysTick->CTRL = ( SysTick_CTRL_ENABLE_Msk + |SysTick_CTRL_CLKSOURCE_Msk + |SysTick_CTRL_TICKINT_Msk + ); + } + + +/**************************************************************************** + * Timer2 * + * Author : J. Altenburg * + * Revison : 18.07.17 * + * Parameters * + * Input : Nothing * + * Output : Nothing * + ****************************************************************************/ +void vTimer2Init(void) { + RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; /* Power on */ + TIM2->PSC = 8; /* 90MHz^-1 * (8+1) = 100 ns */ + TIM2->ARR = 60000; /* 100ns * 10000 = 1 ms */ + TIM2->CR1 &= ~TIM_CR1_DIR; /* aufw?rts z?hlen */ + //TIM2->CCR1 = 20000; + NVIC_SetPriority(TIM2_IRQn, nMillisecLevel); + NVIC_EnableIRQ(TIM2_IRQn); + TIM2->DIER = TIM_DIER_CC1IE; /* compare interrupt enable */ + TIM2->CR1 |= TIM_CR1_CEN; + } + +/**************************************************************************** + * Timer4 als Interruptquelle Uhrzeiger-Arithmetik * + * Author : J. Altenburg * + * Revison : 21.05.20 * + * Parameters * + * Input : Nothing * + * Output : Nothing * + ****************************************************************************/ +void vTimer4Init(void) { + RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; /* Power on */ + TIM4->PSC = 8; /* 90MHz^-1 * (8+1) = 100 ns */ + TIM4->ARR = 0xffff; /* 100ns * 10000 = 1 ms */ + TIM4->CR1 &= ~TIM_CR1_DIR; /* aufwärts zählen */ + TIM4->CCR1 = 15000; + NVIC_SetPriority(TIM4_IRQn, nMillisecLevel); + NVIC_EnableIRQ(TIM4_IRQn); + TIM4->DIER = TIM_DIER_CC1IE; /* compare interrupt enable */ + TIM4->CR1 |= TIM_CR1_CEN; +} + +/**************************************************************************** + * UART 2 + * Author : J. Altenburg + * Revison : 20.07.17 + ****************************************************************************/ +void vUart2Init(void) { + RCC->APB1ENR |= RCC_APB1ENR_USART2EN; /* UART2 freigeben */ + USART2->CR3 = 0; /* Reset-Value */ + /* 1 Stop Bit; Keine Parität; 8-Databits */ + USART2->CR1 |= (USART_CR1_UE + USART_CR1_RXNEIE + USART_CR1_RE + USART_CR1_TCIE + USART_CR1_TE); + /* Baudrate UART */ + /* Bit 0-3 sind Fraction->Kommazahl; 15-4 sind Mantissa->ganze Zahl */ + /* UARTDIV = f/(Baud*16); UART5->BRR = UARTDIV << 4 | UARTDIV_Komma */ + /* 146.48 = 45MHz/(19200 * 16) */ + USART2->BRR = (word)((146 << 4) | 5); +#if 0 + NVIC_SetPriority(USART2_IRQn, nMillisecLevel); /* Prioritaet */ + NVIC_EnableIRQ(USART2_IRQn); +#endif +} + + + +/**************************************************************************** + * ISR - Systemtimer * + * - Aufruf der APPs alle x ms * + * - Aufruf des "Millisekunden"-Containers * + * Author : J. Altenburg * + * Revison : 17.07.17 * + ****************************************************************************/ +extern "C" void SysTick_Handler( void ){ + SysTick->CTRL &= ~SysTick_CTRL_COUNTFLAG_Msk; + //GPIOA->ODR ^= (1<<15); /* Testsignal auf GPIO legen */ + } + + +/**************************************************************************** + * ISR - Timer 2 * + * Author : J. Altenburg * + * Revison : 30.08.17 * + * Parameters * + * Laufzeit: x.y µs * + ****************************************************************************/ +extern "C" void TIM2_IRQHandler(void) { + //volatile word w; + TIM2->SR &= ~TIM_SR_CC1IF; /* clear pending bit (sicherheitshalber) */ + //TIM2->CCR1 += 10000; + //GPIOA->ODR ^= (1<<15); + //pinLed2 = !pinLed2; + } + +/**************************************************************************** + * ISR - Timer 4 * + * Author : J. Altenburg * + * Revison : 30.08.17 * + * Parameters * + * Laufzeit: x.y µs * + ****************************************************************************/ +extern "C" void TIM4_IRQHandler(void) { + //volatile word w; + TIM4->SR &= ~TIM_SR_CC1IF; /* clear pending bit (sicherheitshalber) */ + TIM4->CCR1 += wTimer; + wTimer += 1500; + //GPIOA->ODR ^= (1<<15); /* Testsignal auf GPIO legen */ + } + +/* I2C - Zugriff */ +void vSDAOutput( void ){ /* SDA-Datenrichtung -> Output */ + pinLed2.output(); /* auf Ausgang setzen */ + } + +void vSDAInput( void ){ /* SDA-Datenrichtung -> Input */ + pinLed2.input(); /* auf Ausgang setzen */ + } + +void vSDA_H( void ){ /* SDA setzen */ + pinLed2 = On; + } + +void vSDA_L( void ){ /* SDA löschen */ + pinLed2 = Off; + } + +void vSCL_H( void ){ /* SCL setzen */ + pinLed4 = On; + } + +void vSCL_L( void ){ /* SCL löschen */ + pinLed4 = Off; + } + + +void vI2CDelay( void ){ /* ca. 5µs Verzögerung */ + volatile word wDelay = 6; + while(wDelay--); + } + +void vI2CShort( void ){ /* ca. 5µs Verzögerung */ + volatile word wDelay = 2; + while(wDelay--); + } +/* schnelles Blinken */ +void vWaitFast( void ){ + wait(0.2); + } + +/* langsames Blinken */ +void vWaitSlow( void ){ + wait(1); + } + +Def_stValue stRaw1 = {1,1,1,1,1,1,1,1}; +Def_stValue stRaw2 = {2,2,2,2,2,2,2,2}; + +byte bAverage1(Def_stValue stLocal){ + byte i, j = 0; + for(i = 0; i < 8; i++){ + j = j + stLocal.abData[i]; + } + return j>>3; + } + +void vAverage2(byte *pAverage, Def_stValue *stLocal){ + byte i, j = 0; + for(i = 0; i < 8; i++){ + j = j + stLocal->abData[i]; + } + *pAverage = (j>>3); + } + + +int main() { + byte abText[] = "Hallo OLED!"; + dword dwTime = 11; + byte bPos = 0; + byte i = 'A'; + byte y = 0; + pinLed2.mode(OpenDrain); /* bidirektionaler Pin */ + //pinLed2.output(); /* auf Ausgang setzen */ + mcIntDisable(); + vSysClockInit(); + vPortAInit(); + vSystickInit(); + vTimer2Init(); + vTimer4Init(); + vUart2Init(); + mcIntEnable(); + vOledInit(); + ssd1306_fill4(255, 255, 255, 255); + ssd1306_fill4(0, 0, 0, 0); + pafFuncList = &afFuncList[0]; /* referenzieren auf Liste */ + y = bAverage1(stRaw1); + ssd1306tx_large(y+'0', 4, 10); + vAverage2(&y, &stRaw2); + ssd1306tx_large(y+'0', 4, 2); + y = 1; + while(1) { +#if 1 + bPos = 0; + for(i = 0; i < sizeof(abText)-1; i++){ + pinLed3 = 0; + ssd1306tx_large(abText[i], bPos, 6); + bPos = bPos + 9; + pinLed3 = 1; + USART2->DR = 'J'; + (*(pafFuncList + y))(); /* unterschiedliche Wartezeiten */ + dwTime--; + if(dwTime == 0){ + dwTime = 11; + (y == 0) ? y = 1 : y = 0; + ssd1306_fill4(0, 0, 0, 0); + } + GPIOA->ODR ^= (1<<15); + } +#else + dwTime = 10000000; + while(dwTime--); + pinLed3 = 0; + ssd1306_setpos(0,0); + //ssd1306_setpos(bPos, y); + //ssd1306tx_char(i); + ssd1306tx_large(i, bPos, y); + pinLed3 = 1; + if(i < 'Z') i++; + else i = 'A'; + bPos = bPos + 9; + y = y + 2; +#endif + } + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Wed Mar 17 13:55:03 2021 +0000 @@ -0,0 +1,94 @@ +/******************************************************************** + * + * Name: main.h + * Beschreibung: grundlegende Typdefinitionen + * Autor: + * Erstellung: 29.05.2020 + * + * Revisionsliste + * Datum | Autor | ├änderung + * ------------+---------------+-------------------------- + * 29.05.2020 | Altenburg | Ersterstellung + * ------------+---------------+-------------------------- + * + ********************************************************************/ +#ifndef MAIN_H +#define MAIN_H + +/**************************************************************************/ +/* Definitions */ +/**************************************************************************/ +typedef unsigned char byte; /* vorzeichenlose 8-Bit-Zahl */ +typedef unsigned short word; /* vorzeichenlose 16-Bit-Zahl */ +typedef signed char int8; /* vorzeichenbehaftete 8-Bit-Zahl */ +typedef signed short int16; /* vorzeichenbehaftete 16-Bit-Zahl */ +//typedef byte bool; /* True/False Aussage */ +typedef unsigned long dword; /* Long-Zahl */ +typedef signed long int32; + +typedef void (* Def_fFunc)( void );/* Prototyp eines Funktionspointers */ + +typedef struct { + byte abData[8]; + }Def_stValue; + + +#define True 1 +#define False 0 +#define true 1 +#define false 0 +#define On 1 +#define Off 0 +#define Yes 1 +#define No 0 + +#define Bit0 0x01 /* Bit-Definitionen */ +#define Bit1 0x02 +#define Bit2 0x04 +#define Bit3 0x08 +#define Bit4 0x10 +#define Bit5 0x20 +#define Bit6 0x40 +#define Bit7 0x80 +#define Bit8 (unsigned long)(1 << 8) /* Bit-Definitionen */ +#define Bit9 (unsigned long)(1 << 9) +#define Bit10 (1 << 10) +#define Bit11 (unsigned long)(1 << 11) +#define Bit12 (1 << 12) +#define Bit13 (unsigned long)(1 << 13) +#define Bit14 (1 << 14) +#define Bit15 (unsigned long)(1 << 15) +#define Bit16 (unsigned long)(1 << 16) /* Bit-Definitionen */ +#define Bit17 (unsigned long)(1 << 17) +#define Bit18 (unsigned long)(1 << 18) +#define Bit19 (unsigned long)(1 << 19) +#define Bit20 (unsigned long)(1 << 20) +#define Bit21 (unsigned long)(1 << 21) +#define Bit22 (unsigned long)(1 << 22) +#define Bit23 (unsigned long)(1 << 23) +#define Bit24 (unsigned long)(1 << 24) /* Bit-Definitionen */ +#define Bit25 (unsigned long)(1 << 25) +#define Bit26 (unsigned long)(1 << 26) +#define Bit27 (unsigned long)(1 << 27) +#define Bit28 (unsigned long)(1 << 28) +#define Bit29 (unsigned long)(1 << 29) +#define Bit30 (unsigned long)(1 << 30) +#define Bit31 (unsigned long)(1 << 31) + +/************************************************************************** + * I2C - Zugriff auf HAL + **************************************************************************/ +void vSDAOutput ( void ); /* SDA-Datenrichtung -> Output */ +void vSDAInput ( void ); /* SDA-Datenrichtung -> Input */ + +void vSDA_H ( void ); /* SDA setzen */ +void vSDA_L ( void ); /* SDA löschen */ +void vSCL_H ( void ); /* SCL setzen */ +void vSCL_L ( void ); /* SCL löschen */ + +void vI2CDelay ( void ); /* Warteschleife für SCL-Takt */ +void vI2CShort ( void ); /* Warteschleife für set-up-Zeiten */ + +#endif +/********************************************************************/ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 17 13:55:03 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/oled.cpp Wed Mar 17 13:55:03 2021 +0000 @@ -0,0 +1,196 @@ +/** + * SSD1306xLED - Library for the SSD1306 based OLED/PLED 128x64 displays + * + * @author Neven Boyanov + * + * This is part of the Tinusaur/SSD1306xLED project. + * + * Copyright (c) 2018 Neven Boyanov, The Tinusaur Team. All Rights Reserved. + * Distributed as open source software under MIT License, see LICENSE.txt file. + * Retain in your source code the link http://tinusaur.org to the Tinusaur project. + * + * Source code available at: https://bitbucket.org/tinusaur/ssd1306xled + * + */ + +// ============================================================================ +// ACKNOWLEDGEMENTS: +// - Some code and ideas initially based on "IIC_wtihout_ACK" +// by http://www.14blog.com/archives/1358 (defunct) +// - Init sequence used info from Adafruit_SSD1306.cpp init code. +// ============================================================================ + +// ============================================================================ +// STATEMENT: +// - gründlich aufgeräumt +// 29.05.2020 by Jens Altenburg +// ============================================================================ + +#include "oled.h" +#include "font6_8.h" +#include "font8_16.h" + +// ---------------------------------------------------------------------------- + +void ssd1306_start_command(void); // Initiate transmission of command +void ssd1306_start_data(void); // Initiate transmission of data +void ssd1306_data_byte(byte); // Transmission 1 byte of data +void ssd1306_stop(void); // Finish transmission + +// ---------------------------------------------------------------------------- + +const byte ssd1306_init_sequence[] = { // Initialization Sequence + + 0xAE, // Set Display ON/OFF - AE=OFF, AF=ON + 0xD5, 0xF0, // Set display clock divide ratio/oscillator frequency, set divide ratio + 0xA8, 0x3F, // Set multiplex ratio (1 to 64) ... (height - 1) + 0xD3, 0x00, // Set display offset. 00 = no offset + 0x40 | 0x00, // Set start line address, at 0. + 0x8D, 0x14, // Charge Pump Setting, 14h = Enable Charge Pump + 0x20, 0x00, // Set Memory Addressing Mode - 00=Horizontal, 01=Vertical, 10=Page, 11=Invalid + 0xA0 | 0x01, // Set Segment Re-map + 0xC8, // Set COM Output Scan Direction + 0xDA, 0x12, // Set COM Pins Hardware Configuration - 128x32:0x02, 128x64:0x12 + 0x81, 0x3F, // Set contrast control register + 0xD9, 0x22, // Set pre-charge period (0x22 or 0xF1) + 0xDB, 0x20, // Set Vcomh Deselect Level - 0x00: 0.65 x VCC, 0x20: 0.77 x VCC (RESET), 0x30: 0.83 x VCC + 0xA4, // Entire Display ON (resume) - output RAM to display + 0xA6, // Set Normal/Inverse Display mode. A6=Normal; A7=Inverse + 0x2E, // Deactivate Scroll command + 0xAF, // Set Display ON/OFF - AE=OFF, AF=ON + // + 0x22, 0x00, 0x3f, // Set Page Address (start,end) + 0x21, 0x00, 0x7f, // Set Column Address (start,end) + // + }; + + +// ---------------------------------------------------------------------------- + +void i2csw_start(void); +void i2csw_stop(void); +void i2csw_byte(byte); + +// ---------------------------------------------------------------------------- + +void i2csw_start(void) { + vSDAOutput(); + /* SCL ist immer Output */ + vSDA_H(); /* SDA setzen */ + vSCL_H(); /* SCL setzen */ + vSDA_L(); /* SDA löschen */ + vSCL_L(); + } + +void i2csw_stop(void) { + vSDA_L(); /* SDA löschen */ + vSCL_L(); /* SCL löschen */ + vSDA_H(); /* SDA, SCL setzen */ + vSCL_H(); + vSDAInput(); /* SDA-Datenrichtung -> Input */ + } + +void i2csw_byte(byte bData) { + byte i; + for (i = 0; i < 8; i++) { + if ((bData << i) & 0x80) vSDA_H(); + else vSDA_L(); + vI2CShort(); /* set-up-Zeit */ + vSCL_H(); + vI2CDelay(); /* SCL-high-time */ + vSCL_L(); + vI2CShort(); /* set-up-Zeit */ + } + vSDA_L(); + vI2CShort(); /* set-up-Zeit */ + vSCL_H(); + vI2CDelay(); /* SCL-high-time */ + vSCL_L(); + vI2CShort(); /* set-up-Zeit */ + } + +// ============================================================================ + +void ssd1306_start_command(void) { + i2csw_start(); + i2csw_byte(0x78); // Slave address: R/W(SA0)=0 - write + i2csw_byte(0x00); // Control byte: D/C=0 - write command +} + +void ssd1306_start_data(void) { + i2csw_start(); + i2csw_byte(0x78); // Slave address, R/W(SA0)=0 - write + i2csw_byte(0x40); // Control byte: D/C=1 - write data +} + +void ssd1306_data_byte(byte b) { + i2csw_byte(b); +} + +void ssd1306_stop(void) { + i2csw_stop(); +} + +// ============================================================================ + +void vOledInit(void) { + byte i; + ssd1306_start_command(); // Initiate transmission of command + for (i = 0; i < sizeof (ssd1306_init_sequence); i++) { + ssd1306_data_byte(ssd1306_init_sequence[i]); // Send the command out + } + ssd1306_stop(); // Finish transmission +} + +void ssd1306_setpos(byte x, byte y) { + ssd1306_start_command(); + ssd1306_data_byte(0xb0 | (y & 0x07)); // Set page start address + ssd1306_data_byte(x & 0x0f); // Set the lower nibble of the column start address + ssd1306_data_byte(0x10 | (x >> 4)); // Set the higher nibble of the column start address + ssd1306_stop(); // Finish transmission +} + +void ssd1306_fill4(byte p1, byte p2, byte p3, byte p4) { + word i; + ssd1306_setpos(0, 0); + ssd1306_start_data(); // Initiate transmission of data + for (i = 0; i < 128 * 8 / 4; i++) { + ssd1306_data_byte(p1); + ssd1306_data_byte(p2); + ssd1306_data_byte(p3); + ssd1306_data_byte(p4); + } + ssd1306_stop(); // Finish transmission +} + +// ---------------------------------------------------------------------------- + +void ssd1306tx_char(byte ch) { + byte i; + word j = (ch-32)*6; + ssd1306_start_data(); + for (i = 0; i < 6; i++) { + ssd1306_data_byte(ssd1306xled_font6x8data[j + i]); + } + ssd1306_stop(); +} + +void ssd1306tx_large(byte ch, byte x, byte y) { + byte i, yy; + word j = (ch-32)*16; + yy = y >> 1; + ssd1306_setpos(x, (yy)); + ssd1306_start_data(); + for (i = 0; i < 8; i++) { + ssd1306_data_byte(ssd1306xled_font8x16data[j + i]); + } + ssd1306_stop(); + ssd1306_setpos(x, (yy+1)); + ssd1306_start_data(); + for (i = 8; i < 16; i++) { + ssd1306_data_byte(ssd1306xled_font8x16data[j + i]); + } + ssd1306_stop(); + } + +// ============================================================================ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/oled.h Wed Mar 17 13:55:03 2021 +0000 @@ -0,0 +1,50 @@ +#if 1 +/** + * SSD1306xLED - Library for the SSD1306 based OLED/PLED 128x64 displays + * + * @author Neven Boyanov + * + * This is part of the Tinusaur/SSD1306xLED project. + * + * Copyright (c) 2018 Neven Boyanov, The Tinusaur Team. All Rights Reserved. + * Distributed as open source software under MIT License, see LICENSE.txt file. + * Retain in your source code the link http://tinusaur.org to the Tinusaur project. + * + * Source code available at: https://bitbucket.org/tinusaur/ssd1306xled + * + */ + +#ifndef SSD1306XLED_H +#define SSD1306XLED_H + +#include "main.h" + +// ============================================================================ + +// -----(+)-------------------->-----> [Vcc] Pin 1 on the SSD1306 display board +// -----(-)-------------------->-----> [GND] Pin 2 on the SSD1306 display board +#define SSD1306_SCL PB2 // ----> [SCL] Pin 3 on the SSD1306 display board +#define SSD1306_SDA PB0 // ----> [SDA] Pin 4 on the SSD1306 display board + +#define SSD1306_SADDR 0x78 // Display IC2 slave address, default 0x78 + +// ---------------------------------------------------------------------------- + +#define ssd1306_clear() ssd1306_fill4(0, 0, 0, 0) +#define ssd1306_fill(p) ssd1306_fill4(p, p, p, p) +#define ssd1306_fill2(p1, p2) ssd1306_fill4(p1, p2, p1, p2) + +// ---------------------------------------------------------------------------- + +//void ssd1306_init(void); +void vOledInit(void); +void ssd1306_setpos(byte x, byte y); +void ssd1306_fill4(byte, byte, byte, byte); +void ssd1306tx_char(byte ); +void ssd1306tx_large(byte, byte, byte ); + +// ============================================================================ + +#endif + +#endif \ No newline at end of file