#include "config.h"
#include "df_mem.h"
#include "df.h"
Include dependency graph for df_mem.c:
Go to the source code of this file.
Defines | |
#define | MEM_BASE_ADDRESS 0x0000 |
Functions | |
void | df_check_init (void) |
void | df_mem_init (void) |
This function initializes the hw/sw ressources required to drive the DF. | |
Ctrl_status | df_test_unit_ready (void) |
This function tests the state of the DF memory. | |
Ctrl_status | df_read_capacity (U32 _MEM_TYPE_SLOW_ *u32_nb_sector) |
This function gives the address of the last valid sector. | |
Bool | df_wr_protect (void) |
This function returns the write protected status of the memory. | |
Bool | df_removal (void) |
This function tells if the memory has been removed or not. | |
Ctrl_status | df_read_10 (U32 addr, U16 nb_sector) |
This function performs a read operation of n sectors from a given address on. | |
Ctrl_status | df_write_10 (U32 addr, U16 nb_sector) |
This fonction initialise the memory for a write operation. | |
Ctrl_status | df_usb_read () |
This fonction transfer the memory data (programed in scsi_read_10) directly to the usb interface. | |
Ctrl_status | df_usb_write (void) |
This fonction transfer the usb data (programed in scsi_write_10) directly to the memory data. | |
Ctrl_status | df_ram_2_df (U32 addr, U8 *ram) |
This fonction initialise the memory for a write operation from ram buffer. | |
Ctrl_status | df_df_2_ram (U32 addr, U8 *ram) |
This fonction read 1 sector from DF to ram buffer. | |
Ctrl_status | df_df_2_ram_read () |
This fonction transfer the memory data to ram. | |
Ctrl_status | df_ram_2_df_write (void) |
This fonction transfer ram to the memory data. | |
Variables | |
data U32 | gl_ptr_mem |
bit | reserved_disk_space = FALSE |
xdata U32 | DF_DISK_SIZE |
Please read file license.txt for copyright notice.
Definition in file df_mem.c.
void df_check_init | ( | void | ) |
void df_mem_init | ( | void | ) |
This function initializes the hw/sw ressources required to drive the DF.
none |
Definition at line 59 of file df_mem.c.
References df_init().
Referenced by storage_task_init().
00060 { 00061 df_init(); // Init the DF driver and its communication link. 00062 }
Here is the call graph for this function:
Ctrl_status df_test_unit_ready | ( | void | ) |
This function tests the state of the DF memory.
none |
Definition at line 76 of file df_mem.c.
References CTRL_GOOD, CTRL_NO_PRESENT, df_mem_check(), and OK.
00077 { 00078 return( (OK==df_mem_check()) ? CTRL_GOOD : CTRL_NO_PRESENT); 00079 }
Here is the call graph for this function:
Ctrl_status df_read_capacity | ( | U32 _MEM_TYPE_SLOW_ * | u32_nb_sector | ) |
This function gives the address of the last valid sector.
*u32_nb_sector | number of sector (sector = 512B). OUT |
Definition at line 92 of file df_mem.c.
References CTRL_GOOD, and DF_DISK_SIZE.
00093 { 00094 *u32_nb_sector = DF_DISK_SIZE; 00095 return CTRL_GOOD; 00096 }
Bool df_wr_protect | ( | void | ) |
This function returns the write protected status of the memory.
Only used by memory removal with a HARDWARE SPECIFIC write protected detection !!! The customer must unplug the memory to change this write protected status, which cannot be for a DF.
Definition at line 110 of file df_mem.c.
References FALSE.
00111 { 00112 return FALSE; 00113 }
Bool df_removal | ( | void | ) |
Ctrl_status df_read_10 | ( | U32 | addr, | |
U16 | nb_sector | |||
) |
This function performs a read operation of n sectors from a given address on.
(sector = 512B)
DATA FLOW is: DF => USB
addr | Sector address to start the read from | |
nb_sector | Number of sectors to transfer |
Definition at line 150 of file df_mem.c.
References CTRL_GOOD, df_read_close(), df_read_open(), df_read_sector(), and LSB0.
00151 { 00152 #if (DF_NB_MEM != 1) // if more than 1 memory, variables are needed for zones mangement 00153 U32 next_sector_addr = addr; 00154 U16 nb_sectors_remaining = nb_sector; 00155 #endif 00156 00157 #if (DF_NB_MEM == 1) /* 1 DATAFLASH */ 00158 df_read_open(addr); // wait device is not busy, then send command & address 00159 df_read_sector(nb_sector); // transfer data from memory to USB 00160 #else /* 2 or 4 DATAFLASH */ 00161 #ifdef DF_4_MB // 512B PAGES 00162 while (nb_sectors_remaining != 0) 00163 { 00164 df_read_open(next_sector_addr); // wait device is not busy, then send command & address 00165 df_read_sector(1); // transfer the page from memory to USB 00166 df_read_close(); 00167 nb_sectors_remaining--; 00168 next_sector_addr++; 00169 } 00170 #else // 1024B PAGES 00171 while (nb_sectors_remaining != 0) 00172 { 00173 df_read_open(next_sector_addr); // wait device is not busy, then send command & address 00174 if ((LSB0(next_sector_addr)&0x01) == 0) 00175 { 00176 if (nb_sectors_remaining == 1) 00177 { 00178 df_read_sector(1); 00179 df_read_close(); 00180 nb_sectors_remaining--; 00181 next_sector_addr++; 00182 } 00183 else 00184 { 00185 df_read_sector(2); 00186 df_read_close(); 00187 nb_sectors_remaining -= 2; 00188 next_sector_addr += 2; 00189 } 00190 } 00191 else 00192 { 00193 df_read_sector(1); 00194 df_read_close(); 00195 nb_sectors_remaining--; 00196 next_sector_addr++; 00197 } 00198 } 00199 #endif 00200 #endif 00201 df_read_close(); // unselect memory 00202 return CTRL_GOOD; 00203 }
Here is the call graph for this function:
Ctrl_status df_write_10 | ( | U32 | addr, | |
U16 | nb_sector | |||
) |
This fonction initialise the memory for a write operation.
DATA FLOW is: USB => DF
(sector = 512B)
addr | Sector address to start write | |
nb_sector | Number of sectors to transfer |
Definition at line 219 of file df_mem.c.
References CTRL_GOOD, df_write_close(), df_write_open(), df_write_sector(), and LSB0.
00220 { 00221 #if (DF_NB_MEM != 1) // if more than 1 memory, variables are needed for zones mangement 00222 U32 next_sector_addr = addr; 00223 U16 nb_sectors_remaining = nb_sector; 00224 #endif 00225 00226 #if (DF_NB_MEM == 1) /* 1 DATAFLASH */ 00227 df_write_open(addr); // wait device is not busy, then send command & address 00228 df_write_sector(nb_sector); // transfer data from memory to USB 00229 #else /* 2 or 4 DATAFLASH */ 00230 #ifdef DF_4_MB // 512B PAGES 00231 while (nb_sectors_remaining != 0) 00232 { 00233 df_write_open(next_sector_addr); // wait device is not busy, then send command & address 00234 df_write_sector(1); // transfer the page from memory to USB 00235 df_write_close(); 00236 nb_sectors_remaining--; 00237 next_sector_addr++; 00238 } 00239 #else // 1024B PAGES 00240 while (nb_sectors_remaining != 0) 00241 { 00242 df_write_open(next_sector_addr); // wait device is not busy, then send command & address 00243 if ((LSB0(next_sector_addr)&0x01) == 0) 00244 { 00245 if (nb_sectors_remaining == 1) 00246 { 00247 df_write_sector(1); 00248 df_write_close(); 00249 nb_sectors_remaining--; 00250 next_sector_addr++; 00251 } 00252 else 00253 { 00254 df_write_sector(2); 00255 df_write_close(); 00256 nb_sectors_remaining -= 2; 00257 next_sector_addr += 2; 00258 } 00259 } 00260 else 00261 { 00262 df_write_sector(1); 00263 df_write_close(); 00264 nb_sectors_remaining--; 00265 next_sector_addr++; 00266 } 00267 } 00268 #endif 00269 #endif 00270 df_write_close(); // unselect memory 00271 return CTRL_GOOD; 00272 }
Here is the call graph for this function:
Ctrl_status df_usb_read | ( | void | ) |
Ctrl_status df_usb_write | ( | void | ) |
Ctrl_status df_ram_2_df | ( | U32 | addr, | |
U8 * | ram | |||
) |
This fonction initialise the memory for a write operation from ram buffer.
DATA FLOW is: RAM => DF
(sector = 512B)
addr | Sector address to write | |
ram | Ram buffer pointer |
Definition at line 317 of file df_mem.c.
References CTRL_GOOD, df_write_close(), df_write_open(), and df_write_sector_from_ram().
00318 { 00319 df_write_open(addr); 00320 df_write_sector_from_ram(ram); 00321 df_write_close(); 00322 return CTRL_GOOD; 00323 }
Here is the call graph for this function:
Ctrl_status df_df_2_ram | ( | U32 | addr, | |
U8 * | ram | |||
) |
This fonction read 1 sector from DF to ram buffer.
DATA FLOW is: DF => RAM
(sector = 512B)
addr | Sector address to read | |
ram | Ram buffer pointer |
Definition at line 337 of file df_mem.c.
References CTRL_GOOD, df_read_close(), df_read_open(), and df_read_sector_2_ram().
00338 { 00339 df_read_open(addr); 00340 df_read_sector_2_ram(ram); 00341 df_read_close(); 00342 return CTRL_GOOD; 00343 }
Here is the call graph for this function:
Ctrl_status df_df_2_ram_read | ( | void | ) |
Ctrl_status df_ram_2_df_write | ( | void | ) |
data U32 gl_ptr_mem |
Definition at line 32 of file df_mem.c.
Referenced by df_read_open(), df_read_sector(), df_read_sector_2_ram(), df_write_close(), df_write_open(), df_write_sector(), and df_write_sector_from_ram().
bit reserved_disk_space = FALSE |
xdata U32 DF_DISK_SIZE |
Referenced by df_read_capacity().