]> rtime.felk.cvut.cz Git - arc.git/blob - include/Fls.h
Merge branch 'mikulka' of git@rtime.felk.cvut.cz:arc into mikulka
[arc.git] / include / Fls.h
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 \r
17 \r
18 \r
19 \r
20 \r
21 \r
22 \r
23 #ifndef FLS_H_\r
24 #define FLS_H_\r
25 \r
26 // Only if external flash device\r
27 //#include "Spi.h"\r
28 #include "Std_Types.h"\r
29 #include "Det.h"\r
30 #include "MemIf_Types.h"\r
31 #if defined(USE_DEM)\r
32 #include "Dem.h"\r
33 #endif\r
34 // SW ans Autosar spec versions\r
35 #define FLS_SW_MAJOR_VERSION            1\r
36 #define FLS_SW_MINOR_VERSION            0\r
37 #define FLS_SW_PATCH_VERSION            1\r
38 #define FLS_AR_MAJOR_VERSION            3\r
39 #define FLS_AR_MINOR_VERSION            0\r
40 #define FLS_AR_PATCH_VERSION            2\r
41 \r
42 // API service called with wrong parameter\r
43 #define FLS_E_PARAM_CONFIG                      0x01\r
44 #define FLS_E_PARAM_ADDRESS             0x02\r
45 #define FLS_E_PARAM_LENGTH                      0x03\r
46 #define FLS_E_PARAM_DATA                        0x04\r
47 // API service called without module initialization\r
48 #define FLS_E_UNINIT                            0x05\r
49 // API service called while driver still busy\r
50 #define FLS_E_BUSY                                      0x06\r
51 // Erase verification (blank check) failed\r
52 #define FLS_E_VERIFY_ERASE_FAILED       0x07\r
53 // Write verification (compare) failed\r
54 #define FLS_E_VERIFY_WRITE_FAILED       0x08\r
55 \r
56 // Service id's for fls functions\r
57 #define FLS_INIT_ID                                     0x00\r
58 #define FLS_ERASE_ID                            0x01\r
59 #define FLS_WRITE_ID                            0x02\r
60 #define FLS_CANCEL_ID                           0x03\r
61 #define FLS_GET_STATUS_ID                       0x04\r
62 #define FLS_GET_JOB_RESULT_ID           0x05\r
63 #define FLS_MAIN_FUNCTION_ID            0x06\r
64 #define FLS_READ_ID                                     0x07\r
65 #define FLS_COMPARE_ID                          0x08\r
66 #define FLS_SET_MODE_ID                         0x09\r
67 #define FLS_GET_VERSION_INFO_ID         0x10\r
68 \r
69 // Used as address offset from the configured flash base address to access a certain\r
70 // flash memory area.\r
71 typedef uint32 Fls_AddressType;\r
72 \r
73 // Specifies the number of bytes to read/write/erase/compare\r
74 //\r
75 // Note!\r
76 // Shall be the same type as Fls_AddressType because of\r
77 // arithmetic operations. Size depends on target platform and\r
78 // flash device.\r
79 typedef uint32 Fls_LengthType;\r
80 \r
81 #include "Fls_Cfg.h"\r
82 \r
83 /**\r
84  * Initializes the Flash Driver.\r
85  *\r
86  * @param ConfigPtr Pointer to flash driver configuration set.\r
87  */\r
88 void Fls_Init( const Fls_ConfigType *ConfigPtr );\r
89 \r
90 \r
91 /**\r
92  * Erases flash sector(s).\r
93  *\r
94  * @param TargetAddress Target address in flash memory.\r
95  *                      This address offset will be\r
96  *                                              added to the flash memory base address.\r
97  *                                              Min.: 0\r
98  *                      Max.: FLS_SIZE - 1\r
99  *\r
100  * @param Length                Number of bytes to erase\r
101  *                      Min.: 1\r
102  *                      Max.: FLS_SIZE - TargetAddress\r
103  *\r
104  * @return E_OK: erase command has been accepted\r
105  *         E_NOT_OK: erase command has not been accepted\r
106  */\r
107 \r
108 Std_ReturnType Fls_Erase(       Fls_AddressType   TargetAddress,\r
109                         Fls_LengthType    Length );\r
110 \r
111 \r
112 Std_ReturnType Fls_Write (    Fls_AddressType   TargetAddress,\r
113                         const uint8         *SourceAddressPtr,\r
114                         Fls_LengthType    Length );\r
115 \r
116 #if ( FLS_CANCEL_API == STD_ON )\r
117 void                            Fls_Cancel( void );\r
118 #endif\r
119 \r
120 #if ( FLS_GET_STATUS_API == STD_ON )\r
121 MemIf_StatusType        Fls_GetStatus(  void );\r
122 #endif\r
123 \r
124 #if ( 1 )\r
125 MemIf_JobResultType Fls_GetJobResult( void );\r
126 #endif\r
127 \r
128 void Fls_MainFunction( void );\r
129 \r
130 Std_ReturnType Fls_Read (       Fls_AddressType SourceAddress,\r
131               uint8 *TargetAddressPtr,\r
132               Fls_LengthType Length );\r
133 \r
134 #if ( FLS_COMPARE_API == STD_ON )\r
135 Std_ReturnType Fls_Compare( Fls_AddressType SourceAddress,\r
136               uint8 *TargetAddressPtr,\r
137               Fls_LengthType Length );\r
138 #endif\r
139 \r
140 #if ( FLS_SET_MODE_API == STD_ON )\r
141 void Fls_SetMode(               Fls_ModeType Mode );\r
142 #endif\r
143 \r
144 void Fls_GetVersionInfo( Std_VersionInfoType *VersioninfoPtr );\r
145 \r
146 void Fls_Check( uint32 flsBaseAddress, uint32 flsTotalSize );\r
147 \r
148 #endif /*FLS_H_*/\r