Changes

Jump to: navigation, search

How to use flash if uni

841 bytes added, 14:02, 24 June 2010
no edit summary
This guide describes how to use the flash_if_uni system (which consists of <span style="color:#55E439">flash_if_uni.c </span< and <span style="color:#55E439">flash_if_uni.h</span>).
flash_if_uni allows a designer a simple means of communicating with [http://www.atmel.com Atmel] Flash products ([http://www.atmel.com/dyn/products/product_card_v2.asp?part_id=2955 AT49BV322A], [http://www.atmel.com/dyn/products/product_card_v2.asp?part_id=2956 AT49BV322AT], [http://www.atmel.com/dyn/products/product_card.asp?part_id=3762 AT49BV322D], [http://www.atmel.com/dyn/products/product_card.asp?part_id=3763 AT49BV322DT]) from a Xilinx EDK (Microblaze) project.
====DEFINES====
When using flash_if_uni all options are controlled by #defines at the top of flash_if_uni.h. The following constants are defined.
* <span style="color:#55E439">FLASH_ADDR</span>: This is the Base Address of the XPS_EMC_MCH Memory Controller IP Core in your EDK Project that connects to your Atmel Flash. This should be set to the constant given for the Base Address for the XPS_EMC_MCH in the xparameters.h file generated by EDK.* <span style="color:#55E439">FLASH_RDY_ADDR</span>: This is the Base Address of the XPS_GPIO General Purpose IO IP Core in your EDK Project that connects to the Ready line from your Atmel Flash. This should be set to the constant given for the Base Address for the appropriate XPS_GPIO in the xparameters.h file generated by EDK.* <span style="color:#55E439">FLASH_RDY_MASK</span>: This is a hex number describing which bit in the XPS_GPIO (that FLASH_RDY_ADDR points to) is connected to the Ready line from your Atmel Flash. If the Ready line is the only thing connected to the XPS_GPIO then this should be set to 0xFFFFFFFF* <span style="color:#55E439">EDK_VERSION</span>: This define specifies which version of the Xilinx EDK software you are using. Currently flash_if_uni supports EDK 10.1 and EDK 12.1. Valid values for this define are "10" and "12".* <span style="color:#55E439">DATA_WIDTH</span>: This define specifies how wide your flash interface is. It currently supports 16-bit and 32-bit operation. Valid values afor this define are "16" and "32".
<br />
====TYPEDEFS====
There is, currently, a single typedef in <span style="color:#55E439">flash_if_uni.h </span> to account for the choice between 16-bit and 32-bit operation.f_data_type is either Xuint16 or Xuint32 based on the value of <span style="color:#55E439">DATA_WIDTH</span>.
<br />
<br />
====FUNCTIONS====
The following functions exist within flash_if_uni. Functions shown in italics are internal and not meant to be called by the end user.
* <span style="color:#55E439">void flash_init(void);</span>
*: This runs initialization code for EDK 10. This does nothing in 12 but won't hurt anything.
* <span style="color:#55E439">void erase_flash(void);</span>
*: This allows you to erase the entire Flash.
* <span style="color:#55E439">void erase_flash_sector(Xuint32 ui_sector_num);</span>
*: This allows you to erase only a single sector in Flash. ui_sector_num is a passed parameter with a value from 0 to 69.
* <span style="color:#55E439">void write_flash_data(Xuint32 ui_waddr, f_data_type us_wdata);</span>
*: This allows you to write to a single Flash address. You must pass it a valid address and data word.
*:* ui_waddr must be from 0 to 2,097,151
*:* ui_wdata must be an Xuint16 if <span style="color:#55E439">DATA_WIDTH </span> == 16 and an Xuint32 if <span style="color:#55E439">DATA_WIDTH </span> == 32* <span style="color:#55E439">f_data_type read_flash_data(Xuint32 ui_raddr);</span>
*: This function allows you to read a single data value from a single Flash address.
*:* ui_raddr must be from 0 to 2,097,151
*:* This function will return an Xuint16 if <span style="color:#55E439">DATA_WIDTH </span> == 16 and an Xuint32 if <span style="color:#55E439">DATA_WIDTH </span> == 32* <span style="color:#55E439">''void _flash_write_cycle(Xuint32 ui_waddr, f_data_type us_wdata);''</span>
*: This function is internal and not meant to be run by an end user. It write an address/data pair to the Flash. However, actual reads and writes require multiple, specially crafted write cycles in sequence.
* <span style="color:#55E439">Xint32 flash_busy(void);</span>
*: This checks to see if the Flash is busy completing an operation. It is used extensively by flash_if_uni (internally). But can be polled by a user to wait for things like an erase operation to complete. It returns a '1' if the part is busy and a '0' if the part is ready.
* <span style="color:#55E439">Xuint32 get_edk_version(void);</span>*: This function simply returns the value of <span style="color:#55E439">EDK_VERSION</span>.* <span style="color:#55E439">Xuint32 get_data_width(void);</span>*: This function simply returns the value of <span style="color:#55E439">DATA_WIDTH</span>.

Navigation menu