-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDEV_Config.cpp
More file actions
107 lines (95 loc) · 2.58 KB
/
Copy pathDEV_Config.cpp
File metadata and controls
107 lines (95 loc) · 2.58 KB
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
/*****************************************************************************
* | File : DEV_Config.c
* | Author : Waveshare team
* | Function : Show SDcard BMP picto LCD
* | Info :
* Provide the hardware underlying interface
*----------------
* | This version: V1.0
* | Date : 2018-01-11
* | Info : Basic version
*
******************************************************************************/
#include "DEV_Config.h"
void DEV_Digital_Write(UWORD Pin, UBYTE Value)
{
gpio_put(Pin, Value);
}
UBYTE DEV_Digital_Read(UWORD Pin)
{
return gpio_get(Pin);
}
/**
* GPIO Mode
**/
void DEV_GPIO_Mode(UWORD Pin, UWORD Mode)
{
gpio_init(Pin);
if(Mode == 0 || Mode == GPIO_IN) {
gpio_set_dir(Pin, GPIO_IN);
} else {
gpio_set_dir(Pin, GPIO_OUT);
}
}
void DEV_GPIO_Init(void)
{
DEV_GPIO_Mode(LCD_RST_PIN, GPIO_OUT);
DEV_GPIO_Mode(LCD_DC_PIN, GPIO_OUT);
DEV_GPIO_Mode(LCD_BKL_PIN, GPIO_OUT);
DEV_GPIO_Mode(LCD_CS_PIN, GPIO_OUT);
DEV_GPIO_Mode(TP_CS_PIN, GPIO_OUT);
DEV_GPIO_Mode(TP_IRQ_PIN, GPIO_IN);
DEV_GPIO_Mode(SD_CS_PIN, GPIO_OUT);
gpio_set_pulls(TP_IRQ_PIN, true, false);
gpio_put(TP_CS_PIN , 1);
gpio_put(LCD_CS_PIN, 1);
gpio_put(LCD_BKL_PIN, 1);
gpio_put(SD_CS_PIN, 1);
}
/*******************************************************************************
function: System Init
note: Initialize the communication method
*******************************************************************************/
uint8_t System_Init(void)
{
//stdio_init_all();
DEV_GPIO_Init();
spi_init(SPI_PORT, SPI_SPD);
gpio_set_function(LCD_CLK_PIN, GPIO_FUNC_SPI);
gpio_set_function(LCD_MOSI_PIN, GPIO_FUNC_SPI);
gpio_set_function(LCD_MISO_PIN, GPIO_FUNC_SPI);
return 0;
}
void System_Exit(void)
{
}
/*********************************************
function: Hardware interface
note:
SPI4W_Write_Byte(value) :
Register hardware SPI
*********************************************/
uint8_t SPI4W_Write_Byte(uint8_t value)
{
uint8_t rxDat;
spi_write_read_blocking(spi1, &value, &rxDat, 1);
return rxDat;
}
uint8_t SPI4W_Read_Byte(uint8_t value)
{
return SPI4W_Write_Byte(value);
}
/*******************************************************************************
function: Delay function
note:
Driver_Delay_ms(xms) : Delay x ms
Driver_Delay_us(xus) : Delay x us
*******************************************************************************/
void Driver_Delay_ms(uint32_t xms)
{
sleep_ms(xms);
}
void Driver_Delay_us(uint32_t xus)
{
sleep_us(xus);
}