rs485.rar

  • PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 76KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 7
    下载次数
  • 2010-03-05 16:14
    上传日期
合众达DM6446试验箱学习实验源代码 RS485
rs485.rar
  • 3.2.6 rs485
  • rs485.CS_
  • SYMBOL.FPT
    99.3KB
  • SYMBOL.DBF
    60.3KB
  • FILE.DBF
    656B
  • FILE.FPT
    1.1KB
  • SYMBOL.CDX
    86.5KB
  • FILE.CDX
    3KB
  • Debug
  • rs485.map
    12.8KB
  • seed_dvs_rs485.obj
    6.3KB
  • main.obj
    4KB
  • seed_dvs6446_rs485.obj
    7.8KB
  • rs485.out
    91.9KB
  • cc_build_Debug.log
    876B
  • rs485.cmd
    899B
  • rs485.sbl
    3.1KB
  • main.c
    2KB
  • Debug.lkf
    728B
  • seed_dvs6446_rs485.h
    1.8KB
  • rs485.paf2
    2.9KB
  • seed_dvs_rs485.c
    2KB
  • rs485.pjt
    988B
  • seed_dvs6446_rs485.c
    6.5KB
内容介绍
/* * Copyright 2006 by Spectrum Digital Incorporated. * All rights reserved. Property of Spectrum Digital Incorporated. */ /* * UART implementation * */ #include "seed_dvs6446_rs485.h" Uint16 temp; void _wait( Uint32 delay ) { volatile Uint32 i; for ( i = 0 ; i < delay ; i++ ){ }; } /* ------------------------------------------------------------------------ * * * * _UART_open( id, baudrate ) * * * * Open UART handle * * * * ------------------------------------------------------------------------ */ UART_HANDLE DVS6446_RS485_open( Uint16 id, Uint32 baudrate ) { UART_HANDLE uart_handle; Uint32 divisor; /* * UART clk / ( baudrate * 16 ) * = 27,000,000 / ( 115200 * 16 ) * = 14 */ divisor = 27000000 / ( baudrate * 16 ); switch ( id ) { case 0: uart_handle = ( UART_HANDLE )&UART_MODULE_0; break; case 1: uart_handle = ( UART_HANDLE )&UART_MODULE_1; break; default: return ( UART_HANDLE )-1; } uart_handle->regs->PWREMU_MGMT = 0; // Reset UART TX & RX components _wait( 100 ); uart_handle->regs->DLL = ( divisor & 0xff ); // Set baud rate uart_handle->regs->DLH = ( divisor >> 8 ) & 0xff; uart_handle->regs->FCR = 0x0007; // Clear UART TX & RX FIFOs uart_handle->regs->FCR = 0x0001; // Enable TX & RX FIFOs 1-byte uart_handle->regs->IER = 0x0007; // Enable interrupts uart_handle->regs->LCR = 0x0003; // 8-bit words, // 1 STOP bit generated, // No Parity, No Stick paritiy, // No Break control uart_handle->regs->MCR = 0x0000; // RTS & CTS disabled, // Loopback mode disabled, // Autoflow disabled uart_handle->regs->PWREMU_MGMT = 0x6001; // Emulation Free, // Enable TX & RX componenets if ( ( uart_handle->regs->IIR & 0xC0 ) == 0xC0 )// Check FIFOs are Enabled return uart_handle; else return ( UART_HANDLE )-1; } /* ------------------------------------------------------------------------ * * * * _UART_close( uart_handle ) * * * * Close UART handle * * * * ------------------------------------------------------------------------ */ Int16 DVS6446_RS485_close( UART_HANDLE uart_handle ) { return 0; } /* ------------------------------------------------------------------------ * * * * _UART_xmtReady( uart_handle ) * * * * Check if Transmitter is ready to send * * * * ------------------------------------------------------------------------ */ Int16 DVS6446_RS485_xmtReady( UART_HANDLE uart_handle ) { Uint8 iir_status = ( uart_handle->regs->IIR >> 1 ) & 0x0E; temp=UART1_LCR; temp=UART1_LSR; if ( iir_status == 0 ) // Check for No Interrupts return 0; else if ( iir_status == 1 ) // Check for Current TX emptying return 1; else // Everything else return 0; } /* ------------------------------------------------------------------------ * * * * _UART_putChar( uart_handle, data ) * * * * Send 1 byte of serial data * * * * ------------------------------------------------------------------------ */ Int16 DVS6446_RS485_putChar( UART_HANDLE uart_handle, Uint8 data ) { uart_handle->regs->THR = data; return 0; } /* ------------------------------------------------------------------------ * * * * _UART_rcvReady( uart_handle ) * * * * Check if Receiver is ready to read * * * * ------------------------------------------------------------------------ */ Int16 DVS6446_RS485_rcvReady( UART_HANDLE uart_handle ) { Uint8 iir_status = ( uart_handle->regs->IIR >> 1 ) & 0x0E; temp=UART1_LCR; temp=UART1_LSR; if ( iir_status == 2 ) // Check for Data Ready return 0; else if ( iir_status == 0 ) // Check for No Interrupts return 1; else // Everything else return 2; } /* ------------------------------------------------------------------------ * * * * _UART_getChar( uart_handle, data ) * * * * Recv 1 byte of serial data * * * * ------------------------------------------------------------------------ */ Int16 DVS6446_RS485_getChar( UART_HANDLE uart_handle, Uint8* data ) { *data = uart_handle->regs->THR; return 0; }
评论
    相关推荐