46 lines
1.4 KiB
C
46 lines
1.4 KiB
C
#ifndef __SPI_H
|
|
#define __SPI_H
|
|
|
|
#include "stm32f4xx.h"
|
|
|
|
|
|
|
|
/* MAX31865参考电阻 */
|
|
#define RREF (400) //400Ω
|
|
|
|
|
|
/* MAX31865控制口 */
|
|
#define MAX31865_CONTROL_PORT GPIOB
|
|
#define MAX31865_DRDYL_PORT GPIOD
|
|
#define MAX31865_SDO GPIO_Pin_14
|
|
#define MAX31865_CS GPIO_Pin_12
|
|
#define MAX31865_SCLK GPIO_Pin_13
|
|
#define MAX31865_SDI GPIO_Pin_15
|
|
#define MAX31865_DRDY GPIO_Pin_8
|
|
|
|
#define MAX31865_CS_SET GPIO_WriteBit(MAX31865_CONTROL_PORT,MAX31865_CS,Bit_SET)
|
|
#define MAX31865_CS_CLR GPIO_WriteBit(MAX31865_CONTROL_PORT,MAX31865_CS,Bit_RESET)
|
|
#define MAX31865_SCLK_SET GPIO_WriteBit(MAX31865_CONTROL_PORT,MAX31865_SCLK,Bit_SET)
|
|
#define MAX31865_SCLK_CLR GPIO_WriteBit(MAX31865_CONTROL_PORT,MAX31865_SCLK,Bit_RESET)
|
|
#define MAX31865_SDI_SET GPIO_WriteBit(MAX31865_CONTROL_PORT,MAX31865_SDI,Bit_SET)
|
|
#define MAX31865_SDI_CLR GPIO_WriteBit(MAX31865_CONTROL_PORT,MAX31865_SDI,Bit_RESET)
|
|
|
|
#define MAX31865_SDO_READ GPIO_ReadInputDataBit(MAX31865_CONTROL_PORT,MAX31865_SDO)
|
|
#define MAX31865_DRDY_READ GPIO_ReadInputDataBit(MAX31865_DRDYL_PORT,MAX31865_DRDY)
|
|
|
|
void MAX31865_Init(void); //MAX31865 初始化,软件模拟
|
|
void MAX31865_Cfg(void); //MAX31865 配置
|
|
float MAX31865_GetTemp(void);//MAX31865 获取温度
|
|
|
|
void MAX31865_Write(unsigned char addr, unsigned char data);
|
|
unsigned char MAX31865_Read(unsigned char addr);
|
|
//void SPI_Inital(void);
|
|
void Delay_Times(int d);
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|