-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
110 lines (89 loc) · 3.89 KB
/
main.c
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
/******************************************************************************/
/* Files to Include */
/******************************************************************************/
#ifdef __XC32
#include <xc.h> /* Defines special funciton registers, CP0 regs */
#endif
#include <plib.h> /* Include to use PIC32 peripheral libraries */
#include <stdint.h> /* For uint32_t definition */
#include <stdbool.h> /* For true/false definition */
#include "system.h" /* System funct/params, like osc/periph config */
#include "user.h" /* User funct/params, such as InitApp */
#include "config_bits.h"
#include "Primitives LLD/SSD1963.h"
/******************************************************************************/
/* Global Variable Declaration */
/******************************************************************************/
/* i.e. uint32_t <variable_name>; */
/******************************************************************************/
/* Main Program */
/******************************************************************************/
int32_t main(void)
{
BYTE x, y;
/*Refer to the C32 peripheral library documentation for more
information on the SYSTEMConfig function.
This function sets the PB divider, the Flash Wait States, and the DRM
/wait states to the optimum value. It also enables the cacheability for
the K0 segment. It could has side effects of possibly alter the pre-fetch
buffer and cache. It sets the RAM wait states to 0. Other than
the SYS_FREQ, this takes these parameters. The top 3 may be '|'ed
together:
SYS_CFG_WAIT_STATES (configures flash wait states from system clock)
SYS_CFG_PB_BUS (configures the PB bus from the system clock)
SYS_CFG_PCACHE (configures the pCache if used)
SYS_CFG_ALL (configures the flash wait states, PB bus, and pCache)*/
/* TODO Add user clock/system configuration code if appropriate. */
SYSTEMConfig(SYS_FREQ, SYS_CFG_ALL);
/* Initialize I/O and Peripherals for application */
InitApp();
/*Configure Multivector Interrupt Mode. Using Single Vector Mode
is expensive from a timing perspective, so most applications
should probably not use a Single Vector Mode*/
INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
/* TODO <INSERT USER APPLICATION CODE HERE> */
/*
Configure the device for maximum performance.
This macro sets flash wait states, PBCLK divider and DRM wait states
based on the specified clock frequency. It also turns on the cache
mode if avaialble.
Based on the current frequency, the PBCLK divider will be set at 1:1.
This knowledge is required to correctly set UART baud rate, timer
reload value and other time sensitive setting.
*/
SYSTEMConfigPerformance(GetSystemClock());
// Use PBCLK divider of 1:1 to calculate UART baud, timer tick etc.
ResetDevice();
SetBacklight(255); //full brightness
while(1)
{
// Show a few colors as an opening screen
_color = WHITE;
ClearDevice();
DelayMs(1000);
_color = BLUE;
ClearDevice();
DelayMs(1000);
_color = BRIGHTYELLOW;
for(x=100; x<200; x++)
{
for(y=50; y<120; y++) {PutPixel(x,y);}
}
DelayMs(1000);
_color = LIGHTRED;
ClearDevice();
DelayMs(1000);
_color = BRIGHTBLUE;
for(x=50; x<90; x++)
{
for(y=30; y<200; y++) {PutPixel(x,y);}
}
DelayMs(1000);
_color = BRIGHTGREEN;
ClearDevice();
DelayMs(1000);
_color = BLACK;
ClearDevice();
DelayMs(1000);
}
}