-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux_w25qxx.c
More file actions
53 lines (38 loc) · 803 Bytes
/
linux_w25qxx.c
File metadata and controls
53 lines (38 loc) · 803 Bytes
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
#include "w25qxx_Demo.h"
static int GPIO_Init(void);
static int SPI1_Init(void);
int main()
{
if (GPIO_Init())
return 1;
if (SPI1_Init())
return 1;
if (w25qxx_Demo(w25qxx_Print, false))
{
printf("w25qxx data write/read sequence - no match\n");
return 1;
}
return 0;
}
static int GPIO_Init(void)
{
printf("GPIO init...\n");
if (wiringPiSetup())
{
printf("GPIO init failed\n");
return 1;
}
pinMode(SPI1_CS0_PIN, OUTPUT);
return 0;
}
static int SPI1_Init(void)
{
printf("SPI init...\n");
int fd = wiringPiSPISetup(SPI_DEV, SPI_SPEED);
if (fd < 0)
{
printf("SPI init failed\n");
return 1;
}
return 0;
}