⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s29jl064h.c

📁 (1)本人基于MPC860的vxworks bsp的程序 (2)实现了FEC 100M和 SCC 10M的网口功能 (3)实现了nor flash的TFFS文件系统 (4)实现了系统的自检 (
💻 C
📖 第 1 页 / 共 5 页
字号:
                   if ((combined_togl_mask & 0xFFFF0000)   == (toglbit2_mask & 0xFFFF0000))   dq2togl_active &= 0x0000FFFF;                   break;             }             break;          case 0xFFFFFFFF:             if (combined_togl_mask == toglbit2_mask) dq2togl_active = 0;             break;       }       active_mask_tmp  = dq6togl_active >> 6;       active_mask_tmp |= dq2togl_active >> 2;    }    else    {       active_mask_tmp  = dq6togl_active >> 6;       active_mask_tmp |= dq2togl_active >> 2;    }    active_mask_tmp *= (FLASHDATA) GetUnitReadMask(data_cfg);    *active_mask_ptr = active_mask_tmp;    return (AM29LV160_OK);}/******************************************************************************/int AreDevicesInTransition(int        *flag_ptr,                            FLASHDATA  data1,                            FLASHDATA  data2,                            PARAM      data_cfg,                           PARAM      *err_code_ptr,                               char       *err_buf                                       ){    int          status = AM29LV160_OK;    FLASHDATA    dq7_dev_mask;    FLASHDATA    dq5_dev_mask;    dq7_dev_mask = DQ7_BIT_MASK;    dq5_dev_mask = DQ5_BIT_MASK;    if ((dq7_dev_mask & data1) != (dq7_dev_mask & data2))    {        *flag_ptr = TRUE;        return AM29LV160_OK;    }        if ((dq5_dev_mask & data1) != (dq5_dev_mask & data2))    {        *flag_ptr = TRUE;        return AM29LV160_OK;    }    *flag_ptr = FALSE;    return AM29LV160_OK;}int UnlockAddrsInit(ADDRESS *unlock_addr1,  /* first unlock address */ADDRESS *unlock_addr2,  /* second unlock address */PARAM data_cfg,         /* flash data width and # of devices */PARAM *err_code_ptr,    /* variable to store error code */char *err_buf           /* buffer to store error text */){           int             status = AM29LV160_OK;    switch(data_cfg)    {      case X8X16_AS_X8:        *unlock_addr1 = NOR_UNLOCK_ADDR1_X8;        *unlock_addr2 = NOR_UNLOCK_ADDR2_X8;        break;      case X8X16_AS_X16:        *unlock_addr1 = NOR_UNLOCK_ADDR1_X8_X16;        *unlock_addr2 = NOR_UNLOCK_ADDR2_X8_X16;        break;				      default:        *err_code_ptr = INVALID_PARAMETER;        #ifdef FLASH_DEBUG_PRINT        FLASH_DEBUG_PRINT(err_buf, "Invalid data config.\n");        #endif				        status = AM29LV160_ERROR;    }    return(status);}int ReadMaskInit(FLASHDATA *read_mask,   /* variable in which to store mask */PARAM data_cfg,         /* flash data width and # of devices */PARAM *err_code_ptr,    /* variable to store error code */char *err_buf           /* buffer to store error text */){           int             status = AM29LV160_OK;    switch(data_cfg)    {      case X8X16_AS_X8:        *read_mask = 0xFF;        break;      case X8X16_AS_X16:        *read_mask = 0xFFFF;        break;      default:        *err_code_ptr = INVALID_PARAMETER;        #ifdef FLASH_DEBUG_PRINT        FLASH_DEBUG_PRINT(err_buf, "Invalid data config.\n");        #endif        status = ERROR;    }    return(status);}int ToggleBit1MaskInit(FLASHDATA *toglbit1_mask,                             /* variable in which to store mask */PARAM data_cfg,                                       /* flash data width and # of devices */PARAM *err_code_ptr,                                  /* variable to store error code */char *err_buf                                         /* buffer to store error text */){           int status = AM29LV160_OK;    *toglbit1_mask = DQ6_BIT_MASK;    return(status);}int ToggleBit2MaskInit(FLASHDATA *toglbit2_mask,                             /* variable in which to store mask */PARAM data_cfg,                                       /* flash data width and # of devices */PARAM *err_code_ptr,                                  /* variable to store error code */char *err_buf                                         /* buffer to store error text */){           int status = AM29LV160_OK;    *toglbit2_mask = DQ2_BIT_MASK;    return(status);}int ExceedTimeLimitMaskInit(FLASHDATA *xcdtimelim_mask,                           /* variable in which to store mask */PARAM data_cfg,                                       /* flash data width and # of devices */PARAM *err_code_ptr,                                  /* variable to store error code */char *err_buf                                         /* buffer to store error text */){           int status = AM29LV160_OK;    *xcdtimelim_mask = DQ5_BIT_MASK;    return(status);}int WrtBufAbortMaskInit(FLASHDATA *wrtbufabort_mask_ptr,                      /* variable in which to store mask */PARAM data_cfg,                                       /* data width, # of devices */PARAM *err_code_ptr,                                  /* variable to store error code */char *err_buf                                         /* buffer to store error text */){           int status = AM29LV160_OK;    *wrtbufabort_mask_ptr = DQ1_BIT_MASK;    return(status);}/*******************************************************************************    * am29lv160_StatusGet - Determines Flash Status*** RETURNS: am29lv160_OK, or am29lv160_ERROR** ERRNO:    *  INTERNAL_ERROR*  WRITE_BUFFER_LOAD_ERROR;*  FLASH_INTERNAL_TIMEOUT*  errors from Init functions*  errors generated by HAL functions*/int am29lv160_StatusGet   (    ADDRESS     base_addr,      /* device base address in system */    ADDRESS     offset,         /* address offset from base address */    PARAM       data_cfg,       /* flash data width and # of devices */    DEVSTATUS*  dev_status_ptr, /* device status */    FLASHDATA*  act_data_ptr,   /* actual data */    PARAM       polling_type,   /* type of polling to perform */    PARAM*      err_code_ptr,   /* variable to store error code */        char*       err_buf         /* buffer to store error text */    ){    int status = AM29LV160_OK;    FLASHDATA    new_data             = 0;    FLASHDATA    old_data             = 0;    FLASHDATA    read_mask          = 0xFFFF;    FLASHDATA    active_mask       = 0;    FLASHDATA    toglbit1_mask     = DQ6_BIT_MASK;    FLASHDATA    toglbit2_mask     = DQ2_BIT_MASK;    FLASHDATA    xcdtimelim_mask   = DQ5_BIT_MASK;    FLASHDATA    wrtbufabort_mask  = DQ1_BIT_MASK;    int          flag;    /* Initialize Masks */    #if 0    status = ReadMaskInit(&read_mask, data_cfg, err_code_ptr, err_buf);    if (status != AM29LV160_OK)        return status;    #endif        /* do the first status read of the device */    status = HalRead(base_addr + offset, &old_data,                      err_code_ptr, err_buf);    if (status != AM29LV160_OK)        return (status);    /* do the second status read of the device */    status = HalRead(base_addr + offset,    &new_data,                      err_code_ptr, err_buf);    if (status != AM29LV160_OK)        return (status);        /* Store most recent read data for caller (before clean-up) */    *act_data_ptr = new_data;        /* clean up data */    old_data &= read_mask;        new_data &= read_mask;        /* Check if steady state */    if (old_data == new_data)            /* If you get the same data   */    {                                               /* twice, the device has      */        *dev_status_ptr = dev_not_busy;  /* obviously finished without errors.*/        return (AM29LV160_OK);                   }        /* flash devices transition from program and erase        */    /* operations to reading array data on their own.  While polling,  */    /* it is common for the first read of status to be status, but     */    /* the second read is the actual data itself.  Since we must       */    /* compare the first and second reads together to determine        */    /* whether toggling is occurring, etc., we have chosen to ignore   */    /* cases where it appears the first read is status and the         */    /* second read is data. If we see transitions on DQ7 or DQ5,       */    /* we exits with a busy return value, assuming things will         */    /* have settled down by the next set of reads.                     */    status = AreDevicesInTransition(&flag, old_data, new_data, data_cfg,                                      err_code_ptr, err_buf);    if (status != AM29LV160_OK)        return status;    if (flag)    {        *dev_status_ptr = dev_busy;        return (AM29LV160_OK);    }    #if 0    /* At this point, we have two samples of status/data from all     */    /* the devices interleaved together.  Some devices may be         */    /* reporting status both times while others may be reporting      */    /* data both times.                                               */    /* Create some masks for isolating specific bits.                 */    status = ToggleBit1MaskInit(&toglbit1_mask, data_cfg,                                 err_code_ptr, err_buf);    if (status != AM29LV160_OK)        return status;    status = ToggleBit2MaskInit(&toglbit2_mask, data_cfg,                                 err_code_ptr, err_buf);    if (status != AM29LV160_OK)        return status;    status = ExceedTimeLimitMaskInit(&xcdtimelim_mask, data_cfg,                                      err_code_ptr, err_buf);    if (status != AM29LV160_OK)        return status;    status = WrtBufAbortMaskInit(&wrtbufabort_mask, data_cfg,                                  err_code_ptr, err_buf);    if (status != AM29LV160_OK)        return status;    #endif		    /* This is a special mask for isolating only the busy devices. */    status = ActiveMaskInit(&active_mask, old_data, new_data, data_cfg, polling_type,                            err_code_ptr, err_buf);    if (status != AM29LV160_OK)        return status;        /* check that active devices were identified */    if (active_mask == 0)    {        if (polling_type == POLL_RESUME)        {           *dev_status_ptr = dev_not_busy;           return (AM29LV160_OK);        }        else        {           *dev_status_ptr = dev_status_unknown;           *err_code_ptr  = INTERNAL_ERROR;           return (AM29LV160_ERROR);        }    }    /* mask out inactive (ready) devices */    old_data &= active_mask;    new_data &= active_mask;        xcdtimelim_mask  &= active_mask;    wrtbufabort_mask &= active_mask;    toglbit1_mask    &= active_mask;    toglbit2_mask    &= active_mask;    *dev_status_ptr = dev_status_unknown;    /* Check if time limits exceeded:      * if all active devices have their DQ5 bits == 1      * then this is an error condition.      */    if ((new_data & xcdtimelim_mask) == (xcdtimelim_mask))    {        *dev_status_ptr = dev_exceeded_time_limits;        #ifdef FLASH_DEBUG_PRINT        FLASH_DEBUG_PRINT(err_buf, "Internal Time Limits Exceeded.\n");        #endif        *err_code_ptr   = FLASH_INTERNAL_TIMEOUT;        return (AM29LV160_OK);    }    /* check for write buffer abort      * Note: if some devices started programming successfully     *       then this allows them to finish      *       Only when all active devices are in write buffer abort state      *       will this function return a "write buffer abort" error     */          if (polling_type == POLL_WRT_BUF_PGM)    {        if ((new_data & wrtbufabort_mask) == (wrtbufabort_mask))        {            *dev_status_ptr  = dev_write_buffer_abort;            *err_code_ptr    = WRITE_BUFFER_LOAD_ERROR;            #ifdef FLASH_DEBUG_PRINT            FLASH_DEBUG_PRINT(err_buf, "Write Buffer Load Error.\n");            #endif            return (AM29LV160_OK);        }    }    /* check for suspend:      * Toggle Bit 1 has stopped toggling on all active devices     * AND Toggle Bit 2 is toggling on all active devices      */    if ( ((new_data & toglbit1_mask) == (old_data & toglbit1_mask)) &&         ((((new_data ^ old_data) & toglbit2_mask) ^ toglbit2_mask) == 0) &&         (polling_type != POLL_RESUME) )    {        *dev_status_ptr = dev_suspend;        return (AM29LV160_OK);    }    /* note: new default return value is busy.       *       this removes "undetermined state" check present in old     *       "status get" function     */    *dev_status_ptr = dev_busy;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -