flash_protect_enable问题



  • /*********************************************************************
     * @fn      flash_protect_enable
     *
     * @brief   protect flash chip from erase and write.
     *
     * @param   wr_mode     - 0: write.enable with command 0x50
     *                        1: write enable with command 0x06
     *
     * @return  None.
     */
    __attribute__((section("ram_code"))) void flash_protect_enable(uint8_t wr_mode);
    
    /*********************************************************************
     * @fn      flash_protect_enable1
     *
     * @brief   protect flash chip from erase and write.
     *
     * @param   wr_mode     - 0: write.enable with command 0x50
     *                        1: write enable with command 0x06
     *          mask        protect bits mask, refer to flash spec
     *
     * @return  None.
     */
    __attribute__((section("ram_code"))) void flash_protect_enable1(uint8_t wr_mode,uint8_t mask);
    
    /*********************************************************************
     * @fn      flash_protect_disable
     *
     * @brief   remove protection flash chip from erase and write.
     *
     * @param   wr_mode     - 0: write.enable with command 0x50
     *                        1: write enable with command 0x06
     *
     * @return  None.
     */
    __attribute__((section("ram_code"))) void flash_protect_disable(uint8_t wr_mode);
    
    
    
    

    flash_protect_enable和flash_protect_enable1有什么区别吗?



  • @uplooking 不建议用flash_protect_enable1,正常就用flash_protect_enable就好,wr_mode 0代表易失,1代表非易失,一般上电先flash_protect_enable(1)进行flash保护,中间需要擦写flash时就flash_protect_disable(0),操作完成就flash_protect_enable(0)恢复保护