⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uartsw.h

📁 GPS application software. DOC and Source Code
💻 H
字号:
/*! \file uartsw.h \brief Software Interrupt-driven UART Driver. *///*****************************************************************************//// File Name	: 'uartsw.h'// Title		: Software Interrupt-driven UART Driver// Author		: Pascal Stang - Copyright (C) 2002-2004// Created		: 7/20/2002// Revised		: 4/27/2004// Version		: 0.1// Target MCU	: Atmel AVR Series (intended for the ATmega16 and ATmega32)// Editor Tabs	: 4/////	\ingroup driver_sw/// \defgroup uartsw Software Interrupt-driven UART Driver (uartsw.c)/// \code #include "uartsw.h" \endcode/// \par Overview///		This uart library emulates the operation of a UART (serial port) using///	the AVR's hardware timers, I/O pins, and some software.//////	Specifically, this code uses:///		-Timer 1 Output Compare A for transmit timing///		-Timer 1 Output Compare B for receive timing///		-Timer 1 Input Capture for receive triggering//////	The above resources cannot be used for other purposes while this software///	UART is enabled.  The overflow interrupt from Timer1 can still be used for///	other timing, but the prescaler for Timer1 must not be changed.//////	Serial output from this UART can be routed to any I/O pin.  Serial input///	for this UART must come from the Timer1 Input Capture (IC1) I/O pin.///	These options should be configured by editing your local copy of///	"uartswconf.h".//// This code is distributed under the GNU Public License//		which can be found at http://www.gnu.org/licenses/gpl.txt////*****************************************************************************#ifndef UARTSW_H#define UARTSW_H#include "global.h"#include "buffer.h"// include configuration#include "uartswconf.h"// constants/macros/typdefs// automatically allocate space in ram for each bufferstatic char uartswRxData[UARTSW_RX_BUFFER_SIZE];// functions//! enable and initialize the software uartvoid uartswInit(u32 BR);//! create and initialize the uart buffersvoid uartswInitBuffers(void);//! turns off software UARTvoid uartswOff(void);//! returns the receive buffer structure cBuffer* uartswGetRxBuffer(void);//! sets the uart baud ratevoid uartswSetBaudRate(u32 baudrate);//! sends a single byte over the uartvoid uartswSendByte(u08 data);//! gets a single byte from the uart receive buffer// Function returns TRUE if data was available, FALSE if not.// Actual data is returned in variable pointed to by "data".// example usage:// char myReceivedByte;// uartswReceiveByte( &myReceivedByte );u08 uartswReceiveByte(u08* rxData);//! internal transmit bit handlervoid uartswTxBitService(void);//! internal receive bit handlervoid uartswRxBitService(void);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -