...
A single NOR volume is opened as shown in Listing - Opening a NOR device volume. The file system initialization (FS_Init()
) function must have previously been called.
ROM characteristics and performance benchmarks of the NOR driver can be found in Driver Characterization. The NOR driver also provides interface functions to perform low-level operations (see FAT System Driver Functions).
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
CPU_BOOLEAN App_FS_AddNOR (void) { FS_DEV_NOR_CFG nor_cfg; FS_ERR err; FS_DevDrvAdd((FS_DEV_API *)&FSDev_Nor, (1) (FS_ERR *)&err); if ((err != FS_ERR_NONE) && (err != FS_ERR_DEV_DRV_ALREADY_ADDED)) { return (DEF_FAIL); } (2) nor_cfg.AddrBase = APP_CFG_FS_NOR_ADDR_BASE; nor_cfg.RegionNbr = APP_CFG_FS_NOR_REGION_NBR; nor_cfg.AddrStart = APP_CFG_FS_NOR_ADDR_START; nor_cfg.DevSize = APP_CFG_FS_NOR_DEV_SIZE; nor_cfg.SecSize = APP_CFG_FS_NOR_SEC_SIZE; nor_cfg.PctRsvd = APP_CFG_FS_NOR_PCT_RSVD; nor_cfg.PctRsvdSecActive = APP_CFG_FS_NOR_PCT_RSVD_SEC_ACTIVE; nor_cfg.EraseCntDiffTh = APP_CFG_FS_NOR_ERASE_CNT_DIFF_TH; nor_cfg.PhyPtr = (FS_DEV_NOR_PHY_API *)APP_CFG_FS_NOR_PHY_PTR; nor_cfg.BusWidth = APP_CFG_FS_NOR_BUS_WIDTH; nor_cfg.BusWidthMax = APP_CFG_FS_NOR_BUS_WIDTH_MAX; nor_cfg.PhyDevCnt = APP_CFG_FS_NOR_PHY_DEV_CNT; nor_cfg.MaxClkFreq = APP_CFG_FS_NOR_MAX_CLK_FREQ; (3) FSDev_Open((CPU_CHAR *)"nor:0:", (a) (void *)&nor_cfg, (b) (FS_ERR *)&err); switch (err) { case FS_ERR_NONE: APP_TRACE_DBG((" ...opened device.\r\n")); break; case FS_ERR_DEV_INVALID_LOW_FMT: /* Low fmt invalid. */ APP_TRACE_DBG((" ...opened device (not low-level formatted).\r\n")); FSDev_NOR_LowFmt("nor:0:", &err); (4) if (err != FS_ERR_NONE) { APP_TRACE_DBG((" ...low-level format failed.\r\n")); return (DEF_FAIL); } break; default: /* Device error. */ APP_TRACE_DBG((" ...opening device failed w/err = %d.\r\n\r\n", err)); return (DEF_FAIL); } (5) FSVol_Open((CPU_CHAR *)"nor:0:", (a) (CPU_CHAR *)"nor:0:", (b) (FS_PARTITION_NBR ) 0, (c) (FS_ERR *)&err); switch (err) { case FS_ERR_NONE: APP_TRACE_DBG((" ...opened volume (mounted).\r\n")); break; case FS_ERR_PARTITION_NOT_FOUND: /* Volume error. */ APP_TRACE_DBG((" ...opened device (not formatted).\r\n")); FSVol_Fmt("nor:0:", (void *)0, &err); (6) if (err != FS_ERR_NONE) { APP_TRACE_DBG((" ...format failed.\r\n")); return (DEF_FAIL); } break; default: /* Device error. */ APP_TRACE_DBG((" ...opening volume failed w/err = %d.\r\n\r\n", err)); return (DEF_FAIL); } return (DEF_OK); } |
Panel |
---|
(1) Register the NOR device driver (2) The NOR device configuration should be assigned. For more information about these parameters, see FS_DEV_NOR_CFG. (3) (4) (5) (6) |
If the NOR initialization succeeds, the file system will produce the trace output as shown in Figure - NOR detection trace output (if a sufficiently high trace level is configured). See Trace Configuration about configuring the trace level.
Panel | ||||
---|---|---|---|---|
| ||||