赞
踩
SPI,是英语Serial Peripheral Interface的缩写,顾名思义就是串行外围设备接口。SPI,是一种高速的,全双工,同步的通信总线,并且在芯片的管脚上只占用四根线,节约了芯片的管脚,同时为PCB的布局上节省空间,提供方便,正是出于这种简单易用的特性,现在越来越多的芯片集成了这种通信协议。
由单片机传送数据到FPGA,在signaltap上验证
单片机部分代码
//main函数部分 #include "stm32f4xx.h" #include "delay.h" #include "test.h" #include "SPI.h" void gpio_led_tick_loop(int n){ int count = n; while(count) { GPIO_SetBits(GPIOA,GPIO_Pin_15); delay_ms(2000); GPIO_ResetBits(GPIOA,GPIO_Pin_15); delay_ms(2000); break; } } void gpio_clk_loop(){ while(1) { GPIO_SetBits (GPIOC,GPIO_Pin_4); GPIO_ResetBits(GPIOC,GPIO_Pin_4); GPIO_SetBits (GPIOA,GPIO_Pin_7); GPIO_ResetBits(GPIOA,GPIO_Pin_7); GPIO_SetBits (GPIOC,GPIO_Pin_5); GPIO_ResetBits(GPIOC,GPIO_Pin_5); } } int main(void) { delay_init(168); ALLGPIO_Init(); gpio_led_tick_loop(1); // spi_wr_test_loop(); // spi_wr_data_loop(); gpio_clk_loop(); } //管脚初始化设置 #include "test.h" void ALLGPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);//±ØÐëʹÄÜGPIOAʱÖÓ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);//±ØÐëʹÄÜGPIOCʱÖÓ //³õʼ»¯LED GPIOA->MODER=0x01; //GPIOA15³õʼ»¯ÉèÖà GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;//LED1¶ÔÓ¦IO¿ÚPA15 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//ÆÕͨÊä³öģʽ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//ÍÆÍìÊä³ö GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz,ËÙ¶ÈÑ¡ÔñûÓдóÓ°Ïì GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;//ÏÂÀ£¬³õʼ״̬ʱÊä³öµÍµçƽ£¬µÆÃð GPIO_Init(GPIOA,
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。