📄 ctrl_access.c
字号:
/* This file has been prepared for Doxygen automatic documentation generation.*//*! \file ctrl_access.c ********************************************************************* * * \brief * This file contains the interface : * - between USB <-> MEMORY * OR * - between USB <- Access Memory Ctrl -> Memory * * This interface may be controled by a "Access Memory Control" for : * - include a management of write protect global or specific * - include a management of access password * * \addtogroup usbstick * * \author * Atmel Corporation: http://www.atmel.com \n * Support email: avr@atmel.com ******************************************************************************//* Copyright (c) 2004 ATMEL Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*//** \addtogroup usbstorage @{*///_____ I N C L U D E S ____________________________________________________#include "config.h"#include "storage/ctrl_access.h"//_____ D E F I N I T I O N S ______________________________________________#if (ACCESS_MEM_TO_MEM == ENABLED) #include "modules/file_system/fat.h" U8 buf_sector[FS_SIZE_OF_SECTOR];#endif//! Computed the maximum of static lun (don't add the lun of Mass Storage in mode USB Host)// FYC: Memory = Logical Unit // CHECK FOR LUN DEFINE#ifndef LUN_0 # error LUN_0 must be defined with ENABLE or DISABLE in conf_access.h#endif#ifndef LUN_1 # error LUN_1 must be defined with ENABLE or DISABLE in conf_access.h#endif#ifndef LUN_2 # error LUN_2 must be defined with ENABLE or DISABLE in conf_access.h#endif#ifndef LUN_3 # error LUN_3 must be defined with ENABLE or DISABLE in conf_access.h#endif#ifndef LUN_4 # error LUN_4 must be defined with ENABLE or DISABLE in conf_access.h#endif#ifndef LUN_5 # error LUN_5 must be defined with ENABLE or DISABLE in conf_access.h#endif#ifndef LUN_6 # error LUN_6 must be defined with ENABLE or DISABLE in conf_access.h#endif#ifndef LUN_7 # error LUN_7 must be defined with ENABLE or DISABLE in conf_access.h#endif#ifndef LUN_USB # error LUN_USB must be defined with ENABLE or DISABLE in conf_access.h#endif#if (LUN_0 == ENABLE) #define LUN_0_EN 1 U8 FLASH lun0_name[]=LUN_0_NAME; #else #define LUN_0_EN 0#endif#if (LUN_1 == ENABLE) #define LUN_1_EN 1 U8 FLASH lun1_name[]=LUN_1_NAME; #else #define LUN_1_EN 0#endif#if (LUN_2 == ENABLE) #define LUN_2_EN 1 U8 FLASH lun2_name[]=LUN_2_NAME; #else #define LUN_2_EN 0#endif#if (LUN_3 == ENABLE) #define LUN_3_EN 1 U8 FLASH lun3_name[]=LUN_3_NAME; #else #define LUN_3_EN 0#endif#if (LUN_4 == ENABLE) #define LUN_4_EN 1 U8 FLASH lun4_name[]=LUN_4_NAME; #else #define LUN_4_EN 0#endif#if (LUN_5 == ENABLE) #define LUN_5_EN 1 U8 FLASH lun5_name[]=LUN_5_NAME; #else #define LUN_5_EN 0#endif#if (LUN_6 == ENABLE) #define LUN_6_EN 1 U8 FLASH lun6_name[]=LUN_6_NAME; #else #define LUN_6_EN 0#endif#if (LUN_7 == ENABLE) #define LUN_7_EN 1 U8 FLASH lun7_name[]=LUN_7_NAME; #else #define LUN_7_EN 0#endif#if (LUN_USB == ENABLE) #define LUN_USB_EN 1 U8 FLASH lunusb_name[]=LUN_USB_NAME; #else #define LUN_USB_EN 0#endif#define LUN_ID_0 (0)#define LUN_ID_1 (LUN_0_EN)#define LUN_ID_2 (LUN_0_EN+LUN_1_EN)#define LUN_ID_3 (LUN_0_EN+LUN_1_EN+LUN_2_EN)#define LUN_ID_4 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN)#define LUN_ID_5 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN)#define LUN_ID_6 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN+LUN_5_EN)#define LUN_ID_7 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN+LUN_5_EN+LUN_6_EN)#define MAX_LUN (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN+LUN_5_EN+LUN_6_EN+LUN_7_EN)#define LUN_ID_USB (MAX_LUN)// Check configuration#if (MAX_LUN == 0) #error No memory is active in conf_access.h#endif// Write protect variable#if (GLOBAL_WR_PROTECT == ENABLED) static U8 g_u8_wr_protect;#endif//_____ D E F I N I T I O N S __ F O N C T I O N S _________________________//! This fonction return the number of logical unit//!//! @return U8 number of logical unit in the system//!U8 get_nb_lun(){#if (MEM_USB == ENABLED) return (MAX_LUN + Host_getlun());#else return MAX_LUN;#endif}//! This fonction return the current logical unit//!//! @return U8 number of logical unit in the system//!U8 get_cur_lun(){ return 0; //TODO}//! This fonction test the state of memory, and start the initialisation of the memory//!//! MORE (see SPC-3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -