SDK4.0
This document shows Ameba SDK 4.0 APIs
|
flash functions More...
Ameba Common | |
typedef struct flash_s | flash_t |
void | flash_erase_sector (flash_t *obj, uint32_t address) |
Erase flash sector. More... | |
void | flash_erase_block (flash_t *obj, uint32_t address) |
Erase flash block(64KB) More... | |
int | flash_read_word (flash_t *obj, uint32_t address, uint32_t *data) |
Read a word from specified address. More... | |
int | flash_write_word (flash_t *obj, uint32_t address, uint32_t data) |
Write a word to specified address. More... | |
int | flash_stream_read (flash_t *obj, uint32_t address, uint32_t len, uint8_t *data) |
Read a stream of data from specified address. More... | |
int | flash_stream_write (flash_t *obj, uint32_t address, uint32_t len, uint8_t *data) |
Write a stream of data to specified address. More... | |
void | flash_write_protect (flash_t *obj, uint32_t protect) |
Control the flash chip write protect enable/disable. More... | |
int | flash_get_status (flash_t *obj) |
Get the value of status register1. More... | |
int | flash_set_status (flash_t *obj, uint32_t data) |
Set Status register to enable desired operation. More... | |
void | flash_reset_status (flash_t *obj) |
This function aims to reset the status register, please make sure the operation is appropriate. More... | |
int | flash_burst_write (flash_t *obj, uint32_t address, uint32_t Length, uint8_t *data) |
It is the same with flash_stream_write function which is used to write a stream of data to specified address. More... | |
int | flash_burst_read (flash_t *obj, uint32_t address, uint32_t Length, uint8_t *data) |
It is the same with flash_stream_read function which is used to read a stream of data from specified address. More... | |
int | flash_set_extend_addr (flash_t *obj, uint32_t data) |
This function is only for Micron 128MB flash to access beyond 16MB by switching between eight 16MB-area(segment). Please refer to flash datasheet for more information about memory mapping. More... | |
int | flash_get_extend_addr (flash_t *obj) |
This function is only for Micron 128MB flash to read from Extended Address Register, which shows the current segment. Please refer to flash datasheet for more information about memory mapping. More... | |
int | flash_read_id (flash_t *obj, uint8_t *buf, uint8_t len) |
Get flash ID (command: 0x9F). More... | |
int | flash_read_unique_id (flash_t *obj, uint8_t *buf, uint8_t len) |
This function is only for Winbond flash to get unique ID (command: 0x4B). More... | |
AmebaZ Only | |
void | flash_erase_chip (flash_t *obj) |
Erase the whole flash chip. More... | |
flash functions
int flash_burst_read | ( | flash_t * | obj, |
uint32_t | address, | ||
uint32_t | Length, | ||
uint8_t * | data | ||
) |
It is the same with flash_stream_read function which is used to read a stream of data from specified address.
obj | Flash object define in application software. |
address | Specifies the starting address to read from. |
len | Specifies the length of the data to read. |
data | Specified the address to save the readback data. |
1 | Success |
int flash_burst_write | ( | flash_t * | obj, |
uint32_t | address, | ||
uint32_t | Length, | ||
uint8_t * | data | ||
) |
It is the same with flash_stream_write function which is used to write a stream of data to specified address.
obj | Flash object define in application software. |
address | Specifies the starting address to write to. |
len | Specifies the length of the data to write. |
data | Pointer to a byte array that is to be written. |
1 | Success |
void flash_erase_block | ( | flash_t * | obj, |
uint32_t | address | ||
) |
Erase flash block(64KB)
obj | Flash object define in application software. |
address | Specifies the starting address to be erased.LSB 16bits will be masked. |
none |
void flash_erase_chip | ( | flash_t * | obj | ) |
Erase the whole flash chip.
obj | Flash object define in application software. |
none |
void flash_erase_sector | ( | flash_t * | obj, |
uint32_t | address | ||
) |
Erase flash sector.
obj | Flash object define in application software. |
address | Specifies the starting address to be erased. |
none |
int flash_get_extend_addr | ( | flash_t * | obj | ) |
This function is only for Micron 128MB flash to read from Extended Address Register, which shows the current segment. Please refer to flash datasheet for more information about memory mapping.
obj | Flash object define in application software. |
The value of current Extended Address Register. |
int flash_get_status | ( | flash_t * | obj | ) |
Get the value of status register1.
obj | Flash object define in application software. |
The value of status register1. |
int flash_read_id | ( | flash_t * | obj, |
uint8_t * | buf, | ||
uint8_t | len | ||
) |
Get flash ID (command: 0x9F).
obj | Flash object define in application software. |
buf | Pointer to a byte array to save the readback ID. |
len | Specifies the length of the buf. It should be 3. |
-1 | Fail. |
int flash_read_unique_id | ( | flash_t * | obj, |
uint8_t * | buf, | ||
uint8_t | len | ||
) |
This function is only for Winbond flash to get unique ID (command: 0x4B).
obj | Flash object define in application software. |
buf | Pointer to a byte array to save the readback unique ID. |
len | Specifies the length of the buf. It should be 8. |
-1 | Fail. |
int flash_read_word | ( | flash_t * | obj, |
uint32_t | address, | ||
uint32_t * | data | ||
) |
Read a word from specified address.
obj | Flash object define in application software. |
address | Specifies the address to read from. |
data | Specified the address to save the readback data. |
1 | Success |
void flash_reset_status | ( | flash_t * | obj | ) |
This function aims to reset the status register, please make sure the operation is appropriate.
obj | Specifies the parameter of flash object. |
none |
int flash_set_extend_addr | ( | flash_t * | obj, |
uint32_t | data | ||
) |
This function is only for Micron 128MB flash to access beyond 16MB by switching between eight 16MB-area(segment). Please refer to flash datasheet for more information about memory mapping.
obj | Flash object define in application software. |
data | Specified which segment to choose. |
1 | Success |
int flash_set_status | ( | flash_t * | obj, |
uint32_t | data | ||
) |
Set Status register to enable desired operation.
obj | Specifies the parameter of flash object. |
data | Specifies which bit users like to set. ex: if users want to set the third bit, data = 0x8. |
1 | Success |
int flash_stream_read | ( | flash_t * | obj, |
uint32_t | address, | ||
uint32_t | len, | ||
uint8_t * | data | ||
) |
Read a stream of data from specified address.
obj | Flash object define in application software. |
address | Specifies the starting address to read from. |
len | Specifies the length of the data to read. |
data | Specified the address to save the readback data. |
1 | Success |
int flash_stream_write | ( | flash_t * | obj, |
uint32_t | address, | ||
uint32_t | len, | ||
uint8_t * | data | ||
) |
Write a stream of data to specified address.
obj | Flash object define in application software. |
address | Specifies the starting address to write to. |
len | Specifies the length of the data to write. |
data | Pointer to a byte array that is to be written. |
1 | Success |
void flash_write_protect | ( | flash_t * | obj, |
uint32_t | protect | ||
) |
Control the flash chip write protect enable/disable.
obj | Flash object define in application software. |
protect | This parameter can be 1 or 0.
|
none |
int flash_write_word | ( | flash_t * | obj, |
uint32_t | address, | ||
uint32_t | data | ||
) |
Write a word to specified address.
obj | Flash object define in application software. |
address | Specifies the address to be programmed to. |
data | Specified the data to be programmed. |
1 | Success |