本文整理汇总了C++中SPIx_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ SPIx_Init函数的具体用法?C++ SPIx_Init怎么用?C++ SPIx_Init使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SPIx_Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SD_IO_Init
/**
* @brief Initializes the SD Card and put it into StandBy State (Ready for
* data transfer).
* @retval None
*/
void SD_IO_Init(void)
{
GPIO_InitTypeDef gpioinitstruct = {0};
uint8_t counter = 0;
/* SD_CS_GPIO Periph clock enable */
SD_CS_GPIO_CLK_ENABLE();
/* Configure SD_CS_PIN pin: SD Card CS pin */
gpioinitstruct.Pin = SD_CS_PIN;
gpioinitstruct.Mode = GPIO_MODE_OUTPUT_PP;
gpioinitstruct.Pull = GPIO_PULLUP;
gpioinitstruct.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(SD_CS_GPIO_PORT, &gpioinitstruct);
/*------------Put SD in SPI mode--------------*/
/* SD SPI Config */
SPIx_Init();
/* SD chip select high */
SD_CS_HIGH();
/* Send dummy byte 0xFF, 10 times with CS high */
/* Rise CS and MOSI for 80 clocks cycles */
for (counter = 0; counter <= 9; counter++)
{
/* Send dummy byte 0xFF */
SD_IO_WriteByte(SD_DUMMY_BYTE);
}
}
示例2: LCD_IO_Init
/**
* @brief Initialize the LCD
* @retval None
*/
void LCD_IO_Init(void)
{
GPIO_InitTypeDef gpioinitstruct = {0};
/* LCD_CS_GPIO and LCD_DC_GPIO Periph clock enable */
LCD_CS_GPIO_CLK_ENABLE();
LCD_DC_GPIO_CLK_ENABLE();
/* Configure LCD_CS_PIN pin: LCD Card CS pin */
gpioinitstruct.Pin = LCD_CS_PIN;
gpioinitstruct.Mode = GPIO_MODE_OUTPUT_PP;
gpioinitstruct.Pull = GPIO_NOPULL;
gpioinitstruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(SD_CS_GPIO_PORT, &gpioinitstruct);
/* Configure LCD_DC_PIN pin: LCD Card DC pin */
gpioinitstruct.Pin = LCD_DC_PIN;
HAL_GPIO_Init(LCD_DC_GPIO_PORT, &gpioinitstruct);
/* LCD chip select high */
LCD_CS_HIGH();
/* LCD SPI Config */
SPIx_Init();
}
示例3: NRF24L01_Init
//初始化24L01的IO口
void NRF24L01_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOC, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP ; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_SetBits(GPIOA,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP ; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_SetBits(GPIOC,GPIO_Pin_4);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU ; //上拉输入
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
SPIx_Init(); //初始化SPI
Clr_NRF24L01_CE; //使能24L01 NRF24L01_CE
Set_NRF24L01_CSN; //SPI片选取消 NRF24L01_CSN
}
示例4: GYRO_IO_Init
/**
* @brief Configures the GYRO SPI interface.
* @param None
* @retval None
*/
void GYRO_IO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure the Gyroscope Control pins ------------------------------------*/
/* Enable CS GPIO clock and Configure GPIO PIN for Gyroscope Chip select */
GYRO_CS_GPIO_CLK_ENABLE();
GPIO_InitStructure.Pin = GYRO_CS_PIN;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_NOPULL;
GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM;
HAL_GPIO_Init(GYRO_CS_GPIO_PORT, &GPIO_InitStructure);
/* Deselect : Chip Select high */
GYRO_CS_HIGH();
// /* Enable INT1, INT2 GPIO clock and Configure GPIO PINs to detect Interrupts */
// GYRO_INT_GPIO_CLK_ENABLE();
// GPIO_InitStructure.Pin = GYRO_INT1_PIN | GYRO_INT2_PIN;
// GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
// GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
// GPIO_InitStructure.Pull= GPIO_NOPULL;
// HAL_GPIO_Init(GYRO_INT_GPIO_PORT, &GPIO_InitStructure);
SPIx_Init();
}
示例5: main
int main(void)
{
// uint32_t pre = 0 ;
uint8_t* p = 0;
timer_config();
SPIx_Init();
Led_Init();
Key_Init();
Usart2_Init(9600);
// enc28j60_init(mac);
install_uart_dev();
stack_init();
// test_hardhandler(2,(int*)1);
my_tftp_init();
telnet_service_init();
// web_server_init();
// *p = 1 ;
#if 0
while(1)
{
stack_process();
Led_Process();
shell();
}
#endif
bootstart();
return 0 ;
}
示例6: SPI_Flash_Init
//初始化SPI FLASH的IO口
void SPI_Flash_Init(void)
{
RCC->APB2ENR|=1<<2; //PORTA时钟使能
GPIOA->CRL&=0XFFF000FF;
GPIOA->CRL|=0X00033300;//PA2.3.4 推挽
GPIOA->ODR|=0X7<<2; //PA2.3.4上拉
SPIx_Init(); //初始化SPI
}
示例7: SPIx_Error
/**
* @brief SPIx error treatment function.
* @param None
* @retval None
*/
static void SPIx_Error(void)
{
/* De-initialize the SPI comunication bus */
HAL_SPI_DeInit(&SpiHandle);
/* Re-Initiaize the SPI comunication bus */
SPIx_Init();
}
示例8: SPIx_Error
/**
* @brief SPI error treatment function
* @param None
* @retval None
*/
static void SPIx_Error (void)
{
/* De-initialize the SPI communication BUS */
HAL_SPI_DeInit(&heval_Spi);
/* Re- Initiaize the SPI communication BUS */
SPIx_Init();
}
示例9: main
int main(void)
{
DelayInit();
lcd16x2_init(LCD16X2_DISPLAY_ON_CURSOR_OFF_BLINK_OFF);
SPIx_Init();
while (1)
{
// Enable slave
SPIx_EnableSlave();
// Write command to slave to turn on LED blinking
SPIx_Transfer((uint8_t) '1');
DelayUs(10);
// Write command to slave for asking LED blinking status
SPIx_Transfer((uint8_t) '?');
DelayUs(10);
// Read LED blinking status (off/on) from slave by transmitting dummy byte
receivedByte = SPIx_Transfer(0);
// Disable slave
SPIx_DisableSlave();
// Display LED blinking status
lcd16x2_clrscr();
if (receivedByte == 0)
{
lcd16x2_puts("LED Blinking Off");
}
else if (receivedByte == 1)
{
lcd16x2_puts("LED Blinking On");
}
DelayMs(2500);
// Enable slave
SPIx_EnableSlave();
// Write command to slave to turn off LED blinking
SPIx_Transfer((uint8_t) '0');
DelayUs(10);
// Write command to slave for asking LED blinking status
SPIx_Transfer((uint8_t) '?');
DelayUs(10);
// Read LED blinking status (off/on) from slave by transmitting dummy byte
receivedByte = SPIx_Transfer(0);
// Disable slave
SPIx_DisableSlave();
// Display LED blinking status
lcd16x2_clrscr();
if (receivedByte == 0)
{
lcd16x2_puts("LED Blinking Off");
}
else if (receivedByte == 1)
{
lcd16x2_puts("LED Blinking On");
}
DelayMs(2500);
}
}
示例10: SPI_Flash_Init
//初始化SPI FLASH的IO口
void SPI_Flash_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4; //SPI CS
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //复用推挽输出
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_SetBits(GPIOA,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4);
SPIx_Init(); //初始化SPI
}
示例11: nRF_Init
void nRF_Init() {
nRFSPIConf.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
nRFSPIConf.SPI_Mode = SPI_Mode_Master;
nRFSPIConf.SPI_DataSize = SPI_DataSize_8b;
nRFSPIConf.SPI_CPOL = SPI_CPOL_Low;
nRFSPIConf.SPI_CPHA = SPI_CPHA_1Edge;
nRFSPIConf.SPI_NSS = SPI_NSS_Soft;
nRFSPIConf.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8;
nRFSPIConf.SPI_FirstBit = SPI_FirstBit_MSB;
nRFSPIConf.SPI_CRCPolynomial = 7;
SPIx_Init(SPI1);
}
示例12: SPI_Flash_Init
//初始化SPI FLASH的IO口
void SPI_Flash_Init(void)
{
//RCC->APB2ENR|=1<<2; //PORTA时钟使能
//这里
//GPIOA->CRL&=0XFFF000FF;
//GPIOA->CRL|=0X00033300;//PA2.3.4 推挽
//GPIOA->ODR|=0X7<<2; //PA2.3.4上拉
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4; //SPI CS
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //复用推挽输出
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_SetBits(GPIOA,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4);
SPIx_Init(); //初始化SPI
}
示例13: NRF24L01_Init
//初始化24L01的IO口
void NRF24L01_Init(void)
{
RCC->APB2ENR|=1<<2; //使能PORTA口时钟
RCC->APB2ENR|=1<<4; //使能PORTC口时钟
GPIOA->CRL&=0XFFF000FF;//PA4输出
GPIOA->CRL|=0X00033300;
GPIOA->ODR|=7<<2; //PA2.3.4 输出1
GPIOC->CRL&=0XFF00FFFF;//PC4输出 PC5输出
GPIOC->CRL|=0X00830000;
GPIOC->ODR|=3<<4; //上拉
//这里要修改SPI初始化函数
//设置:CPHA=0 CPOL=0
SPIx_Init(); //初始化SPI
NRF24L01_CE=0; //使能24L01
NRF24L01_CSN=1; //SPI片选取消
}
示例14: SD_IO_Init
/**
* @brief Initializes the SD Card and put it into StandBy State (Ready for
* data transfer).
* @param None
* @retval None
*/
void SD_IO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
uint8_t counter;
/* SD_CS_GPIO Periph clock enable */
SD_CS_GPIO_CLK_ENABLE();
/* Configure SD_CS_PIN pin: SD Card CS pin */
GPIO_InitStruct.Pin = SD_CS_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(SD_CS_GPIO_PORT, &GPIO_InitStruct);
/* LCD chip select line perturbs SD also when the LCD is not used */
/* this is a workaround to avoid sporadic failures during r/w operations */
LCD_CS_GPIO_CLK_ENABLE();
GPIO_InitStruct.Pin = LCD_CS_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(LCD_CS_GPIO_PORT, &GPIO_InitStruct);
LCD_CS_HIGH();
/*------------Put SD in SPI mode--------------*/
/* SD SPI Config */
SPIx_Init();
/* SD chip select high */
SD_CS_HIGH();
/* Send dummy byte 0xFF, 10 times with CS high */
/* Rise CS and MOSI for 80 clocks cycles */
for (counter = 0; counter <= 9; counter++)
{
/* Send dummy byte 0xFF */
SD_IO_WriteByte(SD_DUMMY_BYTE);
}
}
示例15: LCD_IO_Init
/**
* @brief Configures the LCD_SPI interface.
* @param None
* @retval None
*/
void LCD_IO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Configure the LCD Control pins ------------------------------------------*/
LCD_NCS_GPIO_CLK_ENABLE();
/* Configure NCS in Output Push-Pull mode */
GPIO_InitStruct.Pin = LCD_NCS_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW ;
HAL_GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStruct);
/* Set or Reset the control line */
LCD_CS_LOW();
LCD_CS_HIGH();
SPIx_Init();
}