📄 io_uart---fujitsu.c
字号:
/** @file
*
* @brief
*
* File name:
*
* $Revision:
*
* Traceability information:
*
* Deviation(s) from standards:
*
*/
/*
*
* Fine-tech Electronic CO.,LTD
* 9F,NO. 53,TZU YU STREET YUNGHO CITY,
* TAIPEI HSIEN , TAIWAN, R.O.C.
* Phone:+886-2-2525-7569 Fax:+886-2-29271903
*
* The copyright of the computer program(s) herein is the property of
* Fine-Tech. The programs(s) may be used and/or copied only with the
* written permission of Fine-Tech or in accordance with the terms and
* conditions stipulated in the agreement/contract under which the
* program(s) have been supplied.
*
******************************************************************************/
/*****************************************************************************/
/* Included header files */
/*****************************************************************************/
/*****************************************************************************/
/* Private types */
/*****************************************************************************/
/*****************************************************************************/
/* Private component-specific macro and defines */
/*****************************************************************************/
#define IO_SOT RA2
typedef enum {
BPR4M_300 = 62318, BPR4M_600 = 63995, BPR4M_1200 = 64760, BPR4M_2400 = 65190,
BPR8M_600 = 62318, BPR8M_1200 = 63995,
}IO_Uart_BPR_enum;
#define IO_Uart_BPR BPR8M_1200
/*****************************************************************************/
/* Private constants & variables */
/*****************************************************************************/
const AS_U08 HexASCtable[] = "0123456789ABCDEF";
#define MaxPrintBufferSize 50
AS_U08 PrintBuffer[MaxPrintBufferSize+1]; //={ 0x55,0xaa,0x5a};
AS_U08 BuffHead=0,BufferEnd=0;
//AS_U08 PrintBuffer[MaxPrintBufferSize+1]={"KeeLoq Test ..."};
//AS_U08 BuffHead=0,BufferEnd=15;
/*****************************************************************************/
/* Public types */
/*****************************************************************************/
/*****************************************************************************/
/* Public macros */
/*****************************************************************************/
/*****************************************************************************/
/* Public component-specific macro and defines */
/*****************************************************************************/
/*****************************************************************************/
/* Public constant & variable */
/*****************************************************************************/
/*****************************************************************************/
/* Private API functions */
/*****************************************************************************/
/* ===========================================================================
* Function:
* Description:
* =========================================================================== */
/* ===========================================================================
* Function:
* Description:
* =========================================================================== */
AS_U08 *strlen(AS_U08 *s)
{
AS_U08 *sc;
for (sc = s; *sc != 0; sc++);
return(sc - s);
}
/*****************************************************************************/
/* Public API functions */
/*****************************************************************************/
/* ===========================================================================
* Function:
* Description:
* =========================================================================== */
void Init_IO_Uart(void)
{
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
set_timer1(IO_Uart_BPR); // 65536-(.000104/(4/4000000))
IO_SOT = 1;
enable_interrupts(INT_TIMER1);
}
/* ===========================================================================
* Function: PrintHandle
* Description: Timer1 overflows interrupt ,Entry by Uart buadrate per time
* =========================================================================== */
#int_TIMER1
void PrintHandle(void)
{
// UartFlag 0 1 2 3 4 5 6 7 8 9 10
// IO_SOT----\_/xxxxxxxxxxxxxxx-----
// UartChar bit 0 1 2 3 4 5 6 7
static AS_U08 Uartchar,UartFlag=10;
set_timer1(IO_Uart_BPR); //300 = 62318
if(UartFlag >= 10) {
IO_SOT = 1;
if(BuffHead != BufferEnd)
{
UartChar = PrintBuffer[BuffHead];
if(BuffHead >= MaxPrintBufferSize) BuffHead=0;
else BuffHead++;
UartFlag = 0;
}
}
else
{
if(UartFlag==0) IO_SOT = 1;
else if(UartFlag==1) IO_SOT = 0;
else{
if(UartChar & 0x01) IO_SOT = 1;
else IO_SOT = 0;
UartChar >>= 1;
}
UartFlag++;
}
}
/* ===========================================================================
* Function:
* Description:
* =========================================================================== */
void IO_putch(AS_U08 ch)
{
AS_U08 i;
i = BufferEnd;
if(i >= MaxPrintBufferSize) i=0; else i++;
while(i == BuffHead); //Buffer is Full,waiting
PrintBuffer[i]=ch;
BufferEnd=i;
}
/* ===========================================================================
* Function:
* Description:
* =========================================================================== */
void IO_put_Return (void)
{
IO_putch(13);IO_putch(10);
}
/* ===========================================================================
* Function:
* Description:
* =========================================================================== */
void IO_puts(AS_U08 *Name2)
{
AS_U08 i,len;
len = strlen(Name2);
for (i=0; i<len; i++) IO_putch (Name2[i]);
}
/* ===========================================================================
* Function:
* Description:
* =========================================================================== */
void putHex (AS_U08 ch)
{
IO_putch ( HexASCtable[AS_HINIBBLE(ch)] );
IO_putch ( HexASCtable[AS_LONIBBLE(ch)] );
}
/* ===========================================================================
* Function:
* Description:
* =========================================================================== */
void putWord (AS_U16 wd)
{
putHex ( AS_HIBYTE(wd));
putHex ( AS_LOWORD(wd));
}
/* ===========================================================================
* Function:
* Description:
* =========================================================================== */
void putDoblueWord (AS_U32 doublewd)
{
putWord (AS_HIWORD(doublewd));
putWord (AS_LOWORD(doublewd));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -