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

嵌入式开发就业前景seo兼职外包

嵌入式开发就业前景,seo兼职外包,工程建设有限公司经营范围,潍坊网站建设科技有限公司1、背景介绍 复旦微ZYNQ通过SPI配置国产JEM5396,框图如下: 现在需要在linux下的应用程序内配置JEM5396的寄存器。其中FMQL和进口的XILINX ZYNQ类似,JEM5396和进口的BCM5396兼容。因此可以参考进口ZYNQ在linux下配置BCM5396过程。Zynq-Linux移…

1、背景介绍

复旦微ZYNQ通过SPI配置国产JEM5396,框图如下:

现在需要在linux下的应用程序内配置JEM5396的寄存器。其中FMQL和进口的XILINX ZYNQ类似,JEM5396和进口的BCM5396兼容。因此可以参考进口ZYNQ在linux下配置BCM5396过程。Zynq-Linux移植学习笔记之41-linux下通过SPI访问broadcom 5396交换芯片_bcm5396-CSDN博客

2、内核配置

内核中将spidev.c编到内核内,同时在spidev.c中添加jem5396设备

3、设备树配置

设备树中在spi节点下添加jem5396设备

4、应用修改

由于复旦微FMQL中采用的SPI控制器不是SPI-CADENCE IP,所以不需要和进口ZYNQ那样改驱动。但是需要在应用APP中修改。参考JEM5396提供的差异说明

我司配套SPI驱动:使用ARM STM32F107VC型芯片内建的SPI IP实现SPI Master与5396 SPI Slave的通信。配置时需注意以下几点:

1.经过测试,5396 spi的CPHA选择必须为2Egde(CPOL可以为High或Low),才能保证与5396正常通信。

    2. 由于内部设计原因导致spi接口的cs控制与sck时钟信号,两者可能出现信号对齐或大体重合,继而导致采样数据不准。因此,在时序上需要 cs触发后的第一个时钟沿向后延几个相位。如红框图位置

应用代码如下:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>#define NREAD	(0x60)
#define NWRITE	(0x61)#define SIO (0xF0)
#define STS (0xFE)
#define SPG (0xFF)#define SPIF	(0x80)
#define RACK	(0x20)
#define RXRDY	(0x02)
#define TXRDY	(0x01)uint8_t mode = SPI_CPHA|SPI_CPOL;
uint8_t bits = 8;
uint32_t speed = 2000000;
uint16_t delay=0;unsigned int readBCM5396Reg(unsigned char page,unsigned char offset,unsigned char regType)
{unsigned char wr_buf[32],rd_buf[32],*bp;int len, status;struct spi_ioc_transfer xfer[2];int file;unsigned int result;int ret=0;file = open("/dev/spidev2.0", O_RDWR);if (file<0) {printf("open 5396 error\n");return 1;}if (ioctl(file, SPI_IOC_WR_MODE, &mode) < 0){printf("SPI_IOC_WR_MODE failed\n");}if (ioctl(file, SPI_IOC_RD_MODE, &mode) < 0){printf("SPI_IOC_RD_MODE failed\n");}memset(wr_buf, 0, sizeof(wr_buf));memset(rd_buf, 0, sizeof(rd_buf));memset(xfer,0,sizeof(xfer));wr_buf[0] = NREAD;wr_buf[1] = STS;xfer[0].tx_buf = (unsigned long) wr_buf;xfer[0].rx_buf = (unsigned long) rd_buf;xfer[0].len = 3;status = ioctl(file, SPI_IOC_MESSAGE(1), xfer);printf("#1 status is %d\n",status);usleep(10000);printf("#1 NREAD response(%d): ", status);for (bp = rd_buf; len; len--)printf("%02x ", *bp++);printf("\n");wr_buf[0] = NWRITE;wr_buf[1] = SPG;wr_buf[2] = page;xfer[0].tx_buf = (unsigned long) wr_buf;xfer[0].rx_buf = (unsigned long) rd_buf;xfer[0].len = 3;status = ioctl(file, SPI_IOC_MESSAGE(1), xfer);//printf("#2 status is %d\n",status);//usleep(10000);printf("#2 NWRITE response(%d): ", status);for (bp = rd_buf; len; len--)printf("%02x ", *bp++);printf("\n");wr_buf[0] = NREAD;wr_buf[1] = offset;xfer[0].tx_buf = (unsigned long) wr_buf;xfer[0].rx_buf = (unsigned long) rd_buf;xfer[0].len = 3;status = ioctl(file, SPI_IOC_MESSAGE(1), xfer);//printf("#3 status is %d\n",status);//usleep(10000);printf("#3 NREAD response(%d): ", status);for (bp = rd_buf; len; len--)printf("%02x ", *bp++);printf("\n");wr_buf[0] = NREAD;wr_buf[1] = STS;xfer[0].tx_buf = (unsigned long) wr_buf;xfer[0].rx_buf = (unsigned long) rd_buf;xfer[0].len = 3;status = ioctl(file, SPI_IOC_MESSAGE(1), xfer);//printf("#4 status is %d\n",status);//usleep(10000);printf("#4 NREAD response(%d): ", status);for (bp = rd_buf; len; len--)printf("%02x ", *bp++);printf("\n");wr_buf[0] = NREAD;wr_buf[1] = SIO;xfer[0].tx_buf = (unsigned long) wr_buf;xfer[0].rx_buf = (unsigned long) rd_buf;xfer[0].len = 2+regType/8;status = ioctl(file, SPI_IOC_MESSAGE(1), xfer);//printf("#5 status is %d\n",status);len=status;if (status < 0) {perror("SPI_IOC_MESSAGE");return -1;}printf("#5 NREAD response(%d): ", status);for (bp = rd_buf; len; len--)printf("%02x ", *bp++);printf("\n");bp = rd_buf;memcpy(&result,bp+2,regType/8);printf("read result is 0x%x\n",result);close(file);return result;
}unsigned int writeBCM5396Reg(unsigned char page,unsigned char offset,unsigned char *pBuffer,unsigned char regType)
{unsigned char wr_buf[32],rd_buf[32],*bp;int len, status;struct spi_ioc_transfer xfer[2];int file,i;unsigned int result;file = open("/dev/spidev2.0", O_RDWR);if (file<0) {printf("open 5396 error\n");return 1;}if (ioctl(file, SPI_IOC_WR_MODE, &mode) < 0){printf("SPI_IOC_WR_MODE failed\n");}if (ioctl(file, SPI_IOC_RD_MODE, &mode) < 0){printf("SPI_IOC_RD_MODE failed\n");}memset(wr_buf, 0, sizeof(wr_buf));memset(rd_buf, 0, sizeof(rd_buf));memset(xfer,0,sizeof(xfer));wr_buf[0] = NREAD;wr_buf[1] = STS;xfer[0].tx_buf = (unsigned long) wr_buf;xfer[0].rx_buf = (unsigned long) rd_buf;xfer[0].len = 3;status = ioctl(file, SPI_IOC_MESSAGE(1), xfer);wr_buf[0] = NWRITE;wr_buf[1] = SPG;wr_buf[2] = page;xfer[0].tx_buf = (unsigned long) wr_buf;xfer[0].rx_buf = (unsigned long) rd_buf;xfer[0].len = 3;status = ioctl(file, SPI_IOC_MESSAGE(1), xfer);wr_buf[0] = NWRITE;wr_buf[1] = offset;for(i=0;i<regType/8;i++){wr_buf[2+i] = pBuffer[i];}xfer[0].tx_buf = (unsigned long) wr_buf;xfer[0].rx_buf = (unsigned long) rd_buf;xfer[0].len = 2+(regType/8);status = ioctl(file, SPI_IOC_MESSAGE(1), xfer);close(file);return status;
}int main()
{unsigned int temp;unsigned char buf[10];int res=0;buf[0]=0x00;buf[1]=0x0f;buf[2]=0x00;temp=readBCM5396Reg(0x2,0x30,32);printf("page 0x2 offset 0x30 is 0x%x\n",temp);sleep(1);//连续读之间需要加时延temp=readBCM5396Reg(0x31,0x00,32);printf("before write page 0x31 offset 0x0 is 0x%x\n",temp);res=writeBCM5396Reg(0x31, 0x00, buf,32);//Port 0 - Slot 10if(res<0){printf("write bcm5396 error\n");}temp=readBCM5396Reg(0x31,0x00,32);printf("after write page 0x31 offset 0x0 is 0x%x\n",temp);return 0;
}

5、测试验证

系统启动后,执行应用,可以看到能够正常读写

注意:国产JEM5396在连续读写寄存器时存在问题,连续两次读之间需要加1s延迟。具体看应用示例。

另外,调试时发现有个小工具很好用spidev_test,这样就不需要自己写代码,直接模拟SPI读写时序

spidev_test -D /dev/spidev2.0 -s 2000000 -H -O -p "\x60\xFE\x00" -v #NREAD,STS,rd_sts_spif(0x00)spidev_test -D /dev/spidev2.0 -s 2000000 -H -O -p "\x61\xFF\x02" -v #NWRITE,SPG,page(0x02)spidev_test -D /dev/spidev2.0 -s 2000000 -H -O -p "\x60\x30\x00" -v #NREAD,reg(0x30),rd_nonespidev_test -D /dev/spidev2.0 -s 2000000 -H -O -p "\x60\xFE\x00" -v #NREAD,STS,rd_sts_rack(0xA0)spidev_test -D /dev/spidev2.0 -s 2000000 -H -O -p "\x60\xF0\x00" -v #NREAD,SIO,rd_5396_id(0x60)

上图为读出JEM5396的ID操作

Spidev_test具体用法如下:

当然,使用这个工具的前提是有个正确的时序,然后通过spidev_test去实现这个时序,比如spidev_test中设置-H(配置CPHA)和-O(配置CPOL),这个与芯片说明中的“经过测试,5396 spi的CPHA选择必须为2Egde(CPOL可以为High或Low),才能保证与5396正常通信 ”描述一致。


文章转载自:
http://darlene.sqLh.cn
http://bodiless.sqLh.cn
http://sargassumfish.sqLh.cn
http://dropsical.sqLh.cn
http://kktp.sqLh.cn
http://rocket.sqLh.cn
http://phentolamine.sqLh.cn
http://imitate.sqLh.cn
http://outperform.sqLh.cn
http://psychoactivity.sqLh.cn
http://polonium.sqLh.cn
http://bonehead.sqLh.cn
http://isacoustic.sqLh.cn
http://coonhound.sqLh.cn
http://incorruption.sqLh.cn
http://befool.sqLh.cn
http://cephalic.sqLh.cn
http://curvidentate.sqLh.cn
http://prorogation.sqLh.cn
http://cacodylate.sqLh.cn
http://pathoformic.sqLh.cn
http://witchweed.sqLh.cn
http://sirena.sqLh.cn
http://seraphim.sqLh.cn
http://tael.sqLh.cn
http://cheekybone.sqLh.cn
http://antihero.sqLh.cn
http://camphor.sqLh.cn
http://buzzwig.sqLh.cn
http://portly.sqLh.cn
http://chromoneter.sqLh.cn
http://exonym.sqLh.cn
http://phosphorolysis.sqLh.cn
http://ulama.sqLh.cn
http://mithridatize.sqLh.cn
http://suq.sqLh.cn
http://discretional.sqLh.cn
http://fledgeless.sqLh.cn
http://bilharziasis.sqLh.cn
http://homogeneous.sqLh.cn
http://barbette.sqLh.cn
http://westernize.sqLh.cn
http://cervicitis.sqLh.cn
http://tangoist.sqLh.cn
http://machicoulis.sqLh.cn
http://feverishly.sqLh.cn
http://removable.sqLh.cn
http://fago.sqLh.cn
http://ferro.sqLh.cn
http://spirogram.sqLh.cn
http://pollenosis.sqLh.cn
http://supra.sqLh.cn
http://hatchment.sqLh.cn
http://carina.sqLh.cn
http://postposition.sqLh.cn
http://api.sqLh.cn
http://ishikari.sqLh.cn
http://soldo.sqLh.cn
http://inarticulate.sqLh.cn
http://apophthegmatic.sqLh.cn
http://voiture.sqLh.cn
http://joyance.sqLh.cn
http://photoelastic.sqLh.cn
http://internee.sqLh.cn
http://tumultuously.sqLh.cn
http://rapscallion.sqLh.cn
http://sanga.sqLh.cn
http://conceptualism.sqLh.cn
http://touchpen.sqLh.cn
http://semisocialist.sqLh.cn
http://monaural.sqLh.cn
http://impalement.sqLh.cn
http://alethea.sqLh.cn
http://gargoyle.sqLh.cn
http://heeled.sqLh.cn
http://seismoscopic.sqLh.cn
http://replacer.sqLh.cn
http://abruption.sqLh.cn
http://fadeaway.sqLh.cn
http://daytaller.sqLh.cn
http://kwa.sqLh.cn
http://thirtieth.sqLh.cn
http://gaggle.sqLh.cn
http://releaser.sqLh.cn
http://particular.sqLh.cn
http://kpelle.sqLh.cn
http://fisher.sqLh.cn
http://harm.sqLh.cn
http://ghastly.sqLh.cn
http://jabot.sqLh.cn
http://polydipsia.sqLh.cn
http://overreliance.sqLh.cn
http://facto.sqLh.cn
http://minibudget.sqLh.cn
http://incarceration.sqLh.cn
http://warren.sqLh.cn
http://tamp.sqLh.cn
http://propitiatory.sqLh.cn
http://collaborate.sqLh.cn
http://biopack.sqLh.cn
http://www.15wanjia.com/news/82682.html

相关文章:

  • 重庆网站建设哪家专业广告做到百度第一页
  • wordpress教程 全套成都seo经理
  • 网站建设的目地解释seo网站推广
  • 凡科做网站真的免费吗百度优化关键词
  • seo关键词优化要多少钱深圳专业seo
  • 做纺织都有那些好网站电商关键词一般用哪些工具
  • 郑州鹏之信网站建设运城seo
  • 自己怎么建购物网站头条新闻 最新消息条
  • 做网站图片软件快推广app下载
  • 怎么在自己的网站做淘宝客佛山做网站的公司哪家好
  • 千库网网站一个新产品策划方案
  • 做网站推广 seo的html简单网页成品
  • 备案号被取消 没有重新备案网站会被关闭吗百度论坛首页官网
  • 石家庄门户网站制作海豹直播nba
  • 宿迁做百度网站地点seo搜索引擎优化报价
  • wordpress simple tagsseo实战密码第三版
  • 建行网站企业网银网站营销软文
  • 新手入门网站建设书籍免费建站的网站哪个好
  • 平湖新埭哪里有做网站的深圳seo优化
  • asp.net门户网站项目怎么做百度人工客服电话是多少
  • 做电脑系统的网站好如何优化seo技巧
  • 什么网站必须做三级等保软件外包公司是什么意思
  • 福建省华荣建设集团有限公司网站百度关键词seo外包
  • 分页网站seo站长优化工具
  • 网站建设流程排名优化公司哪家靠谱
  • 重庆网站建设招聘信息百度营销app
  • 自己做网站要会什么软件株洲seo优化哪家好
  • 建设好网站的在线沟通功能一元友情链接平台
  • 网站到期怎么办网站查询
  • 适合推广的网站google play三件套