产品分类
VK3X多总线UART在嵌入式手持设备中扩展串口及Linux驱动设计
作者: 来源: 时间:2015-02-04 08:53:44浏览量:
目前,Linux以其开放的特性已经广泛的应用到手持设备中,Linux2.6是目前应用较广的版本,在Linux2.6中,采用了新的drivers/serial/serial_core.c基础构架,更易于开发驱动程序,也很方便移植到其它版本的Linux中。下面以基于ARM9(S3C2440)的Linux(2.6内核)平台为例,介绍采用SPI总线接口的VK3X的串口驱动设计示例:
VK3X驱动中包含的头文件:
#include<linux/config.h>
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
#include<linux/slab.h>
#include<linux/console.h>
#include<linux/serial_core.h>
#include<asm/irq.h>
#include<asm/hardware.h>
#include"serial_vk32xx.h"
初始化SPI函数:
inlinevoidsetup_spi(void)
{
SPCON0=SPCON_MSTR|SPCON_ENSCK;
SPPRE0=0x04;//setbandrate
write_gpio_bit(VK32_CS,1);
}
SPI发送函数:
uint8_tspi_send_byte(uint8_tdat)
{
write_gpio_bit(VK32_CS,0);
大功率电感SPTDAT0=dat;
while(!(SPSTA0&SPSTA_READY));
write_gpio_bit(VK32_CS,1);
returnSPRDAT0;
}
写VK3X寄存器函数:
voidvk3xxx_write_reg(uint8_tport,uint8_treg,uint8_tdat)
{
spi_send_byte(0x80|((port-1)<<5)|(reg<<1));
spi_send_byte(dat);
}
读VK3X寄存器函数:
uint8_tvk3xxx_read_reg(uint8_tport,uint8_treg)
{
spi_send_byte(((port-1)<<5)+(reg<<1));
returnspi_send_byte(0x00);
}
初始化VK3X函数:
staticintvk32xx_startup(structuart_port*port,structuart_info*info)
接收数据函数
staticvoid
vk32xx_rx_chars(structuart_info*info,structpt_regs*regs)
{
uint8_tssr;
structtty_struct*tty=info->tty;
unsignedintch,flg,ignored=0;
structuart_port*port=info->port;空心线圈电感
……
}
发送数据函数
staticvoidvk32xx_tx_chars(structuart_info*info)
{
structuart_port*port=info->port;
uint8_tssr;
……
}
VK3X中断处理函数
staticvoidvk32xx_int(intirq,void*dev_id,structpt_regs*regs)
改变VK3X通信速度函数
staticvoidvk32xx_change_spe插件电感ed(structuart_port*port,u_intcflag,u_intiflag,u_intquot)
数据收发相关函数:
staticvoidvk32xx_stop_tx(structuart_port*port,u_intfrom_tty)
staticvoidvk32xx_start_tx(structuart_port*port,u_intnonempty,u_intfrom_tty)
staticvoidvk32xx_stop_rx(structuart_port*port)
控制相关函数:
staticintvk32xx_startup(structuart_port*port,structuart_info*info)
staticvoidvk32大电流电感xx_shutdow共模电感器n(structuart_port*port,structuart_info*info)
staticvoidvk32xx_change_speed(structuart_port*port,u_intcflag,u_intiflag,u_intquot)
子通道操作相关函数:
staticvoidvk32xx_config_port(structuart_port*port,intflags)
staticintvk32xx_verify_port(structuart_port*port,structserial_struct*ser)
staticvoidvk32xx_init_ports(void)
驱动的接口结构如下:
staticstructuart_opsvk32xx_pops={
tx_empty:vk32xx_tx_empty,
set_mctrl:vk32xx_set_mctrl,
get_mctrl:vk32xx_get_mctrl,
stop_tx:vk32xx_stop_tx,
start_tx:vk32xx_start_tx,
stop_rx:vk32xx_stop_rx,
enable_ms:vk32xx_enable_ms,
break_ctl:vk32xx_break_ctl,
startup:vk32xx_startup,
shutdown:vk32xx_shutdown,
change_speed:vk32xx_change_speed,
type:vk32xx_type,
release_port:vk32xx_release_port,
request_port:vk32xx_request_port,
config_port:vk32xx_config_port,
verify_port:vk32xx_verify_port,
};
结束语
嵌入式手持设备需要越来越多的串口外设,在CPU自带的UART串口通道不够的情况下,需要进行串口扩展。针对嵌入式手持设备要求芯片小尺寸,低功耗,低电压的需求,选用低电压版本的VK3X进行串口扩展设计。在硬件设计上,根据不同应用,可以选用本文提供的低速串口扩展,高速串口扩展、高速串口及IO扩展等不同的参考设计方案。在驱动软件方面,可以参考本文提供的Linux驱动设计参考进行驱动设计。
参考文献:
<VK3X系列产品数据手册>www.vkic.com/DataSheetFiles/
<VK3Xlinux驱动编程参考>www.vkic.com/DataSheetFiles/vk3x_linux_drv.rar
TheSerialDriverLayer"byGregKroah-Hartman,www.linux.it/~rubini/docs/serial/serial.html
扁平线圈电感制造厂
请教如何粗略计算纽扣电池供电使用时间纽扣电池cr2032 :容量210mAh,工作电流0.2mA,持续电流3mA,脉冲电流20mA。 现在有一个系统,采用cr2032供电。 系统工作电流约1.5mA,另,每隔8s有一个7mA的脉冲电流(此时总工作电流约8.5mA=1.5+7),脉冲电流持续时间约20ms。 请教:纽扣电池的工作时间大约是多长,怎么计算?谢谢!开20ms 关8秒 持续7ma 周期8.02秒那么换算到小时 1小时3600秒,开了448次 共耗电 3136mA 那么得到近似0.87mah1.5+0.87=2.37mah210/
NIST开发出微机电系统(MEMS)延迟线内存控制器 4月08日 第三届·无线通信技术研讨会 立即报名 12月04日 2015•第二届中国IoT大会 精彩回顾 10月30日ETF•智能硬件开发技术培训会 精彩回顾 10月23日ETF•第三届 消费
从DC24V转DC5V方案 请问:
DC24V输入,给RS232及CAN接口电路供电,总功耗小于1W,从24V到5V,是采用DC-DC方案好呢,还是直接用LDO好?
谢谢!
输出功率小,直接用7805吧。。
如果体积还要小。