The main() function

The main() function for the driver, which you'll find in the main.c file in the sample directories, is the first thing that needs to be modified for your system. Let's look at the main.c file for the 800FADS board example:

/*
** File: main.c for 800FADS board
*/
#include <sys/f3s_mtd.h>
#include "f3s_800fads.h"

int main(int argc, char **argv)
{
   int error;
   static f3s_service_t service[]=
   {
      {
         sizeof(f3s_service_t),
         f3s_800fads_open,
         f3s_800fads_page,
         f3s_800fads_status,
         f3s_800fads_close
      },
      {
         /* mandatory last entry */
         0, 0, 0, 0, 0  
      }
   };

   static f3s_flash_v2_t flash[] =
   {
      {
         sizeof(f3s_flash_v2_t),
         f3s_a29f040_ident,      /* Common Ident             */
         f3s_a29f040_reset,      /* Common Reset             */

         /* v1 Read/Write/Erase/Suspend/Resume/Sync (Unused) */	  
         NULL, NULL, NULL, NULL, NULL, NULL,

         NULL,                   /* v2 Read (Use default)    */
      
         f3s_a29f040_v2write,    /* v2 Write                 */
         f3s_a29f040_v2erase,    /* v2 Erase                 */
         f3s_a29f040_v2suspend,  /* v2 Suspend               */
         f3s_a29f040_v2resume,   /* v2 Resume                */
         f3s_a29f040_v2sync,     /* v2 Sync                  */

         /* v2 Islock/Lock/Unlock/Unlockall (not supported)  */
         NULL, NULL, NULL, NULL
      },
      
      {
         /* mandatory last entry */
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
			
      }
   };

   /* init f3s */
   f3s_init(argc, argv, flash);

   /* start f3s */
   error = f3s_start(service, flash);

   return error;
}

The service array contains one or more f3s_service_t structures, depending on how many different sockets your driver has to support. The f3s_service_t structure, defined in <fs/f3s_socket.h>, contains function pointers to the socket services routines.

The flash array contains one or more f3s_flash_t structures, depending on how many different types of flash device your driver has to support. The f3s_flash_t structure, defined in <fs/f3s_flash.h>, contains function pointers to the flash services routines.

The f3s_init() and f3s_start() functions are defined in the <fs/f3s_api.h> header file.

Note: Don't use the <fs/f3s_socket.h>, <fs/f3s_flash.h>, and <fs/f3s_api.h> header files directly. Instead, you should include <sys/f3s_mtd.h> for backward and forward compatibility.