基本信息
源码名称:C6747_spi.c
源码大小:1.96KB
文件格式:.c
开发语言:C/C++
更新时间:2022-01-09
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
C6747_spi.c
Uint32 spidat1;
SPI_SPIGCR0 = 0; //SPI复位
C6747_wait(0xff);
SPI_SPIGCR0 = 1; //SPI取消复位
SPI_SPIGCR1 = 0 //设置为Master模式
| (0 << 24) //enable
| (0 << 16) //Internal loop-back test mode disabled:自检
| (1 << 1)
| (1 << 0); //3:Master;0:Slave
SPI_SPIPC0 = 0 //1:SPI功能引脚;0:GPIO功能引脚
| (1 << 11) //SPI_SOMI
| (1 << 10) //SPI_SIMO
| (1 << 9) //SPI_CLK
| (0 << 8) //SPI_ENA
| (1 << 0); //SPI_SCS
SPI_SPIPC1 = 0 //SPI引脚的输入输出配置
| (0 << 11) //SPI_SOMI pin is an input
| (1 << 10) //SPI_SIMO pin is an output
| (1 << 9) //SPI_CLK pin is an output
// | (1 << 8) //SPI_ENA pin is an output
| (1 << 0); //SPI_SCS pin is an output
// spidat1 = 0
// | (0 << 28)
// | (0 << 24)
// | (2 << 16)
// | (0 << 0);
spidat1 = 0
| (0 << 28) //CSHOLD:CS始终为低
| (0 << 25)
| (0 << 24) //FORMAT:0
| (0 << 16) //CSRN:CS -> LOW
| (0 << 0); //TXDATA
SPI_SPIDAT1 = spidat1;
SPI_SPIFMT0 = 0
| (0 << 20) //Most significant bit is shifted out first:高位移出
| (0 << 18) //delay enable:0;delay disable:1
| (0 << 17) //POLARITY
| (0 << 16) //PHASE
| (11 << 8) //SPIclk -> 12.5MHz
| (8 << 0); //SPI data word length 8bits
SPI_SPIDEF = 0
| (0 << 0); //define the state of the SPIx_SCS[n] pins when no transmissions are performed.
SPI_SPIDELAY = 0
| (18 << 24)
| (18 << 16);
SPI_SPIINT = 0
| (1 << 24) //high-impedance
| (0 << 16)
| (0 << 8)
| (0 << 6)
| (1 << 4); //enables interrupt on the error
SPI_SPILVL = 0
| (0 << 8) //Receive interrupt is mapped to interrupt line INT1 it is 1;(reserved)
| (0 << 6) //Receive overrun interrupt is mapped to interrupt line INT1 it is 1;(reserved)
| (0 << 4); //Bit error interrupt is mapped to the interrupt the INT1 if it is 1;(reserved)
SPI_SPIGCR1 |= (1 << 24); //enable
}
C6747_spi.c
void SPIconfig()
{Uint32 spidat1;
SPI_SPIGCR0 = 0; //SPI复位
C6747_wait(0xff);
SPI_SPIGCR0 = 1; //SPI取消复位
SPI_SPIGCR1 = 0 //设置为Master模式
| (0 << 24) //enable
| (0 << 16) //Internal loop-back test mode disabled:自检
| (1 << 1)
| (1 << 0); //3:Master;0:Slave
SPI_SPIPC0 = 0 //1:SPI功能引脚;0:GPIO功能引脚
| (1 << 11) //SPI_SOMI
| (1 << 10) //SPI_SIMO
| (1 << 9) //SPI_CLK
| (0 << 8) //SPI_ENA
| (1 << 0); //SPI_SCS
SPI_SPIPC1 = 0 //SPI引脚的输入输出配置
| (0 << 11) //SPI_SOMI pin is an input
| (1 << 10) //SPI_SIMO pin is an output
| (1 << 9) //SPI_CLK pin is an output
// | (1 << 8) //SPI_ENA pin is an output
| (1 << 0); //SPI_SCS pin is an output
// spidat1 = 0
// | (0 << 28)
// | (0 << 24)
// | (2 << 16)
// | (0 << 0);
spidat1 = 0
| (0 << 28) //CSHOLD:CS始终为低
| (0 << 25)
| (0 << 24) //FORMAT:0
| (0 << 16) //CSRN:CS -> LOW
| (0 << 0); //TXDATA
SPI_SPIDAT1 = spidat1;
SPI_SPIFMT0 = 0
| (0 << 20) //Most significant bit is shifted out first:高位移出
| (0 << 18) //delay enable:0;delay disable:1
| (0 << 17) //POLARITY
| (0 << 16) //PHASE
| (11 << 8) //SPIclk -> 12.5MHz
| (8 << 0); //SPI data word length 8bits
SPI_SPIDEF = 0
| (0 << 0); //define the state of the SPIx_SCS[n] pins when no transmissions are performed.
SPI_SPIDELAY = 0
| (18 << 24)
| (18 << 16);
SPI_SPIINT = 0
| (1 << 24) //high-impedance
| (0 << 16)
| (0 << 8)
| (0 << 6)
| (1 << 4); //enables interrupt on the error
SPI_SPILVL = 0
| (0 << 8) //Receive interrupt is mapped to interrupt line INT1 it is 1;(reserved)
| (0 << 6) //Receive overrun interrupt is mapped to interrupt line INT1 it is 1;(reserved)
| (0 << 4); //Bit error interrupt is mapped to the interrupt the INT1 if it is 1;(reserved)
SPI_SPIGCR1 |= (1 << 24); //enable
}