GD32F103 — 14-软件SPI的W25QXX驱动

GD32F103 DRG GD-1 14-软件SPI的W25QXX驱动 示例

GD32F103 — 14-软件SPI的W25QXX驱动

来源: DRG GD-1 开发板例程
源文件: GD32/drg_gd_1_gd32f103c8t6-master/14-软件SPI的W25QXX驱动/test/APP/main.c

子模块

  • Firmware
  • test

关键代码

 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
#include <stdio.h>
#include "systick.h"
#include "i2c.h"
#include "oled_i2c.h"
#include "w25qxx_spi.h"
#include "KEY.h"

int main(){
	systick_config();

	i2c_init();
	KEY_Init();
	w25qxx_init();
	
	oled_init();
	oled_clear_all();
	oled_show_string(24, 0, (uint8_t *)"SPI Test", 16);
	oled_show_string(2, 2, (uint8_t *)"A:W B:R C:E", 16);

	uint8_t write_buffer[] = "GenBotter";

	while(1){
		uint8_t read_buffer[10];
		if(KEY_A_Pressed()){ //дgenbotter
			oled_clear_all();
			oled_show_string(2, 0, (uint8_t *)"Write Data", 16);
			w25qxx_write(write_buffer, 0x00000000,10);
			oled_show_string(2, 2, write_buffer, 16);
			oled_show_string(2, 4, (uint8_t *)"Write Done", 16);
		}
		if(KEY_B_Pressed()){ //
			oled_clear_all();
			oled_show_string(2, 0, (uint8_t *)"Read Data", 16);
			w25qxx_read(read_buffer, 0x00000000,10);
			oled_show_string(2, 2, read_buffer, 16);
			oled_show_string(2, 4, (uint8_t *)"Read Done", 16);
		}
		if(KEY_C_Pressed()){ //
			oled_clear_all();
			oled_show_string(2, 0, (uint8_t *)"Erase Data", 16);
			w25qxx_erase_sector(0x00000000);
			oled_show_string(2, 4, (uint8_t *)"Erase Done", 16);
		}
	}
}
世界是你们
使用 Hugo 构建
主题 StackJimmy 设计