ImageVerifierCode 换一换
格式:DOCX , 页数:8 ,大小:16.75KB ,
资源ID:5805821      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5805821.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(LPC2138外围模块底层驱动程序.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

LPC2138外围模块底层驱动程序.docx

1、LPC2138外围模块底层驱动程序LPC2138外围模块底层驱动程序(刚写的,待续)上一篇 / 下一篇 2008-12-30 11:51:01 查看( 20 ) / 评论( 0 ) / 评分( 0 / 0 ) /* 文件名:main.c* 功 能:底层驱动模块(触摸屏)* 作 者:Andy Jiang* 日 期:2008年12月23号| main.c| by Andy jiang| 2008.12.123| | CS8920 software group| www.midoriya.co.jp| */#include config.h#define baud_rate 1200#define

2、ADC0 18#define ADC1 21#define UART0 6#define UART1 7#define TIMER0 4#define EXTRN 14#define TIMER1 5#define RTC 13uint32 adresult;uint32 voltage1;uint32 voltage2;/uint8 a100=0;uint8 send_counter;uint32 state;/*/*function prototypes*/*/void EXTRN_Init(void);void Port_Init( void );void Timer0_Init( vo

3、id );void UART1_Init( void );void UART0_Init( void );void RTCI_Init( void );void UART0_Sendbyte( uint8 sendbyte);void UART0_Senddata( uint8 send_bytes, uint8 *buffer );uint8 UART0_Recebyte( void ); void UART0_Recdata( uint8 rece_bytes, uint8 *buffer );void UART1_Senddata(uint8 send_bytes, uint8 *buf

4、fer );void Timer0_Int( void ) _irq ; void ADC0_Int ( void ) _irq;void Uart0_Int ( void ) _irq;void Uart1_Int ( void ) _irq;void EXTRN_Int ( void ) _irq;void RTC_Int ( void ) _irq ; /*/*serial0 driver*/*/ void RTC_Int ( void ) _irq VICVectAddr=0xFF;void ADC0_Int( ) _irq /AD0 i nterrupt service progra

5、mme VICVectAddr=0xFF; void ADC1_Int( ) _irq /AD1 interrupt service programme VICVectAddr=0xFF; void EXTRN_Int( ) _irq /EXTRN interrupt service programme IO0SET=0X00; while(EXTINT&0X01)!=0X01) EXTINT=0X01; EXTINT=0X01; VICVectAddr=0xFF; void Timer0_Int( ) _irq /Timer0 interrupt service programme T0IR

6、=0X01; VICVectAddr=0xFF; void Uart0_Int( ) _irq /UART0 interrupt service programme VICVectAddr = 0xFF; void Uart1_Int( )_irq /UART1 interrupt service programme VICVectAddr = 0xFF; void Port_Init( void ) / Port initialize PINSEL0=0X00; PINSEL1=0X00000001; / PINSEL2=0X00; /BE CARE FOR THIS CODE!! IO0D

7、IR= 0X00; IO1DIR= 0X00; IO2DIR= 0X00; IO3DIR= 0X00; IO0SET= 0X00; IO0CLR= 0X00; IO1SET= 0X00; IO1CLR= 0X00; EXTMODE= 0X00; void Timer0_Init( void) T0TC= 0; T0PR= 0; T0MCR= 0X03; T0MR0= Fpclk/2; T0TCR= 0X01; VICIntSelect= 0x00000000; /*dispatch as IRQ */ VICVectCntl3= 0x20|TIMER0; /*Timer0 as IRQ slo

8、t1 */ VICVectAddr3= (uint32)Timer0_Int; /*get timer0 inter service */ VICIntEnable= 1TIMER0; /*timer0 Enable */ void UART0_Init( void ) PINSEL0= PINSEL0&(0x0F)|0x05; /* Enable RxD0 and TxD0 */ U0LCR= 0x83; /* 8 bits, no Parity, 1 Stop bit */ U0DLL= 625%256; /* 1200 Baud Rate 12MHz VPB Clock */ U0DLM

9、= 625/256; U0LCR= 0x03; /*LOCK*/ U0IER= 0X07; / U0LCR=0X81; /*INT ENABLE*/ VICVectCntl0= 0x20|UART0; /*UART0 as IRQ slot0*/ VICVectAddr0= (uint32)Uart0_Int; /*get UART0 inter service*/ VICIntEnable= 1UART0; void UART1_Init( void ) PINSEL0= PINSEL0&(0x0F16)|(0x0516); /* Enable RxD1 and TxD1 */ U1LCR=

10、 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLL= 65535%256; /* 1200 Baud Rate 12MHz VPB Clock */ U1DLM= 65535/256; U1LCR= 0x03; U1IER= 0X03; VICVectCntl0= 0x20|UART1; /*UART0 as IRQ slot0*/ VICVectAddr2= (uint32)Uart1_Int; /*get UART0 inter service*/ VICIntEnable= 1UART1; uint16 ADC0_Init( void) ui

11、nt16 adresult; VICIntSelect=0x00000000; /dispatch as IRQ VICVectCntl0=0x20|ADC0; /AD0 as IRQ slot0 VICVectAddr0=(uint32)ADC0_Int; /get ad inter service VICIntEnable=1ADC0; return (adresult); uint16 ADC1_Init( void) uint16 adresult; VICIntSelect=0x00000000; /dispatch as IRQ VICVectCntl0=0x20|ADC1; /A

12、D0 as IRQ slot0 VICVectAddr0=(uint32)ADC1_Int; /get ad inter service VICIntEnable=1ADC1; return (adresult); void EXTRN_Init( void) VICIntSelect=0x00000000; /dispatch as IRQ PINSEL0=0X00000001; VICVectCntl0=0x20|EXTRN; /EXT0 as IRQ slot0 VICVectAddr0=(uint32)EXTRN_Int; /get ad inter service VICIntEna

13、ble=1EXTRN; void UART0_Sendbyte(uint8 sendbyte) U0THR= sendbyte; while( U0LSR&0X40= 0); void RTC_Init( void) PREINT=Fpclk/32768-1; PREFRAC=Fpclk-(Fpclk/32768)*32768; CIIR=0X01; VICIntSelect= 0x00000000; /*dispatch as IRQ */ VICVectCntl3= 0x20|RTC; /*Timer0 as IRQ slot1 */ VICVectAddr3= (uint32)RTC_I

14、nt; /*get timer0 inter service */ VICIntEnable= 1RTC; /*timer0 Enable */ void UART0_Senddata(uint8 send_bytes, uint8 *buffer) uint8 i ; for(i=0; isend_bytes; i+) U0THR=*buffer; buffer+; while( U0LSR&0x40= 0); uint8 UART0_Recebyte( void ) uint8 Recebyte; while(!(U0LSR&0X01); Recebyte=U0RBR; return (R

15、ecebyte); void UART0_Recdata( uint8 rece_bytes,uint8 *buffer) uint8 i ; for(i=0; irece_bytes; i+) while(!(U0LSR&0X01); *buffer=U0RBR; buffer+; /*/*serial1 driver*/*/ void UART1_Senddata(uint8 send_bytes, uint8 *buffer) uint8 i ; for(i=0;isend_bytes;i+) U1THR=*buffer; buffer+; while( U1LSR&0x40=0); v

16、oid UART1_Recdata( uint8 rece_bytes,uint8 *buffer) uint8 i ; for(i=0;irece_bytes;i+) while(!(U1LSR&0X01); *buffer=U1RBR; buffer+; void delayms(uint8 time) uint16 i;uint16 j;uint8 k;for(i=0;i=time;i+) for(j=0;j=10000;j+) for(k=0;k=10000 ;k+) ; void touchgetx( void ) uint8 adtime; IOSET=IOSET|0X02; IO

17、0CLR=IO0CLR|0X02; delayms(10); for( adtime=0;adtime=20;adtime+) ; /*/*中断服务程序*/*/*/*主程序*/*/ int main ( ) uint8 volt_high,volt_low,volt_midd; / IRQEnable( ); /IRQ enable Port_Init( ); Timer0_Init( ); UART0_Init( ); UART1_Init( ); ADC0_Init( ); ADC1_Init( ); / while(1) ; / UART0_Init( ); / while(1) / / UART0_Sendbyte(0x30); / while(1); / /*/ /*AD SUB PROG*/ /*/ / PINSEL1=PINSEL1&(0X0326)|(0X0126); /pin mapped as ad in / AD0CR=(12) | /channel select / (0XFF8) | /convert clock frequency

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1