MSPM0_ValvanoWare  1.0
ECE445L starter code
Files | Functions
Flash

Flash programming functions. More...

Files

file  Flash.h
 Flash programming functions.
 
file  FlashFile.h
 High-level implementation of the file system implementation.
 

Functions

uint32_t Flash_Write (uint32_t addr, const uint32_t *data)
 Write to flash. More...
 
uint32_t Flash_WriteArray (uint32_t addr, const uint32_t *data, uint32_t count)
 Write array to flash. More...
 
uint32_t Flash_Erase (uint32_t addr)
 Write to flash. More...
 
uint32_t OS_File_New (uint32_t buf[64])
 create new file More...
 
uint32_t OS_File_Size (uint32_t num)
 file size new file More...
 
uint32_t OS_File_Append (uint32_t num, uint32_t buf[64])
 append to existing file More...
 
uint32_t * OS_File_Read (uint32_t num, uint32_t location)
 read from existing file More...
 
uint32_t OS_File_Format (void)
 create new file More...
 

Detailed Description

Flash programming functions.

Function Documentation

◆ Flash_Erase()

uint32_t Flash_Erase ( uint32_t  addr)

Write to flash.

Erase 1024-byte sector
addr must be on 1024-byte (64-bit boundary)
Takes 2488 cycles = 31.1us running at 80 MHz

Parameters
addrsets the location to be programmed
Returns
0 on pass and nonzero on fail
See also
Flash_Write() Flash_WriteArray()
Note
Datasheet says flash is indeterminate after erase until it is programmed.

◆ Flash_Write()

uint32_t Flash_Write ( uint32_t  addr,
const uint32_t *  data 
)

Write to flash.

Write 64-bits, 8 bytes, to Flash
addr must have been previously erased
addr must be on 8-byte (64-bit boundary)

Takes 4055 cycles = 50.7us running at 80 MHz

Parameters
addrsets the location to be programmed
datais a 2-element array containing 64 bits
Returns
0 on pass and nonzero on fail
See also
Flash_Erase() Flash_WriteArray()
Note
after erased, this location can only be programmed once

◆ Flash_WriteArray()

uint32_t Flash_WriteArray ( uint32_t  addr,
const uint32_t *  data,
uint32_t  count 
)

Write array to flash.

Write an array of data to Flash
addr must have been previously erased
addr must be on 8-byte (64-bit boundary)
count must be even

Parameters
addrsets the start location to be programmed
datais an array containing count 32-bit words
countis the number of 32-bit words to program
Returns
number of successful writes; return value == count if ok
See also
Flash_Erase() Flash_Write()
Note
after erased, this location can only be programmed once

◆ OS_File_Append()

uint32_t OS_File_Append ( uint32_t  num,
uint32_t  buf[64] 
)

append to existing file

Save 256 bytes into existing file

Parameters
num32-bit file number, 0 to 15
bufpointer to 256 bytes of data
Returns
0 if successful
Note
assumes OS_File_New was called previously
See also
OS_File_New
Warning
returns 255 on failure or disk full

◆ OS_File_Format()

uint32_t OS_File_Format ( void  )

create new file

Erase all files and all data

Parameters
none
Returns
0 if success
Warning
return 1 on disk write failure

◆ OS_File_New()

uint32_t OS_File_New ( uint32_t  buf[64])

create new file

Create a new file and save first block. Save 256 bytes into the new file. Can support up to 32 files

Parameters
bufpointer to 256 bytes of data
Returns
number of the new file, 0 to 15
Note
assumes OS_File_Format was called previously
See also
OS_File_Format
Warning
return 255 on failure or disk full

◆ OS_File_Read()

uint32_t* OS_File_Read ( uint32_t  num,
uint32_t  location 
)

read from existing file

Read 256 bytes from the file

Parameters
num32-bit file number, 0 to 15
locationlogical address, 0 to 239
Returns
pointer to 256 bytes of the file if successful
Warning
returns 0 on failure because no data

◆ OS_File_Size()

uint32_t OS_File_Size ( uint32_t  num)

file size new file

Check the size of this file

Parameters
num32-bit file number, 0 to 15
Returns
the number of blocks allocated to the file
Warning
return 0 if file has not been created