Contiki 2.5
ctrl_access.h
Go to the documentation of this file.
1 /* This file has been prepared for Doxygen automatic documentation generation.*/
2 /*! \file ctrl_access.h *******************************************************
3  *
4  * \brief
5  * This file contains the interface :
6  * - between USB <-> MEMORY
7  * OR
8  * - between USB <- Access Memory Ctrl -> Memory
9  *
10  * This interface may be controled by a "Access Memory Control" for :
11  * - include a management of write protect global or specific
12  * - include a management of access password
13  *
14  * \addtogroup usbstick
15  *
16  * \author
17  * Atmel Corporation: http://www.atmel.com \n
18  * Support email: avr@atmel.com
19  ******************************************************************************/
20 /*
21  Copyright (c) 2004 ATMEL Corporation
22  All rights reserved.
23 
24  Redistribution and use in source and binary forms, with or without
25  modification, are permitted provided that the following conditions are met:
26 
27  * Redistributions of source code must retain the above copyright
28  notice, this list of conditions and the following disclaimer.
29  * Redistributions in binary form must reproduce the above copyright
30  notice, this list of conditions and the following disclaimer in
31  the documentation and/or other materials provided with the
32  distribution.
33  * Neither the name of the copyright holders nor the names of
34  contributors may be used to endorse or promote products derived
35  from this software without specific prior written permission.
36 
37  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
41  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
47  POSSIBILITY OF SUCH DAMAGE.
48 */
49 
50 /**
51  \addtogroup usbstorage
52  @{
53 */
54 
55 #ifndef _MEM_CTRL_H_
56 #define _MEM_CTRL_H_
57 
58 #include "storage/conf_access.h"
59 #include "storage/ctrl_status.h"
60 
61 // FYC: Memory = Logical Unit
62 #if (LUN_0 == ENABLE)
63  #include LUN_0_INCLUDE
64 #endif
65 #if (LUN_1 == ENABLE)
66  #include LUN_1_INCLUDE
67 #endif
68 #if (LUN_2 == ENABLE)
69  #include LUN_2_INCLUDE
70 #endif
71 #if (LUN_3 == ENABLE)
72  #include LUN_3_INCLUDE
73 #endif
74 #if (LUN_4 == ENABLE)
75  #include LUN_4_INCLUDE
76 #endif
77 #if (LUN_5 == ENABLE)
78  #include LUN_5_INCLUDE
79 #endif
80 #if (LUN_6 == ENABLE)
81  #include LUN_6_INCLUDE
82 #endif
83 #if (LUN_7 == ENABLE)
84  #include LUN_7_INCLUDE
85 #endif
86 #if (LUN_USB == ENABLE)
87  #include LUN_USB_INCLUDE
88 #endif
89 
90 
91 //------- Test the configuration in conf_access.h
92 
93 // Specific option control access
94 #ifndef GLOBAL_WR_PROTECT
95 # error GLOBAL_WR_PROTECT must be defined with ENABLED or DISABLED in conf_access.h
96 #endif
97 //------- END OF Test the configuration in conf_access.h
98 
99 
100 
101 //_____ D E F I N I T I O N S ______________________________________________
102 
103 
104 
105 //!**** Listing of commun interface ****************************************
106 
107 U8 get_nb_lun();
108 U8 get_cur_lun();
110 Ctrl_status mem_read_capacity( U8 lun , U32 _MEM_TYPE_SLOW_ *u32_nb_sector );
111 Bool mem_wr_protect( U8 lun );
112 Bool mem_removal( U8 lun );
113 U8 FLASH* mem_name( U8 lun );
114 
115 
116 //!**** Listing of READ/WRITE interface ************************************
117 
118 
119 //---- Interface for USB ---------------------------------------------------
120  Ctrl_status memory_2_usb( U8 lun , U32 addr , U16 nb_sector );
121  Ctrl_status usb_2_memory( U8 lun , U32 addr , U16 nb_sector );
122 #include "usb_drv.h"
123 #include "conf_usb.h"
124 //--------------------------------------------------------------------------
125 
126 //---- Interface for RAM to MEM --------------------------------------------
127 Ctrl_status memory_2_ram( U8 lun , const U32 _MEM_TYPE_SLOW_ *addr , U8 _MEM_TYPE_SLOW_ *ram );
128 Ctrl_status ram_2_memory( U8 lun , const U32 _MEM_TYPE_SLOW_ *addr , U8 _MEM_TYPE_SLOW_ * ram );
129 //--------------------------------------------------------------------------
130 
131 
132 //!---- Interface for streaming interface ----------------------------------
133 #if (ACCESS_STREAM == ENABLED)
134 
135 #define ID_STREAM_ERR 0xFF
136 
137 
138 // RLE #include "dfc_mngt.h"
139 
140 #define TYPE_STREAM_AUDIO DFC_ID_AUDIOPROC1
141 #define TYPE_STREAM_AUDIO2 DFC_ID_AUDIOPROC2
142 #define TYPE_STREAM_SIO DFC_ID_SIO
143 #define TYPE_STREAM_SPI DFC_ID_SPI
144 #define TYPE_STREAM_DEVNULL DFC_ID_NULL_DEV
145 
146  U8 stream_mem_to_mem ( U8 src_lun , U32 src_addr , U8 dest_lun , U32 dest_addr , U16 nb_sector );
147  U8 stream_read_10_start ( U8 TypeStream , U8 lun , U32 addr , U16 nb_sector );
148  U8 stream_write_10_start ( U8 TypeStream , U8 lun , U32 addr , U16 nb_sector );
149  U8 stream_to_stream_start ( U8 TypeStream_src , U8 TypeStream_dest , U16 nb_sector );
150  Ctrl_status stream_state( U8 Id );
151  U16 stream_stop( U8 Id );
152 
153 #endif // (ACCESS_STREAM == ENABLED)
154 //--------------------------------------------------------------------------
155 
156 #endif // _MEM_CTRL_H_
157 /**@}*/