完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
void SPIx_Init(void)
{ GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA|RCC_APB2Periph_SPI1, ENABLE ); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //???????ì???? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_SetBits(GPIOA,GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7); SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //?è??SPI???ò?ò?????ò??????????:SPI?è???????????ò?????¤ SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //?è??SPI?¤×÷????:?è?????÷SPI SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //?è??SPI???????ó??:SPI·???????8?????á?? SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; //???????®???±????????:?±???ü???????? SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; //?????????????????±???? SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; //NSS???????????¨NSS?????©?????í???¨????SSI???©???í:????NSS??????SSI?????? SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256; //?¨???¨?????¤·???????:?¨?????¤·???????256 SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //???¨??????????MSB??????LSB??????:??????????MSB?????? SPI_InitStructure.SPI_CRCPolynomial = 7; //CRC?????????à???? SPI_Init(SPI1, &SPI_InitStructure); //?ù??SPI_InitStruct?????¨???????????????èSPIx?????÷ SPI_Cmd(SPI1, ENABLE); //????SPI???è SPIx_ReadWriteByte(0xff);//???????? } void NRF24L01_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB, ENABLE ); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; //PA4-->NRF2401_CSN 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_4); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //PB0-->NRF2401_CE GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //???ì???? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_SetBits(GPIOB,GPIO_Pin_0); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; //PB1-->NRF2401_IRQ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //???????? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_SetBits(GPIOB,GPIO_Pin_1); SPIx_Init(); //??????SPI Clr_NRF24L01_CE; //NRF24L01???????ú???? NRF24L01_CE Set_NRF24L01_CSN; //SPI???? NRF24L01_CSN } 贴上两个初始化的函数,不知道问题在哪,还请指教 |
|
相关推荐
1个回答
|
|
你硬件没接错吧?
|
|
|
|
只有小组成员才能发言,加入小组>>
如何使用STM32+nrf24l01架构把有线USB设备无线化?
2563 浏览 7 评论
请问能利用51单片机和nRF24L01模块实现实时语音无线传输吗?
2351 浏览 5 评论
3194 浏览 3 评论
2828 浏览 8 评论
为什么ucosii上移植lwip后系统进入了HardFault_Handler?
2782 浏览 4 评论
请教各位大咖:有没有接收频率32M左右的芯片推荐的?先感谢啦!
645浏览 1评论
886浏览 0评论
1007浏览 0评论
653浏览 0评论
482浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-12 13:25 , Processed in 1.139770 second(s), Total 76, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号