Merge branch 'tmaster' into future
[fw/stlink] / example / stm32f4 / STM32_USB_Device_Library / Class / dfu / inc / usbd_dfu_mal.h
1 /**
2   ******************************************************************************
3   * @file    usbd_dfu_mal.h
4   * @author  MCD Application Team
5   * @version V1.0.0
6   * @date    22-July-2011
7   * @brief   Header for usbd_dfu_mal.c file.
8   ******************************************************************************
9   * @attention
10   *
11   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17   *
18   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19   ******************************************************************************
20   */
21
22 /* Define to prevent recursive inclusion -------------------------------------*/
23 #ifndef __DFU_MAL_H
24 #define __DFU_MAL_H
25
26 /* Includes ------------------------------------------------------------------*/
27 #ifdef STM32F2XX
28  #include "stm32f2xx.h"
29 #elif defined(STM32F10X_CL)
30  #include "stm32f10x.h"
31 #endif /* STM32F2XX */
32
33 #include "usbd_conf.h"
34 #include "usbd_dfu_core.h"
35
36 /* Exported types ------------------------------------------------------------*/
37 typedef struct _DFU_MAL_PROP
38 {
39   const uint8_t* pStrDesc;
40   uint16_t (*pMAL_Init)     (void);   
41   uint16_t (*pMAL_DeInit)   (void);   
42   uint16_t (*pMAL_Erase)    (uint32_t Add);
43   uint16_t (*pMAL_Write)    (uint32_t Add, uint32_t Len);
44   uint8_t  *(*pMAL_Read)    (uint32_t Add, uint32_t Len);
45   uint16_t (*pMAL_CheckAdd) (uint32_t Add);
46   const uint32_t EraseTiming;
47   const uint32_t WriteTiming;
48 }
49 DFU_MAL_Prop_TypeDef;
50
51
52 /* Exported constants --------------------------------------------------------*/
53 #define MAL_OK                          0
54 #define MAL_FAIL                        1
55
56 /* utils macro ---------------------------------------------------------------*/
57 #define _1st_BYTE(x)  (uint8_t)((x)&0xFF)             /* 1st addressing cycle */
58 #define _2nd_BYTE(x)  (uint8_t)(((x)&0xFF00)>>8)      /* 2nd addressing cycle */
59 #define _3rd_BYTE(x)  (uint8_t)(((x)&0xFF0000)>>16)   /* 3rd addressing cycle */
60 #define _4th_BYTE(x)  (uint8_t)(((x)&0xFF000000)>>24) /* 4th addressing cycle */
61
62 /* Exported macro ------------------------------------------------------------*/
63 #define SET_POLLING_TIMING(x)   buffer[1] = _1st_BYTE(x);\
64                                 buffer[2] = _2nd_BYTE(x);\
65                                 buffer[3] = _3rd_BYTE(x);  
66
67 /* Exported functions ------------------------------------------------------- */
68
69 uint16_t MAL_Init (void);
70 uint16_t MAL_DeInit (void);
71 uint16_t MAL_Erase (uint32_t SectorAddress);
72 uint16_t MAL_Write (uint32_t SectorAddress, uint32_t DataLength);
73 uint8_t *MAL_Read  (uint32_t SectorAddress, uint32_t DataLength);
74 uint16_t MAL_GetStatus(uint32_t SectorAddress ,uint8_t Cmd, uint8_t *buffer);
75
76 extern uint8_t  MAL_Buffer[XFERSIZE]; /* RAM Buffer for Downloaded Data */
77 #endif /* __DFU_MAL_H */
78
79 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/