资源简介
stm32f103控制w25q64
代码片段和文件信息
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* © Copyright (c) 2019 STMicroelectronics.
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license
* the “License“; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include “main.h“
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
SPI_HandleTypeDef hspi2;
UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_SPI2_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* 添加“printf“打印功能 */
int fputc(int ch FILE *f)
{
HAL_UART_Transmit(&huart1 (uint8_t *)&ch1 0xFFFF);
return ch;
}
/* W25Q64的指令 */
uint8_t w25x_read_id = 0x90; // 读ID
uint8_t m_addr[3] = {000}; // 测试地址0x000000
uint8_t check_addr = 0x05; // 检查线路是否繁忙
uint8_t enable_write = 0x06; // 使能了才能改变芯片数据
uint8_t erase_addr = 0x20; // 擦除命令
uint8_t write_addr = 0x02; // 写数据命令
uint8_t read_addr = 0x03; // 读数据命令
/* 读ID */
void ReadID(void)
{
uint8_t temp_ID[5] = {00000}; // 接收缓存
HAL_GPIO_WritePin(GPIOG GPIO_PIN_13 GPIO_PIN_RESET); // 使能CS
HAL_SPI_Transmit(&hspi2 &w25x_read_id 1 100); // 读ID发送指令
HAL_SPI_Receive(&hspi2 temp_ID 5 100); // 读取ID
HAL_GPIO_WritePin(GPIOG GPIO_PIN_13 GPIO_PIN_SET); // 失能CS
/* 测试打印 */
printf(“readID is %x%x\n“temp_ID[3]temp_ID[4]);
}
/* 检查是否繁忙 */
void CheckBusy(void)
{
uint8_t status=1;
uint32_t timeCount=0;
do
{
相关资源
- C语言的嵌入式汇编基本使用.docx(2页
- stm32f103c8t6开发板原理图+pcb
- STM32内部FLASH模拟eerom
- stm32的半导体除湿机程序
- stm32实现高精度频率测定
- stm32库函数代码自动生成器V1.2
- stm32 DMA例程
- stm32蓝牙小车
- 显示屏操作(stm32f103c8t6(SAN))
- 基于STM32f103 PWM波呼吸灯
- STM32红外检测有人开始录音,并播放录
- Proteus 8.6仿真STM32F103C6
- C语言嵌入式Modbus协议栈,支持主站和
- stm32 +w5500 裸机 远程升级 自动dns pi
- stm32双机spi通信
- STM32 PCB封装库 全系列 全网不好找
- 基于STM32F407的W5500 tcpserver(官网例程
- 串口调试助手(测试STM32串口)
- 基于STM32F407ZG的监控摄像头及FATFS文件
- tm1650+stm32f103源码(board_tm1650.c)
- stm32定时器中断
- 颜色识别形状识别STM103嵌入式代码
- 基于STM32的音频信号采样与FFT分析
- STM32肺活量测试仪
- 基于STM32F103C8T6主控板使用BH1750检测光
- cubeMX设计实现stm32f407上的CAN及485的通
- stm32 BootLoader程序(main.c)
- STM32修炼的最好书
- STM32 BLDC 无刷电机
- GBT 28169-2011 嵌入式软件 C语言编码规范
评论
共有 条评论