ARMEBS4  revision-26.06.2015
usbd_dfu_mal.h
1 #if 0
2 /**
3  ******************************************************************************
4  * @file usbd_dfu_mal.h
5  * @author MCD Application Team
6  * @version V1.1.0
7  * @date 19-March-2012
8  * @brief Header for usbd_dfu_mal.c file.
9  ******************************************************************************
10  * @attention
11  *
12  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
13  *
14  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15  * You may not use this file except in compliance with the License.
16  * You may obtain a copy of the License at:
17  *
18  * http://www.st.com/software_license_agreement_liberty_v2
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS,
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  *
26  ******************************************************************************
27  */
28 
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __DFU_MAL_H
31 #define __DFU_MAL_H
32 
33 /* Includes ------------------------------------------------------------------*/
34 #include "config/usb_conf.h"
35 #include "config/usbd_conf.h"
36 #include "stm32/usbd_dfu_core.h"
37 
38 /* Exported types ------------------------------------------------------------*/
39 typedef struct _DFU_MAL_PROP
40 {
41  const uint8_t* pStrDesc;
42  uint16_t (*pMAL_Init) (void);
43  uint16_t (*pMAL_DeInit) (void);
44  uint16_t (*pMAL_Erase) (uint32_t Add);
45  uint16_t (*pMAL_Write) (uint32_t Add, uint32_t Len);
46  uint8_t *(*pMAL_Read) (uint32_t Add, uint32_t Len);
47  uint16_t (*pMAL_CheckAdd) (uint32_t Add);
48  const uint32_t EraseTiming;
49  const uint32_t WriteTiming;
50 }
51 DFU_MAL_Prop_TypeDef;
52 
53 
54 /* Exported constants --------------------------------------------------------*/
55 #define MAL_OK 0
56 #define MAL_FAIL 1
57 
58 /* utils macro ---------------------------------------------------------------*/
59 #define _1st_BYTE(x) (uint8_t)((x)&0xFF) /* 1st addressing cycle */
60 #define _2nd_BYTE(x) (uint8_t)(((x)&0xFF00)>>8) /* 2nd addressing cycle */
61 #define _3rd_BYTE(x) (uint8_t)(((x)&0xFF0000)>>16) /* 3rd addressing cycle */
62 #define _4th_BYTE(x) (uint8_t)(((x)&0xFF000000)>>24) /* 4th addressing cycle */
63 
64 /* Exported macro ------------------------------------------------------------*/
65 #define SET_POLLING_TIMING(x) buffer[1] = _1st_BYTE(x);\
66  buffer[2] = _2nd_BYTE(x);\
67  buffer[3] = _3rd_BYTE(x);
68 
69 /* Exported functions ------------------------------------------------------- */
70 
71 uint16_t MAL_Init (void);
72 uint16_t MAL_DeInit (void);
73 uint16_t MAL_Erase (uint32_t SectorAddress);
74 uint16_t MAL_Write (uint32_t SectorAddress, uint32_t DataLength);
75 uint8_t *MAL_Read (uint32_t SectorAddress, uint32_t DataLength);
76 uint16_t MAL_GetStatus(uint32_t SectorAddress ,uint8_t Cmd, uint8_t *buffer);
77 
78 extern uint8_t MAL_Buffer[XFERSIZE]; /* RAM Buffer for Downloaded Data */
79 #endif /* __DFU_MAL_H */
80 
81 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
82 #endif