📄 c5131-usb-flash-api-1_0_5.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML><HEAD> <META NAME="GENERATOR" CONTENT="langdoc 1.0.1"> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <TITLE> c5131-usb-flash-api-1_0_5 </TITLE> </HEAD> <BODY> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="6"> <TR> <TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR=BLUE> <H1> <FONT COLOR="#FFFFFF"> c5131-usb-flash-api-1_0_5 </FONT> </H1> </TD> </TR> </TABLE><P ALIGN=RIGHT> <I> Copyright (c) 2004</I> </P><H2> Library Usage </H2><H3> Package Description </H3><H3> Package Summary </H3><H4> Constants </H4><PRE></PRE><H4> Global Variables </H4><PRE></PRE><H4> Macros </H4><PRE></PRE><H4> Functions </H4><PRE><A HREF="#__api_rd_code_byte">__api_rd_code_byte</A> <A HREF="#__api_rd_generic">__api_rd_generic</A> <A HREF="#__api_wr_code_byte">__api_wr_code_byte</A> <A HREF="#__api_wr_code_page">__api_wr_code_page</A> <A HREF="#__api_wr_code_page_fix">__api_wr_code_page_fix</A> <A HREF="#__api_wr_fuse">__api_wr_fuse</A> <A HREF="#__api_wr_generic">__api_wr_generic</A> <A HREF="#api_eeprom_busy">api_eeprom_busy</A> <A HREF="#api_erase_block">api_erase_block</A> <A HREF="#api_rd_eeprom">api_rd_eeprom</A> <A HREF="#api_start_bootloader">api_start_bootloader</A> <A HREF="#api_start_isp">api_start_isp</A> <A HREF="#api_wr_eeprom_byte">api_wr_eeprom_byte</A> <A HREF="#bin_to_asc">bin_to_asc</A> <A HREF="#main">main</A> <A HREF="#send_byte_ascii">send_byte_ascii</A> <A HREF="#send_cr_lf">send_cr_lf</A> <A HREF="#tx_data">tx_data</A> <A HREF="#uart_init">uart_init</A> </PRE><H3> Files List </H3><UL><LI><B><A NAME="config.h"></A> config.h</B><BR></LI><LI><B><A NAME="flash_api.c"></A> flash_api.c</B><BR></LI><UL>This file contains whole of functions to access AT89C5131 Flash and EEPROM.</UL><LI><B><A NAME="flash_api.h"></A> flash_api.h</B><BR></LI><LI><B><A NAME="test_api.c"></A> test_api.c</B><BR></LI><UL></UL></UL><H3> Included Files </H3><UL><LI><B>compiler.h </B><BR></LI><LI><B><A HREF="#config.h">config.h</A> </B><BR></LI><LI><B>ext_5131.h </B><BR></LI><LI><B><A HREF="#flash_api.h">flash_api.h</A> </B><BR></LI><LI><B>reg_5131.h </B><BR></LI><LI><B>stdio.h </B><BR></LI></UL><H2> Types Description </H2><UL><LI><B><A NAME="block_t"></A> block_t</B><BR></LI><UL><PRE>enum { BLOCK_0 = 0x00, BLOCK_1 = 0x20, BLOCK_2 = 0x40, BLOCK_3 = 0x80, BLOCK_4 = 0xC0 } </PRE></UL><LI><B><A NAME="ssb_t"></A> ssb_t</B><BR></LI><UL><PRE>enum { NO_SECURITY = 0xFF, WR_SECURITY = 0xFE, RD_WR_SECURITY = 0xFC } </PRE></UL><LI><B><A NAME="}eeprom_t"></A> }eeprom_t</B><BR></LI><UL><PRE>enum { EEPROM_NOT_BUSY, EEPROM_BUSY </PRE></UL></UL><H2> Constant Macros </H2><H2> Global Variables </H2><H2> Function Macros </H2><H2> Functions </H2><A NAME="__api_rd_code_byte"></A><H3> __api_rd_code_byte </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_RD_CODE_BYTE </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>Uchar <A HREF="#__api_rd_code_byte">__api_rd_code_byte</A> ( Uchar code * pt_address ) </PRE></TD></TABLE><P>This function allows to read a flash memory byte.<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uint16 address : address in flash memory to read return: Uchar device : read value</PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_RD_CODE_BYTE must be define inC header file flash_api.h.<HR><A NAME="__api_rd_generic"></A><H3> __api_rd_generic </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uchar <A HREF="#__api_rd_generic">__api_rd_generic</A> ( Uchar command , Uchar dpl ) </PRE></TD></TABLE><P>This function allows to read xaf and special area<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uchar command: api_command to call Uchar dpl : api_dplreturn: Uchar : read value</PRE></TD></TABLE><HR><A NAME="__api_wr_code_byte"></A><H3> __api_wr_code_byte </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_WR_CODE_BYTE </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>Uchar <A HREF="#__api_wr_code_byte">__api_wr_code_byte</A> ( Uchar xdata * pt_address , Uchar value ) </PRE></TD></TABLE><P>This function allows to program data byte in Flash memory.<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uint16 address : address to programUchar value : data to write return: Uchar return : return = 0x00 -> pass return != 0x00 -> fail</PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_WR_CODE_BYTE must be define inC header file flash_api.h.<HR><A NAME="__api_wr_code_page"></A><H3> __api_wr_code_page </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_WR_CODE_PAGE </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>Uchar <A HREF="#__api_wr_code_page">__api_wr_code_page</A> ( Uchar xdata * pt_code , Uchar xdata * pt_xram , Uchar nb_data ) </PRE></TD></TABLE><P>This function allows to program until 128 Datas in Flash memory.Number of bytes to program is limited such as the Flash write remains in asingle 128 bytes page.<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uint16 add_flash : address of the first byte to program in the FlashUint16 add_xram : address in XRAM of the first data to programUchar nb_data : number of bytes to programreturn: Uchar return : return = 0x00 -> pass return != 0x00 -> fail</PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_WR_CODE_PAGE must be define inC header file flash_api.h.This function used Dual Data Pointer DPTR0&1. At the end of this functionDPTR = DPTR0.<HR><A NAME="__api_wr_code_page_fix"></A><H3> __api_wr_code_page_fix </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_WR_CODE_PAGE_FIX </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>Uchar <A HREF="#__api_wr_code_page_fix">__api_wr_code_page_fix</A> ( Uchar xdata * pt_code , Uchar xdata * pt_xram , Uchar nb_data ) </PRE></TD></TABLE><P>This function allows to program until 128 Datas in Flash memory.Number of bytes to program is limited such as the Flash write remains in asingle 128 bytes page.<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uint16 add_flash : address of the first byte to program in the FlashUint16 add_xram : address in XRAM of the first data to programUchar nb_data : number of bytes to programreturn: Uchar return : return = 0x00 -> pass return != 0x00 -> fail</PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_WR_CODE_PAGE must be define inC header file flash_api.h.This function used Dual Data Pointer DPTR0&1. At the end of this functionDPTR = DPTR0.<HR><A NAME="__api_wr_fuse"></A><H3> __api_wr_fuse </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uchar <A HREF="#__api_wr_fuse">__api_wr_fuse</A> ( Uchar mask , Uchar filter ) </PRE></TD></TABLE><P><P><HR><A NAME="__api_wr_generic"></A><H3> __api_wr_generic </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uchar <A HREF="#__api_wr_generic">__api_wr_generic</A> ( Uchar command , Uchar value , Uchar dpl ) </PRE></TD></TABLE><P>This function allows to write in xaf<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uchar command: api_command to call Uchar value : api_valueUchar dpl : api_dplreturn: Uchar return: command status (1 - ok)</PRE></TD></TABLE><HR><A NAME="api_eeprom_busy"></A><H3> api_eeprom_busy </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_EEPROM_BUSY </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>eeprom_t __api_eeprom_busy ( void ) </PRE></TD></TABLE><P>This function allows to check if eeprom is busy or not.<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>return: eeprom_t eep : eep = EEPROM_NOT_BUSY eep = EEPROM_BUSY </PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_EEPROM_BUSY must be define inC header file flash_api.h.<HR><A NAME="api_erase_block"></A><H3> api_erase_block </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_ERASE_BLOCK </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>Uchar __api_erase_block ( <A HREF="#block_t">block_t</A> num_block ) </PRE></TD></TABLE><P>This function allows to erase Block in Flash.<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>block_t num_block num_block = BLOCK_0 (erase Flash between 0x0000-0x1FFF) num_block = BLOCK_1 (erase Flash between 0x2000-0x3FFF) num_block = BLOCK_2 (erase Flash between 0x3000-0x7FFF) num_block = BLOCK_3 (erase Flash between 0x8000-0xBFFF) num_block = BLOCK_4 (erase Flash between 0xC000-0xFFFF)return: </PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_ERASE_BLOCK must be define inC header file flash_api.h.<HR><A NAME="api_rd_eeprom"></A><H3> api_rd_eeprom </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_RD_EEPROM_BYTE </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>Uchar __api_rd_eeprom_byte ( Uchar xdata * address ) </PRE></TD></TABLE><P>This function allows to read a byte in Eeprom.<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uchar xdata *address : address to readreturn: </PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_RD_EEPROM must be define inC header file flash_api.h.<HR><A NAME="api_start_bootloader"></A><H3> api_start_bootloader </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_START_BOOTLOADER </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>void __api_start_bootloader ( void ) </PRE></TD></TABLE><P><P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>return: </PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_START_BOOTLOADER must be define inC header file flash_api.h.<HR><A NAME="api_start_isp"></A><H3> api_start_isp </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_START_ISP </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>void __api_start_isp ( void ) </PRE></TD></TABLE><P><P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>return: </PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_START_ISP must be define inC header file flash_api.h.<HR><A NAME="api_wr_eeprom_byte"></A><H3> api_wr_eeprom_byte </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>#ifdef __API_WR_EEPROM_BYTE </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>Uchar __api_wr_eeprom_byte ( Uchar xdata * address , Uchar value ) </PRE></TD></TABLE><P>This function allows to program a byte in Eeprom.<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uchar xdata* address : address to readUchar value : data to writereturn: </PRE></TD></TABLE><H4> Note </H4><P>To use this function the constante __API_WR_EEPROM_BYTE must be define inC header file flash_api.h.<HR><A NAME="bin_to_asc"></A><H3> bin_to_asc </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Uchar bin_to_ascii ( Uchar to_convert ) </PRE></TD></TABLE><P>This function return the ascii value<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>to_convert: byte to parse in ascii</PRE></TD></TABLE><HR><A NAME="main"></A><H3> main </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>void <A HREF="#main">main</A> ( void ) </PRE></TD></TABLE><P><P><HR><A NAME="send_byte_ascii"></A><H3> send_byte_ascii </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>void <A HREF="#send_byte_ascii">send_byte_ascii</A> ( Uchar byte_to_tx ) </PRE></TD></TABLE><P><P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>byte_to_tx: byte to send on UART in ascii</PRE></TD></TABLE><HR><A NAME="send_cr_lf"></A><H3> send_cr_lf </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>void <A HREF="#send_cr_lf">send_cr_lf</A> ( void ) </PRE></TD></TABLE><P><P><HR><A NAME="tx_data"></A><H3> tx_data </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>void <A HREF="#tx_data">tx_data</A> ( Uchar data_to_tx ) </PRE></TD></TABLE><P>This function send on UART the value<P><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#FFD0D0" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>data_to_tx: byte to transmit on the line</PRE></TD></TABLE><HR><A NAME="uart_init"></A><H3> uart_init </H3><TABLE BORDER="0" WIDTH="100 %" BGCOLOR="#D6E8FF" CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>void <A HREF="#uart_init">uart_init</A> ( void ) </PRE></TD></TABLE><P><P><HR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -