/*
Analogysemi xutong
2023/03/06
*/
#ifndef __ADX51X_H
#define __ADX51X_H
#include "bsp_lpspi.h"
/*command define*/
#define ADX51X_WAKEUP 0x00
#define ADX51X_RDATA 0x01
#define ADX51X_RDATAC 0x03
#define ADX51X_SDATAC 0x0F
#define ADX51X_RREG 0x10
#define ADX51X_WREG 0X50
#define ADX51X_SELFCAL 0XF0
#define ADX51X_SELFOCAL 0XF1
#define ADX51X_SELFGCAL 0XF2
#define ADX51X_SYSOCAL 0XF3
#define ADX51X_SYSGCAL 0XF4
#define ADX51X_SYNC 0XFC
#define ADX51X_STANDBY 0xFD
#define ADX51X_RESET 0xFE
//RREG Read n nnnn registers starting at address r rrrr
//First Byte 001r rrrr (2xh)
//Second Byte 000n nnnn
//n nnnn = number of registers to be read or written – 1. For example, to read or write three registers, set n nnnn = 0 (0010). r rrrr = the
//starting register address for read and write commands
//WREG 同上
/*
寄存器定义
*/
#define ADX51X_STATUS 0x00
#define ADX51X_MUX 0x01
#define ADX51X_ADCON 0x02
#define ADX51X_DRATE 0x03
#define ADX51X_IO 0x04
#define ADX51X_OFC0 0x05
#define ADX51X_OFC1 0x06
#define ADX51X_OFC2 0x07
#define ADX51X_FSC0 0x08
#define ADX51X_FSC1 0x09
#define ADX51X_FSC2 0x0A
#define ADX51X_CFG0 0x0B
#define ADX51X_CFG1 0x0C
#define ADX51X_CFG2 0x0D
#define ADX51X_CFG3 0x0E
#define ADX51X_CFG4 0x0F
#define ADX51X_CFG5 0x10
#define ADX51X_DEV_CFG 0x11
#define ADX51X_MOD_STAT 0x12
#define ADX51X_DEV_STAT 0x13
#define ADX51X_CMD_STAT 0x14
#define ADX51X_AIN0 0
#define ADX51X_AIN1 1
#define ADX51X_AIN2 2
#define ADX51X_AIN3 3
#define ADX51X_AIN4 4
#define ADX51X_AIN5 5
#define ADX51X_AIN6 6
#define ADX51X_AIN7 7
#define ADX51X_AIN_COM 8
/*
通道配置
channel config
*/
#define ADX51X_ADC_CH(x) x
#define DRDY_PIN P00
//写命令
void ADX51X_Command(uint8_t Com);
//获取芯片的ID号
uint8_t ADX51X_GetChipID(void);
//获取寄存器值
uint8_t ADX51X_GetReg(uint8_t Rreg);
//获取多个寄存器值
void ADX51X_ReadMultiReg(uint8_t StartReg,uint8_t RegNum,uint8_t *Data);
//写入寄存器值
void ADX51X_WriteReg(uint8_t Wreg,uint8_t Data);
//写多个寄存器的值
void ADX51X_WriteMultiReg(uint8_t StartReg,uint8_t RegNum,uint8_t *Data);
//获取所有寄存器值
void ADX51X_GetAllReg(void);
//设定通道并且获取ADC的值
void ADX51X_GetADC_Value(uint8_t AIN_P,uint8_t AIN_N,uint8_t *Rxdata);
//初始化ADX51X
void ADX51X_Init(void);
#endif
/*
Analogysemi xutong
2024/03/06
*/
#include "ADX51X.h"
#include "bsp_lpspi.h"
//初始化ADX51X
void ADX51X_Init(void)
{
//拉PWDN和RST
}
//获取芯片的ID号
//ADX51X default Value 0x20
uint8_t ADX51X_GetChipID(void)
{
uint8_t ID;
ID=ADX51X_GetReg(ADX51X_STATUS);
return ID;
}
//获取芯片寄存器值
uint8_t ADX51X_GetReg(uint8_t Rreg)
{
uint8_t TxData[3];
uint8_t RxData[3];
//读取命令,
TxData[0]=ADX51X_RREG|Rreg;
//选择要读取的寄存器
TxData[1]=0x00;
//读取单个寄存器
TxData[2]=0X00;
//开始读取
Lpspi_Read(3,TxData,RxData);
//返回寄存器值
return RxData[2];
}
//写单个芯片寄存器值
void ADX51X_WriteReg(uint8_t Wreg,uint8_t Data)
{
uint8_t TxData[3];
//写入命令,
TxData[0]=ADX51X_WREG|Wreg;
//选择要写入的的寄存器
TxData[1]=0x00;
//读取写入寄存器
TxData[2]=Data;
Lpspi_Write(3,TxData);
}
//写多个芯片寄存器值
//StartReg 起始寄存器地址
//RegNum 要写的寄存器数量
//*Data 寄存器参数传入
void ADX51X_WriteMultiReg(uint8_t StartReg,uint8_t RegNum,uint8_t *Data)
{
uint8_t TxData[32];
uint8_t i;
//写入命令,
TxData[0]=ADX51X_WREG|StartReg;
//选择要写入的的寄存器
TxData[1]=RegNum-1;
for(i=0;i<RegNum;i++)
{
//将指针数据赋值给Txdata
TxData[2+i]=*Data;
//指向下个数据地址
Data++;
}
//最终发送多少个数据
Lpspi_Write(2+RegNum,TxData);
}
//读多个芯片寄存器值
//StartReg 起始寄存器地址
//RegNum 要写的寄存器数量
//*Data 寄存器参数传出
void ADX51X_ReadMultiReg(uint8_t StartReg,uint8_t RegNum,uint8_t *Data)
{
//读取寄存器
uint8_t TxData[3];
//读取命令,
TxData[0]=ADX51X_RREG|StartReg;
//选择要写入的的寄存器
TxData[1]=RegNum-1;
//最终接收多少个数据
Lpspi_Read(2+RegNum,TxData,Data);
}
//打印所有寄存器地址
void ADX51X_GetAllReg(void)
{
uint8_t i,j;
for(i=0;i<20;i++)
{
j=ADX51X_GetReg(i);
}
}
//发送ADX51X 数据指令 如SDATAC或者RDATAC
//详情见头文件command define部分
void ADX51X_Command(uint8_t Com)
{
uint8_t TxData[1];
TxData[0]=Com;
Lpspi_Write(1,TxData);
}
//设定通道并且获取adc数据
//获取ADC的值
//ADC负接在AIN1上
void ADX51X_GetADC_Value(uint8_t AIN_P,uint8_t AIN_N,uint8_t *Rxdata)
{
uint8_t TxData[]={0,0,0};
// 可以在这里加DRDY的判断
ADX51X_Command(ADX51X_SDATAC);
ADX51X_WriteReg(ADX51X_MUX,AIN_P<<4|AIN_N);
ADX51X_Command(ADX51X_SYNC);
ADX51X_Command(ADX51X_WAKEUP);
ADX51X_Command(ADX51X_RDATA);
Lpspi_Read(3,TxData,Rxdata);
Lpspi_Stop();
}
补充下驱动
#include "bsp_lpspi.h"
#ifdef HardWare_SPI //Begin of hard_spi
SPI_HandleTypeDef SpiHandle;
void Spi_delay(uint32_t count)
{
volatile uint32_t i = 0;
for (i = 0; i < count*10; ++i)
{
__asm("NOP"); /* 调用nop空指令 */
__asm("NOP"); /* 调用nop空指令 */
__asm("NOP"); /* 调用nop空指令 */
__asm("NOP"); /* 调用nop空指令 */
__asm("NOP"); /* 调用nop空指令 */
}
}
void LPSPI_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Enable SPI1 clock */
SPIx_CLK_ENABLE();
SPIx_SCK_GPIO_CLK_ENABLE();
SPIx_MISO_GPIO_CLK_ENABLE();
SPIx_MOSI_GPIO_CLK_ENABLE();
SPIx_CS_GPIO_CLK_ENABLE();
/* 初始化GPIO 配置*/
/*##-1- Configure peripheral GPIO ##########################################*/
/* SPI SCK GPIO pin configuration */
GPIO_InitStruct.Pin = SPIx_SCK_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
//GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
//GPIO_InitStruct.Alternate = SPIx_SCK_AF;
HAL_GPIO_Init(SPIx_SCK_GPIO_PORT, &GPIO_InitStruct);
/* SPI MISO GPIO pin configuration */
GPIO_InitStruct.Pin = SPIx_MISO_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
//GPIO_InitStruct.Alternate = SPIx_MISO_AF;
HAL_GPIO_Init(SPIx_MISO_GPIO_PORT, &GPIO_InitStruct);
/* SPI MOSI GPIO pin configuration */
GPIO_InitStruct.Pin = SPIx_MOSI_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
//GPIO_InitStruct.Alternate = SPIx_MOSI_AF;
HAL_GPIO_Init(SPIx_MOSI_GPIO_PORT, &GPIO_InitStruct);
/* SPI CS GPIO pin configuration */
GPIO_InitStruct.Pin = SPIx_CS_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
//GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(SPIx_CS_GPIO_PORT, &GPIO_InitStruct);
/* 初始化SPI 配置*/
/*##-2- Configure the SPI peripheral #######################################*/
/* Set the SPI parameters */
SpiHandle.Instance = SPIx;
SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
SpiHandle.Init.Direction = SPI_DIRECTION_2LINES;
SpiHandle.Init.CLKPhase = SPI_PHASE_2EDGE ;
SpiHandle.Init.CLKPolarity = SPI_POLARITY_LOW;
SpiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
SpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
SpiHandle.Init.TIMode = SPI_TIMODE_DISABLE;
SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
SpiHandle.Init.CRCPolynomial = 7;
SpiHandle.Init.NSS = SPI_NSS_SOFT;
SpiHandle.Init.Mode = SPI_MODE_MASTER;
//初始化SPI
HAL_SPI_Init(&SpiHandle);
__HAL_SPI_ENABLE(&SpiHandle);
//默认拉高CS引脚
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_SET);
}
void Lpspi_Start(void)
{
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_RESET);
}
void Lpspi_Stop(void)
{
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_SET);
}
void Lpspi_Write(uint8_t datasize,uint8_t *data)
{
//写数据
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_RESET);
HAL_SPI_Transmit(&SpiHandle,data, datasize, 5000);
Spi_delay(30);
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_SET);
}
void Lpspi_Read(uint8_t datasize,uint8_t *data,uint8_t *Rxdata)
{
// 读写数据
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_RESET);
HAL_SPI_TransmitReceive(&SpiHandle,data,Rxdata, datasize, 5000);
Spi_delay(30);
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_SET);
}
#endif //end of hard_spi
#ifdef Soft_SPI //begin of soft_spi
SPI_HandleTypeDef SpiHandle;
void Spi_delay(uint32_t count)
{
volatile uint32_t i = 0;
for (i = 0; i < count; ++i)
{
__asm("NOP"); /* 调用nop空指令 */
__asm("NOP"); /* 调用nop空指令 */
__asm("NOP"); /* 调用nop空指令 */
__asm("NOP"); /* 调用nop空指令 */
__asm("NOP"); /* 调用nop空指令 */
}
}
void LPSPI_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Enable SPI1 clock */
//SPIx_CLK_ENABLE();
SPIx_SCK_GPIO_CLK_ENABLE();
SPIx_MISO_GPIO_CLK_ENABLE();
SPIx_MOSI_GPIO_CLK_ENABLE();
SPIx_CS_GPIO_CLK_ENABLE();
/* 初始化GPIO 配置*/
/*##-1- Configure peripheral GPIO ##########################################*/
/* SPI SCK GPIO pin configuration */
GPIO_InitStruct.Pin = SPIx_SCK_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
//GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
//GPIO_InitStruct.Alternate = SPIx_SCK_AF;
HAL_GPIO_Init(SPIx_SCK_GPIO_PORT, &GPIO_InitStruct);
/* SPI MISO GPIO pin configuration */
GPIO_InitStruct.Pin = SPIx_MISO_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
//GPIO_InitStruct.Alternate = SPIx_MISO_AF;
HAL_GPIO_Init(SPIx_MISO_GPIO_PORT, &GPIO_InitStruct);
/* SPI MOSI GPIO pin configuration */
GPIO_InitStruct.Pin = SPIx_MOSI_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
//GPIO_InitStruct.Alternate = SPIx_MOSI_AF;
HAL_GPIO_Init(SPIx_MOSI_GPIO_PORT, &GPIO_InitStruct);
/* SPI CS GPIO pin configuration */
GPIO_InitStruct.Pin = SPIx_CS_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
//GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(SPIx_CS_GPIO_PORT, &GPIO_InitStruct);
//默认拉高CS引脚
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_SET);
//SCLK空闲拉低
HAL_GPIO_WritePin(SPIx_SCK_GPIO_PORT,SPIx_SCK_PIN,GPIO_PIN_RESET);
//SCLK空闲拉高
//HAL_GPIO_WritePin(SPIx_SCK_GPIO_PORT,SPIx_SCK_PIN,GPIO_PIN_SET);
}
void Lpspi_Start(void)
{
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_RESET);
}
void Lpspi_Stop(void)
{
HAL_GPIO_WritePin(SPIx_CS_GPIO_PORT,SPIx_CS_PIN,GPIO_PIN_SET);
}
void SCLK_H(void)
{
HAL_GPIO_WritePin(SPIx_SCK_GPIO_PORT,SPIx_SCK_PIN,GPIO_PIN_SET);
}
void SCLK_L(void)
{
HAL_GPIO_WritePin(SPIx_SCK_GPIO_PORT,SPIx_SCK_PIN,GPIO_PIN_RESET);
}
void SPI_Transmit_Data_mode0(uint8_t *Data ,uint8_t Size) //SCLK low first edge
{
uint8_t i,a=0,data=0;
for(a=0;a<Size;a++)
{
data = Data[a];
for(i = 0;i < 8;i++)
{
SCLK_L();
if(data&(0x80))//data bit = 1
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_SET);//MOSI SET 1
}
else
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_RESET);//MOSI SET 0
}
SCLK_H();
data <<=1;
}
}
}
void SPI_Receive_Data_mode0( uint8_t *Data,uint8_t *Rxdata ,uint8_t Size) //SCLK low first edge
{
uint8_t i,a,data;
for(a=0;a<Size;a++)
{
data = Data[a];
Rxdata[a]=0;
for(i = 0;i < 8;i++)
{
SCLK_L();
if(data&(0x80))//data bit = 1
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_SET);//MOSI SET 1
}
else
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_RESET);//MOSI SET 0
}
if(HAL_GPIO_ReadPin(SPIx_MISO_GPIO_PORT,SPIx_MISO_PIN)==1)
{
Rxdata[a]|=(0x80 >>i);
}
SCLK_H();
data <<=1;
}
}
}
void SPI_Transmit_Data_mode1(uint8_t *Data ,uint8_t Size) //SCLK low second edge
{
uint8_t i,a=0,data=0;
for(a=0;a<Size;a++)
{
data = Data[a];
for(i = 0;i < 8;i++)
{
SCLK_H();
if(data&(0x80))//data bit = 1
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_SET);//MOSI SET 1
}
else
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_RESET);//MOSI SET 0
}
data <<=1;
SCLK_L();
}
}
}
void SPI_Receive_Data_mode1( uint8_t *Data,uint8_t *Rxdata ,uint8_t Size) //SCLK low second edge
{
uint8_t i,a,data=0;
for(a=0;a<Size;a++)
{
data = Data[a];
Rxdata[a]=0;
for(i = 0;i < 8;i++)
{
SCLK_H();
if(data&(0x80))//data bit = 1
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_SET);//MOSI SET 1
}
else
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_RESET);//MOSI SET 0
}
data <<=1;
SCLK_L();
if(HAL_GPIO_ReadPin(SPIx_MISO_GPIO_PORT,SPIx_MISO_PIN)==1)
{
Rxdata[a]|=(0x80 >>i);
}
}
}
}
void SPI_Transmit_Data_mode2(uint8_t *Data ,uint8_t Size) //SCLK high first edge
{
uint8_t i,a=0,data=0;
for(a=0;a<Size;a++)
{
data = Data[a];
for(i = 0;i < 8;i++)
{
SCLK_H();
//Spi_delay(1);
if(data&(0x80))//data bit = 1
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_SET);//MOSI SET 1
}
else
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_RESET);//MOSI SET 0
}
//Spi_delay(1);
SCLK_L();
//Spi_delay(1);
data <<=1;
SCLK_H();
//Spi_delay(1);
}
}
}
void SPI_Receive_Data_mode2( uint8_t *Data,uint8_t *Rxdata ,uint8_t Size) //SCLK low first edge
{
uint8_t i,a,data=0;
for(a=0;a<Size;a++)
{
data = Data[a];
Rxdata[a]=0;
for(i = 0;i < 8;i++)
{
SCLK_H();
//Spi_delay(1);
if(data&(0x80))//data bit = 1
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_SET);//MOSI SET 1
}
else
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_RESET);//MOSI SET 0
}
SCLK_L();
if(HAL_GPIO_ReadPin(SPIx_MISO_GPIO_PORT,SPIx_MISO_PIN)==1)
{
Rxdata[a]|=(0x80 >>i);
}
data <<=1;
SCLK_H();
}
}
}
void SPI_Transmit_Data_mode3(uint8_t *Data ,uint8_t Size) //SCLK high second edge
{
uint8_t i,a=0,data=0;
for(a=0;a<Size;a++)
{
data = Data[a];
for(i = 0;i < 8;i++)
{
SCLK_L();
if(data&(0x80))//data bit = 1
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_SET);//MOSI SET 1
}
else
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_RESET);//MOSI SET 0
}
data <<=1;
SCLK_H();
}
}
}
void SPI_Receive_Data_mode3( uint8_t *Data,uint8_t *Rxdata ,uint8_t Size) //SCLK low second edge
{
uint8_t i,a,data=0;
for(a=0;a<Size;a++)
{
data = Data[a];
Rxdata[a]=0;
for(i = 0;i < 8;i++)
{
SCLK_L();
if(data&(0x80))//data bit = 1
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_SET);//MOSI SET 1
}
else
{
HAL_GPIO_WritePin(SPIx_MOSI_GPIO_PORT,SPIx_MOSI_PIN,GPIO_PIN_RESET);//MOSI SET 0
}
data <<=1;
SCLK_H();
if(HAL_GPIO_ReadPin(SPIx_MISO_GPIO_PORT,SPIx_MISO_PIN)==1)
{
Rxdata[a]|=(0x80 >>i);
}
}
}
}
void Lpspi_Write(uint8_t datasize,uint8_t *data)
{
//写数据
Lpspi_Start();
SPI_Transmit_Data_mode1(data,datasize);
Spi_delay(30);
//Lpspi_Stop();
}
void Lpspi_Read(uint8_t datasize,uint8_t *data,uint8_t *Rxdata)
{
// 读写数据
Lpspi_Start();
SPI_Receive_Data_mode1( data,Rxdata ,datasize);
//Spi_delay(30);
//Lpspi_Stop();
}
#endif //end of soft_spi
/*
analogysemi
xutong 2023/10/19
*/
#ifndef __BSP_LPSPI_H
#define __BSP_LPSPI_H
#include "stm32h7xx_hal.h"
//#include "stm32g0xx_hal.h"
//#include "stm32f1xx.h"
//#include "stm32f4xx.h"
//#define HardWare_SPI
#define Soft_SPI
#define SPIx SPI1
#define SPIx_CLK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE()
#define SPIx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define SPIx_MISO_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define SPIx_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define SPIx_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
/* Definition for SPIx Pins */
#define SPIx_SCK_PIN GPIO_PIN_3
#define SPIx_SCK_GPIO_PORT GPIOB
#define SPIx_SCK_AF GPIO_AF5_SPI1
#define SPIx_MISO_PIN GPIO_PIN_4
#define SPIx_MISO_GPIO_PORT GPIOB
#define SPIx_MISO_AF GPIO_AF5_SPI1
#define SPIx_MOSI_PIN GPIO_PIN_5
#define SPIx_MOSI_GPIO_PORT GPIOB
#define SPIx_MOSI_AF GPIO_AF5_SPI1
#define SPIx_CS_PIN GPIO_PIN_6
#define SPIx_CS_GPIO_PORT GPIOB
void Spi_delay(uint32_t count);
void LPSPI_Init(void);
void Lpspi_Start(void);
void Lpspi_Stop(void);
void Lpspi_Write(uint8_t datasize,uint8_t *data);
void Lpspi_Read(uint8_t datasize,uint8_t *data,uint8_t *Rxdata);
void SCLK_H(void);
void SCLK_L(void);
void SPI_Receive_Data( uint8_t *Data,uint8_t *Rxdata ,uint8_t Size);
void SPI_Transmit_Data(uint8_t *Data ,uint8_t Size);
#endif /* __BSP_LPSPI_H */
|