Numworks Epsilon  1.4.1
Graphing Calculator Operating System
display.h
Go to the documentation of this file.
1 #ifndef ION_DEVICE_DISPLAY_H
2 #define ION_DEVICE_DISPLAY_H
3 
4 #include <kandinsky/rect.h>
5 #include <kandinsky/color.h>
6 extern "C" {
7 #include <stddef.h>
8 }
9 #include "regs/regs.h"
10 
11 namespace Ion {
12 namespace Display {
13 namespace Device {
14 
15 /* Pin | Role | Mode | Function | Note
16  * -----+-------------------+-----------------------+----------|------
17  * PA2 | LCD D4 | Alternate Function 12 | FSMC_D4 |
18  * PA3 | LCD D5 | Alternate Function 12 | FSMC_D5 |
19  * PA4 | LCD D6 | Alternate Function 12 | FSMC_D6 |
20  * PB12 | LCD D13 | Alternate Function 12 | FSMC_D13 |
21  * PB14 | LCD power | Output | | LCD controller is powered directly from GPIO
22  * PD0 | LCD D2 | Alternate Function 12 | FSMC_D2 |
23  * PD1 | LCD D3 | Alternate Function 12 | FSMC_D3 |
24  * PD4 | LCD read signal | Alternate Function 12 | FSMC_NOE |
25  * PD5 | LCD write signal | Alternate Function 12 | FSMC_NWE
26  * PD7 | LCD chip select | Alternate Function 12 | FSMC_NE1 | Memory bank 1
27  * PD9 | LCD D14 | Alternate Function 12 | FSMC_D14 |
28  * PD10 | LCD D15 | Alternate Function 12 | FSMC_D15 |
29  * PD11 | LCD data/command | Alternate Function 12 | FSMC_A16 | Data/Command is address bit 16
30  * PD14 | LCD D0 | Alternate Function 12 | FSMC_D0 |
31  * PD15 | LCD D1 | Alternate Function 12 | FSMC_D1 |
32  * PE9 | LCD reset | Output | |
33  * PE10 | LCD D7 | Alternate Function 12 | FSMC_D7 |
34  * PE11 | LCD D8 | Alternate Function 12 | FSMC_D8 |
35  * PE12 | LCD D9 | Alternate Function 12 | FSMC_D9 |
36  * PE13 | LCD D10 | Alternate Function 12 | FSMC_D10 |
37  * PE14 | LCD D11 | Alternate Function 12 | FSMC_D11 |
38  * PE15 | LCD D12 | Alternate Function 12 | FSMC_D12 |
39  */
40 
41 void init();
42 void shutdown();
43 
44 void initDMA();
45 void initGPIO();
46 void shutdownGPIO();
47 void initFSMC();
48 void shutdownFSMC();
49 void initPanel();
50 void shutdownPanel();
51 
52 enum class Orientation {
53  Landscape = 0,
54  Portrait = 1
55 };
56 
59 void pushPixels(const KDColor * pixels, size_t numberOfPixels);
60 void pushColor(KDColor color, size_t numberOfPixels);
61 void pullPixels(KDColor * pixels, size_t numberOfPixels);
62 
63 enum class Command : uint16_t {
64  Nop = 0x00,
65  Reset = 0x01,
66  SleepIn = 0x10,
67  SleepOut = 0x11,
68  DisplayOff = 0x28,
69  DisplayOn = 0x29,
70  ColumnAddressSet = 0x2A,
71  PageAddressSet = 0x2B,
72  MemoryWrite = 0x2C,
73  MemoryRead = 0x2E,
74  TearingEffectLineOn = 0x35,
75  MemoryAccessControl = 0x36,
76  PixelFormatSet = 0x3A,
77  FrameRateControl = 0xC6
78 };
79 
80 constexpr static GPIOPin FSMCPins[] = {
81  GPIOPin(GPIOA, 2), GPIOPin(GPIOA, 3), GPIOPin(GPIOA, 4), GPIOPin(GPIOB, 12),
82  GPIOPin(GPIOB, 12), GPIOPin(GPIOD, 0), GPIOPin(GPIOD, 1), GPIOPin(GPIOD, 4),
83  GPIOPin(GPIOD, 5), GPIOPin(GPIOD, 7), GPIOPin(GPIOD, 9), GPIOPin(GPIOD, 10),
84  GPIOPin(GPIOD, 11), GPIOPin(GPIOD, 14), GPIOPin(GPIOD, 15), GPIOPin(GPIOE, 10),
85  GPIOPin(GPIOE, 11), GPIOPin(GPIOE, 12), GPIOPin(GPIOE, 13), GPIOPin(GPIOE, 14),
86  GPIOPin(GPIOE, 15)
87 };
88 
89 constexpr static GPIOPin PowerPin = GPIOPin(GPIOB, 14);
90 constexpr static GPIOPin ResetPin = GPIOPin(GPIOE, 9);
91 constexpr static GPIOPin ExtendedCommandPin = GPIOPin(GPIOB, 13);
92 constexpr static GPIOPin TearingEffectPin = GPIOPin(GPIOB, 10);
93 
94 constexpr static int FSMCMemoryBank = 1;
95 constexpr static int FSMCDataCommandAddressBit = 16;
96 
97 constexpr static uint32_t FSMCBaseAddress = 0x60000000;
98 constexpr static uint32_t FSMCBankAddress = FSMCBaseAddress + (FSMCMemoryBank-1)*0x04000000;
99 
100 constexpr static DMA DMAEngine = DMA2;
101 constexpr static int DMAStream = 0;
102 
103 static volatile Command * const CommandAddress = (Command *)(FSMCBankAddress);
104 static volatile uint16_t * const DataAddress = (uint16_t *)(FSMCBankAddress | (1<<(FSMCDataCommandAddressBit+1)));
105 
106 }
107 }
108 }
109 
110 #endif
constexpr DMA DMA2(1)
void Display(const char *input)
Definition: display.cpp:11
void pullPixels(KDColor *pixels, size_t numberOfPixels)
Definition: display.cpp:320
void setDrawingArea(KDRect r, Orientation o)
Definition: display.cpp:247
void pushPixels(const KDColor *pixels, size_t numberOfPixels)
Definition: display.cpp:277
unsigned short uint16_t
Definition: stdint.h:5
constexpr GPIO GPIOB(1)
void pushColor(KDColor color, size_t numberOfPixels)
Definition: display.cpp:303
unsigned int uint32_t
Definition: stdint.h:6
constexpr GPIO GPIOE(4)
constexpr GPIO GPIOD(3)
void waitForPendingDMAUploadCompletion()
Definition: rect.h:26
Definition: color.h:6
Definition: gpio.h:95
constexpr GPIO GPIOA(0)
Definition: backlight.h:6
Definition: dma.h:6