manufacturer of I/O-rich SBCs, operator interfaces, handheld instruments, and development tools for embedded control low cost single board computers, embedded controllers, and operator interfaces for scientific instruments & industrial control development tools for embedded control order our low cost I/O-rich embedded control products embedded controller manufacturer profile single board computers & embedded controllers development tools & starter kits for your embedded design operator interfaces with touchscreens and graphical user interface plug-in expansion modules for digital & analog I/O C language & Forth language integrated development tools, IDE single board and embedded computer accessories embedded controller enclosures, bezels, environmental gaskets
Table of Contents

Introduction

Specifications

Hardware

Flash Card

Connecting To the Wildcard Bus

Selecting the Wildcard Address

Installing the CF Card

CF Card Software Package User Guide and Glossary

How To Install the CF Software

Using the Driver Code with C

Using the Driver Code with Forth

CF Card Software

Categorized List of Functions and Constants

ATA Failure Codes

ATA Primitives

CF Card Information

Directory

File Access and Position Modes

File I/O

File Processing

File System Error Handling

Initialization

Overview of Glossary Notation

Using the File System Functions

Commonly Used Terms

String Parameters and the Use of THIS_PAGE

Access Privileges

Root Directory Only and File Name Restrictions

File Position Indicator

Error Handling

Real-Time Clock on the Host Computer Enables Time/Date Marking of Files 12

Initialization

Automatic Initialization and File Processing

Upgrade note for former Memory Interface Board (MIB) Users

How To Create and Use an AUTOEXEC.QED File

Compile a Program into Flash Memory

Create a Set of Image Files

Transfer the Image File Contents into Memory

Restrictions on Software Upgrades

Recovering from Buggy AUTOSTART.QED Files

Compact Flash Card Software Package Main Glossary

Upgrade Notice for Prior Users of the Memory Interface Board

Sample FILEDEMO.C File (pdf)

Sample FILEDEMO.4th File (pdf)

CF Wildcard Hardware Schematic

The Compact-Flash Wildcard and
CF Card Software Package User Guide

<< Previous | Next>>

C: int Init_File_Heap( uint maxopen_files, uint file_bufsize, xaddr xheap_start, xaddr xheap_end )
4th: Init_File_Heap ( maxopen_files\file_bufsize\xheap_start\xheap_end -- error)
Initializes a heap in the memory region defined by heap_start to heap_end to contain the arrays and buffers used by the file system. All arrays in the specified file heap are dimensioned, and all except the File_Contents buffer are zeroed. This function is typically not called directly by the programmer; rather, it is called via Init_File_IO or Init_File_System functions. See the glossary entry of Init_File_System for the default parameter values passed to this function. FI must point to a 300 byte block of available RAM before this function is called; this initialization is handled by Init_File_IO or Init_File_System. The parameter maxopen_files specifies the maximum number of files that can be open at one time, and file_bufsize indicates the size of a file contents buffer that is available to the user and is also used by the File_Copy and File_Type functions (see File_Contents). A minimum size of 512 bytes (i.e., 1 sector) is enforced on file_bufsize to ensure that File_Copy, File_To_Memory, and File_Type will work properly. The returned error parameter is -1 if the specified heap is too small to accommodate the required arrays and buffers. The heap size must be at least:
    2.5K + [ (1.6K + file_bufsize) * maxopen_files ]
The heap may span multiple contiguous pages.

C: int Init_File_IO( uint maxopen_files, uint file_bufsize, xaddr xheap_start, xaddr xheap_end,
    xaddr xfat_info )
4th: Init_File_IO (maxopen_files\file_bufsize\xheap_start\xheap_end\xfat_info -- error)
Initializes all of the data structures needed by the ATA/FAT file system as described below. Note that the Set_CF_Module must be executed before calling this function. The module number must correspond to the module address set by the module address selection jumpers and the module port (see Table 1 above). See the glossary entry of Init_File_System for the default parameter values passed to this function. The xfat_info parameter must point to a 300 byte block of available RAM in either common memory or paged memory. The xheap_start and xheap_end parameters are the extended addresses that define the boundaries of the heap that contains the arrays and buffers used by the file system. This function calls Init_File_Heap to set up the heap, dimension the required arrays in the heap, and zero all arrays except the File_Contents array. The parameter maxopen_files specifies the maximum number of files that can be open at one time, and file_bufsize indicates the size of a file contents buffer that is available to the user (see File_Contents). A minimum size of 512 bytes (i.e., 1 sector) is enforced on file_bufsize to ensure that File_Copy, File_To_Memory, and File_Type (which use File_Contents) will work properly. The returned error parameter is nonzero if the specified heap is too small to accommodate the required arrays and buffers. The heap size must be at least:
    2.5K + [ (1.6K + file_bufsize) * maxopen_files ]
The heap may span multiple contiguous pages. The returned error parameter is 0 if there are no errors. The error parameter is -1 if the specified heap is too small to accommodate the required arrays and buffers; the error parameter may also equal ERR_NON_DOS_DRIVE or ERR_ATA_READ or ERR_FAIL_ID_DRIVE (see their glossary entries).
Initialization Procedure: This function stores the specified xfat_info as the base address of the master parameter (see the FI glossary entry), sets the hardware control signals to their inactive states, calls Init_File_Heap (see its glossary entry) to configure the heap and dimension the arrays and buffers used by the file system, zeros the CF resource variable at the base of FI and, if there are no heap errors, calls ATA_ID_DRIVE to obtain necessary information about the ATA flash card. Then this function reads the boot sector on the flash disk. The relevant information obtained by these queries is stored in the appropriate data structures for use by the file system routines. This function or Init_File_System should be called any time (that is, after) a new ATA Flash card is placed into the CF Card socket.

C: int Init_File_System( void )
4th: Init_File_System ( -- error )
This is the highest level initialization routine for the ATA/FAT file system. This function calls Init_File_IO with the following parameters:

max_open_files: 5;
file_bufsize: 1 Kbyte per file;
xheap_start: 0x4180 on page 0x03;
xheap_end: 0x7FFF on page 0x03;
xfat_info: 0x4000 on page 0x03;
module_num: specified by Set_CF_Module
See the entry for Init_File_IO for a detailed description of these parameters and the initialization. Note that the Set_CF_Module must be executed before calling this function. The module number must correspond to the module address set by the module address selection jumpers and the module port (see Table 1 above). See the glossary entry for FI for a description of the fat_info structure. Note that this function uses the top 16 Kbytes of the page 3 RAM. User-available RAM on page 3 in the STANDARD.MAP thus ends at 0x4000. If you need this page 3 RAM for other purposes, call Init_File_IO with parameters of your choosing to set up an appropriate memory map.
Implementation Notes: If a CF Card is installed, this routine is automatically called by Do_Autoexec; see its glossary entry for details. Thus, one way to ensure that the CF Card is automatically initialized at startup is to include in your Priority Autostart routine an initialization statement that calls Set_CF_Module and then calls Do_Autoexec. Another way is to invoke Set_CF_Module, and then call Init_File_System or Init_File_IO directly from the Priority Autostart routine. This function or Init_File_IO should be called any time (that is, after) a new CF Card is placed into the socket.

C: void Link_File_IO( void )
4th: Link_File_IO ( -- )
A do-nothing function included for backward compatibility with prior kernel-resident versions of this software. The legacy kernel-resident version supports only the Memory Interface Board (MIB) hardware.

C: ulong Max_File_Size( void )
4th: Max_File_Size ( -- d.numbytes )
Returns the maximum number of bytes per file for the flash card that was present when Init_File_System or Init_File_IO was performed. The returned value is the product of the implementation-defined maximum of 128 allowed clusters per file times the number of bytes per cluster for the installed flash disk. A "cluster" is a group of sectors (see SECTOR_SIZE) that is allocated at one time by the FAT file system; cluster size is determined when a disk is originally formatted. This function may be called anytime after the file system is initialized to determine the maximum file size that can be managed for a given ATA flash card. Zero is returned if the file system is not initialized. The implementation-defined maximum of 128 clusters per file supports a minimum file size of 64 Kbytes at 1 sector per cluster, which is typical of a 1 MByte card. The maximum file size increases to 512 Kbytes for a typical 10 Mbyte flash disk with 8 sectors/cluster.

<< Previous | Next>>


Home|Site Map|Products|Manuals|Resources|Order|About Us
Copyright (c) 2006 Mosaic Industries, Inc.
Your source for single board computers, embedded controllers, and operator interfaces for instruments and automation