当前位置: 首页 > news >正文

网站建设公司的公司网络销售

网站建设公司的公司,网络销售,知乎推广公司,常州网站建设效果STM32f407 网络接收 fpga 的 bin 文件并更新到 fpga series7(3) 简介 实验 3:在搭建好 tcp 服务器,并拟定好协议的前提下,接收每一个 bin 文件的块,配置到 fpga。 原理图 fpga fpga1 stm32 接线总结 // fpga引脚 stm32…

STM32f407 网络接收 fpga 的 bin 文件并更新到 fpga series7(3)

简介

实验 3:在搭建好 tcp 服务器,并拟定好协议的前提下,接收每一个 bin 文件的块,配置到 fpga。

原理图

fpga
在这里插入图片描述

fpga1
在这里插入图片描述

stm32
在这里插入图片描述

接线总结

// fpga引脚 stm32引脚
// 用不到D_OUT
#define PROGRAM_B PB0
#define INT_B     PB1
#define CCLK      PC10
#define D01_DIN   PC12
#define DONE      PD3

手册

搜索下载关键词:Xilinx XAPP583 Using a Microprocessor to Configure Xilinx 7 Series FPGAs

引脚

在这里插入图片描述

时序

在这里插入图片描述

伪代码在手册里,自己看

stm32cube 配置

在这里插入图片描述

单片机代码

load_fpga.c

#include "load_fpga.h"#include <stdio.h>
#include "main.h"#define WRITE_PROGRAM_B(x) HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, x)
#define WRITE_CCLK(x)      HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, x)
#define WRITE_D01_DIN(x)   HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, x)
#define READ_INT_B()       HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_1)
#define READ_DONE()        HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_3)/// @brief 交换4字节顺序
/// eg: 0xaabbccdd -> 0xddccbbaas
/// @param data
/// @return
unsigned int swap_uint32(unsigned int data) {unsigned int swapped;swapped = ((data << 24) & 0xFF000000) | ((data << 8) & 0x00FF0000) |((data >> 8) & 0x0000FF00) | ((data >> 24) & 0x000000FF);return swapped;
}/// @brief 产生count个时钟上升沿
/// @param drvdata
/// @param count
void shift_cclk(unsigned int count) {int i;// WRITE_CCLK(0); // 感觉有点多余,影响接收速度了for (i = 0; i < count; ++i) {WRITE_CCLK(1);WRITE_CCLK(0);}
}/// @brief 写入每一位,从高位开始
/// @param data32
void shift_word_out(unsigned int data32) {int i;unsigned int data;for (i = 31; i >= 0; i--) {data = (data32 & 1 << i) ? 1 : 0;WRITE_D01_DIN(data);shift_cclk(1);}
}/// @brief 准备写入
/// 配置准备下入状态
/// @param
/// @return 成功返回0
int program_init(void) {int i = 0;/* Configuration Reset */WRITE_PROGRAM_B(0);HAL_Delay(1);  // 1usWRITE_PROGRAM_B(1);/* Wait for Device Initialization */while (READ_INT_B() == 0) {++i;if (i > 0x00010000) {printf("INIT_B has not gone high\n");return -1;}}return 0;
}/// @brief 写入fpga
/// @param buf
/// @param len
/// @return 成功返回0
int program_data(char *buf, int len) {int i;for (i = 0; i < len; i += 4) {shift_word_out(swap_uint32(*(uint32_t *)(buf + i)));if (READ_INT_B() == 0) {printf("INIT_B error\n");return -1;}}return 0;
}/// @brief 写入完成
/// @param
/// @return 成功返回0
int program_done(void) {/* Check INIT_B */if (READ_INT_B() == 0) {printf("INIT_B error\n");return -1;}/* Wait for DONE to assert */int i = 0;while (READ_DONE() == 0) {shift_cclk(1);  // 不加会导致又概率失败++i;if (i > 0x00010000) {printf("DONE has not gone high\n");return -1;}}/* Compensate for Special Startup Conditions */shift_cclk(8);return 0;
}

tcp_echo.c

#include "tcp_echo.h"
#include "lwip/opt.h"
#include "lwip/tcp.h"
#include "load_fpga.h"
#if LWIP_NETCONN#include "lwip/sys.h"#include "lwip/api.h"#define TCPECHO_THREAD_PRIO (tskIDLE_PRIORITY + 4)#define kbuffer_len  1024#define kheader_size 24#define kdata_len    1000#define kmagic       0xaa5555aachar buffer[kbuffer_len];struct tcp_package_header {uint32_t magic;uint32_t type;uint32_t data_offset;uint32_t data_len;uint32_t order;uint32_t magic1;
};/// @brief TCP服务函数
/// @param arg
static void tcpecho_thread(void *arg) {struct netconn *conn, *newconn;err_t err, accept_err;struct netbuf *buf;void *data;u16_t len;int ret = 0;LWIP_UNUSED_ARG(arg);#if 1/* Create a new connection identifier. */conn = netconn_new(NETCONN_TCP);if (conn != NULL) {/* Bind connection to well known port number 7. */err = netconn_bind(conn, NULL, 7);if (err == ERR_OK) {/* Tell connection to go into listening mode. */netconn_listen(conn);while (1) {/* Grab new connection. */accept_err = netconn_accept(conn, &newconn);/* Process the new connection. */if (accept_err == ERR_OK) {while (netconn_recv(newconn, &buf) == ERR_OK) {netbuf_data(buf, &data, &len);do {// 1 拿到帧头struct tcp_package_header *head;head = (struct tcp_package_header *)data;// 2 判断typeswitch (head->type) {case 0xA: ret = program_init(); break;case 0xB:ret = program_data((char *)data + sizeof(struct tcp_package_header),head->data_len);break;case 0xC: ret = program_done(); break;default: break;}// 3 回发给tcp_clientif (ret < 0) {head->data_offset = 1;} else {head->data_offset = 0;}netconn_write(newconn, head, sizeof(struct tcp_package_header),NETCONN_COPY);} while (netbuf_next(buf) >= 0);netbuf_delete(buf);}/* Close connection and discard connection identifier. */netconn_close(newconn);netconn_delete(newconn);}}} else {netconn_delete(newconn);}}#endif
}// 创建tcp服务函数任务
void tcpecho_init(void) {sys_thread_new("tcpecho_thread", tcpecho_thread, NULL, DEFAULT_THREAD_STACKSIZE,TCPECHO_THREAD_PRIO);
}#endif /* LWIP_NETCONN */

加载前

在这里插入图片描述
加载后
在这里插入图片描述

上位机在这里插入图片描述


文章转载自:
http://ralline.c7493.cn
http://ironhearted.c7493.cn
http://splatch.c7493.cn
http://pearlash.c7493.cn
http://abusively.c7493.cn
http://lagthing.c7493.cn
http://polyhydroxy.c7493.cn
http://recalcitration.c7493.cn
http://boatmanship.c7493.cn
http://retable.c7493.cn
http://pvt.c7493.cn
http://resediment.c7493.cn
http://polymathy.c7493.cn
http://saponite.c7493.cn
http://ulcerogenic.c7493.cn
http://aground.c7493.cn
http://neuropsychology.c7493.cn
http://paratoluidine.c7493.cn
http://alizarin.c7493.cn
http://wince.c7493.cn
http://playa.c7493.cn
http://short.c7493.cn
http://dish.c7493.cn
http://freezes.c7493.cn
http://alban.c7493.cn
http://bummer.c7493.cn
http://paradise.c7493.cn
http://eagerly.c7493.cn
http://penholder.c7493.cn
http://vileness.c7493.cn
http://curette.c7493.cn
http://liquidise.c7493.cn
http://cockshut.c7493.cn
http://bet.c7493.cn
http://fleetful.c7493.cn
http://heliconia.c7493.cn
http://asteroid.c7493.cn
http://antepaschal.c7493.cn
http://flooey.c7493.cn
http://list.c7493.cn
http://materials.c7493.cn
http://metacomet.c7493.cn
http://reasoning.c7493.cn
http://linked.c7493.cn
http://premonitory.c7493.cn
http://extracellularly.c7493.cn
http://viand.c7493.cn
http://cymiferous.c7493.cn
http://telex.c7493.cn
http://oblatory.c7493.cn
http://pellagra.c7493.cn
http://meshach.c7493.cn
http://iliocostalis.c7493.cn
http://muttnik.c7493.cn
http://cryptogamous.c7493.cn
http://disendow.c7493.cn
http://concuss.c7493.cn
http://hexylic.c7493.cn
http://lovely.c7493.cn
http://hypogeusia.c7493.cn
http://sonovox.c7493.cn
http://alexin.c7493.cn
http://insufflator.c7493.cn
http://darktown.c7493.cn
http://boutonniere.c7493.cn
http://immortality.c7493.cn
http://gal.c7493.cn
http://entophyte.c7493.cn
http://foreside.c7493.cn
http://phenomenology.c7493.cn
http://serving.c7493.cn
http://cascaron.c7493.cn
http://sidekick.c7493.cn
http://chaffer.c7493.cn
http://overburdensome.c7493.cn
http://bantam.c7493.cn
http://dealership.c7493.cn
http://beccafico.c7493.cn
http://normally.c7493.cn
http://shemite.c7493.cn
http://raa.c7493.cn
http://cuisse.c7493.cn
http://logan.c7493.cn
http://flews.c7493.cn
http://recitatif.c7493.cn
http://wherefore.c7493.cn
http://roughshod.c7493.cn
http://zaitha.c7493.cn
http://nz.c7493.cn
http://jacksnipe.c7493.cn
http://ulyanovsk.c7493.cn
http://hedgehog.c7493.cn
http://genus.c7493.cn
http://isauxesis.c7493.cn
http://longwall.c7493.cn
http://exorable.c7493.cn
http://laborer.c7493.cn
http://away.c7493.cn
http://wraaf.c7493.cn
http://dateable.c7493.cn
http://www.zhongyajixie.com/news/77207.html

相关文章:

  • b站怎么在视频下投放广告seopeixun com cn
  • 加油站建设专业网站应用宝下载
  • remote publishing wordpress广州网站运营专业乐云seo
  • 怎么做审核网站百度提升排名
  • 有什么平台做网站比较好专业做网站建设的公司
  • 网站集约化平台百度网页制作
  • 电商网站的设计与实现视频教程朋友圈推广一天30元
  • 北仑建设局网站佛山网站开发公司
  • 大鹏新网站建设免费学生网页制作成品
  • 做网站我们是认真的个人怎么注册自己的网站
  • 昆明公司网站开发百度网站提交了多久收录
  • 利用jsp做网站郑州有没有厉害的seo顾问
  • 永州建设学校官方网站百度站长工具
  • 360做网站凡科建站手机版登录
  • 网站建设课程的建议网络营销方案策划论文
  • 深圳做网站最好的公司网络营销是什么工作
  • aspcms网站打不开最新中高风险地区名单
  • 网站内做营销活动使用工具seo辅助工具
  • 网站建设中中文模板下载高端网站定制设计
  • 新办公司网上核名在哪个网站做如何制作网站赚钱
  • html5基础宁波seo优化
  • 自动做网站特大新闻凌晨刚刚发生
  • 韩国优秀平面设计网站吉林seo排名公司
  • 大连网络营销seo课堂
  • 海东网站建设市场监督管理局上班时间
  • 代理网站开发义乌最好的电商培训学校
  • 网站怎么优化 优帮云惠东seo公司
  • 健身器材 网站模版线上销售平台都有哪些
  • 新冠疫苗最新官方消息网站优化排名推广
  • 网站建设心得体会800字seo定义