Difference between revisions of "How to use flash if uni"
Line 1: | Line 1: | ||
− | This guide describes how to use the flash_if_uni system (which consists of flash_if_uni.c and flash_if_uni.h). | + | 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. | 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. | ||
Line 9: | Line 9: | ||
====DEFINES==== | ====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. | When using flash_if_uni all options are controlled by #defines at the top of flash_if_uni.h. The following constants are defined. | ||
− | * FLASH_ADDR: 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_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. |
− | * FLASH_RDY_ADDR: 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_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. |
− | * FLASH_RDY_MASK: 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">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 |
− | * EDK_VERSION: 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">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". |
− | * DATA_WIDTH: 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". | + | * <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 /> | <br /> | ||
====TYPEDEFS==== | ====TYPEDEFS==== | ||
− | There is, currently, a single typedef in flash_if_uni.h to account for the choice between 16-bit and 32-bit operation. | + | 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 DATA_WIDTH. | + | f_data_type is either Xuint16 or Xuint32 based on the value of <span style="color:#55E439">DATA_WIDTH</span>. |
<br /> | <br /> | ||
<br /> | <br /> | ||
Line 24: | Line 24: | ||
====FUNCTIONS==== | ====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. | The following functions exist within flash_if_uni. Functions shown in italics are internal and not meant to be called by the end user. | ||
− | * void flash_init(void); | + | * <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. | *: This runs initialization code for EDK 10. This does nothing in 12 but won't hurt anything. | ||
− | * void erase_flash(void); | + | * <span style="color:#55E439">void erase_flash(void);</span> |
*: This allows you to erase the entire Flash. | *: This allows you to erase the entire Flash. | ||
− | * void erase_flash_sector(Xuint32 ui_sector_num); | + | * <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. | *: 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. | ||
− | * void write_flash_data(Xuint32 ui_waddr, f_data_type us_wdata); | + | * <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. | *: 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_waddr must be from 0 to 2,097,151 | ||
− | *:* ui_wdata must be an Xuint16 if DATA_WIDTH == 16 and an Xuint32 if DATA_WIDTH == 32 | + | *:* 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 |
− | * f_data_type read_flash_data(Xuint32 ui_raddr); | + | * <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. | *: 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 | *:* ui_raddr must be from 0 to 2,097,151 | ||
− | *:* This function will return an Xuint16 if DATA_WIDTH == 16 and an Xuint32 if DATA_WIDTH == 32 | + | *:* 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 |
− | * ''void _flash_write_cycle(Xuint32 ui_waddr, f_data_type us_wdata);'' | + | * <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. | *: 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. | ||
− | * Xint32 flash_busy(void); | + | * <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. | *: 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. | ||
− | * Xuint32 get_edk_version(void); | + | * <span style="color:#55E439">Xuint32 get_edk_version(void);</span> |
− | *: This function simply returns the value of EDK_VERSION. | + | *: This function simply returns the value of <span style="color:#55E439">EDK_VERSION</span>. |
− | * Xuint32 get_data_width(void); | + | * <span style="color:#55E439">Xuint32 get_data_width(void);</span> |
− | *: This function simply returns the value of DATA_WIDTH | + | *: This function simply returns the value of <span style="color:#55E439">DATA_WIDTH</span>. |
Revision as of 09:02, 24 June 2010
This guide describes how to use the flash_if_uni system (which consists of flash_if_uni.c</span< and flash_if_uni.h).
flash_if_uni allows a designer a simple means of communicating with Atmel Flash products (AT49BV322A, AT49BV322AT, AT49BV322D, 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.
- FLASH_ADDR: 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.
- FLASH_RDY_ADDR: 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.
- FLASH_RDY_MASK: 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
- EDK_VERSION: 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".
- DATA_WIDTH: 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".
TYPEDEFS
There is, currently, a single typedef in flash_if_uni.h 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 DATA_WIDTH.
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.
- void flash_init(void);
- This runs initialization code for EDK 10. This does nothing in 12 but won't hurt anything.
- void erase_flash(void);
- This allows you to erase the entire Flash.
- void erase_flash_sector(Xuint32 ui_sector_num);
- 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.
- void write_flash_data(Xuint32 ui_waddr, f_data_type us_wdata);
- 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 DATA_WIDTH == 16 and an Xuint32 if DATA_WIDTH == 32
- This allows you to write to a single Flash address. You must pass it a valid address and data word.
- f_data_type read_flash_data(Xuint32 ui_raddr);
- 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 DATA_WIDTH == 16 and an Xuint32 if DATA_WIDTH == 32
- This function allows you to read a single data value from a single Flash address.
- void _flash_write_cycle(Xuint32 ui_waddr, f_data_type us_wdata);
- 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.
- Xint32 flash_busy(void);
- 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.
- Xuint32 get_edk_version(void);
- This function simply returns the value of EDK_VERSION.
- Xuint32 get_data_width(void);
- This function simply returns the value of DATA_WIDTH.