-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathInclude.h
134 lines (106 loc) · 3.73 KB
/
Include.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* @cond
* The following section will be excluded from the documentation.
*/
// ****************************************************************************
//
// Main code
//
// ****************************************************************************
#ifndef _INCLUDE_H
#define _INCLUDE_H
typedef unsigned char Bool;
#define True 1
#define False 0
// NULL
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void*)0)
#endif
#endif
// I/O port prefix
#define __IO volatile
// request to use inline
#define INLINE __attribute__((always_inline)) inline
// avoid to use inline
#define NOINLINE __attribute__((noinline))
// weak function
#define WEAK __attribute__((weak))
// align array to 4-bytes
#define ALIGNED __attribute__((aligned(4)))
// default LED pin
#define LED_PIN 25
// nop instruction
INLINE void nop()
{ __asm volatile (" nop\n"); }
// compiler barrier
INLINE void cb()
{ __asm volatile ("" ::: "memory"); }
// ----------------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------------
#define BIT(pos) (1UL<<(pos))
// ----------------------------------------------------------------------------
// Includes
// ----------------------------------------------------------------------------
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"
#include <string.h>
#include "hardware/divider.h"
#include "hardware/dma.h"
#include "hardware/irq.h"
#include "hardware/gpio.h"
#include "pico/binary_info.h"
#include "configuration.h"
#include "hardware/watchdog.h"
#include "hardware/clocks.h"
#include "hardware/flash.h"
#include "hardware/adc.h"
#include "hardware/exception.h"
#include "hardware/structs/systick.h"
#include "hardware/structs/scb.h"
#include "hardware/vreg.h"
#include <pico/bootrom.h>
#include "hardware/irq.h"
#include "hardware/pio.h"
#ifndef HDMI
#include "PicoMiteVGA.pio.h"
#include "PicoMiteI2S.pio.h"
#endif
#ifndef USBKEYBOARD
#include "pico/unique_id.h"
#include "class/cdc/cdc_device.h"
#endif
// ****************************************************************************
//
// QVGA configuration
//
// ****************************************************************************
// port pins
// GP22... VGA
// GP16 ... VGA HSYNC/CSYNC synchronization (inverted: negative SYNC=LOW=0x80, BLACK=HIGH=0x00)
// GP17 ... VSYNC
// QVGA port pins
#define QVGA_GPIO_FIRST PinDef[Option.VGA_BLUE].GPno // first QVGA GPIO
#define QVGA_GPIO_NUM 4 // number of QVGA color GPIOs, without HSYNC and VSYNC
#define QVGA_GPIO_LAST (QVGA_GPIO_FIRST+QVGA_GPIO_NUM-1) // last QVGA GPIO
#define QVGA_GPIO_HSYNC PinDef[Option.VGA_HSYNC].GPno // QVGA HSYNC/CSYNC GPIO
#define QVGA_GPIO_VSYNC (QVGA_GPIO_HSYNC+1) // QVGA VSYNC GPIO
// QVGA display resolution
//#define FRAMESIZE (38400) // display frame size in bytes (=38400)
// 126 MHz timings
#define QVGA_TOTAL_F 4000// total clock ticks (= QVGA_HSYNC + QVGA_BP + WIDTH*QVGA_CPP[1600] + QVGA_FP)
#define QVGA_HSYNC_F 480 // horizontal sync clock ticks
#define QVGA_BP_F 240 // back porch clock ticks
#define QVGA_FP_F 80 // front porch clock ticks
// QVGA vertical timings
#define QVGA_VTOT_F 525 // total scanlines (= QVGA_VSYNC + QVGA_VBACK + QVGA_VACT + QVGA_VFRONT)
#define QVGA_VSYNC_F 2 // length of V sync (number of scanlines)
#define QVGA_VBACK_F 33 // V back porch
#define QVGA_VACT_F 480 // V active scanlines (= 2*HEIGHT)
#define QVGA_VFRONT_F 10 // V front porch
#endif // _MAIN_H
/* @endcond */