mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-901 Updated F4 CMSIS startup files, Moved USB OTG and USB Device library to common
This commit is contained in:
parent
f0c01d0eff
commit
976ad90211
@ -0,0 +1,164 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_audio_core.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header file for the usbd_audio_core.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USB_AUDIO_CORE_H_
|
||||
#define __USB_AUDIO_CORE_H_
|
||||
|
||||
#include "usbd_ioreq.h"
|
||||
#include "usbd_req.h"
|
||||
#include "usbd_desc.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_audio
|
||||
* @brief This file is the Header file for USBD_audio.c
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */
|
||||
#define AUDIO_OUT_PACKET (uint32_t)(((USBD_AUDIO_FREQ * 2 * 2) /1000))
|
||||
|
||||
/* Number of sub-packets in the audio transfer buffer. You can modify this value but always make sure
|
||||
that it is an even number and higher than 3 */
|
||||
#define OUT_PACKET_NUM 4
|
||||
/* Total size of the audio transfer buffer */
|
||||
#define TOTAL_OUT_BUF_SIZE ((uint32_t)(AUDIO_OUT_PACKET * OUT_PACKET_NUM))
|
||||
|
||||
#define AUDIO_CONFIG_DESC_SIZE 109
|
||||
#define AUDIO_INTERFACE_DESC_SIZE 9
|
||||
#define USB_AUDIO_DESC_SIZ 0x09
|
||||
#define AUDIO_STANDARD_ENDPOINT_DESC_SIZE 0x09
|
||||
#define AUDIO_STREAMING_ENDPOINT_DESC_SIZE 0x07
|
||||
|
||||
#define AUDIO_DESCRIPTOR_TYPE 0x21
|
||||
#define USB_DEVICE_CLASS_AUDIO 0x01
|
||||
#define AUDIO_SUBCLASS_AUDIOCONTROL 0x01
|
||||
#define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02
|
||||
#define AUDIO_PROTOCOL_UNDEFINED 0x00
|
||||
#define AUDIO_STREAMING_GENERAL 0x01
|
||||
#define AUDIO_STREAMING_FORMAT_TYPE 0x02
|
||||
|
||||
/* Audio Descriptor Types */
|
||||
#define AUDIO_INTERFACE_DESCRIPTOR_TYPE 0x24
|
||||
#define AUDIO_ENDPOINT_DESCRIPTOR_TYPE 0x25
|
||||
|
||||
/* Audio Control Interface Descriptor Subtypes */
|
||||
#define AUDIO_CONTROL_HEADER 0x01
|
||||
#define AUDIO_CONTROL_INPUT_TERMINAL 0x02
|
||||
#define AUDIO_CONTROL_OUTPUT_TERMINAL 0x03
|
||||
#define AUDIO_CONTROL_FEATURE_UNIT 0x06
|
||||
|
||||
#define AUDIO_INPUT_TERMINAL_DESC_SIZE 0x0C
|
||||
#define AUDIO_OUTPUT_TERMINAL_DESC_SIZE 0x09
|
||||
#define AUDIO_STREAMING_INTERFACE_DESC_SIZE 0x07
|
||||
|
||||
#define AUDIO_CONTROL_MUTE 0x0001
|
||||
|
||||
#define AUDIO_FORMAT_TYPE_I 0x01
|
||||
#define AUDIO_FORMAT_TYPE_III 0x03
|
||||
|
||||
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
|
||||
#define AUDIO_ENDPOINT_GENERAL 0x01
|
||||
|
||||
#define AUDIO_REQ_GET_CUR 0x81
|
||||
#define AUDIO_REQ_SET_CUR 0x01
|
||||
|
||||
#define AUDIO_OUT_STREAMING_CTRL 0x02
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
typedef struct _Audio_Fops
|
||||
{
|
||||
uint8_t (*Init) (uint32_t AudioFreq, uint32_t Volume, uint32_t options);
|
||||
uint8_t (*DeInit) (uint32_t options);
|
||||
uint8_t (*AudioCmd) (uint8_t* pbuf, uint32_t size, uint8_t cmd);
|
||||
uint8_t (*VolumeCtl) (uint8_t vol);
|
||||
uint8_t (*MuteCtl) (uint8_t cmd);
|
||||
uint8_t (*PeriodicTC) (uint8_t cmd);
|
||||
uint8_t (*GetState) (void);
|
||||
}AUDIO_FOPS_TypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
#define AUDIO_PACKET_SZE(frq) (uint8_t)(((frq * 2 * 2)/1000) & 0xFF), \
|
||||
(uint8_t)((((frq * 2 * 2)/1000) >> 8) & 0xFF)
|
||||
#define SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern USBD_Class_cb_TypeDef AUDIO_cb;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CORE_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif // __USB_AUDIO_CORE_H_
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,125 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_audio_out_if.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header file for the usbd_audio_out_if.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USB_AUDIO_OUT_IF_H_
|
||||
#define __USB_AUDIO_OUT_IF_H_
|
||||
|
||||
#ifdef STM32F2XX
|
||||
#include "stm322xg_usb_audio_codec.h"
|
||||
#elif defined(STM32F4XX)
|
||||
#include "stm324xg_usb_audio_codec.h"
|
||||
#elif defined(STM32F10X_CL)
|
||||
#include "stm3210c_usb_audio_codec.h"
|
||||
#endif /* STM32F2XX */
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_audio
|
||||
* @brief This file is the Header file for USBD_audio.c
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
/* Audio Commands enmueration */
|
||||
typedef enum
|
||||
{
|
||||
AUDIO_CMD_PLAY = 1,
|
||||
AUDIO_CMD_PAUSE,
|
||||
AUDIO_CMD_STOP,
|
||||
}AUDIO_CMD_TypeDef;
|
||||
|
||||
/* Mute commands */
|
||||
#define AUDIO_MUTE 0x01
|
||||
#define AUDIO_UNMUTE 0x00
|
||||
|
||||
/* Functions return value */
|
||||
#define AUDIO_OK 0x00
|
||||
#define AUDIO_FAIL 0xFF
|
||||
|
||||
/* Audio Machine States */
|
||||
#define AUDIO_STATE_INACTIVE 0x00
|
||||
#define AUDIO_STATE_ACTIVE 0x01
|
||||
#define AUDIO_STATE_PLAYING 0x02
|
||||
#define AUDIO_STATE_PAUSED 0x03
|
||||
#define AUDIO_STATE_STOPPED 0x04
|
||||
#define AUDIO_STATE_ERROR 0x05
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern AUDIO_FOPS_TypeDef AUDIO_OUT_fops;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CORE_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USB_AUDIO_OUT_IF_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,671 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_audio_core.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides the high layer firmware functions to manage the
|
||||
* following functionalities of the USB Audio Class:
|
||||
* - Initialization and Configuration of high and low layer
|
||||
* - Enumeration as Audio Streaming Device
|
||||
* - Audio Streaming data transfer
|
||||
* - AudioControl requests management
|
||||
* - Error management
|
||||
*
|
||||
* @verbatim
|
||||
*
|
||||
* ===================================================================
|
||||
* Audio Class Driver Description
|
||||
* ===================================================================
|
||||
* This driver manages the Audio Class 1.0 following the "USB Device Class Definition for
|
||||
* Audio Devices V1.0 Mar 18, 98".
|
||||
* This driver implements the following aspects of the specification:
|
||||
* - Device descriptor management
|
||||
* - Configuration descriptor management
|
||||
* - Standard AC Interface Descriptor management
|
||||
* - 1 Audio Streaming Interface (with single channel, PCM, Stereo mode)
|
||||
* - 1 Audio Streaming Endpoint
|
||||
* - 1 Audio Terminal Input (1 channel)
|
||||
* - Audio Class-Specific AC Interfaces
|
||||
* - Audio Class-Specific AS Interfaces
|
||||
* - AudioControl Requests: only SET_CUR and GET_CUR requests are supported (for Mute)
|
||||
* - Audio Feature Unit (limited to Mute control)
|
||||
* - Audio Synchronization type: Asynchronous
|
||||
* - Single fixed audio sampling rate (configurable in usbd_conf.h file)
|
||||
*
|
||||
* @note
|
||||
* The Audio Class 1.0 is based on USB Specification 1.0 and thus supports only
|
||||
* Low and Full speed modes and does not allow High Speed transfers.
|
||||
* Please refer to "USB Device Class Definition for Audio Devices V1.0 Mar 18, 98"
|
||||
* for more details.
|
||||
*
|
||||
* These aspects may be enriched or modified for a specific user application.
|
||||
*
|
||||
* This driver doesn't implement the following aspects of the specification
|
||||
* (but it is possible to manage these features with some modifications on this driver):
|
||||
* - AudioControl Endpoint management
|
||||
* - AudioControl requsests other than SET_CUR and GET_CUR
|
||||
* - Abstraction layer for AudioControl requests (only Mute functionality is managed)
|
||||
* - Audio Synchronization type: Adaptive
|
||||
* - Audio Compression modules and interfaces
|
||||
* - MIDI interfaces and modules
|
||||
* - Mixer/Selector/Processing/Extension Units (Feature unit is limited to Mute control)
|
||||
* - Any other application-specific modules
|
||||
* - Multiple and Variable audio sampling rates
|
||||
* - Out Streaming Endpoint/Interface (microphone)
|
||||
*
|
||||
* @endverbatim
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#include "usbd_audio_core.h"
|
||||
#include "usbd_audio_out_if.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio
|
||||
* @brief usbd core module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_audio_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
AUDIO Device library callbacks
|
||||
*********************************************/
|
||||
static uint8_t usbd_audio_Init (void *pdev, uint8_t cfgidx);
|
||||
static uint8_t usbd_audio_DeInit (void *pdev, uint8_t cfgidx);
|
||||
static uint8_t usbd_audio_Setup (void *pdev, USB_SETUP_REQ *req);
|
||||
static uint8_t usbd_audio_EP0_RxReady(void *pdev);
|
||||
static uint8_t usbd_audio_DataIn (void *pdev, uint8_t epnum);
|
||||
static uint8_t usbd_audio_DataOut (void *pdev, uint8_t epnum);
|
||||
static uint8_t usbd_audio_SOF (void *pdev);
|
||||
static uint8_t usbd_audio_OUT_Incplt (void *pdev);
|
||||
|
||||
/*********************************************
|
||||
AUDIO Requests management functions
|
||||
*********************************************/
|
||||
static void AUDIO_Req_GetCurrent(void *pdev, USB_SETUP_REQ *req);
|
||||
static void AUDIO_Req_SetCurrent(void *pdev, USB_SETUP_REQ *req);
|
||||
static uint8_t *USBD_audio_GetCfgDesc (uint8_t speed, uint16_t *length);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_audio_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
/* Main Buffer for Audio Data Out transfers and its relative pointers */
|
||||
uint8_t IsocOutBuff [TOTAL_OUT_BUF_SIZE * 2];
|
||||
uint8_t* IsocOutWrPtr = IsocOutBuff;
|
||||
uint8_t* IsocOutRdPtr = IsocOutBuff;
|
||||
|
||||
/* Main Buffer for Audio Control Rrequests transfers and its relative variables */
|
||||
uint8_t AudioCtl[64];
|
||||
uint8_t AudioCtlCmd = 0;
|
||||
uint32_t AudioCtlLen = 0;
|
||||
uint8_t AudioCtlUnit = 0;
|
||||
|
||||
static uint32_t PlayFlag = 0;
|
||||
|
||||
static __IO uint32_t usbd_audio_AltSet = 0;
|
||||
static uint8_t usbd_audio_CfgDesc[AUDIO_CONFIG_DESC_SIZE];
|
||||
|
||||
/* AUDIO interface class callbacks structure */
|
||||
USBD_Class_cb_TypeDef AUDIO_cb =
|
||||
{
|
||||
usbd_audio_Init,
|
||||
usbd_audio_DeInit,
|
||||
usbd_audio_Setup,
|
||||
NULL, /* EP0_TxSent */
|
||||
usbd_audio_EP0_RxReady,
|
||||
usbd_audio_DataIn,
|
||||
usbd_audio_DataOut,
|
||||
usbd_audio_SOF,
|
||||
NULL,
|
||||
usbd_audio_OUT_Incplt,
|
||||
USBD_audio_GetCfgDesc,
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
USBD_audio_GetCfgDesc, /* use same config as per FS */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* USB AUDIO device Configuration Descriptor */
|
||||
static uint8_t usbd_audio_CfgDesc[AUDIO_CONFIG_DESC_SIZE] =
|
||||
{
|
||||
/* Configuration 1 */
|
||||
0x09, /* bLength */
|
||||
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
LOBYTE(AUDIO_CONFIG_DESC_SIZE), /* wTotalLength 109 bytes*/
|
||||
HIBYTE(AUDIO_CONFIG_DESC_SIZE),
|
||||
0x02, /* bNumInterfaces */
|
||||
0x01, /* bConfigurationValue */
|
||||
0x00, /* iConfiguration */
|
||||
0xC0, /* bmAttributes BUS Powred*/
|
||||
0x32, /* bMaxPower = 100 mA*/
|
||||
/* 09 byte*/
|
||||
|
||||
/* USB Speaker Standard interface descriptor */
|
||||
AUDIO_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x00, /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
0x00, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOCONTROL, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
/* 09 byte*/
|
||||
|
||||
/* USB Speaker Class-specific AC Interface Descriptor */
|
||||
AUDIO_INTERFACE_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_HEADER, /* bDescriptorSubtype */
|
||||
0x00, /* 1.00 */ /* bcdADC */
|
||||
0x01,
|
||||
0x27, /* wTotalLength = 39*/
|
||||
0x00,
|
||||
0x01, /* bInCollection */
|
||||
0x01, /* baInterfaceNr */
|
||||
/* 09 byte*/
|
||||
|
||||
/* USB Speaker Input Terminal Descriptor */
|
||||
AUDIO_INPUT_TERMINAL_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_INPUT_TERMINAL, /* bDescriptorSubtype */
|
||||
0x01, /* bTerminalID */
|
||||
0x01, /* wTerminalType AUDIO_TERMINAL_USB_STREAMING 0x0101 */
|
||||
0x01,
|
||||
0x00, /* bAssocTerminal */
|
||||
0x01, /* bNrChannels */
|
||||
0x00, /* wChannelConfig 0x0000 Mono */
|
||||
0x00,
|
||||
0x00, /* iChannelNames */
|
||||
0x00, /* iTerminal */
|
||||
/* 12 byte*/
|
||||
|
||||
/* USB Speaker Audio Feature Unit Descriptor */
|
||||
0x09, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_FEATURE_UNIT, /* bDescriptorSubtype */
|
||||
AUDIO_OUT_STREAMING_CTRL, /* bUnitID */
|
||||
0x01, /* bSourceID */
|
||||
0x01, /* bControlSize */
|
||||
AUDIO_CONTROL_MUTE, /* bmaControls(0) */
|
||||
0x00, /* bmaControls(1) */
|
||||
0x00, /* iTerminal */
|
||||
/* 09 byte*/
|
||||
|
||||
/*USB Speaker Output Terminal Descriptor */
|
||||
0x09, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_OUTPUT_TERMINAL, /* bDescriptorSubtype */
|
||||
0x03, /* bTerminalID */
|
||||
0x01, /* wTerminalType 0x0301*/
|
||||
0x03,
|
||||
0x00, /* bAssocTerminal */
|
||||
0x02, /* bSourceID */
|
||||
0x00, /* iTerminal */
|
||||
/* 09 byte*/
|
||||
|
||||
/* USB Speaker Standard AS Interface Descriptor - Audio Streaming Zero Bandwith */
|
||||
/* Interface 1, Alternate Setting 0 */
|
||||
AUDIO_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x01, /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
0x00, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
/* 09 byte*/
|
||||
|
||||
/* USB Speaker Standard AS Interface Descriptor - Audio Streaming Operational */
|
||||
/* Interface 1, Alternate Setting 1 */
|
||||
AUDIO_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x01, /* bInterfaceNumber */
|
||||
0x01, /* bAlternateSetting */
|
||||
0x01, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
/* 09 byte*/
|
||||
|
||||
/* USB Speaker Audio Streaming Interface Descriptor */
|
||||
AUDIO_STREAMING_INTERFACE_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_STREAMING_GENERAL, /* bDescriptorSubtype */
|
||||
0x01, /* bTerminalLink */
|
||||
0x01, /* bDelay */
|
||||
0x01, /* wFormatTag AUDIO_FORMAT_PCM 0x0001*/
|
||||
0x00,
|
||||
/* 07 byte*/
|
||||
|
||||
/* USB Speaker Audio Type III Format Interface Descriptor */
|
||||
0x0B, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype */
|
||||
AUDIO_FORMAT_TYPE_III, /* bFormatType */
|
||||
0x02, /* bNrChannels */
|
||||
0x02, /* bSubFrameSize : 2 Bytes per frame (16bits) */
|
||||
16, /* bBitResolution (16-bits per sample) */
|
||||
0x01, /* bSamFreqType only one frequency supported */
|
||||
SAMPLE_FREQ(USBD_AUDIO_FREQ), /* Audio sampling frequency coded on 3 bytes */
|
||||
/* 11 byte*/
|
||||
|
||||
/* Endpoint 1 - Standard Descriptor */
|
||||
AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /* bLength */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_OUT_EP, /* bEndpointAddress 1 out endpoint*/
|
||||
USB_ENDPOINT_TYPE_ISOCHRONOUS, /* bmAttributes */
|
||||
AUDIO_PACKET_SZE(USBD_AUDIO_FREQ), /* wMaxPacketSize in Bytes (Freq(Samples)*2(Stereo)*2(HalfWord)) */
|
||||
0x01, /* bInterval */
|
||||
0x00, /* bRefresh */
|
||||
0x00, /* bSynchAddress */
|
||||
/* 09 byte*/
|
||||
|
||||
/* Endpoint - Audio Streaming Descriptor*/
|
||||
AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /* bLength */
|
||||
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_ENDPOINT_GENERAL, /* bDescriptor */
|
||||
0x00, /* bmAttributes */
|
||||
0x00, /* bLockDelayUnits */
|
||||
0x00, /* wLockDelay */
|
||||
0x00,
|
||||
/* 07 byte*/
|
||||
} ;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_audio_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_Init
|
||||
* Initilaizes the AUDIO interface.
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_audio_Init (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
/* Open EP OUT */
|
||||
DCD_EP_Open(pdev,
|
||||
AUDIO_OUT_EP,
|
||||
AUDIO_OUT_PACKET,
|
||||
USB_OTG_EP_ISOC);
|
||||
|
||||
/* Initialize the Audio output Hardware layer */
|
||||
if (AUDIO_OUT_fops.Init(USBD_AUDIO_FREQ, DEFAULT_VOLUME, 0) != USBD_OK)
|
||||
{
|
||||
return USBD_FAIL;
|
||||
}
|
||||
|
||||
/* Prepare Out endpoint to receive audio data */
|
||||
DCD_EP_PrepareRx(pdev,
|
||||
AUDIO_OUT_EP,
|
||||
(uint8_t*)IsocOutBuff,
|
||||
AUDIO_OUT_PACKET);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_Init
|
||||
* DeInitializes the AUDIO layer.
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_audio_DeInit (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
DCD_EP_Close (pdev , AUDIO_OUT_EP);
|
||||
|
||||
/* DeInitialize the Audio output Hardware layer */
|
||||
if (AUDIO_OUT_fops.DeInit(0) != USBD_OK)
|
||||
{
|
||||
return USBD_FAIL;
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_Setup
|
||||
* Handles the Audio control request parsing.
|
||||
* @param pdev: instance
|
||||
* @param req: usb requests
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_audio_Setup (void *pdev,
|
||||
USB_SETUP_REQ *req)
|
||||
{
|
||||
uint16_t len=USB_AUDIO_DESC_SIZ;
|
||||
uint8_t *pbuf=usbd_audio_CfgDesc + 18;
|
||||
|
||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||
{
|
||||
/* AUDIO Class Requests -------------------------------*/
|
||||
case USB_REQ_TYPE_CLASS :
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case AUDIO_REQ_GET_CUR:
|
||||
AUDIO_Req_GetCurrent(pdev, req);
|
||||
break;
|
||||
|
||||
case AUDIO_REQ_SET_CUR:
|
||||
AUDIO_Req_SetCurrent(pdev, req);
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_CtlError (pdev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
/* Standard Requests -------------------------------*/
|
||||
case USB_REQ_TYPE_STANDARD:
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case USB_REQ_GET_DESCRIPTOR:
|
||||
if( (req->wValue >> 8) == AUDIO_DESCRIPTOR_TYPE)
|
||||
{
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
pbuf = usbd_audio_Desc;
|
||||
#else
|
||||
pbuf = usbd_audio_CfgDesc + 18;
|
||||
#endif
|
||||
len = MIN(USB_AUDIO_DESC_SIZ , req->wLength);
|
||||
}
|
||||
|
||||
USBD_CtlSendData (pdev,
|
||||
pbuf,
|
||||
len);
|
||||
break;
|
||||
|
||||
case USB_REQ_GET_INTERFACE :
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)&usbd_audio_AltSet,
|
||||
1);
|
||||
break;
|
||||
|
||||
case USB_REQ_SET_INTERFACE :
|
||||
if ((uint8_t)(req->wValue) < AUDIO_TOTAL_IF_NUM)
|
||||
{
|
||||
usbd_audio_AltSet = (uint8_t)(req->wValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the error management function (command will be nacked */
|
||||
USBD_CtlError (pdev, req);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_EP0_RxReady
|
||||
* Handles audio control requests data.
|
||||
* @param pdev: device device instance
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_audio_EP0_RxReady (void *pdev)
|
||||
{
|
||||
/* Check if an AudioControl request has been issued */
|
||||
if (AudioCtlCmd == AUDIO_REQ_SET_CUR)
|
||||
{/* In this driver, to simplify code, only SET_CUR request is managed */
|
||||
/* Check for which addressed unit the AudioControl request has been issued */
|
||||
if (AudioCtlUnit == AUDIO_OUT_STREAMING_CTRL)
|
||||
{/* In this driver, to simplify code, only one unit is manage */
|
||||
/* Call the audio interface mute function */
|
||||
AUDIO_OUT_fops.MuteCtl(AudioCtl[0]);
|
||||
|
||||
/* Reset the AudioCtlCmd variable to prevent re-entering this function */
|
||||
AudioCtlCmd = 0;
|
||||
AudioCtlLen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_DataIn
|
||||
* Handles the audio IN data stage.
|
||||
* @param pdev: instance
|
||||
* @param epnum: endpoint number
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_audio_DataIn (void *pdev, uint8_t epnum)
|
||||
{
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_DataOut
|
||||
* Handles the Audio Out data stage.
|
||||
* @param pdev: instance
|
||||
* @param epnum: endpoint number
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_audio_DataOut (void *pdev, uint8_t epnum)
|
||||
{
|
||||
if (epnum == AUDIO_OUT_EP)
|
||||
{
|
||||
/* Increment the Buffer pointer or roll it back when all buffers are full */
|
||||
if (IsocOutWrPtr >= (IsocOutBuff + (AUDIO_OUT_PACKET * OUT_PACKET_NUM)))
|
||||
{/* All buffers are full: roll back */
|
||||
IsocOutWrPtr = IsocOutBuff;
|
||||
}
|
||||
else
|
||||
{/* Increment the buffer pointer */
|
||||
IsocOutWrPtr += AUDIO_OUT_PACKET;
|
||||
}
|
||||
|
||||
/* Toggle the frame index */
|
||||
((USB_OTG_CORE_HANDLE*)pdev)->dev.out_ep[epnum].even_odd_frame =
|
||||
(((USB_OTG_CORE_HANDLE*)pdev)->dev.out_ep[epnum].even_odd_frame)? 0:1;
|
||||
|
||||
/* Prepare Out endpoint to receive next audio packet */
|
||||
DCD_EP_PrepareRx(pdev,
|
||||
AUDIO_OUT_EP,
|
||||
(uint8_t*)(IsocOutWrPtr),
|
||||
AUDIO_OUT_PACKET);
|
||||
|
||||
/* Trigger the start of streaming only when half buffer is full */
|
||||
if ((PlayFlag == 0) && (IsocOutWrPtr >= (IsocOutBuff + ((AUDIO_OUT_PACKET * OUT_PACKET_NUM) / 2))))
|
||||
{
|
||||
/* Enable start of Streaming */
|
||||
PlayFlag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_SOF
|
||||
* Handles the SOF event (data buffer update and synchronization).
|
||||
* @param pdev: instance
|
||||
* @param epnum: endpoint number
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_audio_SOF (void *pdev)
|
||||
{
|
||||
/* Check if there are available data in stream buffer.
|
||||
In this function, a single variable (PlayFlag) is used to avoid software delays.
|
||||
The play operation must be executed as soon as possible after the SOF detection. */
|
||||
if (PlayFlag)
|
||||
{
|
||||
/* Start playing received packet */
|
||||
AUDIO_OUT_fops.AudioCmd((uint8_t*)(IsocOutRdPtr), /* Samples buffer pointer */
|
||||
AUDIO_OUT_PACKET, /* Number of samples in Bytes */
|
||||
AUDIO_CMD_PLAY); /* Command to be processed */
|
||||
|
||||
/* Increment the Buffer pointer or roll it back when all buffers all full */
|
||||
if (IsocOutRdPtr >= (IsocOutBuff + (AUDIO_OUT_PACKET * OUT_PACKET_NUM)))
|
||||
{/* Roll back to the start of buffer */
|
||||
IsocOutRdPtr = IsocOutBuff;
|
||||
}
|
||||
else
|
||||
{/* Increment to the next sub-buffer */
|
||||
IsocOutRdPtr += AUDIO_OUT_PACKET;
|
||||
}
|
||||
|
||||
/* If all available buffers have been consumed, stop playing */
|
||||
if (IsocOutRdPtr == IsocOutWrPtr)
|
||||
{
|
||||
/* Pause the audio stream */
|
||||
AUDIO_OUT_fops.AudioCmd((uint8_t*)(IsocOutBuff), /* Samples buffer pointer */
|
||||
AUDIO_OUT_PACKET, /* Number of samples in Bytes */
|
||||
AUDIO_CMD_PAUSE); /* Command to be processed */
|
||||
|
||||
/* Stop entering play loop */
|
||||
PlayFlag = 0;
|
||||
|
||||
/* Reset buffer pointers */
|
||||
IsocOutRdPtr = IsocOutBuff;
|
||||
IsocOutWrPtr = IsocOutBuff;
|
||||
}
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_OUT_Incplt
|
||||
* Handles the iso out incomplete event.
|
||||
* @param pdev: instance
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_audio_OUT_Incplt (void *pdev)
|
||||
{
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
AUDIO Class requests management
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @brief AUDIO_Req_GetCurrent
|
||||
* Handles the GET_CUR Audio control request.
|
||||
* @param pdev: instance
|
||||
* @param req: setup class request
|
||||
* @retval status
|
||||
*/
|
||||
static void AUDIO_Req_GetCurrent(void *pdev, USB_SETUP_REQ *req)
|
||||
{
|
||||
/* Send the current mute state */
|
||||
USBD_CtlSendData (pdev,
|
||||
AudioCtl,
|
||||
req->wLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AUDIO_Req_SetCurrent
|
||||
* Handles the SET_CUR Audio control request.
|
||||
* @param pdev: instance
|
||||
* @param req: setup class request
|
||||
* @retval status
|
||||
*/
|
||||
static void AUDIO_Req_SetCurrent(void *pdev, USB_SETUP_REQ *req)
|
||||
{
|
||||
if (req->wLength)
|
||||
{
|
||||
/* Prepare the reception of the buffer over EP0 */
|
||||
USBD_CtlPrepareRx (pdev,
|
||||
AudioCtl,
|
||||
req->wLength);
|
||||
|
||||
/* Set the global variables indicating current request and its length
|
||||
to the function usbd_audio_EP0_RxReady() which will process the request */
|
||||
AudioCtlCmd = AUDIO_REQ_SET_CUR; /* Set the request value */
|
||||
AudioCtlLen = req->wLength; /* Set the request data length */
|
||||
AudioCtlUnit = HIBYTE(req->wIndex); /* Set the request target unit */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_audio_GetCfgDesc
|
||||
* Returns configuration descriptor.
|
||||
* @param speed : current device speed
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
static uint8_t *USBD_audio_GetCfgDesc (uint8_t speed, uint16_t *length)
|
||||
{
|
||||
*length = sizeof (usbd_audio_CfgDesc);
|
||||
return usbd_audio_CfgDesc;
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,321 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_audio_out_if.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides the Audio Out (palyback) interface API.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_audio_core.h"
|
||||
#include "usbd_audio_out_if.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio_out_if
|
||||
* @brief usbd out interface module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_audio_out_if_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio_out_if_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio_out_if_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_audio_out_if_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
static uint8_t Init (uint32_t AudioFreq, uint32_t Volume, uint32_t options);
|
||||
static uint8_t DeInit (uint32_t options);
|
||||
static uint8_t AudioCmd (uint8_t* pbuf, uint32_t size, uint8_t cmd);
|
||||
static uint8_t VolumeCtl (uint8_t vol);
|
||||
static uint8_t MuteCtl (uint8_t cmd);
|
||||
static uint8_t PeriodicTC (uint8_t cmd);
|
||||
static uint8_t GetState (void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_audio_out_if_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
AUDIO_FOPS_TypeDef AUDIO_OUT_fops =
|
||||
{
|
||||
Init,
|
||||
DeInit,
|
||||
AudioCmd,
|
||||
VolumeCtl,
|
||||
MuteCtl,
|
||||
PeriodicTC,
|
||||
GetState
|
||||
};
|
||||
|
||||
static uint8_t AudioState = AUDIO_STATE_INACTIVE;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_audio_out_if_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Init
|
||||
* Initialize and configures all required resources for audio play function.
|
||||
* @param AudioFreq: Statrtup audio frequency.
|
||||
* @param Volume: Startup volume to be set.
|
||||
* @param options: specific options passed to low layer function.
|
||||
* @retval AUDIO_OK if all operations succeed, AUDIO_FAIL else.
|
||||
*/
|
||||
static uint8_t Init (uint32_t AudioFreq,
|
||||
uint32_t Volume,
|
||||
uint32_t options)
|
||||
{
|
||||
static uint32_t Initialized = 0;
|
||||
|
||||
/* Check if the low layer has already been initialized */
|
||||
if (Initialized == 0)
|
||||
{
|
||||
/* Call low layer function */
|
||||
if (EVAL_AUDIO_Init(OUTPUT_DEVICE_AUTO, Volume, AudioFreq) != 0)
|
||||
{
|
||||
AudioState = AUDIO_STATE_ERROR;
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
|
||||
/* Set the Initialization flag to prevent reinitializing the interface again */
|
||||
Initialized = 1;
|
||||
}
|
||||
|
||||
/* Update the Audio state machine */
|
||||
AudioState = AUDIO_STATE_ACTIVE;
|
||||
|
||||
return AUDIO_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit
|
||||
* Free all resources used by low layer and stops audio-play function.
|
||||
* @param options: options passed to low layer function.
|
||||
* @retval AUDIO_OK if all operations succeed, AUDIO_FAIL else.
|
||||
*/
|
||||
static uint8_t DeInit (uint32_t options)
|
||||
{
|
||||
/* Update the Audio state machine */
|
||||
AudioState = AUDIO_STATE_INACTIVE;
|
||||
|
||||
return AUDIO_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AudioCmd
|
||||
* Play, Stop, Pause or Resume current file.
|
||||
* @param pbuf: address from which file shoud be played.
|
||||
* @param size: size of the current buffer/file.
|
||||
* @param cmd: command to be executed, can be AUDIO_CMD_PLAY , AUDIO_CMD_PAUSE,
|
||||
* AUDIO_CMD_RESUME or AUDIO_CMD_STOP.
|
||||
* @retval AUDIO_OK if all operations succeed, AUDIO_FAIL else.
|
||||
*/
|
||||
static uint8_t AudioCmd(uint8_t* pbuf,
|
||||
uint32_t size,
|
||||
uint8_t cmd)
|
||||
{
|
||||
/* Check the current state */
|
||||
if ((AudioState == AUDIO_STATE_INACTIVE) || (AudioState == AUDIO_STATE_ERROR))
|
||||
{
|
||||
AudioState = AUDIO_STATE_ERROR;
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
/* Process the PLAY command ----------------------------*/
|
||||
case AUDIO_CMD_PLAY:
|
||||
/* If current state is Active or Stopped */
|
||||
if ((AudioState == AUDIO_STATE_ACTIVE) || \
|
||||
(AudioState == AUDIO_STATE_STOPPED) || \
|
||||
(AudioState == AUDIO_STATE_PLAYING))
|
||||
{
|
||||
Audio_MAL_Play((uint32_t)pbuf, (size/2));
|
||||
AudioState = AUDIO_STATE_PLAYING;
|
||||
return AUDIO_OK;
|
||||
}
|
||||
/* If current state is Paused */
|
||||
else if (AudioState == AUDIO_STATE_PAUSED)
|
||||
{
|
||||
if (EVAL_AUDIO_PauseResume(AUDIO_RESUME, (uint32_t)pbuf, (size/2)) != 0)
|
||||
{
|
||||
AudioState = AUDIO_STATE_ERROR;
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
AudioState = AUDIO_STATE_PLAYING;
|
||||
return AUDIO_OK;
|
||||
}
|
||||
}
|
||||
else /* Not allowed command */
|
||||
{
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
|
||||
/* Process the STOP command ----------------------------*/
|
||||
case AUDIO_CMD_STOP:
|
||||
if (AudioState != AUDIO_STATE_PLAYING)
|
||||
{
|
||||
/* Unsupported command */
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
else if (EVAL_AUDIO_Stop(CODEC_PDWN_SW) != 0)
|
||||
{
|
||||
AudioState = AUDIO_STATE_ERROR;
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
AudioState = AUDIO_STATE_STOPPED;
|
||||
return AUDIO_OK;
|
||||
}
|
||||
|
||||
/* Process the PAUSE command ---------------------------*/
|
||||
case AUDIO_CMD_PAUSE:
|
||||
if (AudioState != AUDIO_STATE_PLAYING)
|
||||
{
|
||||
/* Unsupported command */
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
else if (EVAL_AUDIO_PauseResume(AUDIO_PAUSE, (uint32_t)pbuf, (size/2)) != 0)
|
||||
{
|
||||
AudioState = AUDIO_STATE_ERROR;
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
AudioState = AUDIO_STATE_PAUSED;
|
||||
return AUDIO_OK;
|
||||
}
|
||||
|
||||
/* Unsupported command ---------------------------------*/
|
||||
default:
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief VolumeCtl
|
||||
* Set the volume level in %
|
||||
* @param vol: volume level to be set in % (from 0% to 100%)
|
||||
* @retval AUDIO_OK if all operations succeed, AUDIO_FAIL else.
|
||||
*/
|
||||
static uint8_t VolumeCtl (uint8_t vol)
|
||||
{
|
||||
/* Call low layer volume setting function */
|
||||
if (EVAL_AUDIO_VolumeCtl(vol) != 0)
|
||||
{
|
||||
AudioState = AUDIO_STATE_ERROR;
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
|
||||
return AUDIO_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MuteCtl
|
||||
* Mute or Unmute the audio current output
|
||||
* @param cmd: can be 0 to unmute, or 1 to mute.
|
||||
* @retval AUDIO_OK if all operations succeed, AUDIO_FAIL else.
|
||||
*/
|
||||
static uint8_t MuteCtl (uint8_t cmd)
|
||||
{
|
||||
/* Call low layer mute setting function */
|
||||
if (EVAL_AUDIO_Mute(cmd) != 0)
|
||||
{
|
||||
AudioState = AUDIO_STATE_ERROR;
|
||||
return AUDIO_FAIL;
|
||||
}
|
||||
|
||||
return AUDIO_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
* @retval AUDIO_OK if all operations succeed, AUDIO_FAIL else.
|
||||
*/
|
||||
static uint8_t PeriodicTC (uint8_t cmd)
|
||||
{
|
||||
|
||||
|
||||
return AUDIO_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief GetState
|
||||
* Return the current state of the audio machine
|
||||
* @param None
|
||||
* @retval Current State.
|
||||
*/
|
||||
static uint8_t GetState (void)
|
||||
{
|
||||
return AudioState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,143 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_cdc_core.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header file for the usbd_cdc_core.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USB_CDC_CORE_H_
|
||||
#define __USB_CDC_CORE_H_
|
||||
|
||||
#include "usbd_ioreq.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_cdc
|
||||
* @brief This file is the Header file for USBD_cdc.c
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_cdc_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#define USB_CDC_CONFIG_DESC_SIZ (67)
|
||||
#define USB_CDC_DESC_SIZ (67-9)
|
||||
|
||||
#define CDC_DESCRIPTOR_TYPE 0x21
|
||||
|
||||
#define DEVICE_CLASS_CDC 0x02
|
||||
#define DEVICE_SUBCLASS_CDC 0x00
|
||||
|
||||
|
||||
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
|
||||
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
|
||||
#define USB_STRING_DESCRIPTOR_TYPE 0x03
|
||||
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
|
||||
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
|
||||
|
||||
#define STANDARD_ENDPOINT_DESC_SIZE 0x09
|
||||
|
||||
#define CDC_DATA_IN_PACKET_SIZE CDC_DATA_MAX_PACKET_SIZE
|
||||
|
||||
#define CDC_DATA_OUT_PACKET_SIZE CDC_DATA_MAX_PACKET_SIZE
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* CDC definitions */
|
||||
/*---------------------------------------------------------------------*/
|
||||
|
||||
/**************************************************/
|
||||
/* CDC Requests */
|
||||
/**************************************************/
|
||||
#define SEND_ENCAPSULATED_COMMAND 0x00
|
||||
#define GET_ENCAPSULATED_RESPONSE 0x01
|
||||
#define SET_COMM_FEATURE 0x02
|
||||
#define GET_COMM_FEATURE 0x03
|
||||
#define CLEAR_COMM_FEATURE 0x04
|
||||
#define SET_LINE_CODING 0x20
|
||||
#define GET_LINE_CODING 0x21
|
||||
#define SET_CONTROL_LINE_STATE 0x22
|
||||
#define SEND_BREAK 0x23
|
||||
#define NO_CMD 0xFF
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
typedef struct _CDC_IF_PROP
|
||||
{
|
||||
uint16_t (*pIf_Init) (void);
|
||||
uint16_t (*pIf_DeInit) (void);
|
||||
uint16_t (*pIf_Ctrl) (uint32_t Cmd, uint8_t* Buf, uint32_t Len);
|
||||
uint16_t (*pIf_DataTx) (uint8_t* Buf, uint32_t Len);
|
||||
uint16_t (*pIf_DataRx) (uint8_t* Buf, uint32_t Len);
|
||||
}
|
||||
CDC_IF_Prop_TypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern USBD_Class_cb_TypeDef USBD_CDC_cb;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CORE_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif // __USB_CDC_CORE_H_
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,46 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_cdc_if_template.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Header for dfu_mal.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USBD_CDC_IF_TEMPLATE_H
|
||||
#define __USBD_CDC_IF_TEMPLATE_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usb_conf.h"
|
||||
#include "usbd_conf.h"
|
||||
#include "usbd_cdc_core.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
extern CDC_IF_Prop_TypeDef TEMPLATE_fops;
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
#endif /* __USBD_CDC_IF_TEMPLATE_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,817 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_cdc_core.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides the high layer firmware functions to manage the
|
||||
* following functionalities of the USB CDC Class:
|
||||
* - Initialization and Configuration of high and low layer
|
||||
* - Enumeration as CDC Device (and enumeration for each implemented memory interface)
|
||||
* - OUT/IN data transfer
|
||||
* - Command IN transfer (class requests management)
|
||||
* - Error management
|
||||
*
|
||||
* @verbatim
|
||||
*
|
||||
* ===================================================================
|
||||
* CDC Class Driver Description
|
||||
* ===================================================================
|
||||
* This driver manages the "Universal Serial Bus Class Definitions for Communications Devices
|
||||
* Revision 1.2 November 16, 2007" and the sub-protocol specification of "Universal Serial Bus
|
||||
* Communications Class Subclass Specification for PSTN Devices Revision 1.2 February 9, 2007"
|
||||
* This driver implements the following aspects of the specification:
|
||||
* - Device descriptor management
|
||||
* - Configuration descriptor management
|
||||
* - Enumeration as CDC device with 2 data endpoints (IN and OUT) and 1 command endpoint (IN)
|
||||
* - Requests management (as described in section 6.2 in specification)
|
||||
* - Abstract Control Model compliant
|
||||
* - Union Functional collection (using 1 IN endpoint for control)
|
||||
* - Data interface class
|
||||
|
||||
* @note
|
||||
* For the Abstract Control Model, this core allows only transmitting the requests to
|
||||
* lower layer dispatcher (ie. usbd_cdc_vcp.c/.h) which should manage each request and
|
||||
* perform relative actions.
|
||||
*
|
||||
* These aspects may be enriched or modified for a specific user application.
|
||||
*
|
||||
* This driver doesn't implement the following aspects of the specification
|
||||
* (but it is possible to manage these features with some modifications on this driver):
|
||||
* - Any class-specific aspect relative to communication classes should be managed by user application.
|
||||
* - All communication classes other than PSTN are not managed
|
||||
*
|
||||
* @endverbatim
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_cdc_core.h"
|
||||
#include "usbd_desc.h"
|
||||
#include "usbd_req.h"
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_cdc
|
||||
* @brief usbd core module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_cdc_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_cdc_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_cdc_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_cdc_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
CDC Device library callbacks
|
||||
*********************************************/
|
||||
static uint8_t usbd_cdc_Init (void *pdev, uint8_t cfgidx);
|
||||
static uint8_t usbd_cdc_DeInit (void *pdev, uint8_t cfgidx);
|
||||
static uint8_t usbd_cdc_Setup (void *pdev, USB_SETUP_REQ *req);
|
||||
static uint8_t usbd_cdc_EP0_RxReady (void *pdev);
|
||||
static uint8_t usbd_cdc_DataIn (void *pdev, uint8_t epnum);
|
||||
static uint8_t usbd_cdc_DataOut (void *pdev, uint8_t epnum);
|
||||
static uint8_t usbd_cdc_SOF (void *pdev);
|
||||
|
||||
/*********************************************
|
||||
CDC specific management functions
|
||||
*********************************************/
|
||||
static void Handle_USBAsynchXfer (void *pdev);
|
||||
static uint8_t *USBD_cdc_GetCfgDesc (uint8_t speed, uint16_t *length);
|
||||
#ifdef USE_USB_OTG_HS
|
||||
static uint8_t *USBD_cdc_GetOtherCfgDesc (uint8_t speed, uint16_t *length);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_cdc_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
extern CDC_IF_Prop_TypeDef APP_FOPS;
|
||||
extern uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC];
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t usbd_cdc_CfgDesc [USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END ;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t usbd_cdc_OtherCfgDesc [USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END ;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static __IO uint32_t usbd_cdc_AltSet __ALIGN_END = 0;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t USB_Rx_Buffer [CDC_DATA_MAX_PACKET_SIZE] __ALIGN_END ;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t APP_Rx_Buffer [APP_RX_DATA_SIZE] __ALIGN_END ;
|
||||
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t CmdBuff[CDC_CMD_PACKET_SZE] __ALIGN_END ;
|
||||
|
||||
uint32_t APP_Rx_ptr_in = 0;
|
||||
uint32_t APP_Rx_ptr_out = 0;
|
||||
uint32_t APP_Rx_length = 0;
|
||||
|
||||
uint8_t USB_Tx_State = 0;
|
||||
|
||||
static uint32_t cdcCmd = 0xFF;
|
||||
static uint32_t cdcLen = 0;
|
||||
|
||||
/* CDC interface class callbacks structure */
|
||||
USBD_Class_cb_TypeDef USBD_CDC_cb =
|
||||
{
|
||||
usbd_cdc_Init,
|
||||
usbd_cdc_DeInit,
|
||||
usbd_cdc_Setup,
|
||||
NULL, /* EP0_TxSent, */
|
||||
usbd_cdc_EP0_RxReady,
|
||||
usbd_cdc_DataIn,
|
||||
usbd_cdc_DataOut,
|
||||
usbd_cdc_SOF,
|
||||
NULL,
|
||||
NULL,
|
||||
USBD_cdc_GetCfgDesc,
|
||||
#ifdef USE_USB_OTG_HS
|
||||
USBD_cdc_GetOtherCfgDesc, /* use same cobfig as per FS */
|
||||
#endif /* USE_USB_OTG_HS */
|
||||
};
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
/* USB CDC device Configuration Descriptor */
|
||||
__ALIGN_BEGIN uint8_t usbd_cdc_CfgDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
/*Configuration Descriptor*/
|
||||
0x09, /* bLength: Configuration Descriptor size */
|
||||
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
|
||||
USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */
|
||||
0x00,
|
||||
0x02, /* bNumInterfaces: 2 interface */
|
||||
0x01, /* bConfigurationValue: Configuration value */
|
||||
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
|
||||
0xC0, /* bmAttributes: self powered */
|
||||
0x32, /* MaxPower 0 mA */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*Interface Descriptor */
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */
|
||||
/* Interface descriptor type */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x01, /* bNumEndpoints: One endpoints used */
|
||||
0x02, /* bInterfaceClass: Communication Interface Class */
|
||||
0x02, /* bInterfaceSubClass: Abstract Control Model */
|
||||
0x01, /* bInterfaceProtocol: Common AT commands */
|
||||
0x00, /* iInterface: */
|
||||
|
||||
/*Header Functional Descriptor*/
|
||||
0x05, /* bLength: Endpoint Descriptor size */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x00, /* bDescriptorSubtype: Header Func Desc */
|
||||
0x10, /* bcdCDC: spec release number */
|
||||
0x01,
|
||||
|
||||
/*Call Management Functional Descriptor*/
|
||||
0x05, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x01, /* bDescriptorSubtype: Call Management Func Desc */
|
||||
0x00, /* bmCapabilities: D0+D1 */
|
||||
0x01, /* bDataInterface: 1 */
|
||||
|
||||
/*ACM Functional Descriptor*/
|
||||
0x04, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x02, /* bDescriptorSubtype: Abstract Control Management desc */
|
||||
0x02, /* bmCapabilities */
|
||||
|
||||
/*Union Functional Descriptor*/
|
||||
0x05, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x06, /* bDescriptorSubtype: Union func desc */
|
||||
0x00, /* bMasterInterface: Communication class interface */
|
||||
0x01, /* bSlaveInterface0: Data Class Interface */
|
||||
|
||||
/*Endpoint 2 Descriptor*/
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
|
||||
CDC_CMD_EP, /* bEndpointAddress */
|
||||
0x03, /* bmAttributes: Interrupt */
|
||||
LOBYTE(CDC_CMD_PACKET_SZE), /* wMaxPacketSize: */
|
||||
HIBYTE(CDC_CMD_PACKET_SZE),
|
||||
#ifdef USE_USB_OTG_HS
|
||||
0x10, /* bInterval: */
|
||||
#else
|
||||
0xFF, /* bInterval: */
|
||||
#endif /* USE_USB_OTG_HS */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*Data class interface descriptor*/
|
||||
0x09, /* bLength: Endpoint Descriptor size */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */
|
||||
0x01, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints: Two endpoints used */
|
||||
0x0A, /* bInterfaceClass: CDC */
|
||||
0x00, /* bInterfaceSubClass: */
|
||||
0x00, /* bInterfaceProtocol: */
|
||||
0x00, /* iInterface: */
|
||||
|
||||
/*Endpoint OUT Descriptor*/
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
|
||||
CDC_OUT_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
LOBYTE(CDC_DATA_MAX_PACKET_SIZE), /* wMaxPacketSize: */
|
||||
HIBYTE(CDC_DATA_MAX_PACKET_SIZE),
|
||||
0x00, /* bInterval: ignore for Bulk transfer */
|
||||
|
||||
/*Endpoint IN Descriptor*/
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
|
||||
CDC_IN_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
LOBYTE(CDC_DATA_MAX_PACKET_SIZE), /* wMaxPacketSize: */
|
||||
HIBYTE(CDC_DATA_MAX_PACKET_SIZE),
|
||||
0x00 /* bInterval: ignore for Bulk transfer */
|
||||
} ;
|
||||
|
||||
#ifdef USE_USB_OTG_HS
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t usbd_cdc_OtherCfgDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
0x09, /* bLength: Configuation Descriptor size */
|
||||
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION,
|
||||
USB_CDC_CONFIG_DESC_SIZ,
|
||||
0x00,
|
||||
0x02, /* bNumInterfaces: 2 interfaces */
|
||||
0x01, /* bConfigurationValue: */
|
||||
0x04, /* iConfiguration: */
|
||||
0xC0, /* bmAttributes: */
|
||||
0x32, /* MaxPower 100 mA */
|
||||
|
||||
/*Interface Descriptor */
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */
|
||||
/* Interface descriptor type */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x01, /* bNumEndpoints: One endpoints used */
|
||||
0x02, /* bInterfaceClass: Communication Interface Class */
|
||||
0x02, /* bInterfaceSubClass: Abstract Control Model */
|
||||
0x01, /* bInterfaceProtocol: Common AT commands */
|
||||
0x00, /* iInterface: */
|
||||
|
||||
/*Header Functional Descriptor*/
|
||||
0x05, /* bLength: Endpoint Descriptor size */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x00, /* bDescriptorSubtype: Header Func Desc */
|
||||
0x10, /* bcdCDC: spec release number */
|
||||
0x01,
|
||||
|
||||
/*Call Management Functional Descriptor*/
|
||||
0x05, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x01, /* bDescriptorSubtype: Call Management Func Desc */
|
||||
0x00, /* bmCapabilities: D0+D1 */
|
||||
0x01, /* bDataInterface: 1 */
|
||||
|
||||
/*ACM Functional Descriptor*/
|
||||
0x04, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x02, /* bDescriptorSubtype: Abstract Control Management desc */
|
||||
0x02, /* bmCapabilities */
|
||||
|
||||
/*Union Functional Descriptor*/
|
||||
0x05, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x06, /* bDescriptorSubtype: Union func desc */
|
||||
0x00, /* bMasterInterface: Communication class interface */
|
||||
0x01, /* bSlaveInterface0: Data Class Interface */
|
||||
|
||||
/*Endpoint 2 Descriptor*/
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
|
||||
CDC_CMD_EP, /* bEndpointAddress */
|
||||
0x03, /* bmAttributes: Interrupt */
|
||||
LOBYTE(CDC_CMD_PACKET_SZE), /* wMaxPacketSize: */
|
||||
HIBYTE(CDC_CMD_PACKET_SZE),
|
||||
0xFF, /* bInterval: */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*Data class interface descriptor*/
|
||||
0x09, /* bLength: Endpoint Descriptor size */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */
|
||||
0x01, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints: Two endpoints used */
|
||||
0x0A, /* bInterfaceClass: CDC */
|
||||
0x00, /* bInterfaceSubClass: */
|
||||
0x00, /* bInterfaceProtocol: */
|
||||
0x00, /* iInterface: */
|
||||
|
||||
/*Endpoint OUT Descriptor*/
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
|
||||
CDC_OUT_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
0x40, /* wMaxPacketSize: */
|
||||
0x00,
|
||||
0x00, /* bInterval: ignore for Bulk transfer */
|
||||
|
||||
/*Endpoint IN Descriptor*/
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
|
||||
CDC_IN_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
0x40, /* wMaxPacketSize: */
|
||||
0x00,
|
||||
0x00 /* bInterval */
|
||||
};
|
||||
#endif /* USE_USB_OTG_HS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_cdc_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief usbd_cdc_Init
|
||||
* Initilaize the CDC interface
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_cdc_Init (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
uint8_t *pbuf;
|
||||
|
||||
/* Open EP IN */
|
||||
DCD_EP_Open(pdev,
|
||||
CDC_IN_EP,
|
||||
CDC_DATA_IN_PACKET_SIZE,
|
||||
USB_OTG_EP_BULK);
|
||||
|
||||
/* Open EP OUT */
|
||||
DCD_EP_Open(pdev,
|
||||
CDC_OUT_EP,
|
||||
CDC_DATA_OUT_PACKET_SIZE,
|
||||
USB_OTG_EP_BULK);
|
||||
|
||||
/* Open Command IN EP */
|
||||
DCD_EP_Open(pdev,
|
||||
CDC_CMD_EP,
|
||||
CDC_CMD_PACKET_SZE,
|
||||
USB_OTG_EP_INT);
|
||||
|
||||
pbuf = (uint8_t *)USBD_DeviceDesc;
|
||||
pbuf[4] = DEVICE_CLASS_CDC;
|
||||
pbuf[5] = DEVICE_SUBCLASS_CDC;
|
||||
|
||||
/* Initialize the Interface physical components */
|
||||
APP_FOPS.pIf_Init();
|
||||
|
||||
/* Prepare Out endpoint to receive next packet */
|
||||
DCD_EP_PrepareRx(pdev,
|
||||
CDC_OUT_EP,
|
||||
(uint8_t*)(USB_Rx_Buffer),
|
||||
CDC_DATA_OUT_PACKET_SIZE);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_cdc_Init
|
||||
* DeInitialize the CDC layer
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_cdc_DeInit (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
/* Open EP IN */
|
||||
DCD_EP_Close(pdev,
|
||||
CDC_IN_EP);
|
||||
|
||||
/* Open EP OUT */
|
||||
DCD_EP_Close(pdev,
|
||||
CDC_OUT_EP);
|
||||
|
||||
/* Open Command IN EP */
|
||||
DCD_EP_Close(pdev,
|
||||
CDC_CMD_EP);
|
||||
|
||||
/* Restore default state of the Interface physical components */
|
||||
APP_FOPS.pIf_DeInit();
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_cdc_Setup
|
||||
* Handle the CDC specific requests
|
||||
* @param pdev: instance
|
||||
* @param req: usb requests
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_cdc_Setup (void *pdev,
|
||||
USB_SETUP_REQ *req)
|
||||
{
|
||||
uint16_t len=USB_CDC_DESC_SIZ;
|
||||
uint8_t *pbuf=usbd_cdc_CfgDesc + 9;
|
||||
|
||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||
{
|
||||
/* CDC Class Requests -------------------------------*/
|
||||
case USB_REQ_TYPE_CLASS :
|
||||
/* Check if the request is a data setup packet */
|
||||
if (req->wLength)
|
||||
{
|
||||
/* Check if the request is Device-to-Host */
|
||||
if (req->bmRequest & 0x80)
|
||||
{
|
||||
/* Get the data to be sent to Host from interface layer */
|
||||
APP_FOPS.pIf_Ctrl(req->bRequest, CmdBuff, req->wLength);
|
||||
|
||||
/* Send the data to the host */
|
||||
USBD_CtlSendData (pdev,
|
||||
CmdBuff,
|
||||
req->wLength);
|
||||
}
|
||||
else /* Host-to-Device requeset */
|
||||
{
|
||||
/* Set the value of the current command to be processed */
|
||||
cdcCmd = req->bRequest;
|
||||
cdcLen = req->wLength;
|
||||
|
||||
/* Prepare the reception of the buffer over EP0
|
||||
Next step: the received data will be managed in usbd_cdc_EP0_TxSent()
|
||||
function. */
|
||||
USBD_CtlPrepareRx (pdev,
|
||||
CmdBuff,
|
||||
req->wLength);
|
||||
}
|
||||
}
|
||||
else /* No Data request */
|
||||
{
|
||||
/* Transfer the command to the interface layer */
|
||||
APP_FOPS.pIf_Ctrl(req->bRequest, NULL, 0);
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
|
||||
default:
|
||||
USBD_CtlError (pdev, req);
|
||||
return USBD_FAIL;
|
||||
|
||||
|
||||
|
||||
/* Standard Requests -------------------------------*/
|
||||
case USB_REQ_TYPE_STANDARD:
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case USB_REQ_GET_DESCRIPTOR:
|
||||
if( (req->wValue >> 8) == CDC_DESCRIPTOR_TYPE)
|
||||
{
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
pbuf = usbd_cdc_Desc;
|
||||
#else
|
||||
pbuf = usbd_cdc_CfgDesc + 9 + (9 * USBD_ITF_MAX_NUM);
|
||||
#endif
|
||||
len = MIN(USB_CDC_DESC_SIZ , req->wLength);
|
||||
}
|
||||
|
||||
USBD_CtlSendData (pdev,
|
||||
pbuf,
|
||||
len);
|
||||
break;
|
||||
|
||||
case USB_REQ_GET_INTERFACE :
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)&usbd_cdc_AltSet,
|
||||
1);
|
||||
break;
|
||||
|
||||
case USB_REQ_SET_INTERFACE :
|
||||
if ((uint8_t)(req->wValue) < USBD_ITF_MAX_NUM)
|
||||
{
|
||||
usbd_cdc_AltSet = (uint8_t)(req->wValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the error management function (command will be nacked */
|
||||
USBD_CtlError (pdev, req);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_cdc_EP0_RxReady
|
||||
* Data received on control endpoint
|
||||
* @param pdev: device device instance
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_cdc_EP0_RxReady (void *pdev)
|
||||
{
|
||||
if (cdcCmd != NO_CMD)
|
||||
{
|
||||
/* Process the data */
|
||||
APP_FOPS.pIf_Ctrl(cdcCmd, CmdBuff, cdcLen);
|
||||
|
||||
/* Reset the command variable to default value */
|
||||
cdcCmd = NO_CMD;
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_DataIn
|
||||
* Data sent on non-control IN endpoint
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint number
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_cdc_DataIn (void *pdev, uint8_t epnum)
|
||||
{
|
||||
uint16_t USB_Tx_ptr;
|
||||
uint16_t USB_Tx_length;
|
||||
|
||||
if (USB_Tx_State == 1)
|
||||
{
|
||||
if (APP_Rx_length == 0)
|
||||
{
|
||||
USB_Tx_State = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (APP_Rx_length > CDC_DATA_IN_PACKET_SIZE){
|
||||
USB_Tx_ptr = APP_Rx_ptr_out;
|
||||
USB_Tx_length = CDC_DATA_IN_PACKET_SIZE;
|
||||
|
||||
APP_Rx_ptr_out += CDC_DATA_IN_PACKET_SIZE;
|
||||
APP_Rx_length -= CDC_DATA_IN_PACKET_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_Tx_ptr = APP_Rx_ptr_out;
|
||||
USB_Tx_length = APP_Rx_length;
|
||||
|
||||
APP_Rx_ptr_out += APP_Rx_length;
|
||||
APP_Rx_length = 0;
|
||||
}
|
||||
|
||||
/* Prepare the available data buffer to be sent on IN endpoint */
|
||||
DCD_EP_Tx (pdev,
|
||||
CDC_IN_EP,
|
||||
(uint8_t*)&APP_Rx_Buffer[USB_Tx_ptr],
|
||||
USB_Tx_length);
|
||||
}
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_cdc_DataOut
|
||||
* Data received on non-control Out endpoint
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint number
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_cdc_DataOut (void *pdev, uint8_t epnum)
|
||||
{
|
||||
uint16_t USB_Rx_Cnt;
|
||||
|
||||
/* Get the received data buffer and update the counter */
|
||||
USB_Rx_Cnt = ((USB_OTG_CORE_HANDLE*)pdev)->dev.out_ep[epnum].xfer_count;
|
||||
|
||||
/* USB data will be immediately processed, this allow next USB traffic being
|
||||
NAKed till the end of the application Xfer */
|
||||
APP_FOPS.pIf_DataRx(USB_Rx_Buffer, USB_Rx_Cnt);
|
||||
|
||||
/* Prepare Out endpoint to receive next packet */
|
||||
DCD_EP_PrepareRx(pdev,
|
||||
CDC_OUT_EP,
|
||||
(uint8_t*)(USB_Rx_Buffer),
|
||||
CDC_DATA_OUT_PACKET_SIZE);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_audio_SOF
|
||||
* Start Of Frame event management
|
||||
* @param pdev: instance
|
||||
* @param epnum: endpoint number
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_cdc_SOF (void *pdev)
|
||||
{
|
||||
static uint32_t FrameCount = 0;
|
||||
|
||||
if (FrameCount++ == CDC_IN_FRAME_INTERVAL)
|
||||
{
|
||||
/* Reset the frame counter */
|
||||
FrameCount = 0;
|
||||
|
||||
/* Check the data to be sent through IN pipe */
|
||||
Handle_USBAsynchXfer(pdev);
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handle_USBAsynchXfer
|
||||
* Send data to USB
|
||||
* @param pdev: instance
|
||||
* @retval None
|
||||
*/
|
||||
static void Handle_USBAsynchXfer (void *pdev)
|
||||
{
|
||||
uint16_t USB_Tx_ptr;
|
||||
uint16_t USB_Tx_length;
|
||||
|
||||
if(USB_Tx_State != 1)
|
||||
{
|
||||
if (APP_Rx_ptr_out == APP_RX_DATA_SIZE)
|
||||
{
|
||||
APP_Rx_ptr_out = 0;
|
||||
}
|
||||
|
||||
if(APP_Rx_ptr_out == APP_Rx_ptr_in)
|
||||
{
|
||||
USB_Tx_State = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if(APP_Rx_ptr_out > APP_Rx_ptr_in) /* rollback */
|
||||
{
|
||||
APP_Rx_length = APP_RX_DATA_SIZE - APP_Rx_ptr_out;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
APP_Rx_length = APP_Rx_ptr_in - APP_Rx_ptr_out;
|
||||
|
||||
}
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
APP_Rx_length &= ~0x03;
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
|
||||
if (APP_Rx_length > CDC_DATA_IN_PACKET_SIZE)
|
||||
{
|
||||
USB_Tx_ptr = APP_Rx_ptr_out;
|
||||
USB_Tx_length = CDC_DATA_IN_PACKET_SIZE;
|
||||
|
||||
APP_Rx_ptr_out += CDC_DATA_IN_PACKET_SIZE;
|
||||
APP_Rx_length -= CDC_DATA_IN_PACKET_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_Tx_ptr = APP_Rx_ptr_out;
|
||||
USB_Tx_length = APP_Rx_length;
|
||||
|
||||
APP_Rx_ptr_out += APP_Rx_length;
|
||||
APP_Rx_length = 0;
|
||||
}
|
||||
USB_Tx_State = 1;
|
||||
|
||||
DCD_EP_Tx (pdev,
|
||||
CDC_IN_EP,
|
||||
(uint8_t*)&APP_Rx_Buffer[USB_Tx_ptr],
|
||||
USB_Tx_length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_cdc_GetCfgDesc
|
||||
* Return configuration descriptor
|
||||
* @param speed : current device speed
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
static uint8_t *USBD_cdc_GetCfgDesc (uint8_t speed, uint16_t *length)
|
||||
{
|
||||
*length = sizeof (usbd_cdc_CfgDesc);
|
||||
return usbd_cdc_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_cdc_GetCfgDesc
|
||||
* Return configuration descriptor
|
||||
* @param speed : current device speed
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
#ifdef USE_USB_OTG_HS
|
||||
static uint8_t *USBD_cdc_GetOtherCfgDesc (uint8_t speed, uint16_t *length)
|
||||
{
|
||||
*length = sizeof (usbd_cdc_OtherCfgDesc);
|
||||
return usbd_cdc_OtherCfgDesc;
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,207 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_cdc_if_template.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Generic media access Layer.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#pragma data_alignment = 4
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_cdc_if_template.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* These are external variables imported from CDC core to be used for IN
|
||||
transfer management. */
|
||||
extern uint8_t APP_Rx_Buffer []; /* Write CDC received data in this buffer.
|
||||
These data will be sent over USB IN endpoint
|
||||
in the CDC core functions. */
|
||||
extern uint32_t APP_Rx_ptr_in; /* Increment this pointer or roll it back to
|
||||
start address when writing received data
|
||||
in the buffer APP_Rx_Buffer. */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static uint16_t TEMPLATE_Init (void);
|
||||
static uint16_t TEMPLATE_DeInit (void);
|
||||
static uint16_t TEMPLATE_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len);
|
||||
static uint16_t TEMPLATE_DataTx (uint8_t* Buf, uint32_t Len);
|
||||
static uint16_t TEMPLATE_DataRx (uint8_t* Buf, uint32_t Len);
|
||||
|
||||
CDC_IF_Prop_TypeDef TEMPLATE_fops =
|
||||
{
|
||||
TEMPLATE_Init,
|
||||
TEMPLATE_DeInit,
|
||||
TEMPLATE_Ctrl,
|
||||
TEMPLATE_DataTx,
|
||||
TEMPLATE_DataRx
|
||||
};
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief TEMPLATE_Init
|
||||
* Initializes the CDC media low layer
|
||||
* @param None
|
||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static uint16_t TEMPLATE_Init(void)
|
||||
{
|
||||
/*
|
||||
Add your initialization code here
|
||||
*/
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TEMPLATE_DeInit
|
||||
* DeInitializes the CDC media low layer
|
||||
* @param None
|
||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static uint16_t TEMPLATE_DeInit(void)
|
||||
{
|
||||
/*
|
||||
Add your deinitialization code here
|
||||
*/
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief TEMPLATE_Ctrl
|
||||
* Manage the CDC class requests
|
||||
* @param Cmd: Command code
|
||||
* @param Buf: Buffer containing command data (request parameters)
|
||||
* @param Len: Number of data to be sent (in bytes)
|
||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static uint16_t TEMPLATE_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len)
|
||||
{
|
||||
switch (Cmd)
|
||||
{
|
||||
case SEND_ENCAPSULATED_COMMAND:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case GET_ENCAPSULATED_RESPONSE:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case SET_COMM_FEATURE:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case GET_COMM_FEATURE:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case CLEAR_COMM_FEATURE:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case SET_LINE_CODING:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case GET_LINE_CODING:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case SET_CONTROL_LINE_STATE:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case SEND_BREAK:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TEMPLATE_DataTx
|
||||
* CDC received data to be send over USB IN endpoint are managed in
|
||||
* this function.
|
||||
* @param Buf: Buffer of data to be sent
|
||||
* @param Len: Number of data to be sent (in bytes)
|
||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static uint16_t TEMPLATE_DataTx (uint8_t* Buf, uint32_t Len)
|
||||
{
|
||||
|
||||
/* Get the data to be sent */
|
||||
for (i = 0; i < Len; i++)
|
||||
{
|
||||
/* APP_Rx_Buffer[APP_Rx_ptr_in] = XXX_ReceiveData(XXX); */
|
||||
}
|
||||
|
||||
/* Increment the in pointer */
|
||||
APP_Rx_ptr_in++;
|
||||
|
||||
/* To avoid buffer overflow */
|
||||
if(APP_Rx_ptr_in == APP_RX_DATA_SIZE)
|
||||
{
|
||||
APP_Rx_ptr_in = 0;
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TEMPLATE_DataRx
|
||||
* Data received over USB OUT endpoint are sent over CDC interface
|
||||
* through this function.
|
||||
*
|
||||
* @note
|
||||
* This function will block any OUT packet reception on USB endpoint
|
||||
* untill exiting this function. If you exit this function before transfer
|
||||
* is complete on CDC interface (ie. using DMA controller) it will result
|
||||
* in receiving more data while previous ones are still not sent.
|
||||
*
|
||||
* @param Buf: Buffer of data to be received
|
||||
* @param Len: Number of data received (in bytes)
|
||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static uint16_t TEMPLATE_DataRx (uint8_t* Buf, uint32_t Len)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
/* Send the received buffer */
|
||||
for (i = 0; i < Len; i++)
|
||||
{
|
||||
/* XXXX_SendData(XXXX, *(Buf + i) ); */
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,193 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_dfu_core.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header file for the usbd_dfu_core.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USB_DFU_CORE_H_
|
||||
#define __USB_DFU_CORE_H_
|
||||
|
||||
#include "usbd_ioreq.h"
|
||||
#include "usbd_dfu_mal.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_dfu
|
||||
* @brief This file is the Header file for USBD_dfu.c
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_dfu_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#define USB_DFU_CONFIG_DESC_SIZ (18 + (9 * USBD_ITF_MAX_NUM))
|
||||
#define USB_DFU_DESC_SIZ 9
|
||||
|
||||
#define DFU_DESCRIPTOR_TYPE 0x21
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* DFU definitions */
|
||||
/*---------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/**************************************************/
|
||||
/* DFU Requests DFU states */
|
||||
/**************************************************/
|
||||
|
||||
|
||||
#define STATE_appIDLE 0
|
||||
#define STATE_appDETACH 1
|
||||
#define STATE_dfuIDLE 2
|
||||
#define STATE_dfuDNLOAD_SYNC 3
|
||||
#define STATE_dfuDNBUSY 4
|
||||
#define STATE_dfuDNLOAD_IDLE 5
|
||||
#define STATE_dfuMANIFEST_SYNC 6
|
||||
#define STATE_dfuMANIFEST 7
|
||||
#define STATE_dfuMANIFEST_WAIT_RESET 8
|
||||
#define STATE_dfuUPLOAD_IDLE 9
|
||||
#define STATE_dfuERROR 10
|
||||
|
||||
/**************************************************/
|
||||
/* DFU Requests DFU status */
|
||||
/**************************************************/
|
||||
|
||||
#define STATUS_OK 0x00
|
||||
#define STATUS_ERRTARGET 0x01
|
||||
#define STATUS_ERRFILE 0x02
|
||||
#define STATUS_ERRWRITE 0x03
|
||||
#define STATUS_ERRERASE 0x04
|
||||
#define STATUS_ERRCHECK_ERASED 0x05
|
||||
#define STATUS_ERRPROG 0x06
|
||||
#define STATUS_ERRVERIFY 0x07
|
||||
#define STATUS_ERRADDRESS 0x08
|
||||
#define STATUS_ERRNOTDONE 0x09
|
||||
#define STATUS_ERRFIRMWARE 0x0A
|
||||
#define STATUS_ERRVENDOR 0x0B
|
||||
#define STATUS_ERRUSBR 0x0C
|
||||
#define STATUS_ERRPOR 0x0D
|
||||
#define STATUS_ERRUNKNOWN 0x0E
|
||||
#define STATUS_ERRSTALLEDPKT 0x0F
|
||||
|
||||
/**************************************************/
|
||||
/* DFU Requests DFU states Manifestation State */
|
||||
/**************************************************/
|
||||
|
||||
#define Manifest_complete 0x00
|
||||
#define Manifest_In_Progress 0x01
|
||||
|
||||
|
||||
/**************************************************/
|
||||
/* Special Commands with Download Request */
|
||||
/**************************************************/
|
||||
|
||||
#define CMD_GETCOMMANDS 0x00
|
||||
#define CMD_SETADDRESSPOINTER 0x21
|
||||
#define CMD_ERASE 0x41
|
||||
|
||||
/**************************************************/
|
||||
/* Other defines */
|
||||
/**************************************************/
|
||||
/* Bit Detach capable = bit 3 in bmAttributes field */
|
||||
#define DFU_DETACH_MASK (uint8_t)(1 << 4)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**************************************************/
|
||||
/* DFU Requests */
|
||||
/**************************************************/
|
||||
|
||||
typedef enum _DFU_REQUESTS {
|
||||
DFU_DETACH = 0,
|
||||
DFU_DNLOAD = 1,
|
||||
DFU_UPLOAD,
|
||||
DFU_GETSTATUS,
|
||||
DFU_CLRSTATUS,
|
||||
DFU_GETSTATE,
|
||||
DFU_ABORT
|
||||
} DFU_REQUESTS;
|
||||
|
||||
typedef void (*pFunction)(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
/********** Descriptor of DFU interface 0 Alternate setting n ****************/
|
||||
#define USBD_DFU_IF_DESC(n) 0x09, /* bLength: Interface Descriptor size */ \
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ \
|
||||
0x00, /* bInterfaceNumber: Number of Interface */ \
|
||||
(n), /* bAlternateSetting: Alternate setting */ \
|
||||
0x00, /* bNumEndpoints*/ \
|
||||
0xFE, /* bInterfaceClass: Application Specific Class Code */ \
|
||||
0x01, /* bInterfaceSubClass : Device Firmware Upgrade Code */ \
|
||||
0x02, /* nInterfaceProtocol: DFU mode protocol */ \
|
||||
USBD_IDX_INTERFACE_STR + (n) + 1 /* iInterface: Index of string descriptor */ \
|
||||
/* 18 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern USBD_Class_cb_TypeDef DFU_cb;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CORE_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif // __USB_DFU_CORE_H_
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,81 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_dfu_mal.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Header for usbd_dfu_mal.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __DFU_MAL_H
|
||||
#define __DFU_MAL_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usb_conf.h"
|
||||
|
||||
#include "usbd_conf.h"
|
||||
#include "usbd_dfu_core.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef struct _DFU_MAL_PROP
|
||||
{
|
||||
const uint8_t* pStrDesc;
|
||||
uint16_t (*pMAL_Init) (void);
|
||||
uint16_t (*pMAL_DeInit) (void);
|
||||
uint16_t (*pMAL_Erase) (uint32_t Add);
|
||||
uint16_t (*pMAL_Write) (uint32_t Add, uint32_t Len);
|
||||
uint8_t *(*pMAL_Read) (uint32_t Add, uint32_t Len);
|
||||
uint16_t (*pMAL_CheckAdd) (uint32_t Add);
|
||||
const uint32_t EraseTiming;
|
||||
const uint32_t WriteTiming;
|
||||
}
|
||||
DFU_MAL_Prop_TypeDef;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define MAL_OK 0
|
||||
#define MAL_FAIL 1
|
||||
|
||||
/* utils macro ---------------------------------------------------------------*/
|
||||
#define _1st_BYTE(x) (uint8_t)((x)&0xFF) /* 1st addressing cycle */
|
||||
#define _2nd_BYTE(x) (uint8_t)(((x)&0xFF00)>>8) /* 2nd addressing cycle */
|
||||
#define _3rd_BYTE(x) (uint8_t)(((x)&0xFF0000)>>16) /* 3rd addressing cycle */
|
||||
#define _4th_BYTE(x) (uint8_t)(((x)&0xFF000000)>>24) /* 4th addressing cycle */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#define SET_POLLING_TIMING(x) buffer[1] = _1st_BYTE(x);\
|
||||
buffer[2] = _2nd_BYTE(x);\
|
||||
buffer[3] = _3rd_BYTE(x);
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
uint16_t MAL_Init (void);
|
||||
uint16_t MAL_DeInit (void);
|
||||
uint16_t MAL_Erase (uint32_t SectorAddress);
|
||||
uint16_t MAL_Write (uint32_t SectorAddress, uint32_t DataLength);
|
||||
uint8_t *MAL_Read (uint32_t SectorAddress, uint32_t DataLength);
|
||||
uint16_t MAL_GetStatus(uint32_t SectorAddress ,uint8_t Cmd, uint8_t *buffer);
|
||||
|
||||
extern uint8_t MAL_Buffer[XFERSIZE]; /* RAM Buffer for Downloaded Data */
|
||||
#endif /* __DFU_MAL_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_flash_if.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Header for usbd_flash_if.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __FLASH_IF_MAL_H
|
||||
#define __FLASH_IF_MAL_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_dfu_mal.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define FLASH_START_ADD 0x08000000
|
||||
|
||||
#ifdef STM32F2XX
|
||||
#define FLASH_END_ADD 0x08100000
|
||||
#define FLASH_IF_STRING "@Internal Flash /0x08000000/03*016Ka,01*016Kg,01*064Kg,07*128Kg"
|
||||
#elif defined(STM32F4XX)
|
||||
#define FLASH_END_ADD 0x08100000
|
||||
#define FLASH_IF_STRING "@Internal Flash /0x08000000/03*016Ka,01*016Kg,01*064Kg,07*128Kg"
|
||||
#elif defined(STM32F10X_CL)
|
||||
#define FLASH_END_ADD 0x08040000
|
||||
#define FLASH_IF_STRING "@Internal Flash /0x08000000/06*002Ka,122*002Kg"
|
||||
#endif /* STM32F2XX */
|
||||
|
||||
|
||||
extern DFU_MAL_Prop_TypeDef DFU_Flash_cb;
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
#endif /* __FLASH_IF_MAL_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,51 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_mem_if_template.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Header for usbd_mem_if_template.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MEM_IF_MAL_H
|
||||
#define __MEM_IF_MAL_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usb_conf.h"
|
||||
|
||||
#include "usbd_dfu_mal.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define MEM_START_ADD 0x00000000 /* Dummy start address */
|
||||
#define MEM_END_ADD (uint32_t)(MEM_START_ADD + (5 * 1024)) /* Dummy Size = 5KB */
|
||||
|
||||
#define MEM_IF_STRING "@Dummy Memory /0x00000000/01*002Kg,03*001Kg"
|
||||
|
||||
extern DFU_MAL_Prop_TypeDef DFU_Mem_cb;
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
#endif /* __MEM_IF_MAL_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_otp_if.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Header for usbd_otp_if.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __OTP_IF_MAL_H
|
||||
#define __OTP_IF_MAL_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_dfu_mal.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define OTP_START_ADD 0x1FFF7800
|
||||
#define OTP_END_ADD (uint32_t)(OTP_START_ADD + 528)
|
||||
|
||||
#define OTP_IF_STRING "@OTP Area /0x1FFF7800/01*512 g,01*016 g"
|
||||
|
||||
extern DFU_MAL_Prop_TypeDef DFU_Otp_cb;
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
#endif /* __OTP_IF_MAL_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,1052 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_dfu_core.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides the high layer firmware functions to manage the
|
||||
* following functionalities of the USB DFU Class:
|
||||
* - Initialization and Configuration of high and low layer
|
||||
* - Enumeration as DFU Device (and enumeration for each implemented memory interface)
|
||||
* - Transfers to/from memory interfaces
|
||||
* - Easy-to-customize "plug-in-like" modules for adding/removing memory interfaces.
|
||||
* - Error management
|
||||
*
|
||||
* @verbatim
|
||||
*
|
||||
* ===================================================================
|
||||
* DFU Class Driver Description
|
||||
* ===================================================================
|
||||
* This driver manages the DFU class V1.1 following the "Device Class Specification for
|
||||
* Device Firmware Upgrade Version 1.1 Aug 5, 2004".
|
||||
* This driver implements the following aspects of the specification:
|
||||
* - Device descriptor management
|
||||
* - Configuration descriptor management
|
||||
* - Enumeration as DFU device (in DFU mode only)
|
||||
* - Requests management (supporting ST DFU sub-protocol)
|
||||
* - Memory operations management (Download/Upload/Erase/Detach/GetState/GetStatus)
|
||||
* - DFU state machine implementation.
|
||||
*
|
||||
* @note
|
||||
* ST DFU sub-protocol is compliant with DFU protocol and use sub-requests to manage
|
||||
* memory addressing, commands processing, specific memories operations (ie. Erase) ...
|
||||
* As required by the DFU specification, only endpoint 0 is used in this application.
|
||||
* Other endpoints and functions may be added to the application (ie. DFU ...)
|
||||
*
|
||||
* These aspects may be enriched or modified for a specific user application.
|
||||
*
|
||||
* This driver doesn't implement the following aspects of the specification
|
||||
* (but it is possible to manage these features with some modifications on this driver):
|
||||
* - Manifestation Tolerant mode
|
||||
*
|
||||
* @endverbatim
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_dfu_core.h"
|
||||
#include "usbd_desc.h"
|
||||
#include "usbd_req.h"
|
||||
#include "usb_bsp.h"
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_dfu
|
||||
* @brief usbd core module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_dfu_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_dfu_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_dfu_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_dfu_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
DFU Device library callbacks
|
||||
*********************************************/
|
||||
static uint8_t usbd_dfu_Init (void *pdev,
|
||||
uint8_t cfgidx);
|
||||
|
||||
static uint8_t usbd_dfu_DeInit (void *pdev,
|
||||
uint8_t cfgidx);
|
||||
|
||||
static uint8_t usbd_dfu_Setup (void *pdev,
|
||||
USB_SETUP_REQ *req);
|
||||
|
||||
static uint8_t EP0_TxSent (void *pdev);
|
||||
|
||||
static uint8_t EP0_RxReady (void *pdev);
|
||||
|
||||
|
||||
static uint8_t *USBD_DFU_GetCfgDesc (uint8_t speed,
|
||||
uint16_t *length);
|
||||
|
||||
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
static uint8_t *USBD_DFU_GetOtherCfgDesc (uint8_t speed,
|
||||
uint16_t *length);
|
||||
#endif
|
||||
|
||||
static uint8_t* USBD_DFU_GetUsrStringDesc (uint8_t speed,
|
||||
uint8_t index ,
|
||||
uint16_t *length);
|
||||
|
||||
/*********************************************
|
||||
DFU Requests management functions
|
||||
*********************************************/
|
||||
static void DFU_Req_DETACH (void *pdev,
|
||||
USB_SETUP_REQ *req);
|
||||
|
||||
static void DFU_Req_DNLOAD (void *pdev,
|
||||
USB_SETUP_REQ *req);
|
||||
|
||||
static void DFU_Req_UPLOAD (void *pdev,
|
||||
USB_SETUP_REQ *req);
|
||||
|
||||
static void DFU_Req_GETSTATUS (void *pdev);
|
||||
|
||||
static void DFU_Req_CLRSTATUS (void *pdev);
|
||||
|
||||
static void DFU_Req_GETSTATE (void *pdev);
|
||||
|
||||
static void DFU_Req_ABORT (void *pdev);
|
||||
|
||||
static void DFU_LeaveDFUMode (void *pdev);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_dfu_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t usbd_dfu_CfgDesc[USB_DFU_CONFIG_DESC_SIZ] __ALIGN_END ;
|
||||
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t usbd_dfu_OtherCfgDesc[USB_DFU_CONFIG_DESC_SIZ] __ALIGN_END ;
|
||||
|
||||
/* The list of Interface String descriptor pointers is defined in usbd_dfu_mal.c
|
||||
file. This list can be updated whenever a memory has to be added or removed */
|
||||
extern const uint8_t* usbd_dfu_StringDesc[];
|
||||
|
||||
/* State Machine variables */
|
||||
uint8_t DeviceState;
|
||||
uint8_t DeviceStatus[6];
|
||||
uint32_t Manifest_State = Manifest_complete;
|
||||
/* Data Management variables */
|
||||
static uint32_t wBlockNum = 0, wlength = 0;
|
||||
static uint32_t Pointer = APP_DEFAULT_ADD; /* Base Address to Erase, Program or Read */
|
||||
static __IO uint32_t usbd_dfu_AltSet = 0;
|
||||
|
||||
extern uint8_t MAL_Buffer[];
|
||||
|
||||
/* DFU interface class callbacks structure */
|
||||
USBD_Class_cb_TypeDef DFU_cb =
|
||||
{
|
||||
usbd_dfu_Init,
|
||||
usbd_dfu_DeInit,
|
||||
usbd_dfu_Setup,
|
||||
EP0_TxSent,
|
||||
EP0_RxReady,
|
||||
NULL, /* DataIn, */
|
||||
NULL, /* DataOut, */
|
||||
NULL, /*SOF */
|
||||
NULL,
|
||||
NULL,
|
||||
USBD_DFU_GetCfgDesc,
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
USBD_DFU_GetOtherCfgDesc, /* use same cobfig as per FS */
|
||||
#endif
|
||||
USBD_DFU_GetUsrStringDesc,
|
||||
};
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
/* USB DFU device Configuration Descriptor */
|
||||
__ALIGN_BEGIN uint8_t usbd_dfu_CfgDesc[USB_DFU_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
0x09, /* bLength: Configuation Descriptor size */
|
||||
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
|
||||
USB_DFU_CONFIG_DESC_SIZ,
|
||||
/* wTotalLength: Bytes returned */
|
||||
0x00,
|
||||
0x01, /*bNumInterfaces: 1 interface*/
|
||||
0x01, /*bConfigurationValue: Configuration value*/
|
||||
0x02, /*iConfiguration: Index of string descriptor describing the configuration*/
|
||||
0xC0, /*bmAttributes: bus powered and Supprts Remote Wakeup */
|
||||
0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
|
||||
/* 09 */
|
||||
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 0 **************/
|
||||
USBD_DFU_IF_DESC(0), /* This interface is mandatory for all devices */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 1)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 1 **************/
|
||||
USBD_DFU_IF_DESC(1),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 1) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 2)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 2 **************/
|
||||
USBD_DFU_IF_DESC(2),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 2) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 3)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 3 **************/
|
||||
USBD_DFU_IF_DESC(3),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 3) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 4)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 4 **************/
|
||||
USBD_DFU_IF_DESC(4),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 4) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 5)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 5 **************/
|
||||
USBD_DFU_IF_DESC(5),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 5) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 6)
|
||||
#error "ERROR: usbd_dfu_core.c: Modify the file to support more descriptors!"
|
||||
#endif /* (USBD_ITF_MAX_NUM > 6) */
|
||||
|
||||
/******************** DFU Functional Descriptor********************/
|
||||
0x09, /*blength = 9 Bytes*/
|
||||
DFU_DESCRIPTOR_TYPE, /* DFU Functional Descriptor*/
|
||||
0x0B, /*bmAttribute
|
||||
bitCanDnload = 1 (bit 0)
|
||||
bitCanUpload = 1 (bit 1)
|
||||
bitManifestationTolerant = 0 (bit 2)
|
||||
bitWillDetach = 1 (bit 3)
|
||||
Reserved (bit4-6)
|
||||
bitAcceleratedST = 0 (bit 7)*/
|
||||
0xFF, /*DetachTimeOut= 255 ms*/
|
||||
0x00,
|
||||
/*WARNING: In DMA mode the multiple MPS packets feature is still not supported
|
||||
==> In this case, when using DMA XFERSIZE should be set to 64 in usbd_conf.h */
|
||||
TRANSFER_SIZE_BYTES(XFERSIZE), /* TransferSize = 1024 Byte*/
|
||||
0x1A, /* bcdDFUVersion*/
|
||||
0x01
|
||||
/***********************************************************/
|
||||
/* 9*/
|
||||
} ;
|
||||
|
||||
#ifdef USE_USB_OTG_HS
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
|
||||
__ALIGN_BEGIN uint8_t usbd_dfu_OtherCfgDesc[USB_DFU_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
0x09, /* bLength: Configuation Descriptor size */
|
||||
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||
USB_DFU_CONFIG_DESC_SIZ,
|
||||
/* wTotalLength: Bytes returned */
|
||||
0x00,
|
||||
0x01, /*bNumInterfaces: 1 interface*/
|
||||
0x01, /*bConfigurationValue: Configuration value*/
|
||||
0x02, /*iConfiguration: Index of string descriptor describing the configuration*/
|
||||
0xC0, /*bmAttributes: bus powered and Supprts Remote Wakeup */
|
||||
0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
|
||||
/* 09 */
|
||||
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 0 **************/
|
||||
USBD_DFU_IF_DESC(0), /* This interface is mandatory for all devices */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 1)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 1 **************/
|
||||
USBD_DFU_IF_DESC(1),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 1) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 2)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 2 **************/
|
||||
USBD_DFU_IF_DESC(2),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 2) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 3)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 3 **************/
|
||||
USBD_DFU_IF_DESC(3),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 3) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 4)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 4 **************/
|
||||
USBD_DFU_IF_DESC(4),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 4) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 5)
|
||||
/********** Descriptor of DFU interface 0 Alternate setting 5 **************/
|
||||
USBD_DFU_IF_DESC(5),
|
||||
#endif /* (USBD_ITF_MAX_NUM > 5) */
|
||||
|
||||
#if (USBD_ITF_MAX_NUM > 6)
|
||||
#error "ERROR: usbd_dfu_core.c: Modify the file to support more descriptors!"
|
||||
#endif /* (USBD_ITF_MAX_NUM > 6) */
|
||||
|
||||
/******************** DFU Functional Descriptor********************/
|
||||
0x09, /*blength = 9 Bytes*/
|
||||
DFU_DESCRIPTOR_TYPE, /* DFU Functional Descriptor*/
|
||||
0x0B, /*bmAttribute
|
||||
bitCanDnload = 1 (bit 0)
|
||||
bitCanUpload = 1 (bit 1)
|
||||
bitManifestationTolerant = 0 (bit 2)
|
||||
bitWillDetach = 1 (bit 3)
|
||||
Reserved (bit4-6)
|
||||
bitAcceleratedST = 0 (bit 7)*/
|
||||
0xFF, /*DetachTimeOut= 255 ms*/
|
||||
0x00,
|
||||
/*WARNING: In DMA mode the multiple MPS packets feature is still not supported
|
||||
==> In this case, when using DMA XFERSIZE should be set to 64 in usbd_conf.h */
|
||||
TRANSFER_SIZE_BYTES(XFERSIZE), /* TransferSize = 1024 Byte*/
|
||||
0x1A, /* bcdDFUVersion*/
|
||||
0x01
|
||||
/***********************************************************/
|
||||
/* 9*/
|
||||
};
|
||||
#endif /* USE_USB_OTG_HS */
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
|
||||
__ALIGN_BEGIN static uint8_t usbd_dfu_Desc[USB_DFU_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
0x09, /*blength = 9 Bytes*/
|
||||
DFU_DESCRIPTOR_TYPE, /* DFU Functional Descriptor*/
|
||||
0x0B, /*bmAttribute
|
||||
bitCanDnload = 1 (bit 0)
|
||||
bitCanUpload = 1 (bit 1)
|
||||
bitManifestationTolerant = 0 (bit 2)
|
||||
bitWillDetach = 1 (bit 3)
|
||||
Reserved (bit4-6)
|
||||
bitAcceleratedST = 0 (bit 7)*/
|
||||
0xFF, /*DetachTimeOut= 255 ms*/
|
||||
0x00,
|
||||
/*WARNING: In DMA mode the multiple MPS packets feature is still not supported
|
||||
==> In this case, when using DMA XFERSIZE should be set to 64 in usbd_conf.h */
|
||||
TRANSFER_SIZE_BYTES(XFERSIZE), /* TransferSize = 1024 Byte*/
|
||||
0x1A, /* bcdDFUVersion*/
|
||||
0x01
|
||||
};
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_dfu_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief usbd_dfu_Init
|
||||
* Initializes the DFU interface.
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_dfu_Init (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
/* Initilialize the MAL(Media Access Layer) */
|
||||
MAL_Init();
|
||||
|
||||
/* Initialize the state of the DFU interface */
|
||||
DeviceState = STATE_dfuIDLE;
|
||||
DeviceStatus[0] = STATUS_OK;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_dfu_Init
|
||||
* De-initializes the DFU layer.
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_dfu_DeInit (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
/* Restore default state */
|
||||
DeviceState = STATE_dfuIDLE;
|
||||
DeviceStatus[0] = STATUS_OK;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
wBlockNum = 0;
|
||||
wlength = 0;
|
||||
|
||||
/* DeInitilialize the MAL(Media Access Layer) */
|
||||
MAL_DeInit();
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usbd_dfu_Setup
|
||||
* Handles the DFU request parsing.
|
||||
* @param pdev: instance
|
||||
* @param req: usb requests
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t usbd_dfu_Setup (void *pdev,
|
||||
USB_SETUP_REQ *req)
|
||||
{
|
||||
uint16_t len = 0;
|
||||
uint8_t *pbuf = NULL;
|
||||
|
||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||
{
|
||||
/* DFU Class Requests -------------------------------*/
|
||||
case USB_REQ_TYPE_CLASS :
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case DFU_DNLOAD:
|
||||
DFU_Req_DNLOAD(pdev, req);
|
||||
break;
|
||||
|
||||
case DFU_UPLOAD:
|
||||
DFU_Req_UPLOAD(pdev, req);
|
||||
break;
|
||||
|
||||
case DFU_GETSTATUS:
|
||||
DFU_Req_GETSTATUS(pdev);
|
||||
break;
|
||||
|
||||
case DFU_CLRSTATUS:
|
||||
DFU_Req_CLRSTATUS(pdev);
|
||||
break;
|
||||
|
||||
case DFU_GETSTATE:
|
||||
DFU_Req_GETSTATE(pdev);
|
||||
break;
|
||||
|
||||
case DFU_ABORT:
|
||||
DFU_Req_ABORT(pdev);
|
||||
break;
|
||||
|
||||
case DFU_DETACH:
|
||||
DFU_Req_DETACH(pdev, req);
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_CtlError (pdev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
/* Standard Requests -------------------------------*/
|
||||
case USB_REQ_TYPE_STANDARD:
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case USB_REQ_GET_DESCRIPTOR:
|
||||
if( (req->wValue >> 8) == DFU_DESCRIPTOR_TYPE)
|
||||
{
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
pbuf = usbd_dfu_Desc;
|
||||
#else
|
||||
pbuf = usbd_dfu_CfgDesc + 9 + (9 * USBD_ITF_MAX_NUM);
|
||||
#endif
|
||||
len = MIN(USB_DFU_DESC_SIZ , req->wLength);
|
||||
}
|
||||
|
||||
USBD_CtlSendData (pdev,
|
||||
pbuf,
|
||||
len);
|
||||
break;
|
||||
|
||||
case USB_REQ_GET_INTERFACE :
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)&usbd_dfu_AltSet,
|
||||
1);
|
||||
break;
|
||||
|
||||
case USB_REQ_SET_INTERFACE :
|
||||
if ((uint8_t)(req->wValue) < USBD_ITF_MAX_NUM)
|
||||
{
|
||||
usbd_dfu_AltSet = (uint8_t)(req->wValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the error management function (command will be nacked */
|
||||
USBD_CtlError (pdev, req);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief EP0_TxSent
|
||||
* Handles the DFU control endpoint data IN stage.
|
||||
* @param pdev: device instance
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t EP0_TxSent (void *pdev)
|
||||
{
|
||||
uint32_t Addr;
|
||||
USB_SETUP_REQ req;
|
||||
|
||||
if (DeviceState == STATE_dfuDNBUSY)
|
||||
{
|
||||
/* Decode the Special Command*/
|
||||
if (wBlockNum == 0)
|
||||
{
|
||||
if ((MAL_Buffer[0] == CMD_GETCOMMANDS) && (wlength == 1))
|
||||
{}
|
||||
else if (( MAL_Buffer[0] == CMD_SETADDRESSPOINTER ) && (wlength == 5))
|
||||
{
|
||||
Pointer = MAL_Buffer[1];
|
||||
Pointer += MAL_Buffer[2] << 8;
|
||||
Pointer += MAL_Buffer[3] << 16;
|
||||
Pointer += MAL_Buffer[4] << 24;
|
||||
}
|
||||
else if (( MAL_Buffer[0] == CMD_ERASE ) && (wlength == 5))
|
||||
{
|
||||
Pointer = MAL_Buffer[1];
|
||||
Pointer += MAL_Buffer[2] << 8;
|
||||
Pointer += MAL_Buffer[3] << 16;
|
||||
Pointer += MAL_Buffer[4] << 24;
|
||||
MAL_Erase(Pointer);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Reset the global length and block number */
|
||||
wlength = 0;
|
||||
wBlockNum = 0;
|
||||
/* Call the error management function (command will be nacked) */
|
||||
req.bmRequest = 0;
|
||||
req.wLength = 1;
|
||||
USBD_CtlError (pdev, &req);
|
||||
}
|
||||
}
|
||||
/* Regular Download Command */
|
||||
else if (wBlockNum > 1)
|
||||
{
|
||||
/* Decode the required address */
|
||||
Addr = ((wBlockNum - 2) * XFERSIZE) + Pointer;
|
||||
|
||||
/* Preform the write operation */
|
||||
MAL_Write(Addr, wlength);
|
||||
}
|
||||
/* Reset the global lenght and block number */
|
||||
wlength = 0;
|
||||
wBlockNum = 0;
|
||||
|
||||
/* Update the state machine */
|
||||
DeviceState = STATE_dfuDNLOAD_SYNC;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
return USBD_OK;
|
||||
}
|
||||
else if (DeviceState == STATE_dfuMANIFEST)/* Manifestation in progress*/
|
||||
{
|
||||
/* Start leaving DFU mode */
|
||||
DFU_LeaveDFUMode(pdev);
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief EP0_RxReady
|
||||
* Handles the DFU control endpoint data OUT stage.
|
||||
* @param pdev: device instance
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t EP0_RxReady (void *pdev)
|
||||
{
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
DFU Class requests management
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @brief DFU_Req_DETACH
|
||||
* Handles the DFU DETACH request.
|
||||
* @param pdev: device instance
|
||||
* @param req: pointer to the request structure.
|
||||
* @retval None.
|
||||
*/
|
||||
static void DFU_Req_DETACH(void *pdev, USB_SETUP_REQ *req)
|
||||
{
|
||||
if (DeviceState == STATE_dfuIDLE || DeviceState == STATE_dfuDNLOAD_SYNC
|
||||
|| DeviceState == STATE_dfuDNLOAD_IDLE || DeviceState == STATE_dfuMANIFEST_SYNC
|
||||
|| DeviceState == STATE_dfuUPLOAD_IDLE )
|
||||
{
|
||||
/* Update the state machine */
|
||||
DeviceState = STATE_dfuIDLE;
|
||||
DeviceStatus[0] = STATUS_OK;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0; /*bwPollTimeout=0ms*/
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[5] = 0; /*iString*/
|
||||
wBlockNum = 0;
|
||||
wlength = 0;
|
||||
}
|
||||
|
||||
/* Check the detach capability in the DFU functional descriptor */
|
||||
if ((usbd_dfu_CfgDesc[12 + (9 * USBD_ITF_MAX_NUM)]) & DFU_DETACH_MASK)
|
||||
{
|
||||
/* Perform an Attach-Detach operation on USB bus */
|
||||
DCD_DevDisconnect (pdev);
|
||||
DCD_DevConnect (pdev);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wait for the period of time specified in Detach request */
|
||||
USB_OTG_BSP_mDelay (req->wValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DFU_Req_DNLOAD
|
||||
* Handles the DFU DNLOAD request.
|
||||
* @param pdev: device instance
|
||||
* @param req: pointer to the request structure
|
||||
* @retval None
|
||||
*/
|
||||
static void DFU_Req_DNLOAD(void *pdev, USB_SETUP_REQ *req)
|
||||
{
|
||||
/* Data setup request */
|
||||
if (req->wLength > 0)
|
||||
{
|
||||
if ((DeviceState == STATE_dfuIDLE) || (DeviceState == STATE_dfuDNLOAD_IDLE))
|
||||
{
|
||||
/* Update the global length and block number */
|
||||
wBlockNum = req->wValue;
|
||||
wlength = req->wLength;
|
||||
|
||||
/* Update the state machine */
|
||||
DeviceState = STATE_dfuDNLOAD_SYNC;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
|
||||
/* Prepare the reception of the buffer over EP0 */
|
||||
USBD_CtlPrepareRx (pdev,
|
||||
(uint8_t*)MAL_Buffer,
|
||||
wlength);
|
||||
}
|
||||
/* Unsupported state */
|
||||
else
|
||||
{
|
||||
/* Call the error management function (command will be nacked */
|
||||
USBD_CtlError (pdev, req);
|
||||
}
|
||||
}
|
||||
/* 0 Data DNLOAD request */
|
||||
else
|
||||
{
|
||||
/* End of DNLOAD operation*/
|
||||
if (DeviceState == STATE_dfuDNLOAD_IDLE || DeviceState == STATE_dfuIDLE )
|
||||
{
|
||||
Manifest_State = Manifest_In_Progress;
|
||||
DeviceState = STATE_dfuMANIFEST_SYNC;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the error management function (command will be nacked */
|
||||
USBD_CtlError (pdev, req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DFU_Req_UPLOAD
|
||||
* Handles the DFU UPLOAD request.
|
||||
* @param pdev: instance
|
||||
* @param req: pointer to the request structure
|
||||
* @retval status
|
||||
*/
|
||||
static void DFU_Req_UPLOAD(void *pdev, USB_SETUP_REQ *req)
|
||||
{
|
||||
uint8_t *Phy_Addr = NULL;
|
||||
uint32_t Addr = 0;
|
||||
|
||||
/* Data setup request */
|
||||
if (req->wLength > 0)
|
||||
{
|
||||
if ((DeviceState == STATE_dfuIDLE) || (DeviceState == STATE_dfuUPLOAD_IDLE))
|
||||
{
|
||||
/* Update the global langth and block number */
|
||||
wBlockNum = req->wValue;
|
||||
wlength = req->wLength;
|
||||
|
||||
/* DFU Get Command */
|
||||
if (wBlockNum == 0)
|
||||
{
|
||||
/* Update the state machine */
|
||||
DeviceState = (wlength > 3)? STATE_dfuIDLE:STATE_dfuUPLOAD_IDLE;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
|
||||
/* Store the values of all supported commands */
|
||||
MAL_Buffer[0] = CMD_GETCOMMANDS;
|
||||
MAL_Buffer[1] = CMD_SETADDRESSPOINTER;
|
||||
MAL_Buffer[2] = CMD_ERASE;
|
||||
|
||||
/* Send the status data over EP0 */
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)(&(MAL_Buffer[0])),
|
||||
3);
|
||||
}
|
||||
else if (wBlockNum > 1)
|
||||
{
|
||||
DeviceState = STATE_dfuUPLOAD_IDLE ;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
Addr = ((wBlockNum - 2) * XFERSIZE) + Pointer; /* Change is Accelerated*/
|
||||
|
||||
/* Return the physical address where data are stored */
|
||||
Phy_Addr = MAL_Read(Addr, wlength);
|
||||
|
||||
/* Send the status data over EP0 */
|
||||
USBD_CtlSendData (pdev,
|
||||
Phy_Addr,
|
||||
wlength);
|
||||
}
|
||||
else /* unsupported wBlockNum */
|
||||
{
|
||||
DeviceState = STATUS_ERRSTALLEDPKT;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
|
||||
/* Call the error management function (command will be nacked */
|
||||
USBD_CtlError (pdev, req);
|
||||
}
|
||||
}
|
||||
/* Unsupported state */
|
||||
else
|
||||
{
|
||||
wlength = 0;
|
||||
wBlockNum = 0;
|
||||
/* Call the error management function (command will be nacked */
|
||||
USBD_CtlError (pdev, req);
|
||||
}
|
||||
}
|
||||
/* No Data setup request */
|
||||
else
|
||||
{
|
||||
DeviceState = STATE_dfuIDLE;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DFU_Req_GETSTATUS
|
||||
* Handles the DFU GETSTATUS request.
|
||||
* @param pdev: instance
|
||||
* @retval status
|
||||
*/
|
||||
static void DFU_Req_GETSTATUS(void *pdev)
|
||||
{
|
||||
switch (DeviceState)
|
||||
{
|
||||
case STATE_dfuDNLOAD_SYNC:
|
||||
if (wlength != 0)
|
||||
{
|
||||
DeviceState = STATE_dfuDNBUSY;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
if ((wBlockNum == 0) && (MAL_Buffer[0] == CMD_ERASE))
|
||||
{
|
||||
MAL_GetStatus(Pointer, 0, DeviceStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAL_GetStatus(Pointer, 1, DeviceStatus);
|
||||
}
|
||||
}
|
||||
else /* (wlength==0)*/
|
||||
{
|
||||
DeviceState = STATE_dfuDNLOAD_IDLE;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_dfuMANIFEST_SYNC :
|
||||
if (Manifest_State == Manifest_In_Progress)
|
||||
{
|
||||
DeviceState = STATE_dfuMANIFEST;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[1] = 1; /*bwPollTimeout = 1ms*/
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
//break;
|
||||
}
|
||||
else if ((Manifest_State == Manifest_complete) && \
|
||||
((usbd_dfu_CfgDesc[(11 + (9 * USBD_ITF_MAX_NUM))]) & 0x04))
|
||||
{
|
||||
DeviceState = STATE_dfuIDLE;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
//break;
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
/* Send the status data over EP0 */
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)(&(DeviceStatus[0])),
|
||||
6);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DFU_Req_CLRSTATUS
|
||||
* Handles the DFU CLRSTATUS request.
|
||||
* @param pdev: device instance
|
||||
* @retval status
|
||||
*/
|
||||
static void DFU_Req_CLRSTATUS(void *pdev)
|
||||
{
|
||||
if (DeviceState == STATE_dfuERROR)
|
||||
{
|
||||
DeviceState = STATE_dfuIDLE;
|
||||
DeviceStatus[0] = STATUS_OK;/*bStatus*/
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0; /*bwPollTimeout=0ms*/
|
||||
DeviceStatus[4] = DeviceState;/*bState*/
|
||||
DeviceStatus[5] = 0;/*iString*/
|
||||
}
|
||||
else
|
||||
{ /*State Error*/
|
||||
DeviceState = STATE_dfuERROR;
|
||||
DeviceStatus[0] = STATUS_ERRUNKNOWN;/*bStatus*/
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0; /*bwPollTimeout=0ms*/
|
||||
DeviceStatus[4] = DeviceState;/*bState*/
|
||||
DeviceStatus[5] = 0;/*iString*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DFU_Req_GETSTATE
|
||||
* Handles the DFU GETSTATE request.
|
||||
* @param pdev: device instance
|
||||
* @retval None
|
||||
*/
|
||||
static void DFU_Req_GETSTATE(void *pdev)
|
||||
{
|
||||
/* Return the current state of the DFU interface */
|
||||
USBD_CtlSendData (pdev,
|
||||
&DeviceState,
|
||||
1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DFU_Req_ABORT
|
||||
* Handles the DFU ABORT request.
|
||||
* @param pdev: device instance
|
||||
* @retval None
|
||||
*/
|
||||
static void DFU_Req_ABORT(void *pdev)
|
||||
{
|
||||
if (DeviceState == STATE_dfuIDLE || DeviceState == STATE_dfuDNLOAD_SYNC
|
||||
|| DeviceState == STATE_dfuDNLOAD_IDLE || DeviceState == STATE_dfuMANIFEST_SYNC
|
||||
|| DeviceState == STATE_dfuUPLOAD_IDLE )
|
||||
{
|
||||
DeviceState = STATE_dfuIDLE;
|
||||
DeviceStatus[0] = STATUS_OK;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0; /*bwPollTimeout=0ms*/
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[5] = 0; /*iString*/
|
||||
wBlockNum = 0;
|
||||
wlength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DFU_LeaveDFUMode
|
||||
* Handles the sub-protocol DFU leave DFU mode request (leaves DFU mode
|
||||
* and resets device to jump to user loaded code).
|
||||
* @param pdev: device instance
|
||||
* @retval None
|
||||
*/
|
||||
void DFU_LeaveDFUMode(void *pdev)
|
||||
{
|
||||
Manifest_State = Manifest_complete;
|
||||
|
||||
if ((usbd_dfu_CfgDesc[(11 + (9 * USBD_ITF_MAX_NUM))]) & 0x04)
|
||||
{
|
||||
DeviceState = STATE_dfuMANIFEST_SYNC;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceState = STATE_dfuMANIFEST_WAIT_RESET;
|
||||
DeviceStatus[4] = DeviceState;
|
||||
DeviceStatus[1] = 0;
|
||||
DeviceStatus[2] = 0;
|
||||
DeviceStatus[3] = 0;
|
||||
|
||||
/* Disconnect the USB device */
|
||||
DCD_DevDisconnect (pdev);
|
||||
|
||||
/* DeInitilialize the MAL(Media Access Layer) */
|
||||
MAL_DeInit();
|
||||
|
||||
/* Generate system reset to allow jumping to the user code */
|
||||
NVIC_SystemReset();
|
||||
|
||||
/* This instruction will not be reached (system reset) */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_DFU_GetCfgDesc
|
||||
* Returns configuration descriptor
|
||||
* @param speed : current device speed
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
static uint8_t *USBD_DFU_GetCfgDesc (uint8_t speed, uint16_t *length)
|
||||
{
|
||||
*length = sizeof (usbd_dfu_CfgDesc);
|
||||
return usbd_dfu_CfgDesc;
|
||||
}
|
||||
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
/**
|
||||
* @brief USBD_DFU_GetOtherCfgDesc
|
||||
* Returns other speed configuration descriptor.
|
||||
* @param speed : current device speed
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
static uint8_t *USBD_DFU_GetOtherCfgDesc (uint8_t speed, uint16_t *length)
|
||||
{
|
||||
*length = sizeof (usbd_dfu_OtherCfgDesc);
|
||||
return usbd_dfu_OtherCfgDesc;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief USBD_DFU_GetUsrStringDesc
|
||||
* Manages the transfer of memory interfaces string descriptors.
|
||||
* @param speed : current device speed
|
||||
* @param index: desciptor index
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to the descriptor table or NULL if the descriptor is not supported.
|
||||
*/
|
||||
static uint8_t* USBD_DFU_GetUsrStringDesc (uint8_t speed, uint8_t index , uint16_t *length)
|
||||
{
|
||||
/* Check if the requested string interface is supported */
|
||||
if (index <= (USBD_IDX_INTERFACE_STR + USBD_ITF_MAX_NUM))
|
||||
{
|
||||
|
||||
|
||||
USBD_GetString ((uint8_t *)usbd_dfu_StringDesc[index - USBD_IDX_INTERFACE_STR - 1], USBD_StrDesc, length);
|
||||
return USBD_StrDesc;
|
||||
}
|
||||
/* Not supported Interface Descriptor index */
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,287 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_dfu_mal.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Generic media access Layer.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_dfu_mal.h"
|
||||
|
||||
#include "usbd_flash_if.h"
|
||||
|
||||
#ifdef DFU_MAL_SUPPORT_OTP
|
||||
#include "usbd_otp_if.h"
|
||||
#endif
|
||||
|
||||
#ifdef DFU_MAL_SUPPORT_MEM
|
||||
#include "usbd_mem_if_template.h"
|
||||
#endif
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Global Memories callback and string descriptors reference tables.
|
||||
To add a new memory, modify the value of MAX_USED_MEDIA in usbd_dfu_mal.h
|
||||
and add the pointer to the callback structure in this table.
|
||||
Then add the pointer to the memory string descriptor in usbd_dfu_StringDesc table.
|
||||
No other operation is required. */
|
||||
DFU_MAL_Prop_TypeDef* tMALTab[MAX_USED_MEDIA] = {
|
||||
&DFU_Flash_cb
|
||||
#ifdef DFU_MAL_SUPPORT_OTP
|
||||
, &DFU_Otp_cb
|
||||
#endif
|
||||
#ifdef DFU_MAL_SUPPORT_MEM
|
||||
, &DFU_Mem_cb
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
|
||||
__ALIGN_BEGIN const uint8_t* usbd_dfu_StringDesc[MAX_USED_MEDIA] __ALIGN_END = {
|
||||
FLASH_IF_STRING
|
||||
#ifdef DFU_MAL_SUPPORT_OTP
|
||||
, OTP_IF_STRING
|
||||
#endif
|
||||
#ifdef DFU_MAL_SUPPORT_MEM
|
||||
, MEM_IF_STRING
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
/* RAM Buffer for Downloaded Data */
|
||||
__ALIGN_BEGIN uint8_t MAL_Buffer[XFERSIZE] __ALIGN_END ;
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static uint8_t MAL_CheckAdd (uint32_t Add);
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief MAL_Init
|
||||
* Initializes the Media on the STM32
|
||||
* @param None
|
||||
* @retval Result of the opeartion (MAL_OK in all cases)
|
||||
*/
|
||||
uint16_t MAL_Init(void)
|
||||
{
|
||||
uint32_t memIdx = 0;
|
||||
|
||||
/* Init all supported memories */
|
||||
for(memIdx = 0; memIdx < MAX_USED_MEDIA; memIdx++)
|
||||
{
|
||||
/* If the check addres is positive, exit with the memory index */
|
||||
if (tMALTab[memIdx]->pMAL_Init != NULL)
|
||||
{
|
||||
tMALTab[memIdx]->pMAL_Init();
|
||||
}
|
||||
}
|
||||
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MAL_DeInit
|
||||
* DeInitializes the Media on the STM32
|
||||
* @param None
|
||||
* @retval Result of the opeartion (MAL_OK in all cases)
|
||||
*/
|
||||
uint16_t MAL_DeInit(void)
|
||||
{
|
||||
uint32_t memIdx = 0;
|
||||
|
||||
/* Init all supported memories */
|
||||
for(memIdx = 0; memIdx < MAX_USED_MEDIA; memIdx++)
|
||||
{
|
||||
/* Check if the command is supported */
|
||||
if (tMALTab[memIdx]->pMAL_DeInit != NULL)
|
||||
{
|
||||
tMALTab[memIdx]->pMAL_DeInit();
|
||||
}
|
||||
}
|
||||
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MAL_Erase
|
||||
* Erase a sector of memory.
|
||||
* @param Add: Sector address/code
|
||||
* @retval Result of the opeartion: MAL_OK if all operations are OK else MAL_FAIL
|
||||
*/
|
||||
uint16_t MAL_Erase(uint32_t Add)
|
||||
{
|
||||
uint32_t memIdx = MAL_CheckAdd(Add);
|
||||
|
||||
/* Check if the area is protected */
|
||||
if (DFU_MAL_IS_PROTECTED_AREA(Add))
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
|
||||
if (memIdx < MAX_USED_MEDIA)
|
||||
{
|
||||
/* Check if the command is supported */
|
||||
if (tMALTab[memIdx]->pMAL_Erase != NULL)
|
||||
{
|
||||
return tMALTab[memIdx]->pMAL_Erase(Add);
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MAL_Write
|
||||
* Write sectors of memory.
|
||||
* @param Add: Sector address/code
|
||||
* @param Len: Number of data to be written (in bytes)
|
||||
* @retval Result of the opeartion: MAL_OK if all operations are OK else MAL_FAIL
|
||||
*/
|
||||
uint16_t MAL_Write (uint32_t Add, uint32_t Len)
|
||||
{
|
||||
uint32_t memIdx = MAL_CheckAdd(Add);
|
||||
|
||||
/* Check if the area is protected */
|
||||
if (DFU_MAL_IS_PROTECTED_AREA(Add))
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
|
||||
if (memIdx < MAX_USED_MEDIA)
|
||||
{
|
||||
/* Check if the command is supported */
|
||||
if (tMALTab[memIdx]->pMAL_Write != NULL)
|
||||
{
|
||||
return tMALTab[memIdx]->pMAL_Write(Add, Len);
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MAL_Read
|
||||
* Read sectors of memory.
|
||||
* @param Add: Sector address/code
|
||||
* @param Len: Number of data to be written (in bytes)
|
||||
* @retval Buffer pointer
|
||||
*/
|
||||
uint8_t *MAL_Read (uint32_t Add, uint32_t Len)
|
||||
{
|
||||
uint32_t memIdx = MAL_CheckAdd(Add);
|
||||
|
||||
if (memIdx < MAX_USED_MEDIA)
|
||||
{
|
||||
/* Check if the command is supported */
|
||||
if (tMALTab[memIdx]->pMAL_Read != NULL)
|
||||
{
|
||||
return tMALTab[memIdx]->pMAL_Read(Add, Len);
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_Buffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_Buffer;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MAL_GetStatus
|
||||
* Get the status of a given memory.
|
||||
* @param Add: Sector address/code (allow to determine which memory will be addressed)
|
||||
* @param Cmd: 0 for erase and 1 for write
|
||||
* @param buffer: pointer to the buffer where the status data will be stored.
|
||||
* @retval Buffer pointer
|
||||
*/
|
||||
uint16_t MAL_GetStatus(uint32_t Add , uint8_t Cmd, uint8_t *buffer)
|
||||
{
|
||||
uint32_t memIdx = MAL_CheckAdd(Add);
|
||||
|
||||
if (memIdx < MAX_USED_MEDIA)
|
||||
{
|
||||
if (Cmd & 0x01)
|
||||
{
|
||||
SET_POLLING_TIMING(tMALTab[memIdx]->EraseTiming);
|
||||
}
|
||||
else
|
||||
{
|
||||
SET_POLLING_TIMING(tMALTab[memIdx]->WriteTiming);
|
||||
}
|
||||
|
||||
return MAL_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MAL_CheckAdd
|
||||
* Determine which memory should be managed.
|
||||
* @param Add: Sector address/code (allow to determine which memory will be addressed)
|
||||
* @retval Index of the addressed memory.
|
||||
*/
|
||||
static uint8_t MAL_CheckAdd(uint32_t Add)
|
||||
{
|
||||
uint32_t memIdx = 0;
|
||||
|
||||
/* Check with all supported memories */
|
||||
for(memIdx = 0; memIdx < MAX_USED_MEDIA; memIdx++)
|
||||
{
|
||||
/* If the check addres is positive, exit with the memory index */
|
||||
if (tMALTab[memIdx]->pMAL_CheckAdd(Add) == MAL_OK)
|
||||
{
|
||||
return memIdx;
|
||||
}
|
||||
}
|
||||
/* If no memory found, return MAX_USED_MEDIA */
|
||||
return (MAX_USED_MEDIA);
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,227 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_flash_if.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Specific media access Layer for internal flash.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_flash_if.h"
|
||||
#include "usbd_dfu_mal.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
uint16_t FLASH_If_Init(void);
|
||||
uint16_t FLASH_If_Erase (uint32_t Add);
|
||||
uint16_t FLASH_If_Write (uint32_t Add, uint32_t Len);
|
||||
uint8_t *FLASH_If_Read (uint32_t Add, uint32_t Len);
|
||||
uint16_t FLASH_If_DeInit(void);
|
||||
uint16_t FLASH_If_CheckAdd(uint32_t Add);
|
||||
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
DFU_MAL_Prop_TypeDef DFU_Flash_cb =
|
||||
{
|
||||
FLASH_IF_STRING,
|
||||
FLASH_If_Init,
|
||||
FLASH_If_DeInit,
|
||||
FLASH_If_Erase,
|
||||
FLASH_If_Write,
|
||||
FLASH_If_Read,
|
||||
FLASH_If_CheckAdd,
|
||||
50, /* Erase Time in ms */
|
||||
50 /* Programming Time in ms */
|
||||
};
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief FLASH_If_Init
|
||||
* Memory initialization routine.
|
||||
* @param None
|
||||
* @retval MAL_OK if operation is successeful, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t FLASH_If_Init(void)
|
||||
{
|
||||
/* Unlock the internal flash */
|
||||
FLASH_Unlock();
|
||||
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FLASH_If_DeInit
|
||||
* Memory deinitialization routine.
|
||||
* @param None
|
||||
* @retval MAL_OK if operation is successeful, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t FLASH_If_DeInit(void)
|
||||
{
|
||||
/* Lock the internal flash */
|
||||
FLASH_Lock();
|
||||
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : FLASH_If_Erase
|
||||
* Description : Erase sector
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint16_t FLASH_If_Erase(uint32_t Add)
|
||||
{
|
||||
#if defined (STM32F2XX) || defined (STM32F4XX)
|
||||
/* Check which sector has to be erased */
|
||||
if (Add < 0x08004000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_0, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x08008000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_1, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x0800C000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_2, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x08010000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_3, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x08020000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_4, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x08040000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_5, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x08060000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_6, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x08080000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_7, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x080A0000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_8, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x080C0000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_9, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x080E0000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_10, VoltageRange_3);
|
||||
}
|
||||
else if (Add < 0x08100000)
|
||||
{
|
||||
FLASH_EraseSector(FLASH_Sector_11, VoltageRange_3);
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
#elif defined(STM32F10X_CL)
|
||||
/* Call the standard Flash erase function */
|
||||
FLASH_ErasePage(Add);
|
||||
#endif /* STM32F2XX */
|
||||
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FLASH_If_Write
|
||||
* Memory write routine.
|
||||
* @param Add: Address to be written to.
|
||||
* @param Len: Number of data to be written (in bytes).
|
||||
* @retval MAL_OK if operation is successeful, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t FLASH_If_Write(uint32_t Add, uint32_t Len)
|
||||
{
|
||||
uint32_t idx = 0;
|
||||
|
||||
if (Len & 0x3) /* Not an aligned data */
|
||||
{
|
||||
for (idx = Len; idx < ((Len & 0xFFFC) + 4); idx++)
|
||||
{
|
||||
MAL_Buffer[idx] = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
/* Data received are Word multiple */
|
||||
for (idx = 0; idx < Len; idx = idx + 4)
|
||||
{
|
||||
FLASH_ProgramWord(Add, *(uint32_t *)(MAL_Buffer + idx));
|
||||
Add += 4;
|
||||
}
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FLASH_If_Read
|
||||
* Memory read routine.
|
||||
* @param Add: Address to be read from.
|
||||
* @param Len: Number of data to be read (in bytes).
|
||||
* @retval Pointer to the phyisical address where data should be read.
|
||||
*/
|
||||
uint8_t *FLASH_If_Read (uint32_t Add, uint32_t Len)
|
||||
{
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
uint32_t idx = 0;
|
||||
for (idx = 0; idx < Len; idx += 4)
|
||||
{
|
||||
*(uint32_t*)(MAL_Buffer + idx) = *(uint32_t *)(Add + idx);
|
||||
}
|
||||
return (uint8_t*)(MAL_Buffer);
|
||||
#else
|
||||
return (uint8_t *)(Add);
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FLASH_If_CheckAdd
|
||||
* Check if the address is an allowed address for this memory.
|
||||
* @param Add: Address to be checked.
|
||||
* @param Len: Number of data to be read (in bytes).
|
||||
* @retval MAL_OK if the address is allowed, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t FLASH_If_CheckAdd(uint32_t Add)
|
||||
{
|
||||
if ((Add >= FLASH_START_ADD) && (Add < FLASH_END_ADD))
|
||||
{
|
||||
return MAL_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
}
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,139 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_mem_if_template.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Specific media access Layer for a template memory. This file is
|
||||
provided as template example showing how to implement a new memory
|
||||
interface based on pre-defined API.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_mem_if_template.h"
|
||||
#include "usbd_dfu_mal.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
uint16_t MEM_If_Init(void);
|
||||
uint16_t MEM_If_Erase (uint32_t Add);
|
||||
uint16_t MEM_If_Write (uint32_t Add, uint32_t Len);
|
||||
uint8_t *MEM_If_Read (uint32_t Add, uint32_t Len);
|
||||
uint16_t MEM_If_DeInit(void);
|
||||
uint16_t MEM_If_CheckAdd(uint32_t Add);
|
||||
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
DFU_MAL_Prop_TypeDef DFU_Mem_cb =
|
||||
{
|
||||
MEM_IF_STRING,
|
||||
MEM_If_Init,
|
||||
MEM_If_DeInit,
|
||||
MEM_If_Erase,
|
||||
MEM_If_Write,
|
||||
MEM_If_Read,
|
||||
MEM_If_CheckAdd,
|
||||
10, /* Erase Time in ms */
|
||||
10 /* Programming Time in ms */
|
||||
};
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief MEM_If_Init
|
||||
* Memory initialization routine.
|
||||
* @param None
|
||||
* @retval MAL_OK if operation is successeful, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t MEM_If_Init(void)
|
||||
{
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MEM_If_DeInit
|
||||
* Memory deinitialization routine.
|
||||
* @param None
|
||||
* @retval MAL_OK if operation is successeful, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t MEM_If_DeInit(void)
|
||||
{
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MEM_If_Erase
|
||||
* Erase sector.
|
||||
* @param Add: Address of sector to be erased.
|
||||
* @retval MAL_OK if operation is successeful, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t MEM_If_Erase(uint32_t Add)
|
||||
{
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MEM_If_Write
|
||||
* Memory write routine.
|
||||
* @param Add: Address to be written to.
|
||||
* @param Len: Number of data to be written (in bytes).
|
||||
* @retval MAL_OK if operation is successeful, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t MEM_If_Write(uint32_t Add, uint32_t Len)
|
||||
{
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MEM_If_Read
|
||||
* Memory read routine.
|
||||
* @param Add: Address to be read from.
|
||||
* @param Len: Number of data to be read (in bytes).
|
||||
* @retval Pointer to the phyisical address where data should be read.
|
||||
*/
|
||||
uint8_t *MEM_If_Read (uint32_t Add, uint32_t Len)
|
||||
{
|
||||
/* Return a valid address to avoid HardFault */
|
||||
return (uint8_t*)(MAL_Buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MEM_If_CheckAdd
|
||||
* Check if the address is an allowed address for this memory.
|
||||
* @param Add: Address to be checked.
|
||||
* @param Len: Number of data to be read (in bytes).
|
||||
* @retval MAL_OK if the address is allowed, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t MEM_If_CheckAdd(uint32_t Add)
|
||||
{
|
||||
if ((Add >= MEM_START_ADD) && (Add < MEM_END_ADD))
|
||||
{
|
||||
return MAL_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
}
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,126 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_otp_if.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Specific media access Layer for OTP (One Time Programming) memory.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_otp_if.h"
|
||||
#include "usbd_dfu_mal.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
uint16_t OTP_If_Write (uint32_t Add, uint32_t Len);
|
||||
uint8_t *OTP_If_Read (uint32_t Add, uint32_t Len);
|
||||
uint16_t OTP_If_DeInit(void);
|
||||
uint16_t OTP_If_CheckAdd(uint32_t Add);
|
||||
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
DFU_MAL_Prop_TypeDef DFU_Otp_cb =
|
||||
{
|
||||
OTP_IF_STRING,
|
||||
NULL, /* Init not supported*/
|
||||
NULL, /* DeInit not supported */
|
||||
NULL, /* Erase not supported */
|
||||
OTP_If_Write,
|
||||
OTP_If_Read,
|
||||
OTP_If_CheckAdd,
|
||||
1, /* Erase Time in ms */
|
||||
10 /* Programming Time in ms */
|
||||
};
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief OTP_If_Write
|
||||
* Memory write routine.
|
||||
* @param Add: Address to be written to.
|
||||
* @param Len: Number of data to be written (in bytes).
|
||||
* @retval MAL_OK if operation is successeful, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t OTP_If_Write(uint32_t Add, uint32_t Len)
|
||||
{
|
||||
uint32_t idx = 0;
|
||||
|
||||
if (Len & 0x3) /* Not an aligned data */
|
||||
{
|
||||
for (idx = Len; idx < ((Len & 0xFFFC) + 4); idx++)
|
||||
{
|
||||
MAL_Buffer[idx] = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
/* Data received are Word multiple */
|
||||
for (idx = 0; idx < Len; idx = idx + 4)
|
||||
{
|
||||
FLASH_ProgramWord(Add, *(uint32_t *)(MAL_Buffer + idx));
|
||||
Add += 4;
|
||||
}
|
||||
return MAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OTP_If_Read
|
||||
* Memory read routine.
|
||||
* @param Add: Address to be read from.
|
||||
* @param Len: Number of data to be read (in bytes).
|
||||
* @retval Pointer to the phyisical address where data should be read.
|
||||
*/
|
||||
uint8_t *OTP_If_Read (uint32_t Add, uint32_t Len)
|
||||
{
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
uint32_t idx = 0;
|
||||
for (idx = 0; idx < Len; idx += 4)
|
||||
{
|
||||
*(uint32_t*)(MAL_Buffer + idx) = *(uint32_t *)(Add + idx);
|
||||
}
|
||||
return (uint8_t*)(MAL_Buffer);
|
||||
#else
|
||||
return (uint8_t*)(Add);
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OTP_If_CheckAdd
|
||||
* Check if the address is an allowed address for this memory.
|
||||
* @param Add: Address to be checked.
|
||||
* @param Len: Number of data to be read (in bytes).
|
||||
* @retval MAL_OK if the address is allowed, MAL_FAIL else.
|
||||
*/
|
||||
uint16_t OTP_If_CheckAdd(uint32_t Add)
|
||||
{
|
||||
if ((Add >= OTP_START_ADD) && (Add < OTP_END_ADD))
|
||||
{
|
||||
return MAL_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAL_FAIL;
|
||||
}
|
||||
}
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,116 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_hid_core.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header file for the usbd_hid_core.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USB_HID_CORE_H_
|
||||
#define __USB_HID_CORE_H_
|
||||
|
||||
#include "usbd_ioreq.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_HID
|
||||
* @brief This file is the Header file for USBD_msc.c
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_HID_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#define USB_HID_CONFIG_DESC_SIZ 34
|
||||
#define USB_HID_DESC_SIZ 9
|
||||
#define HID_MOUSE_REPORT_DESC_SIZE 74
|
||||
|
||||
#define HID_DESCRIPTOR_TYPE 0x21
|
||||
#define HID_REPORT_DESC 0x22
|
||||
|
||||
|
||||
#define HID_REQ_SET_PROTOCOL 0x0B
|
||||
#define HID_REQ_GET_PROTOCOL 0x03
|
||||
|
||||
#define HID_REQ_SET_IDLE 0x0A
|
||||
#define HID_REQ_GET_IDLE 0x02
|
||||
|
||||
#define HID_REQ_SET_REPORT 0x09
|
||||
#define HID_REQ_GET_REPORT 0x01
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern USBD_Class_cb_TypeDef USBD_HID_cb;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CORE_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t USBD_HID_SendReport (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t *report,
|
||||
uint16_t len);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif // __USB_HID_CORE_H_
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,487 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_hid_core.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides the HID core functions.
|
||||
*
|
||||
* @verbatim
|
||||
*
|
||||
* ===================================================================
|
||||
* HID Class Description
|
||||
* ===================================================================
|
||||
* This module manages the HID class V1.11 following the "Device Class Definition
|
||||
* for Human Interface Devices (HID) Version 1.11 Jun 27, 2001".
|
||||
* This driver implements the following aspects of the specification:
|
||||
* - The Boot Interface Subclass
|
||||
* - The Mouse protocol
|
||||
* - Usage Page : Generic Desktop
|
||||
* - Usage : Joystick)
|
||||
* - Collection : Application
|
||||
*
|
||||
* @note In HS mode and when the DMA is used, all variables and data structures
|
||||
* dealing with the DMA during the transaction process should be 32-bit aligned.
|
||||
*
|
||||
*
|
||||
* @endverbatim
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_hid_core.h"
|
||||
#include "usbd_desc.h"
|
||||
#include "usbd_req.h"
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_HID
|
||||
* @brief usbd core module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_HID_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_HID_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_HID_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_HID_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
static uint8_t USBD_HID_Init (void *pdev,
|
||||
uint8_t cfgidx);
|
||||
|
||||
static uint8_t USBD_HID_DeInit (void *pdev,
|
||||
uint8_t cfgidx);
|
||||
|
||||
static uint8_t USBD_HID_Setup (void *pdev,
|
||||
USB_SETUP_REQ *req);
|
||||
|
||||
static uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length);
|
||||
|
||||
static uint8_t USBD_HID_DataIn (void *pdev, uint8_t epnum);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_HID_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
USBD_Class_cb_TypeDef USBD_HID_cb =
|
||||
{
|
||||
USBD_HID_Init,
|
||||
USBD_HID_DeInit,
|
||||
USBD_HID_Setup,
|
||||
NULL, /*EP0_TxSent*/
|
||||
NULL, /*EP0_RxReady*/
|
||||
USBD_HID_DataIn, /*DataIn*/
|
||||
NULL, /*DataOut*/
|
||||
NULL, /*SOF */
|
||||
NULL,
|
||||
NULL,
|
||||
USBD_HID_GetCfgDesc,
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
USBD_HID_GetCfgDesc, /* use same config as per FS */
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static uint32_t USBD_HID_AltSet __ALIGN_END = 0;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static uint32_t USBD_HID_Protocol __ALIGN_END = 0;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static uint32_t USBD_HID_IdleState __ALIGN_END = 0;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
/* USB HID device Configuration Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
0x09, /* bLength: Configuration Descriptor size */
|
||||
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
|
||||
USB_HID_CONFIG_DESC_SIZ,
|
||||
/* wTotalLength: Bytes returned */
|
||||
0x00,
|
||||
0x01, /*bNumInterfaces: 1 interface*/
|
||||
0x01, /*bConfigurationValue: Configuration value*/
|
||||
0x00, /*iConfiguration: Index of string descriptor describing
|
||||
the configuration*/
|
||||
0xE0, /*bmAttributes: bus powered and Support Remote Wake-up */
|
||||
0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
|
||||
|
||||
/************** Descriptor of Joystick Mouse interface ****************/
|
||||
/* 09 */
|
||||
0x09, /*bLength: Interface Descriptor size*/
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/
|
||||
0x00, /*bInterfaceNumber: Number of Interface*/
|
||||
0x00, /*bAlternateSetting: Alternate setting*/
|
||||
0x01, /*bNumEndpoints*/
|
||||
0x03, /*bInterfaceClass: HID*/
|
||||
0x01, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
|
||||
0x02, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
|
||||
0, /*iInterface: Index of string descriptor*/
|
||||
/******************** Descriptor of Joystick Mouse HID ********************/
|
||||
/* 18 */
|
||||
0x09, /*bLength: HID Descriptor size*/
|
||||
HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
|
||||
0x11, /*bcdHID: HID Class Spec release number*/
|
||||
0x01,
|
||||
0x00, /*bCountryCode: Hardware target country*/
|
||||
0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
|
||||
0x22, /*bDescriptorType*/
|
||||
HID_MOUSE_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/
|
||||
0x00,
|
||||
/******************** Descriptor of Mouse endpoint ********************/
|
||||
/* 27 */
|
||||
0x07, /*bLength: Endpoint Descriptor size*/
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
|
||||
|
||||
HID_IN_EP, /*bEndpointAddress: Endpoint Address (IN)*/
|
||||
0x03, /*bmAttributes: Interrupt endpoint*/
|
||||
HID_IN_PACKET, /*wMaxPacketSize: 4 Byte max */
|
||||
0x00,
|
||||
0x0A, /*bInterval: Polling Interval (10 ms)*/
|
||||
/* 34 */
|
||||
} ;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
/* USB HID device Configuration Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_HID_Desc[USB_HID_DESC_SIZ] __ALIGN_END=
|
||||
{
|
||||
/* 18 */
|
||||
0x09, /*bLength: HID Descriptor size*/
|
||||
HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
|
||||
0x11, /*bcdHID: HID Class Spec release number*/
|
||||
0x01,
|
||||
0x00, /*bCountryCode: Hardware target country*/
|
||||
0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
|
||||
0x22, /*bDescriptorType*/
|
||||
HID_MOUSE_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/
|
||||
0x00,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END =
|
||||
{
|
||||
0x05, 0x01,
|
||||
0x09, 0x02,
|
||||
0xA1, 0x01,
|
||||
0x09, 0x01,
|
||||
|
||||
0xA1, 0x00,
|
||||
0x05, 0x09,
|
||||
0x19, 0x01,
|
||||
0x29, 0x03,
|
||||
|
||||
0x15, 0x00,
|
||||
0x25, 0x01,
|
||||
0x95, 0x03,
|
||||
0x75, 0x01,
|
||||
|
||||
0x81, 0x02,
|
||||
0x95, 0x01,
|
||||
0x75, 0x05,
|
||||
0x81, 0x01,
|
||||
|
||||
0x05, 0x01,
|
||||
0x09, 0x30,
|
||||
0x09, 0x31,
|
||||
0x09, 0x38,
|
||||
|
||||
0x15, 0x81,
|
||||
0x25, 0x7F,
|
||||
0x75, 0x08,
|
||||
0x95, 0x03,
|
||||
|
||||
0x81, 0x06,
|
||||
0xC0, 0x09,
|
||||
0x3c, 0x05,
|
||||
0xff, 0x09,
|
||||
|
||||
0x01, 0x15,
|
||||
0x00, 0x25,
|
||||
0x01, 0x75,
|
||||
0x01, 0x95,
|
||||
|
||||
0x02, 0xb1,
|
||||
0x22, 0x75,
|
||||
0x06, 0x95,
|
||||
0x01, 0xb1,
|
||||
|
||||
0x01, 0xc0
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_HID_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_Init
|
||||
* Initialize the HID interface
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_HID_Init (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
|
||||
/* Open EP IN */
|
||||
DCD_EP_Open(pdev,
|
||||
HID_IN_EP,
|
||||
HID_IN_PACKET,
|
||||
USB_OTG_EP_INT);
|
||||
|
||||
/* Open EP OUT */
|
||||
DCD_EP_Open(pdev,
|
||||
HID_OUT_EP,
|
||||
HID_OUT_PACKET,
|
||||
USB_OTG_EP_INT);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_Init
|
||||
* DeInitialize the HID layer
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_HID_DeInit (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
/* Close HID EPs */
|
||||
DCD_EP_Close (pdev , HID_IN_EP);
|
||||
DCD_EP_Close (pdev , HID_OUT_EP);
|
||||
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_Setup
|
||||
* Handle the HID specific requests
|
||||
* @param pdev: instance
|
||||
* @param req: usb requests
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_HID_Setup (void *pdev,
|
||||
USB_SETUP_REQ *req)
|
||||
{
|
||||
uint16_t len = 0;
|
||||
uint8_t *pbuf = NULL;
|
||||
|
||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||
{
|
||||
case USB_REQ_TYPE_CLASS :
|
||||
switch (req->bRequest)
|
||||
{
|
||||
|
||||
|
||||
case HID_REQ_SET_PROTOCOL:
|
||||
USBD_HID_Protocol = (uint8_t)(req->wValue);
|
||||
break;
|
||||
|
||||
case HID_REQ_GET_PROTOCOL:
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)&USBD_HID_Protocol,
|
||||
1);
|
||||
break;
|
||||
|
||||
case HID_REQ_SET_IDLE:
|
||||
USBD_HID_IdleState = (uint8_t)(req->wValue >> 8);
|
||||
break;
|
||||
|
||||
case HID_REQ_GET_IDLE:
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)&USBD_HID_IdleState,
|
||||
1);
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_CtlError (pdev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_REQ_TYPE_STANDARD:
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case USB_REQ_GET_DESCRIPTOR:
|
||||
if( req->wValue >> 8 == HID_REPORT_DESC)
|
||||
{
|
||||
len = MIN(HID_MOUSE_REPORT_DESC_SIZE , req->wLength);
|
||||
pbuf = HID_MOUSE_ReportDesc;
|
||||
}
|
||||
else if( req->wValue >> 8 == HID_DESCRIPTOR_TYPE)
|
||||
{
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
pbuf = USBD_HID_Desc;
|
||||
#else
|
||||
pbuf = USBD_HID_CfgDesc + 0x12;
|
||||
#endif
|
||||
len = MIN(USB_HID_DESC_SIZ , req->wLength);
|
||||
}
|
||||
|
||||
USBD_CtlSendData (pdev,
|
||||
pbuf,
|
||||
len);
|
||||
|
||||
break;
|
||||
|
||||
case USB_REQ_GET_INTERFACE :
|
||||
USBD_CtlSendData (pdev,
|
||||
(uint8_t *)&USBD_HID_AltSet,
|
||||
1);
|
||||
break;
|
||||
|
||||
case USB_REQ_SET_INTERFACE :
|
||||
USBD_HID_AltSet = (uint8_t)(req->wValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_SendReport
|
||||
* Send HID Report
|
||||
* @param pdev: device instance
|
||||
* @param buff: pointer to report
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_HID_SendReport (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t *report,
|
||||
uint16_t len)
|
||||
{
|
||||
if (pdev->dev.device_status == USB_OTG_CONFIGURED )
|
||||
{
|
||||
DCD_EP_Tx (pdev, HID_IN_EP, report, len);
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_GetCfgDesc
|
||||
* return configuration descriptor
|
||||
* @param speed : current device speed
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
static uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length)
|
||||
{
|
||||
*length = sizeof (USBD_HID_CfgDesc);
|
||||
return USBD_HID_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_HID_DataIn
|
||||
* handle data IN Stage
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_HID_DataIn (void *pdev,
|
||||
uint8_t epnum)
|
||||
{
|
||||
|
||||
/* Ensure that the FIFO is empty before a new transfer, this condition could
|
||||
be caused by a new transfer before the end of the previous transfer */
|
||||
DCD_EP_Flush(pdev, HID_IN_EP);
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,153 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_msc_bot.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header for the usbd_msc_bot.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
|
||||
#include "usbd_core.h"
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USBD_MSC_BOT_H
|
||||
#define __USBD_MSC_BOT_H
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup MSC_BOT
|
||||
* @brief This file is the Header file for usbd_bot.c
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#define BOT_IDLE 0 /* Idle state */
|
||||
#define BOT_DATA_OUT 1 /* Data Out state */
|
||||
#define BOT_DATA_IN 2 /* Data In state */
|
||||
#define BOT_LAST_DATA_IN 3 /* Last Data In Last */
|
||||
#define BOT_SEND_DATA 4 /* Send Immediate data */
|
||||
|
||||
#define BOT_CBW_SIGNATURE 0x43425355
|
||||
#define BOT_CSW_SIGNATURE 0x53425355
|
||||
#define BOT_CBW_LENGTH 31
|
||||
#define BOT_CSW_LENGTH 13
|
||||
|
||||
/* CSW Status Definitions */
|
||||
#define CSW_CMD_PASSED 0x00
|
||||
#define CSW_CMD_FAILED 0x01
|
||||
#define CSW_PHASE_ERROR 0x02
|
||||
|
||||
/* BOT Status */
|
||||
#define BOT_STATE_NORMAL 0
|
||||
#define BOT_STATE_RECOVERY 1
|
||||
#define BOT_STATE_ERROR 2
|
||||
|
||||
|
||||
#define DIR_IN 0
|
||||
#define DIR_OUT 1
|
||||
#define BOTH_DIR 2
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup MSC_CORE_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef struct _MSC_BOT_CBW
|
||||
{
|
||||
uint32_t dSignature;
|
||||
uint32_t dTag;
|
||||
uint32_t dDataLength;
|
||||
uint8_t bmFlags;
|
||||
uint8_t bLUN;
|
||||
uint8_t bCBLength;
|
||||
uint8_t CB[16];
|
||||
}
|
||||
MSC_BOT_CBW_TypeDef;
|
||||
|
||||
|
||||
typedef struct _MSC_BOT_CSW
|
||||
{
|
||||
uint32_t dSignature;
|
||||
uint32_t dTag;
|
||||
uint32_t dDataResidue;
|
||||
uint8_t bStatus;
|
||||
}
|
||||
MSC_BOT_CSW_TypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern uint8_t MSC_BOT_Data[];
|
||||
extern uint16_t MSC_BOT_DataLen;
|
||||
extern uint8_t MSC_BOT_State;
|
||||
extern uint8_t MSC_BOT_BurstMode;
|
||||
extern MSC_BOT_CBW_TypeDef MSC_BOT_cbw;
|
||||
extern MSC_BOT_CSW_TypeDef MSC_BOT_csw;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup USBD_CORE_Exported_FunctionsPrototypes
|
||||
* @{
|
||||
*/
|
||||
void MSC_BOT_Init (USB_OTG_CORE_HANDLE *pdev);
|
||||
void MSC_BOT_Reset (USB_OTG_CORE_HANDLE *pdev);
|
||||
void MSC_BOT_DeInit (USB_OTG_CORE_HANDLE *pdev);
|
||||
void MSC_BOT_DataIn (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t epnum);
|
||||
|
||||
void MSC_BOT_DataOut (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t epnum);
|
||||
|
||||
void MSC_BOT_SendCSW (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t CSW_Status);
|
||||
|
||||
void MSC_BOT_CplClrFeature (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t epnum);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USBD_MSC_BOT_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -0,0 +1,77 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_msc_core.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header for the usbd_msc_core.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef _USB_MSC_CORE_H_
|
||||
#define _USB_MSC_CORE_H_
|
||||
|
||||
#include "usbd_ioreq.h"
|
||||
|
||||
/** @addtogroup USBD_MSC_BOT
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_MSC
|
||||
* @brief This file is the Header file for USBD_msc.c
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_BOT_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#define BOT_GET_MAX_LUN 0xFE
|
||||
#define BOT_RESET 0xFF
|
||||
#define USB_MSC_CONFIG_DESC_SIZ 32
|
||||
|
||||
#define MSC_EPIN_SIZE MSC_MAX_PACKET
|
||||
#define MSC_EPOUT_SIZE MSC_MAX_PACKET
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CORE_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern USBD_Class_cb_TypeDef USBD_MSC_cb;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif // _USB_MSC_CORE_H_
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,104 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_msc_data.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header for the usbd_msc_data.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
|
||||
#ifndef _USBD_MSC_DATA_H_
|
||||
#define _USBD_MSC_DATA_H_
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_conf.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_INFO
|
||||
* @brief general defines for the usb device library file
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_INFO_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#define MODE_SENSE6_LEN 8
|
||||
#define MODE_SENSE10_LEN 8
|
||||
#define LENGTH_INQUIRY_PAGE00 7
|
||||
#define LENGTH_FORMAT_CAPACITIES 20
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_INFO_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_INFO_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_INFO_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
extern const uint8_t MSC_Page00_Inquiry_Data[];
|
||||
extern const uint8_t MSC_Mode_Sense6_data[];
|
||||
extern const uint8_t MSC_Mode_Sense10_data[] ;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_INFO_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* _USBD_MSC_DATA_H_ */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,112 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_msc_mem.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header for the STORAGE DISK file file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
|
||||
#ifndef __USBD_MEM_H
|
||||
#define __USBD_MEM_H
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_def.h"
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_MEM
|
||||
* @brief header file for the storage disk file
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_MEM_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#define USBD_STD_INQUIRY_LENGTH 36
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_MEM_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef struct _USBD_STORAGE
|
||||
{
|
||||
int8_t (* Init) (uint8_t lun);
|
||||
int8_t (* GetCapacity) (uint8_t lun, uint32_t *block_num, uint32_t *block_size);
|
||||
int8_t (* IsReady) (uint8_t lun);
|
||||
int8_t (* IsWriteProtected) (uint8_t lun);
|
||||
int8_t (* Read) (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
|
||||
int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
|
||||
int8_t (* GetMaxLun)(void);
|
||||
int8_t *pInquiry;
|
||||
|
||||
}USBD_STORAGE_cb_TypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_MEM_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_MEM_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_MEM_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USBD_MEM_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,195 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_msc_scsi.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header for the usbd_msc_scsi.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USBD_MSC_SCSI_H
|
||||
#define __USBD_MSC_SCSI_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_def.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_SCSI
|
||||
* @brief header file for the storage disk file
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_SCSI_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define SENSE_LIST_DEEPTH 4
|
||||
|
||||
/* SCSI Commands */
|
||||
#define SCSI_FORMAT_UNIT 0x04
|
||||
#define SCSI_INQUIRY 0x12
|
||||
#define SCSI_MODE_SELECT6 0x15
|
||||
#define SCSI_MODE_SELECT10 0x55
|
||||
#define SCSI_MODE_SENSE6 0x1A
|
||||
#define SCSI_MODE_SENSE10 0x5A
|
||||
#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1E
|
||||
#define SCSI_READ6 0x08
|
||||
#define SCSI_READ10 0x28
|
||||
#define SCSI_READ12 0xA8
|
||||
#define SCSI_READ16 0x88
|
||||
|
||||
#define SCSI_READ_CAPACITY10 0x25
|
||||
#define SCSI_READ_CAPACITY16 0x9E
|
||||
|
||||
#define SCSI_REQUEST_SENSE 0x03
|
||||
#define SCSI_START_STOP_UNIT 0x1B
|
||||
#define SCSI_TEST_UNIT_READY 0x00
|
||||
#define SCSI_WRITE6 0x0A
|
||||
#define SCSI_WRITE10 0x2A
|
||||
#define SCSI_WRITE12 0xAA
|
||||
#define SCSI_WRITE16 0x8A
|
||||
|
||||
#define SCSI_VERIFY10 0x2F
|
||||
#define SCSI_VERIFY12 0xAF
|
||||
#define SCSI_VERIFY16 0x8F
|
||||
|
||||
#define SCSI_SEND_DIAGNOSTIC 0x1D
|
||||
#define SCSI_READ_FORMAT_CAPACITIES 0x23
|
||||
|
||||
#define NO_SENSE 0
|
||||
#define RECOVERED_ERROR 1
|
||||
#define NOT_READY 2
|
||||
#define MEDIUM_ERROR 3
|
||||
#define HARDWARE_ERROR 4
|
||||
#define ILLEGAL_REQUEST 5
|
||||
#define UNIT_ATTENTION 6
|
||||
#define DATA_PROTECT 7
|
||||
#define BLANK_CHECK 8
|
||||
#define VENDOR_SPECIFIC 9
|
||||
#define COPY_ABORTED 10
|
||||
#define ABORTED_COMMAND 11
|
||||
#define VOLUME_OVERFLOW 13
|
||||
#define MISCOMPARE 14
|
||||
|
||||
|
||||
#define INVALID_CDB 0x20
|
||||
#define INVALID_FIELED_IN_COMMAND 0x24
|
||||
#define PARAMETER_LIST_LENGTH_ERROR 0x1A
|
||||
#define INVALID_FIELD_IN_PARAMETER_LIST 0x26
|
||||
#define ADDRESS_OUT_OF_RANGE 0x21
|
||||
#define MEDIUM_NOT_PRESENT 0x3A
|
||||
#define MEDIUM_HAVE_CHANGED 0x28
|
||||
#define WRITE_PROTECTED 0x27
|
||||
#define UNRECOVERED_READ_ERROR 0x11
|
||||
#define WRITE_FAULT 0x03
|
||||
|
||||
#define READ_FORMAT_CAPACITY_DATA_LEN 0x0C
|
||||
#define READ_CAPACITY10_DATA_LEN 0x08
|
||||
#define MODE_SENSE10_DATA_LEN 0x08
|
||||
#define MODE_SENSE6_DATA_LEN 0x04
|
||||
#define REQUEST_SENSE_DATA_LEN 0x12
|
||||
#define STANDARD_INQUIRY_DATA_LEN 0x24
|
||||
#define BLKVFY 0x04
|
||||
|
||||
extern uint8_t Page00_Inquiry_Data[];
|
||||
extern uint8_t Standard_Inquiry_Data[];
|
||||
extern uint8_t Standard_Inquiry_Data2[];
|
||||
extern uint8_t Mode_Sense6_data[];
|
||||
extern uint8_t Mode_Sense10_data[];
|
||||
extern uint8_t Scsi_Sense_Data[];
|
||||
extern uint8_t ReadCapacity10_Data[];
|
||||
extern uint8_t ReadFormatCapacity_Data [];
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_SCSI_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef struct _SENSE_ITEM {
|
||||
char Skey;
|
||||
union {
|
||||
struct _ASCs {
|
||||
char ASC;
|
||||
char ASCQ;
|
||||
}b;
|
||||
unsigned int ASC;
|
||||
char *pData;
|
||||
} w;
|
||||
} SCSI_Sense_TypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_SCSI_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_SCSI_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
extern SCSI_Sense_TypeDef SCSI_Sense [SENSE_LIST_DEEPTH];
|
||||
extern uint8_t SCSI_Sense_Head;
|
||||
extern uint8_t SCSI_Sense_Tail;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup USBD_SCSI_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
int8_t SCSI_ProcessCmd(USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t lun,
|
||||
uint8_t *cmd);
|
||||
|
||||
void SCSI_SenseCode(uint8_t lun,
|
||||
uint8_t sKey,
|
||||
uint8_t ASC);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USBD_MSC_SCSI_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -0,0 +1,400 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_msc_bot.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides all the BOT protocol core functions.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_msc_bot.h"
|
||||
#include "usbd_msc_scsi.h"
|
||||
#include "usbd_ioreq.h"
|
||||
#include "usbd_msc_mem.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_BOT
|
||||
* @brief BOT protocol module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup MSC_BOT_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_BOT_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_BOT_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_BOT_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
uint16_t MSC_BOT_DataLen;
|
||||
uint8_t MSC_BOT_State;
|
||||
uint8_t MSC_BOT_Status;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t MSC_BOT_Data[MSC_MEDIA_PACKET] __ALIGN_END ;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN MSC_BOT_CBW_TypeDef MSC_BOT_cbw __ALIGN_END ;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN MSC_BOT_CSW_TypeDef MSC_BOT_csw __ALIGN_END ;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_BOT_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
static void MSC_BOT_CBW_Decode (USB_OTG_CORE_HANDLE *pdev);
|
||||
|
||||
static void MSC_BOT_SendData (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t* pbuf,
|
||||
uint16_t len);
|
||||
|
||||
static void MSC_BOT_Abort(USB_OTG_CORE_HANDLE *pdev);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_BOT_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief MSC_BOT_Init
|
||||
* Initialize the BOT Process
|
||||
* @param pdev: device instance
|
||||
* @retval None
|
||||
*/
|
||||
void MSC_BOT_Init (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
MSC_BOT_State = BOT_IDLE;
|
||||
MSC_BOT_Status = BOT_STATE_NORMAL;
|
||||
USBD_STORAGE_fops->Init(0);
|
||||
|
||||
DCD_EP_Flush(pdev, MSC_OUT_EP);
|
||||
DCD_EP_Flush(pdev, MSC_IN_EP);
|
||||
/* Prapare EP to Receive First BOT Cmd */
|
||||
DCD_EP_PrepareRx (pdev,
|
||||
MSC_OUT_EP,
|
||||
(uint8_t *)&MSC_BOT_cbw,
|
||||
BOT_CBW_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MSC_BOT_Reset
|
||||
* Reset the BOT Machine
|
||||
* @param pdev: device instance
|
||||
* @retval None
|
||||
*/
|
||||
void MSC_BOT_Reset (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
MSC_BOT_State = BOT_IDLE;
|
||||
MSC_BOT_Status = BOT_STATE_RECOVERY;
|
||||
/* Prapare EP to Receive First BOT Cmd */
|
||||
DCD_EP_PrepareRx (pdev,
|
||||
MSC_OUT_EP,
|
||||
(uint8_t *)&MSC_BOT_cbw,
|
||||
BOT_CBW_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MSC_BOT_DeInit
|
||||
* Uninitialize the BOT Machine
|
||||
* @param pdev: device instance
|
||||
* @retval None
|
||||
*/
|
||||
void MSC_BOT_DeInit (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
MSC_BOT_State = BOT_IDLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MSC_BOT_DataIn
|
||||
* Handle BOT IN data stage
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint index
|
||||
* @retval None
|
||||
*/
|
||||
void MSC_BOT_DataIn (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t epnum)
|
||||
{
|
||||
|
||||
switch (MSC_BOT_State)
|
||||
{
|
||||
case BOT_DATA_IN:
|
||||
if(SCSI_ProcessCmd(pdev,
|
||||
MSC_BOT_cbw.bLUN,
|
||||
&MSC_BOT_cbw.CB[0]) < 0)
|
||||
{
|
||||
MSC_BOT_SendCSW (pdev, CSW_CMD_FAILED);
|
||||
}
|
||||
break;
|
||||
|
||||
case BOT_SEND_DATA:
|
||||
case BOT_LAST_DATA_IN:
|
||||
MSC_BOT_SendCSW (pdev, CSW_CMD_PASSED);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief MSC_BOT_DataOut
|
||||
* Proccess MSC OUT data
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint index
|
||||
* @retval None
|
||||
*/
|
||||
void MSC_BOT_DataOut (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t epnum)
|
||||
{
|
||||
switch (MSC_BOT_State)
|
||||
{
|
||||
case BOT_IDLE:
|
||||
MSC_BOT_CBW_Decode(pdev);
|
||||
break;
|
||||
|
||||
case BOT_DATA_OUT:
|
||||
|
||||
if(SCSI_ProcessCmd(pdev,
|
||||
MSC_BOT_cbw.bLUN,
|
||||
&MSC_BOT_cbw.CB[0]) < 0)
|
||||
{
|
||||
MSC_BOT_SendCSW (pdev, CSW_CMD_FAILED);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MSC_BOT_CBW_Decode
|
||||
* Decode the CBW command and set the BOT state machine accordingtly
|
||||
* @param pdev: device instance
|
||||
* @retval None
|
||||
*/
|
||||
static void MSC_BOT_CBW_Decode (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
|
||||
MSC_BOT_csw.dTag = MSC_BOT_cbw.dTag;
|
||||
MSC_BOT_csw.dDataResidue = MSC_BOT_cbw.dDataLength;
|
||||
|
||||
if ((USBD_GetRxCount (pdev ,MSC_OUT_EP) != BOT_CBW_LENGTH) ||
|
||||
(MSC_BOT_cbw.dSignature != BOT_CBW_SIGNATURE)||
|
||||
(MSC_BOT_cbw.bLUN > 1) ||
|
||||
(MSC_BOT_cbw.bCBLength < 1) ||
|
||||
(MSC_BOT_cbw.bCBLength > 16))
|
||||
{
|
||||
|
||||
SCSI_SenseCode(MSC_BOT_cbw.bLUN,
|
||||
ILLEGAL_REQUEST,
|
||||
INVALID_CDB);
|
||||
MSC_BOT_Status = BOT_STATE_ERROR;
|
||||
MSC_BOT_Abort(pdev);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(SCSI_ProcessCmd(pdev,
|
||||
MSC_BOT_cbw.bLUN,
|
||||
&MSC_BOT_cbw.CB[0]) < 0)
|
||||
{
|
||||
MSC_BOT_Abort(pdev);
|
||||
}
|
||||
/*Burst xfer handled internally*/
|
||||
else if ((MSC_BOT_State != BOT_DATA_IN) &&
|
||||
(MSC_BOT_State != BOT_DATA_OUT) &&
|
||||
(MSC_BOT_State != BOT_LAST_DATA_IN))
|
||||
{
|
||||
if (MSC_BOT_DataLen > 0)
|
||||
{
|
||||
MSC_BOT_SendData(pdev,
|
||||
MSC_BOT_Data,
|
||||
MSC_BOT_DataLen);
|
||||
}
|
||||
else if (MSC_BOT_DataLen == 0)
|
||||
{
|
||||
MSC_BOT_SendCSW (pdev,
|
||||
CSW_CMD_PASSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MSC_BOT_SendData
|
||||
* Send the requested data
|
||||
* @param pdev: device instance
|
||||
* @param buf: pointer to data buffer
|
||||
* @param len: Data Length
|
||||
* @retval None
|
||||
*/
|
||||
static void MSC_BOT_SendData(USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t* buf,
|
||||
uint16_t len)
|
||||
{
|
||||
|
||||
len = MIN (MSC_BOT_cbw.dDataLength, len);
|
||||
MSC_BOT_csw.dDataResidue -= len;
|
||||
MSC_BOT_csw.bStatus = CSW_CMD_PASSED;
|
||||
MSC_BOT_State = BOT_SEND_DATA;
|
||||
|
||||
DCD_EP_Tx (pdev, MSC_IN_EP, buf, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MSC_BOT_SendCSW
|
||||
* Send the Command Status Wrapper
|
||||
* @param pdev: device instance
|
||||
* @param status : CSW status
|
||||
* @retval None
|
||||
*/
|
||||
void MSC_BOT_SendCSW (USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t CSW_Status)
|
||||
{
|
||||
MSC_BOT_csw.dSignature = BOT_CSW_SIGNATURE;
|
||||
MSC_BOT_csw.bStatus = CSW_Status;
|
||||
MSC_BOT_State = BOT_IDLE;
|
||||
|
||||
DCD_EP_Tx (pdev,
|
||||
MSC_IN_EP,
|
||||
(uint8_t *)&MSC_BOT_csw,
|
||||
BOT_CSW_LENGTH);
|
||||
|
||||
/* Prapare EP to Receive next Cmd */
|
||||
DCD_EP_PrepareRx (pdev,
|
||||
MSC_OUT_EP,
|
||||
(uint8_t *)&MSC_BOT_cbw,
|
||||
BOT_CBW_LENGTH);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MSC_BOT_Abort
|
||||
* Abort the current transfer
|
||||
* @param pdev: device instance
|
||||
* @retval status
|
||||
*/
|
||||
|
||||
static void MSC_BOT_Abort (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
|
||||
if ((MSC_BOT_cbw.bmFlags == 0) &&
|
||||
(MSC_BOT_cbw.dDataLength != 0) &&
|
||||
(MSC_BOT_Status == BOT_STATE_NORMAL) )
|
||||
{
|
||||
DCD_EP_Stall(pdev, MSC_OUT_EP );
|
||||
}
|
||||
DCD_EP_Stall(pdev, MSC_IN_EP);
|
||||
|
||||
if(MSC_BOT_Status == BOT_STATE_ERROR)
|
||||
{
|
||||
DCD_EP_PrepareRx (pdev,
|
||||
MSC_OUT_EP,
|
||||
(uint8_t *)&MSC_BOT_cbw,
|
||||
BOT_CBW_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MSC_BOT_CplClrFeature
|
||||
* Complete the clear feature request
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint index
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void MSC_BOT_CplClrFeature (USB_OTG_CORE_HANDLE *pdev, uint8_t epnum)
|
||||
{
|
||||
if(MSC_BOT_Status == BOT_STATE_ERROR )/* Bad CBW Signature */
|
||||
{
|
||||
DCD_EP_Stall(pdev, MSC_IN_EP);
|
||||
MSC_BOT_Status = BOT_STATE_NORMAL;
|
||||
}
|
||||
else if(((epnum & 0x80) == 0x80) && ( MSC_BOT_Status != BOT_STATE_RECOVERY))
|
||||
{
|
||||
MSC_BOT_SendCSW (pdev, CSW_CMD_FAILED);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,496 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_msc_core.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides all the MSC core functions.
|
||||
*
|
||||
* @verbatim
|
||||
*
|
||||
* ===================================================================
|
||||
* MSC Class Description
|
||||
* ===================================================================
|
||||
* This module manages the MSC class V1.0 following the "Universal
|
||||
* Serial Bus Mass Storage Class (MSC) Bulk-Only Transport (BOT) Version 1.0
|
||||
* Sep. 31, 1999".
|
||||
* This driver implements the following aspects of the specification:
|
||||
* - Bulk-Only Transport protocol
|
||||
* - Subclass : SCSI transparent command set (ref. SCSI Primary Commands - 3 (SPC-3))
|
||||
*
|
||||
* @endverbatim
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_msc_mem.h"
|
||||
#include "usbd_msc_core.h"
|
||||
#include "usbd_msc_bot.h"
|
||||
#include "usbd_req.h"
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_CORE
|
||||
* @brief Mass storage core module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup MSC_CORE_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_CORE_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_CORE_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_CORE_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
uint8_t USBD_MSC_Init (void *pdev,
|
||||
uint8_t cfgidx);
|
||||
|
||||
uint8_t USBD_MSC_DeInit (void *pdev,
|
||||
uint8_t cfgidx);
|
||||
|
||||
uint8_t USBD_MSC_Setup (void *pdev,
|
||||
USB_SETUP_REQ *req);
|
||||
|
||||
uint8_t USBD_MSC_DataIn (void *pdev,
|
||||
uint8_t epnum);
|
||||
|
||||
|
||||
uint8_t USBD_MSC_DataOut (void *pdev,
|
||||
uint8_t epnum);
|
||||
|
||||
uint8_t *USBD_MSC_GetCfgDesc (uint8_t speed,
|
||||
uint16_t *length);
|
||||
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
uint8_t *USBD_MSC_GetOtherCfgDesc (uint8_t speed,
|
||||
uint16_t *length);
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t USBD_MSC_CfgDesc[USB_MSC_CONFIG_DESC_SIZ];
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_CORE_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
USBD_Class_cb_TypeDef USBD_MSC_cb =
|
||||
{
|
||||
USBD_MSC_Init,
|
||||
USBD_MSC_DeInit,
|
||||
USBD_MSC_Setup,
|
||||
NULL, /*EP0_TxSent*/
|
||||
NULL, /*EP0_RxReady*/
|
||||
USBD_MSC_DataIn,
|
||||
USBD_MSC_DataOut,
|
||||
NULL, /*SOF */
|
||||
NULL,
|
||||
NULL,
|
||||
USBD_MSC_GetCfgDesc,
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
USBD_MSC_GetOtherCfgDesc,
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
/* USB Mass storage device Configuration Descriptor */
|
||||
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
|
||||
__ALIGN_BEGIN uint8_t USBD_MSC_CfgDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
|
||||
0x09, /* bLength: Configuation Descriptor size */
|
||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||
USB_MSC_CONFIG_DESC_SIZ,
|
||||
|
||||
0x00,
|
||||
0x01, /* bNumInterfaces: 1 interface */
|
||||
0x01, /* bConfigurationValue: */
|
||||
0x04, /* iConfiguration: */
|
||||
0xC0, /* bmAttributes: */
|
||||
0x32, /* MaxPower 100 mA */
|
||||
|
||||
/******************** Mass Storage interface ********************/
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
0x04, /* bDescriptorType: */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints*/
|
||||
0x08, /* bInterfaceClass: MSC Class */
|
||||
0x06, /* bInterfaceSubClass : SCSI transparent*/
|
||||
0x50, /* nInterfaceProtocol */
|
||||
0x05, /* iInterface: */
|
||||
/******************** Mass Storage Endpoints ********************/
|
||||
0x07, /*Endpoint descriptor length = 7*/
|
||||
0x05, /*Endpoint descriptor type */
|
||||
MSC_IN_EP, /*Endpoint address (IN, address 1) */
|
||||
0x02, /*Bulk endpoint type */
|
||||
LOBYTE(MSC_MAX_PACKET),
|
||||
HIBYTE(MSC_MAX_PACKET),
|
||||
0x00, /*Polling interval in milliseconds */
|
||||
|
||||
0x07, /*Endpoint descriptor length = 7 */
|
||||
0x05, /*Endpoint descriptor type */
|
||||
MSC_OUT_EP, /*Endpoint address (OUT, address 1) */
|
||||
0x02, /*Bulk endpoint type */
|
||||
LOBYTE(MSC_MAX_PACKET),
|
||||
HIBYTE(MSC_MAX_PACKET),
|
||||
0x00 /*Polling interval in milliseconds*/
|
||||
};
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN uint8_t USBD_MSC_OtherCfgDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
|
||||
0x09, /* bLength: Configuation Descriptor size */
|
||||
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION,
|
||||
USB_MSC_CONFIG_DESC_SIZ,
|
||||
|
||||
0x00,
|
||||
0x01, /* bNumInterfaces: 1 interface */
|
||||
0x01, /* bConfigurationValue: */
|
||||
0x04, /* iConfiguration: */
|
||||
0xC0, /* bmAttributes: */
|
||||
0x32, /* MaxPower 100 mA */
|
||||
|
||||
/******************** Mass Storage interface ********************/
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
0x04, /* bDescriptorType: */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints*/
|
||||
0x08, /* bInterfaceClass: MSC Class */
|
||||
0x06, /* bInterfaceSubClass : SCSI transparent command set*/
|
||||
0x50, /* nInterfaceProtocol */
|
||||
0x05, /* iInterface: */
|
||||
/******************** Mass Storage Endpoints ********************/
|
||||
0x07, /*Endpoint descriptor length = 7*/
|
||||
0x05, /*Endpoint descriptor type */
|
||||
MSC_IN_EP, /*Endpoint address (IN, address 1) */
|
||||
0x02, /*Bulk endpoint type */
|
||||
0x40,
|
||||
0x00,
|
||||
0x00, /*Polling interval in milliseconds */
|
||||
|
||||
0x07, /*Endpoint descriptor length = 7 */
|
||||
0x05, /*Endpoint descriptor type */
|
||||
MSC_OUT_EP, /*Endpoint address (OUT, address 1) */
|
||||
0x02, /*Bulk endpoint type */
|
||||
0x40,
|
||||
0x00,
|
||||
0x00 /*Polling interval in milliseconds*/
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static uint8_t USBD_MSC_MaxLun __ALIGN_END = 0;
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
__ALIGN_BEGIN static uint8_t USBD_MSC_AltSet __ALIGN_END = 0;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_CORE_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief USBD_MSC_Init
|
||||
* Initialize the mass storage configuration
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: configuration index
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_MSC_Init (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
USBD_MSC_DeInit(pdev , cfgidx );
|
||||
|
||||
/* Open EP IN */
|
||||
DCD_EP_Open(pdev,
|
||||
MSC_IN_EP,
|
||||
MSC_EPIN_SIZE,
|
||||
USB_OTG_EP_BULK);
|
||||
|
||||
/* Open EP OUT */
|
||||
DCD_EP_Open(pdev,
|
||||
MSC_OUT_EP,
|
||||
MSC_EPOUT_SIZE,
|
||||
USB_OTG_EP_BULK);
|
||||
|
||||
/* Init the BOT layer */
|
||||
MSC_BOT_Init(pdev);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_MSC_DeInit
|
||||
* DeInitilaize the mass storage configuration
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: configuration index
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_MSC_DeInit (void *pdev,
|
||||
uint8_t cfgidx)
|
||||
{
|
||||
/* Close MSC EPs */
|
||||
DCD_EP_Close (pdev , MSC_IN_EP);
|
||||
DCD_EP_Close (pdev , MSC_OUT_EP);
|
||||
|
||||
/* Un Init the BOT layer */
|
||||
MSC_BOT_DeInit(pdev);
|
||||
return USBD_OK;
|
||||
}
|
||||
/**
|
||||
* @brief USBD_MSC_Setup
|
||||
* Handle the MSC specific requests
|
||||
* @param pdev: device instance
|
||||
* @param req: USB request
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_MSC_Setup (void *pdev, USB_SETUP_REQ *req)
|
||||
{
|
||||
|
||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||
{
|
||||
|
||||
/* Class request */
|
||||
case USB_REQ_TYPE_CLASS :
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case BOT_GET_MAX_LUN :
|
||||
|
||||
if((req->wValue == 0) &&
|
||||
(req->wLength == 1) &&
|
||||
((req->bmRequest & 0x80) == 0x80))
|
||||
{
|
||||
USBD_MSC_MaxLun = USBD_STORAGE_fops->GetMaxLun();
|
||||
if(USBD_MSC_MaxLun > 0)
|
||||
{
|
||||
USBD_CtlSendData (pdev,
|
||||
&USBD_MSC_MaxLun,
|
||||
1);
|
||||
}
|
||||
else
|
||||
{
|
||||
USBD_CtlError(pdev , req);
|
||||
return USBD_FAIL;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
USBD_CtlError(pdev , req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
case BOT_RESET :
|
||||
if((req->wValue == 0) &&
|
||||
(req->wLength == 0) &&
|
||||
((req->bmRequest & 0x80) != 0x80))
|
||||
{
|
||||
MSC_BOT_Reset(pdev);
|
||||
}
|
||||
else
|
||||
{
|
||||
USBD_CtlError(pdev , req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_CtlError(pdev , req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
/* Interface & Endpoint request */
|
||||
case USB_REQ_TYPE_STANDARD:
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case USB_REQ_GET_INTERFACE :
|
||||
USBD_CtlSendData (pdev,
|
||||
&USBD_MSC_AltSet,
|
||||
1);
|
||||
break;
|
||||
|
||||
case USB_REQ_SET_INTERFACE :
|
||||
USBD_MSC_AltSet = (uint8_t)(req->wValue);
|
||||
break;
|
||||
|
||||
case USB_REQ_CLEAR_FEATURE:
|
||||
|
||||
/* Flush the FIFO and Clear the stall status */
|
||||
DCD_EP_Flush(pdev, (uint8_t)req->wIndex);
|
||||
|
||||
/* Re-activate the EP */
|
||||
DCD_EP_Close (pdev , (uint8_t)req->wIndex);
|
||||
if((((uint8_t)req->wIndex) & 0x80) == 0x80)
|
||||
{
|
||||
DCD_EP_Open(pdev,
|
||||
((uint8_t)req->wIndex),
|
||||
MSC_EPIN_SIZE,
|
||||
USB_OTG_EP_BULK);
|
||||
}
|
||||
else
|
||||
{
|
||||
DCD_EP_Open(pdev,
|
||||
((uint8_t)req->wIndex),
|
||||
MSC_EPOUT_SIZE,
|
||||
USB_OTG_EP_BULK);
|
||||
}
|
||||
|
||||
/* Handle BOT error */
|
||||
MSC_BOT_CplClrFeature(pdev, (uint8_t)req->wIndex);
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_MSC_DataIn
|
||||
* handle data IN Stage
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint index
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_MSC_DataIn (void *pdev,
|
||||
uint8_t epnum)
|
||||
{
|
||||
MSC_BOT_DataIn(pdev , epnum);
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_MSC_DataOut
|
||||
* handle data OUT Stage
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint index
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_MSC_DataOut (void *pdev,
|
||||
uint8_t epnum)
|
||||
{
|
||||
MSC_BOT_DataOut(pdev , epnum);
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_MSC_GetCfgDesc
|
||||
* return configuration descriptor
|
||||
* @param speed : current device speed
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
uint8_t *USBD_MSC_GetCfgDesc (uint8_t speed, uint16_t *length)
|
||||
{
|
||||
*length = sizeof (USBD_MSC_CfgDesc);
|
||||
return USBD_MSC_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_MSC_GetOtherCfgDesc
|
||||
* return other speed configuration descriptor
|
||||
* @param speed : current device speed
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
uint8_t *USBD_MSC_GetOtherCfgDesc (uint8_t speed,
|
||||
uint16_t *length)
|
||||
{
|
||||
*length = sizeof (USBD_MSC_OtherCfgDesc);
|
||||
return USBD_MSC_OtherCfgDesc;
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,134 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_msc_data.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides all the vital inquiry pages and sense data.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_msc_data.h"
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_DATA
|
||||
* @brief Mass storage info/data module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup MSC_DATA_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_DATA_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_DATA_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_DATA_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* USB Mass storage Page 0 Inquiry Data */
|
||||
const uint8_t MSC_Page00_Inquiry_Data[] = {//7
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
(LENGTH_INQUIRY_PAGE00 - 4),
|
||||
0x00,
|
||||
0x80,
|
||||
0x83
|
||||
};
|
||||
/* USB Mass storage sense 6 Data */
|
||||
const uint8_t MSC_Mode_Sense6_data[] = {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00
|
||||
};
|
||||
/* USB Mass storage sense 10 Data */
|
||||
const uint8_t MSC_Mode_Sense10_data[] = {
|
||||
0x00,
|
||||
0x06,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00
|
||||
};
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_DATA_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_DATA_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,728 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_msc_scsi.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief This file provides all the USBD SCSI layer functions.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_msc_bot.h"
|
||||
#include "usbd_msc_scsi.h"
|
||||
#include "usbd_msc_mem.h"
|
||||
#include "usbd_msc_data.h"
|
||||
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_SCSI
|
||||
* @brief Mass storage SCSI layer module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup MSC_SCSI_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_SCSI_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_SCSI_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_SCSI_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
SCSI_Sense_TypeDef SCSI_Sense [SENSE_LIST_DEEPTH];
|
||||
uint8_t SCSI_Sense_Head;
|
||||
uint8_t SCSI_Sense_Tail;
|
||||
|
||||
uint32_t SCSI_blk_size;
|
||||
uint32_t SCSI_blk_nbr;
|
||||
|
||||
uint32_t SCSI_blk_addr;
|
||||
uint32_t SCSI_blk_len;
|
||||
|
||||
USB_OTG_CORE_HANDLE *cdev;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_SCSI_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
static int8_t SCSI_TestUnitReady(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_Inquiry(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_ReadFormatCapacity(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_ReadCapacity10(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_RequestSense (uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_StartStopUnit(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_ModeSense6 (uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_ModeSense10 (uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_Write10(uint8_t lun , uint8_t *params);
|
||||
static int8_t SCSI_Read10(uint8_t lun , uint8_t *params);
|
||||
static int8_t SCSI_Verify10(uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_CheckAddressRange (uint8_t lun ,
|
||||
uint32_t blk_offset ,
|
||||
uint16_t blk_nbr);
|
||||
static int8_t SCSI_ProcessRead (uint8_t lun);
|
||||
|
||||
static int8_t SCSI_ProcessWrite (uint8_t lun);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup MSC_SCSI_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief SCSI_ProcessCmd
|
||||
* Process SCSI commands
|
||||
* @param pdev: device instance
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
int8_t SCSI_ProcessCmd(USB_OTG_CORE_HANDLE *pdev,
|
||||
uint8_t lun,
|
||||
uint8_t *params)
|
||||
{
|
||||
cdev = pdev;
|
||||
|
||||
switch (params[0])
|
||||
{
|
||||
case SCSI_TEST_UNIT_READY:
|
||||
return SCSI_TestUnitReady(lun, params);
|
||||
|
||||
case SCSI_REQUEST_SENSE:
|
||||
return SCSI_RequestSense (lun, params);
|
||||
case SCSI_INQUIRY:
|
||||
return SCSI_Inquiry(lun, params);
|
||||
|
||||
case SCSI_START_STOP_UNIT:
|
||||
return SCSI_StartStopUnit(lun, params);
|
||||
|
||||
case SCSI_ALLOW_MEDIUM_REMOVAL:
|
||||
return SCSI_StartStopUnit(lun, params);
|
||||
|
||||
case SCSI_MODE_SENSE6:
|
||||
return SCSI_ModeSense6 (lun, params);
|
||||
|
||||
case SCSI_MODE_SENSE10:
|
||||
return SCSI_ModeSense10 (lun, params);
|
||||
|
||||
case SCSI_READ_FORMAT_CAPACITIES:
|
||||
return SCSI_ReadFormatCapacity(lun, params);
|
||||
|
||||
case SCSI_READ_CAPACITY10:
|
||||
return SCSI_ReadCapacity10(lun, params);
|
||||
|
||||
case SCSI_READ10:
|
||||
return SCSI_Read10(lun, params);
|
||||
|
||||
case SCSI_WRITE10:
|
||||
return SCSI_Write10(lun, params);
|
||||
|
||||
case SCSI_VERIFY10:
|
||||
return SCSI_Verify10(lun, params);
|
||||
|
||||
default:
|
||||
SCSI_SenseCode(lun,
|
||||
ILLEGAL_REQUEST,
|
||||
INVALID_CDB);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief SCSI_TestUnitReady
|
||||
* Process SCSI Test Unit Ready Command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_TestUnitReady(uint8_t lun, uint8_t *params)
|
||||
{
|
||||
|
||||
/* case 9 : Hi > D0 */
|
||||
if (MSC_BOT_cbw.dDataLength != 0)
|
||||
{
|
||||
SCSI_SenseCode(MSC_BOT_cbw.bLUN,
|
||||
ILLEGAL_REQUEST,
|
||||
INVALID_CDB);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(USBD_STORAGE_fops->IsReady(lun) !=0 )
|
||||
{
|
||||
SCSI_SenseCode(lun,
|
||||
NOT_READY,
|
||||
MEDIUM_NOT_PRESENT);
|
||||
return -1;
|
||||
}
|
||||
MSC_BOT_DataLen = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_Inquiry
|
||||
* Process Inquiry command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_Inquiry(uint8_t lun, uint8_t *params)
|
||||
{
|
||||
uint8_t* pPage;
|
||||
uint16_t len;
|
||||
|
||||
if (params[1] & 0x01)/*Evpd is set*/
|
||||
{
|
||||
pPage = (uint8_t *)MSC_Page00_Inquiry_Data;
|
||||
len = LENGTH_INQUIRY_PAGE00;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pPage = (uint8_t *)&USBD_STORAGE_fops->pInquiry[lun * USBD_STD_INQUIRY_LENGTH];
|
||||
len = pPage[4] + 5;
|
||||
|
||||
if (params[4] <= len)
|
||||
{
|
||||
len = params[4];
|
||||
}
|
||||
}
|
||||
MSC_BOT_DataLen = len;
|
||||
|
||||
while (len)
|
||||
{
|
||||
len--;
|
||||
MSC_BOT_Data[len] = pPage[len];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_ReadCapacity10
|
||||
* Process Read Capacity 10 command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_ReadCapacity10(uint8_t lun, uint8_t *params)
|
||||
{
|
||||
|
||||
if(USBD_STORAGE_fops->GetCapacity(lun, &SCSI_blk_nbr, &SCSI_blk_size) != 0)
|
||||
{
|
||||
SCSI_SenseCode(lun,
|
||||
NOT_READY,
|
||||
MEDIUM_NOT_PRESENT);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
MSC_BOT_Data[0] = (uint8_t)(SCSI_blk_nbr - 1 >> 24);
|
||||
MSC_BOT_Data[1] = (uint8_t)(SCSI_blk_nbr - 1 >> 16);
|
||||
MSC_BOT_Data[2] = (uint8_t)(SCSI_blk_nbr - 1 >> 8);
|
||||
MSC_BOT_Data[3] = (uint8_t)(SCSI_blk_nbr - 1);
|
||||
|
||||
MSC_BOT_Data[4] = (uint8_t)(SCSI_blk_size >> 24);
|
||||
MSC_BOT_Data[5] = (uint8_t)(SCSI_blk_size >> 16);
|
||||
MSC_BOT_Data[6] = (uint8_t)(SCSI_blk_size >> 8);
|
||||
MSC_BOT_Data[7] = (uint8_t)(SCSI_blk_size);
|
||||
|
||||
MSC_BOT_DataLen = 8;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief SCSI_ReadFormatCapacity
|
||||
* Process Read Format Capacity command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_ReadFormatCapacity(uint8_t lun, uint8_t *params)
|
||||
{
|
||||
|
||||
uint32_t blk_size;
|
||||
uint32_t blk_nbr;
|
||||
uint16_t i;
|
||||
|
||||
for(i=0 ; i < 12 ; i++)
|
||||
{
|
||||
MSC_BOT_Data[i] = 0;
|
||||
}
|
||||
|
||||
if(USBD_STORAGE_fops->GetCapacity(lun, &blk_nbr, &blk_size) != 0)
|
||||
{
|
||||
SCSI_SenseCode(lun,
|
||||
NOT_READY,
|
||||
MEDIUM_NOT_PRESENT);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
MSC_BOT_Data[3] = 0x08;
|
||||
MSC_BOT_Data[4] = (uint8_t)(blk_nbr - 1 >> 24);
|
||||
MSC_BOT_Data[5] = (uint8_t)(blk_nbr - 1 >> 16);
|
||||
MSC_BOT_Data[6] = (uint8_t)(blk_nbr - 1 >> 8);
|
||||
MSC_BOT_Data[7] = (uint8_t)(blk_nbr - 1);
|
||||
|
||||
MSC_BOT_Data[8] = 0x02;
|
||||
MSC_BOT_Data[9] = (uint8_t)(blk_size >> 16);
|
||||
MSC_BOT_Data[10] = (uint8_t)(blk_size >> 8);
|
||||
MSC_BOT_Data[11] = (uint8_t)(blk_size);
|
||||
|
||||
MSC_BOT_DataLen = 12;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief SCSI_ModeSense6
|
||||
* Process Mode Sense6 command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_ModeSense6 (uint8_t lun, uint8_t *params)
|
||||
{
|
||||
|
||||
uint16_t len = 8 ;
|
||||
MSC_BOT_DataLen = len;
|
||||
|
||||
while (len)
|
||||
{
|
||||
len--;
|
||||
MSC_BOT_Data[len] = MSC_Mode_Sense6_data[len];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_ModeSense10
|
||||
* Process Mode Sense10 command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_ModeSense10 (uint8_t lun, uint8_t *params)
|
||||
{
|
||||
uint16_t len = 8;
|
||||
|
||||
MSC_BOT_DataLen = len;
|
||||
|
||||
while (len)
|
||||
{
|
||||
len--;
|
||||
MSC_BOT_Data[len] = MSC_Mode_Sense10_data[len];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_RequestSense
|
||||
* Process Request Sense command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
|
||||
static int8_t SCSI_RequestSense (uint8_t lun, uint8_t *params)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for(i=0 ; i < REQUEST_SENSE_DATA_LEN ; i++)
|
||||
{
|
||||
MSC_BOT_Data[i] = 0;
|
||||
}
|
||||
|
||||
MSC_BOT_Data[0] = 0x70;
|
||||
MSC_BOT_Data[7] = REQUEST_SENSE_DATA_LEN - 6;
|
||||
|
||||
if((SCSI_Sense_Head != SCSI_Sense_Tail)) {
|
||||
|
||||
MSC_BOT_Data[2] = SCSI_Sense[SCSI_Sense_Head].Skey;
|
||||
MSC_BOT_Data[12] = SCSI_Sense[SCSI_Sense_Head].w.b.ASCQ;
|
||||
MSC_BOT_Data[13] = SCSI_Sense[SCSI_Sense_Head].w.b.ASC;
|
||||
SCSI_Sense_Head++;
|
||||
|
||||
if (SCSI_Sense_Head == SENSE_LIST_DEEPTH)
|
||||
{
|
||||
SCSI_Sense_Head = 0;
|
||||
}
|
||||
}
|
||||
MSC_BOT_DataLen = REQUEST_SENSE_DATA_LEN;
|
||||
|
||||
if (params[4] <= REQUEST_SENSE_DATA_LEN)
|
||||
{
|
||||
MSC_BOT_DataLen = params[4];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_SenseCode
|
||||
* Load the last error code in the error list
|
||||
* @param lun: Logical unit number
|
||||
* @param sKey: Sense Key
|
||||
* @param ASC: Additional Sense Key
|
||||
* @retval none
|
||||
|
||||
*/
|
||||
void SCSI_SenseCode(uint8_t lun, uint8_t sKey, uint8_t ASC)
|
||||
{
|
||||
SCSI_Sense[SCSI_Sense_Tail].Skey = sKey;
|
||||
SCSI_Sense[SCSI_Sense_Tail].w.ASC = ASC << 8;
|
||||
SCSI_Sense_Tail++;
|
||||
if (SCSI_Sense_Tail == SENSE_LIST_DEEPTH)
|
||||
{
|
||||
SCSI_Sense_Tail = 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief SCSI_StartStopUnit
|
||||
* Process Start Stop Unit command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_StartStopUnit(uint8_t lun, uint8_t *params)
|
||||
{
|
||||
MSC_BOT_DataLen = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_Read10
|
||||
* Process Read10 command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_Read10(uint8_t lun , uint8_t *params)
|
||||
{
|
||||
if(MSC_BOT_State == BOT_IDLE) /* Idle */
|
||||
{
|
||||
|
||||
/* case 10 : Ho <> Di */
|
||||
|
||||
if ((MSC_BOT_cbw.bmFlags & 0x80) != 0x80)
|
||||
{
|
||||
SCSI_SenseCode(MSC_BOT_cbw.bLUN,
|
||||
ILLEGAL_REQUEST,
|
||||
INVALID_CDB);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(USBD_STORAGE_fops->IsReady(lun) !=0 )
|
||||
{
|
||||
SCSI_SenseCode(lun,
|
||||
NOT_READY,
|
||||
MEDIUM_NOT_PRESENT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SCSI_blk_addr = (params[2] << 24) | \
|
||||
(params[3] << 16) | \
|
||||
(params[4] << 8) | \
|
||||
params[5];
|
||||
|
||||
SCSI_blk_len = (params[7] << 8) | \
|
||||
params[8];
|
||||
|
||||
|
||||
|
||||
if( SCSI_CheckAddressRange(lun, SCSI_blk_addr, SCSI_blk_len) < 0)
|
||||
{
|
||||
return -1; /* error */
|
||||
}
|
||||
|
||||
MSC_BOT_State = BOT_DATA_IN;
|
||||
SCSI_blk_addr *= SCSI_blk_size;
|
||||
SCSI_blk_len *= SCSI_blk_size;
|
||||
|
||||
/* cases 4,5 : Hi <> Dn */
|
||||
if (MSC_BOT_cbw.dDataLength != SCSI_blk_len)
|
||||
{
|
||||
SCSI_SenseCode(MSC_BOT_cbw.bLUN,
|
||||
ILLEGAL_REQUEST,
|
||||
INVALID_CDB);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
MSC_BOT_DataLen = MSC_MEDIA_PACKET;
|
||||
|
||||
return SCSI_ProcessRead(lun);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_Write10
|
||||
* Process Write10 command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
|
||||
static int8_t SCSI_Write10 (uint8_t lun , uint8_t *params)
|
||||
{
|
||||
if (MSC_BOT_State == BOT_IDLE) /* Idle */
|
||||
{
|
||||
|
||||
/* case 8 : Hi <> Do */
|
||||
|
||||
if ((MSC_BOT_cbw.bmFlags & 0x80) == 0x80)
|
||||
{
|
||||
SCSI_SenseCode(MSC_BOT_cbw.bLUN,
|
||||
ILLEGAL_REQUEST,
|
||||
INVALID_CDB);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check whether Media is ready */
|
||||
if(USBD_STORAGE_fops->IsReady(lun) !=0 )
|
||||
{
|
||||
SCSI_SenseCode(lun,
|
||||
NOT_READY,
|
||||
MEDIUM_NOT_PRESENT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check If media is write-protected */
|
||||
if(USBD_STORAGE_fops->IsWriteProtected(lun) !=0 )
|
||||
{
|
||||
SCSI_SenseCode(lun,
|
||||
NOT_READY,
|
||||
WRITE_PROTECTED);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
SCSI_blk_addr = (params[2] << 24) | \
|
||||
(params[3] << 16) | \
|
||||
(params[4] << 8) | \
|
||||
params[5];
|
||||
SCSI_blk_len = (params[7] << 8) | \
|
||||
params[8];
|
||||
|
||||
/* check if LBA address is in the right range */
|
||||
if(SCSI_CheckAddressRange(lun, SCSI_blk_addr, SCSI_blk_len) < 0)
|
||||
{
|
||||
return -1; /* error */
|
||||
}
|
||||
|
||||
SCSI_blk_addr *= SCSI_blk_size;
|
||||
SCSI_blk_len *= SCSI_blk_size;
|
||||
|
||||
/* cases 3,11,13 : Hn,Ho <> D0 */
|
||||
if (MSC_BOT_cbw.dDataLength != SCSI_blk_len)
|
||||
{
|
||||
SCSI_SenseCode(MSC_BOT_cbw.bLUN,
|
||||
ILLEGAL_REQUEST,
|
||||
INVALID_CDB);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Prepare EP to receive first data packet */
|
||||
MSC_BOT_State = BOT_DATA_OUT;
|
||||
DCD_EP_PrepareRx (cdev,
|
||||
MSC_OUT_EP,
|
||||
MSC_BOT_Data,
|
||||
MIN (SCSI_blk_len, MSC_MEDIA_PACKET));
|
||||
}
|
||||
else /* Write Process ongoing */
|
||||
{
|
||||
return SCSI_ProcessWrite(lun);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief SCSI_Verify10
|
||||
* Process Verify10 command
|
||||
* @param lun: Logical unit number
|
||||
* @param params: Command parameters
|
||||
* @retval status
|
||||
*/
|
||||
|
||||
static int8_t SCSI_Verify10(uint8_t lun , uint8_t *params){
|
||||
if ((params[1]& 0x02) == 0x02)
|
||||
{
|
||||
SCSI_SenseCode (lun, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
||||
return -1; /* Error, Verify Mode Not supported*/
|
||||
}
|
||||
|
||||
if(SCSI_CheckAddressRange(lun, SCSI_blk_addr, SCSI_blk_len) < 0)
|
||||
{
|
||||
return -1; /* error */
|
||||
}
|
||||
MSC_BOT_DataLen = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_CheckAddressRange
|
||||
* Check address range
|
||||
* @param lun: Logical unit number
|
||||
* @param blk_offset: first block address
|
||||
* @param blk_nbr: number of block to be processed
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_CheckAddressRange (uint8_t lun , uint32_t blk_offset , uint16_t blk_nbr)
|
||||
{
|
||||
|
||||
if ((blk_offset + blk_nbr) > SCSI_blk_nbr )
|
||||
{
|
||||
SCSI_SenseCode(lun, ILLEGAL_REQUEST, ADDRESS_OUT_OF_RANGE);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_ProcessRead
|
||||
* Handle Read Process
|
||||
* @param lun: Logical unit number
|
||||
* @retval status
|
||||
*/
|
||||
static int8_t SCSI_ProcessRead (uint8_t lun)
|
||||
{
|
||||
uint32_t len;
|
||||
|
||||
len = MIN(SCSI_blk_len , MSC_MEDIA_PACKET);
|
||||
|
||||
if( USBD_STORAGE_fops->Read(lun ,
|
||||
MSC_BOT_Data,
|
||||
SCSI_blk_addr / SCSI_blk_size,
|
||||
len / SCSI_blk_size) < 0)
|
||||
{
|
||||
|
||||
SCSI_SenseCode(lun, HARDWARE_ERROR, UNRECOVERED_READ_ERROR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
DCD_EP_Tx (cdev,
|
||||
MSC_IN_EP,
|
||||
MSC_BOT_Data,
|
||||
len);
|
||||
|
||||
|
||||
SCSI_blk_addr += len;
|
||||
SCSI_blk_len -= len;
|
||||
|
||||
/* case 6 : Hi = Di */
|
||||
MSC_BOT_csw.dDataResidue -= len;
|
||||
|
||||
if (SCSI_blk_len == 0)
|
||||
{
|
||||
MSC_BOT_State = BOT_LAST_DATA_IN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_ProcessWrite
|
||||
* Handle Write Process
|
||||
* @param lun: Logical unit number
|
||||
* @retval status
|
||||
*/
|
||||
|
||||
static int8_t SCSI_ProcessWrite (uint8_t lun)
|
||||
{
|
||||
uint32_t len;
|
||||
|
||||
len = MIN(SCSI_blk_len , MSC_MEDIA_PACKET);
|
||||
|
||||
if(USBD_STORAGE_fops->Write(lun ,
|
||||
MSC_BOT_Data,
|
||||
SCSI_blk_addr / SCSI_blk_size,
|
||||
len / SCSI_blk_size) < 0)
|
||||
{
|
||||
SCSI_SenseCode(lun, HARDWARE_ERROR, WRITE_FAULT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
SCSI_blk_addr += len;
|
||||
SCSI_blk_len -= len;
|
||||
|
||||
/* case 12 : Ho = Do */
|
||||
MSC_BOT_csw.dDataResidue -= len;
|
||||
|
||||
if (SCSI_blk_len == 0)
|
||||
{
|
||||
MSC_BOT_SendCSW (cdev, CSW_CMD_PASSED);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Prapare EP to Receive next packet */
|
||||
DCD_EP_PrepareRx (cdev,
|
||||
MSC_OUT_EP,
|
||||
MSC_BOT_Data,
|
||||
MIN (SCSI_blk_len, MSC_MEDIA_PACKET));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,185 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_storage_template.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief Memory management layer
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_msc_mem.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Extern function prototypes ------------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
#define STORAGE_LUN_NBR 1
|
||||
|
||||
int8_t STORAGE_Init (uint8_t lun);
|
||||
|
||||
int8_t STORAGE_GetCapacity (uint8_t lun,
|
||||
uint32_t *block_num,
|
||||
uint16_t *block_size);
|
||||
|
||||
int8_t STORAGE_IsReady (uint8_t lun);
|
||||
|
||||
int8_t STORAGE_IsWriteProtected (uint8_t lun);
|
||||
|
||||
int8_t STORAGE_Read (uint8_t lun,
|
||||
uint8_t *buf,
|
||||
uint32_t blk_addr,
|
||||
uint16_t blk_len);
|
||||
|
||||
int8_t STORAGE_Write (uint8_t lun,
|
||||
uint8_t *buf,
|
||||
uint32_t blk_addr,
|
||||
uint16_t blk_len);
|
||||
|
||||
int8_t STORAGE_GetMaxLun (void);
|
||||
|
||||
/* USB Mass storage Standard Inquiry Data */
|
||||
const int8_t STORAGE_Inquirydata[] = {//36
|
||||
|
||||
/* LUN 0 */
|
||||
0x00,
|
||||
0x80,
|
||||
0x02,
|
||||
0x02,
|
||||
(USBD_STD_INQUIRY_LENGTH - 5),
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */
|
||||
'P', 'r', 'o', 'd', 'u', 't', ' ', ' ', /* Product : 16 Bytes */
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
||||
'0', '.', '0' ,'1', /* Version : 4 Bytes */
|
||||
};
|
||||
|
||||
USBD_STORAGE_cb_TypeDef USBD_MICRO_SDIO_fops =
|
||||
{
|
||||
STORAGE_Init,
|
||||
STORAGE_GetCapacity,
|
||||
STORAGE_IsReady,
|
||||
STORAGE_IsWriteProtected,
|
||||
STORAGE_Read,
|
||||
STORAGE_Write,
|
||||
STORAGE_GetMaxLun,
|
||||
STORAGE_Inquirydata,
|
||||
|
||||
};
|
||||
|
||||
USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops = &USBD_MICRO_SDIO_fops;
|
||||
/*******************************************************************************
|
||||
* Function Name : Read_Memory
|
||||
* Description : Handle the Read operation from the microSD card.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
int8_t STORAGE_Init (uint8_t lun)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Read_Memory
|
||||
* Description : Handle the Read operation from the STORAGE card.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint16_t *block_size)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Read_Memory
|
||||
* Description : Handle the Read operation from the STORAGE card.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
int8_t STORAGE_IsReady (uint8_t lun)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Read_Memory
|
||||
* Description : Handle the Read operation from the STORAGE card.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
int8_t STORAGE_IsWriteProtected (uint8_t lun)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Read_Memory
|
||||
* Description : Handle the Read operation from the STORAGE card.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
int8_t STORAGE_Read (uint8_t lun,
|
||||
uint8_t *buf,
|
||||
uint32_t blk_addr,
|
||||
uint16_t blk_len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Function Name : Write_Memory
|
||||
* Description : Handle the Write operation to the STORAGE card.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
int8_t STORAGE_Write (uint8_t lun,
|
||||
uint8_t *buf,
|
||||
uint32_t blk_addr,
|
||||
uint16_t blk_len)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Function Name : Write_Memory
|
||||
* Description : Handle the Write operation to the STORAGE card.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
int8_t STORAGE_GetMaxLun (void)
|
||||
{
|
||||
return (STORAGE_LUN_NBR - 1);
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -0,0 +1,82 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_conf_template.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief usb device configuration template file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USBD_CONF__H__
|
||||
#define __USBD_CONF__H__
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usb_conf.h"
|
||||
|
||||
/** @defgroup USB_CONF_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#define USE_USB_OTG_HS
|
||||
|
||||
#define USBD_CFG_MAX_NUM 1
|
||||
#define USB_MAX_STR_DESC_SIZ 64
|
||||
#define USBD_EP0_MAX_PACKET_SIZE 64
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_CONF_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_CONF_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CONF_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CONF_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#endif //__USBD_CONF__H__
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @date 19-March-2012
|
||||
* @brief Header file for usbd_core.c
|
||||
******************************************************************************
|
||||
* @attention
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
@ -114,7 +114,7 @@ USBD_Status USBD_SetCfg(USB_OTG_CORE_HANDLE *pdev, uint8_t cfgidx);
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @date 19-March-2012
|
||||
* @brief general defines for the usb device library
|
||||
******************************************************************************
|
||||
* @attention
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
@ -153,4 +153,4 @@
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -118,4 +118,4 @@ uint16_t USBD_GetRxCount (USB_OTG_CORE_HANDLE *pdev ,
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -6,7 +6,7 @@
|
||||
* @date 19-March-2012
|
||||
* @brief header file for the usbd_req.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
@ -105,4 +105,4 @@ void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len);
|
||||
*/
|
||||
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -134,7 +134,7 @@ void USBD_USR_HS_DeviceDisconnected(void);
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
|
||||
|
@ -502,5 +502,5 @@ static uint8_t USBD_DevDisconnected(USB_OTG_CORE_HANDLE *pdev)
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -241,4 +241,4 @@ uint16_t USBD_GetRxCount (USB_OTG_CORE_HANDLE *pdev , uint8_t epnum)
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -369,7 +369,7 @@ static void USBD_GetDescriptor(USB_OTG_CORE_HANDLE *pdev,
|
||||
uint16_t len;
|
||||
const uint8_t *pbuf;
|
||||
|
||||
|
||||
|
||||
switch (req->wValue >> 8)
|
||||
{
|
||||
case USB_DESC_TYPE_DEVICE:
|
||||
@ -801,8 +801,8 @@ void USBD_CtlError( USB_OTG_CORE_HANDLE *pdev,
|
||||
__attribute__((unused)) USB_SETUP_REQ *req)
|
||||
{
|
||||
|
||||
DCD_EP_Stall(pdev , 0x80);
|
||||
DCD_EP_Stall(pdev , 0);
|
||||
DCD_EP_Stall(pdev , 0x80);
|
||||
DCD_EP_Stall(pdev , 0);
|
||||
USB_OTG_EP0_OutStart(pdev);
|
||||
}
|
||||
|
||||
@ -865,4 +865,4 @@ static uint8_t USBD_GetLen(uint8_t *buf)
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -99,5 +99,5 @@ void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -0,0 +1,306 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usb_conf.h
|
||||
* @author MCD Application Team
|
||||
* @version V2.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief General low level driver configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_CONF__H__
|
||||
#define __USB_CONF__H__
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usb_conf.h"
|
||||
|
||||
/** @addtogroup USB_OTG_DRIVER
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CONF
|
||||
* @brief USB low level driver configuration file
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CONF_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* USB Core and PHY interface configuration.
|
||||
Tip: To avoid modifying these defines each time you need to change the USB
|
||||
configuration, you can declare the needed define in your toolchain
|
||||
compiler preprocessor.
|
||||
*/
|
||||
/****************** USB OTG FS PHY CONFIGURATION *******************************
|
||||
* The USB OTG FS Core supports one on-chip Full Speed PHY.
|
||||
*
|
||||
* The USE_EMBEDDED_PHY symbol is defined in the project compiler preprocessor
|
||||
* when FS core is used.
|
||||
*******************************************************************************/
|
||||
#ifndef USE_USB_OTG_FS
|
||||
//#define USE_USB_OTG_FS
|
||||
#endif /* USE_USB_OTG_FS */
|
||||
|
||||
#ifdef USE_USB_OTG_FS
|
||||
#define USB_OTG_FS_CORE
|
||||
#endif
|
||||
|
||||
/****************** USB OTG HS PHY CONFIGURATION *******************************
|
||||
* The USB OTG HS Core supports two PHY interfaces:
|
||||
* (i) An ULPI interface for the external High Speed PHY: the USB HS Core will
|
||||
* operate in High speed mode
|
||||
* (ii) An on-chip Full Speed PHY: the USB HS Core will operate in Full speed mode
|
||||
*
|
||||
* You can select the PHY to be used using one of these two defines:
|
||||
* (i) USE_ULPI_PHY: if the USB OTG HS Core is to be used in High speed mode
|
||||
* (ii) USE_EMBEDDED_PHY: if the USB OTG HS Core is to be used in Full speed mode
|
||||
*
|
||||
* Notes:
|
||||
* - The USE_ULPI_PHY symbol is defined in the project compiler preprocessor as
|
||||
* default PHY when HS core is used.
|
||||
* - On STM322xG-EVAL and STM324xG-EVAL boards, only configuration(i) is available.
|
||||
* Configuration (ii) need a different hardware, for more details refer to your
|
||||
* STM32 device datasheet.
|
||||
*******************************************************************************/
|
||||
#ifndef USE_USB_OTG_HS
|
||||
//#define USE_USB_OTG_HS
|
||||
#endif /* USE_USB_OTG_HS */
|
||||
|
||||
#ifndef USE_ULPI_PHY
|
||||
//#define USE_ULPI_PHY
|
||||
#endif /* USE_ULPI_PHY */
|
||||
|
||||
#ifndef USE_EMBEDDED_PHY
|
||||
//#define USE_EMBEDDED_PHY
|
||||
#endif /* USE_EMBEDDED_PHY */
|
||||
|
||||
#ifdef USE_USB_OTG_HS
|
||||
#define USB_OTG_HS_CORE
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* FIFO Size Configuration in Device mode
|
||||
*
|
||||
* (i) Receive data FIFO size = RAM for setup packets +
|
||||
* OUT endpoint control information +
|
||||
* data OUT packets + miscellaneous
|
||||
* Space = ONE 32-bits words
|
||||
* --> RAM for setup packets = 10 spaces
|
||||
* (n is the nbr of CTRL EPs the device core supports)
|
||||
* --> OUT EP CTRL info = 1 space
|
||||
* (one space for status information written to the FIFO along with each
|
||||
* received packet)
|
||||
* --> data OUT packets = (Largest Packet Size / 4) + 1 spaces
|
||||
* (MINIMUM to receive packets)
|
||||
* --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces
|
||||
* (if high-bandwidth EP is enabled or multiple isochronous EPs)
|
||||
* --> miscellaneous = 1 space per OUT EP
|
||||
* (one space for transfer complete status information also pushed to the
|
||||
* FIFO with each endpoint's last packet)
|
||||
*
|
||||
* (ii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for
|
||||
* that particular IN EP. More space allocated in the IN EP Tx FIFO results
|
||||
* in a better performance on the USB and can hide latencies on the AHB.
|
||||
*
|
||||
* (iii) TXn min size = 16 words. (n : Transmit FIFO index)
|
||||
* (iv) When a TxFIFO is not used, the Configuration should be as follows:
|
||||
* case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
|
||||
* --> Txm can use the space allocated for Txn.
|
||||
* case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
|
||||
* --> Txn should be configured with the minimum space of 16 words
|
||||
* (v) The FIFO is used optimally when used TxFIFOs are allocated in the top
|
||||
* of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* FIFO Size Configuration in Host mode
|
||||
*
|
||||
* (i) Receive data FIFO size = (Largest Packet Size / 4) + 1 or
|
||||
* 2x (Largest Packet Size / 4) + 1, If a
|
||||
* high-bandwidth channel or multiple isochronous
|
||||
* channels are enabled
|
||||
*
|
||||
* (ii) For the host nonperiodic Transmit FIFO is the largest maximum packet size
|
||||
* for all supported nonperiodic OUT channels. Typically, a space
|
||||
* corresponding to two Largest Packet Size is recommended.
|
||||
*
|
||||
* (iii) The minimum amount of RAM required for Host periodic Transmit FIFO is
|
||||
* the largest maximum packet size for all supported periodic OUT channels.
|
||||
* If there is at least one High Bandwidth Isochronous OUT endpoint,
|
||||
* then the space must be at least two times the maximum packet size for
|
||||
* that channel.
|
||||
*******************************************************************************/
|
||||
|
||||
/****************** USB OTG HS CONFIGURATION **********************************/
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
#define RX_FIFO_HS_SIZE 512
|
||||
#define TX0_FIFO_HS_SIZE 512
|
||||
#define TX1_FIFO_HS_SIZE 512
|
||||
#define TX2_FIFO_HS_SIZE 0
|
||||
#define TX3_FIFO_HS_SIZE 0
|
||||
#define TX4_FIFO_HS_SIZE 0
|
||||
#define TX5_FIFO_HS_SIZE 0
|
||||
#define TXH_NP_HS_FIFOSIZ 96
|
||||
#define TXH_P_HS_FIFOSIZ 96
|
||||
|
||||
// #define USB_OTG_HS_LOW_PWR_MGMT_SUPPORT
|
||||
// #define USB_OTG_HS_SOF_OUTPUT_ENABLED
|
||||
|
||||
// #define USB_OTG_INTERNAL_VBUS_ENABLED
|
||||
#define USB_OTG_EXTERNAL_VBUS_ENABLED
|
||||
|
||||
#ifdef USE_ULPI_PHY
|
||||
#define USB_OTG_ULPI_PHY_ENABLED
|
||||
#endif
|
||||
#ifdef USE_EMBEDDED_PHY
|
||||
#define USB_OTG_EMBEDDED_PHY_ENABLED
|
||||
#endif
|
||||
#define USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#define USB_OTG_HS_DEDICATED_EP1_ENABLED
|
||||
#endif
|
||||
|
||||
/****************** USB OTG FS CONFIGURATION **********************************/
|
||||
#ifdef USB_OTG_FS_CORE
|
||||
#define RX_FIFO_FS_SIZE 128
|
||||
#define TX0_FIFO_FS_SIZE 64
|
||||
#define TX1_FIFO_FS_SIZE 128
|
||||
#define TX2_FIFO_FS_SIZE 0
|
||||
#define TX3_FIFO_FS_SIZE 0
|
||||
#define TXH_NP_HS_FIFOSIZ 96
|
||||
#define TXH_P_HS_FIFOSIZ 96
|
||||
|
||||
// #define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT
|
||||
// #define USB_OTG_FS_SOF_OUTPUT_ENABLED
|
||||
#endif
|
||||
|
||||
/****************** USB OTG MISC CONFIGURATION ********************************/
|
||||
//#define VBUS_SENSING_ENABLED
|
||||
|
||||
/****************** USB OTG MODE CONFIGURATION ********************************/
|
||||
//#define USE_HOST_MODE
|
||||
#define USE_DEVICE_MODE
|
||||
//#define USE_OTG_MODE
|
||||
|
||||
#ifndef USB_OTG_FS_CORE
|
||||
#ifndef USB_OTG_HS_CORE
|
||||
#error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef USE_DEVICE_MODE
|
||||
#ifndef USE_HOST_MODE
|
||||
#error "USE_DEVICE_MODE or USE_HOST_MODE should be defined"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef USE_USB_OTG_HS
|
||||
#ifndef USE_USB_OTG_FS
|
||||
#error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined"
|
||||
#endif
|
||||
#else //USE_USB_OTG_HS
|
||||
#ifndef USE_ULPI_PHY
|
||||
#ifndef USE_EMBEDDED_PHY
|
||||
#error "USE_ULPI_PHY or USE_EMBEDDED_PHY should be defined"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/****************** C Compilers dependant keywords ****************************/
|
||||
/* In HS mode and when the DMA is used, all variables and data structures dealing
|
||||
with the DMA during the transaction process should be 4-bytes aligned */
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#if defined (__GNUC__) /* GNU Compiler */
|
||||
#define __ALIGN_END __attribute__ ((aligned (4)))
|
||||
#define __ALIGN_BEGIN
|
||||
#else
|
||||
#define __ALIGN_END
|
||||
#if defined (__CC_ARM) /* ARM Compiler */
|
||||
#define __ALIGN_BEGIN __align(4)
|
||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
||||
#define __ALIGN_BEGIN
|
||||
#elif defined (__TASKING__) /* TASKING Compiler */
|
||||
#define __ALIGN_BEGIN __align(4)
|
||||
#endif /* __CC_ARM */
|
||||
#endif /* __GNUC__ */
|
||||
#else
|
||||
#define __ALIGN_BEGIN
|
||||
#define __ALIGN_END
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
|
||||
/* __packed keyword used to decrease the data type alignment to 1-byte */
|
||||
#if defined (__CC_ARM) /* ARM Compiler */
|
||||
#define __packed __packed
|
||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
||||
#define __packed __packed
|
||||
#elif defined ( __GNUC__ ) /* GNU Compiler */
|
||||
#define __packed __attribute__ ((__packed__))
|
||||
#elif defined (__TASKING__) /* TASKING Compiler */
|
||||
#define __packed __unaligned
|
||||
#endif /* __CC_ARM */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_CONF_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_CONF_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CONF_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CONF_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#endif //__USB_CONF__H__
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -413,5 +413,5 @@ uint32_t USB_OTG_GetEPStatus(USB_OTG_CORE_HANDLE *pdev ,USB_OTG_EP *ep);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @date 19-March-2012
|
||||
* @brief Peripheral Driver Header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
@ -160,5 +160,5 @@ void DCD_SetEPStatus (USB_OTG_CORE_HANDLE *pdev ,
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @date 19-March-2012
|
||||
* @brief Peripheral Device Interface Layer
|
||||
******************************************************************************
|
||||
* @attention
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
@ -123,5 +123,5 @@ uint32_t USBD_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -247,5 +247,5 @@ enum USB_OTG_SPEED {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -104,5 +104,5 @@ HC_STATUS HCD_GetHCState (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @date 19-March-2012
|
||||
* @brief Peripheral Device Interface Layer
|
||||
******************************************************************************
|
||||
* @attention
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
@ -137,5 +137,5 @@ uint32_t USBH_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -95,5 +95,5 @@ uint32_t USB_OTG_GetCurrentState (USB_OTG_CORE_DEVICE *pdev);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -166,11 +166,11 @@ typedef struct _USB_OTG_OUTEPREGS
|
||||
{
|
||||
__IO uint32_t DOEPCTL; /* dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h*/
|
||||
uint32_t Reserved04; /* Reserved B00h + (ep_num * 20h) + 04h*/
|
||||
__IO uint32_t DOEPINT; /* dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h*/
|
||||
uint32_t Reserved0C; /* Reserved B00h + (ep_num * 20h) + 0Ch*/
|
||||
__IO uint32_t DOEPTSIZ; /* dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h*/
|
||||
__IO uint32_t DOEPDMA; /* dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h*/
|
||||
uint32_t Reserved18[2]; /* Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch*/
|
||||
__IO uint32_t DOEPINT; /* dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h*/
|
||||
uint32_t Reserved0C; /* Reserved B00h + (ep_num * 20h) + 0Ch*/
|
||||
__IO uint32_t DOEPTSIZ; /* dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h*/
|
||||
__IO uint32_t DOEPDMA; /* dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h*/
|
||||
uint32_t Reserved18[2]; /* Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch*/
|
||||
}
|
||||
USB_OTG_OUTEPREGS;
|
||||
/**
|
||||
@ -588,21 +588,21 @@ typedef union _USB_OTG_HNPTXSTS_TypeDef
|
||||
uint32_t d32;
|
||||
struct
|
||||
{
|
||||
uint32_t nptxfspcavail :
|
||||
16;
|
||||
uint32_t nptxqspcavail :
|
||||
8;
|
||||
uint32_t nptxfspcavail :
|
||||
16;
|
||||
uint32_t nptxqspcavail :
|
||||
8;
|
||||
struct
|
||||
{
|
||||
uint32_t terminate :
|
||||
1;
|
||||
1;
|
||||
uint32_t token :
|
||||
2;
|
||||
uint32_t chnum :
|
||||
2;
|
||||
uint32_t chnum :
|
||||
4;
|
||||
} nptxqtop;
|
||||
uint32_t Reserved :
|
||||
1;
|
||||
uint32_t Reserved :
|
||||
1;
|
||||
}
|
||||
b;
|
||||
} USB_OTG_HNPTXSTS_TypeDef ;
|
||||
@ -688,7 +688,7 @@ uint32_t sgoutnak :
|
||||
uint32_t cgoutnak :
|
||||
1;
|
||||
uint32_t poprg_done :
|
||||
1;
|
||||
1;
|
||||
uint32_t Reserved :
|
||||
20;
|
||||
}
|
||||
@ -924,13 +924,13 @@ uint32_t ptxqspcavail :
|
||||
struct
|
||||
{
|
||||
uint32_t terminate :
|
||||
1;
|
||||
1;
|
||||
uint32_t token :
|
||||
2;
|
||||
uint32_t chnum :
|
||||
2;
|
||||
uint32_t chnum :
|
||||
4;
|
||||
uint32_t odd_even :
|
||||
1;
|
||||
1;
|
||||
} ptxqtop;
|
||||
}
|
||||
b;
|
||||
@ -1184,5 +1184,5 @@ uint32_t Reserved5_31 :
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -203,4 +203,4 @@ void USB_OTG_BSP_TimerIRQ (void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -6,7 +6,7 @@
|
||||
* @date 19-March-2012
|
||||
* @brief USB-OTG Core Layer
|
||||
******************************************************************************
|
||||
* @attention
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
@ -229,7 +229,7 @@ USB_OTG_STS USB_OTG_SelectCore(USB_OTG_CORE_HANDLE *pdev,
|
||||
/* at startup the core is in FS mode */
|
||||
pdev->cfg.speed = USB_OTG_SPEED_FULL;
|
||||
pdev->cfg.mps = USB_OTG_FS_MAX_PACKET_SIZE ;
|
||||
|
||||
|
||||
/* initialize device cfg following its address */
|
||||
if (coreID == USB_OTG_FS_CORE_ID)
|
||||
{
|
||||
@ -259,9 +259,9 @@ USB_OTG_STS USB_OTG_SelectCore(USB_OTG_CORE_HANDLE *pdev,
|
||||
#ifdef USB_OTG_ULPI_PHY_ENABLED
|
||||
pdev->cfg.phy_itface = USB_OTG_ULPI_PHY;
|
||||
#else
|
||||
#ifdef USB_OTG_EMBEDDED_PHY_ENABLED
|
||||
#ifdef USB_OTG_EMBEDDED_PHY_ENABLED
|
||||
pdev->cfg.phy_itface = USB_OTG_EMBEDDED_PHY;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
@ -331,7 +331,7 @@ USB_OTG_STS USB_OTG_CoreInit(USB_OTG_CORE_HANDLE *pdev)
|
||||
gccfg.d32 = 0;
|
||||
ahbcfg.d32 = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
if (pdev->cfg.phy_itface == USB_OTG_ULPI_PHY)
|
||||
{
|
||||
@ -352,9 +352,9 @@ USB_OTG_STS USB_OTG_CoreInit(USB_OTG_CORE_HANDLE *pdev)
|
||||
#ifdef USB_OTG_INTERNAL_VBUS_ENABLED
|
||||
usbcfg.b.ulpi_ext_vbus_drv = 0; /* Use internal VBUS */
|
||||
#else
|
||||
#ifdef USB_OTG_EXTERNAL_VBUS_ENABLED
|
||||
#ifdef USB_OTG_EXTERNAL_VBUS_ENABLED
|
||||
usbcfg.b.ulpi_ext_vbus_drv = 1; /* Use external VBUS */
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
usbcfg.b.term_sel_dl_pulse = 0; /* Data line pulsing using utmi_txvalid */
|
||||
|
||||
@ -374,7 +374,7 @@ USB_OTG_STS USB_OTG_CoreInit(USB_OTG_CORE_HANDLE *pdev)
|
||||
|
||||
}
|
||||
}
|
||||
else /* FS interface (embedded Phy or I2C Phy) */
|
||||
else /* FS interface (embedded Phy) */
|
||||
{
|
||||
|
||||
usbcfg.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->GUSBCFG);;
|
||||
@ -382,7 +382,7 @@ USB_OTG_STS USB_OTG_CoreInit(USB_OTG_CORE_HANDLE *pdev)
|
||||
USB_OTG_WRITE_REG32 (&pdev->regs.GREGS->GUSBCFG, usbcfg.d32);
|
||||
/* Reset after a PHY select and set Host mode */
|
||||
USB_OTG_CoreReset(pdev);
|
||||
/* Enable the I2C interface and deactivate the power down*/
|
||||
/* Deactivate the power down*/
|
||||
gccfg.d32 = 0;
|
||||
gccfg.b.pwdn = 1;
|
||||
|
||||
@ -643,7 +643,7 @@ USB_OTG_STS USB_OTG_CoreInitHost(USB_OTG_CORE_HANDLE *pdev)
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_OTG_InitFSLSPClkSel(pdev , HCFG_48_MHZ); /* in init phase */
|
||||
USB_OTG_InitFSLSPClkSel(pdev , HCFG_48_MHZ);
|
||||
}
|
||||
USB_OTG_ResetPort(pdev);
|
||||
|
||||
@ -668,9 +668,9 @@ USB_OTG_STS USB_OTG_CoreInitHost(USB_OTG_CORE_HANDLE *pdev)
|
||||
}
|
||||
#endif
|
||||
#ifdef USB_OTG_HS_CORE
|
||||
if (pdev->cfg.coreID == USB_OTG_HS_CORE_ID)
|
||||
if (pdev->cfg.coreID == USB_OTG_HS_CORE_ID)
|
||||
{
|
||||
/* set Rx FIFO size */
|
||||
/* set Rx FIFO size */
|
||||
USB_OTG_WRITE_REG32(&pdev->regs.GREGS->GRXFSIZ, RX_FIFO_HS_SIZE);
|
||||
nptxfifosize.b.startaddr = RX_FIFO_HS_SIZE;
|
||||
nptxfifosize.b.depth = TXH_NP_HS_FIFOSIZ;
|
||||
@ -1023,11 +1023,11 @@ USB_OTG_STS USB_OTG_HC_StartXfer(USB_OTG_CORE_HANDLE *pdev , uint8_t hc_num)
|
||||
hcchar.b.chen = 1;
|
||||
hcchar.b.chdis = 0;
|
||||
USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCCHAR, hcchar.d32);
|
||||
|
||||
|
||||
if (pdev->cfg.dma_enable == 0) /* Slave mode */
|
||||
{
|
||||
if((pdev->host.hc[hc_num].ep_is_in == 0) &&
|
||||
(pdev->host.hc[hc_num].xfer_len > 0))
|
||||
(pdev->host.hc[hc_num].xfer_len > 0))
|
||||
{
|
||||
switch(pdev->host.hc[hc_num].ep_type)
|
||||
{
|
||||
@ -1125,7 +1125,7 @@ USB_OTG_STS USB_OTG_HC_DoPing(USB_OTG_CORE_HANDLE *pdev , uint8_t hc_num)
|
||||
USB_OTG_STS status = USB_OTG_OK;
|
||||
USB_OTG_HCCHAR_TypeDef hcchar;
|
||||
USB_OTG_HCTSIZn_TypeDef hctsiz;
|
||||
|
||||
|
||||
hctsiz.d32 = 0;
|
||||
hctsiz.b.dopng = 1;
|
||||
hctsiz.b.pktcnt = 1;
|
||||
@ -1257,7 +1257,7 @@ USB_OTG_STS USB_OTG_CoreInitDev (USB_OTG_CORE_HANDLE *pdev)
|
||||
|
||||
if(pdev->cfg.phy_itface == USB_OTG_ULPI_PHY)
|
||||
{
|
||||
USB_OTG_InitDevSpeed (pdev , USB_OTG_SPEED_PARAM_HIGH);
|
||||
USB_OTG_InitDevSpeed (pdev , USB_OTG_SPEED_PARAM_HIGH);
|
||||
}
|
||||
else /* set High speed phy in Full speed mode */
|
||||
{
|
||||
@ -1330,6 +1330,7 @@ USB_OTG_STS USB_OTG_CoreInitDev (USB_OTG_CORE_HANDLE *pdev)
|
||||
}
|
||||
for (i = 0; i < pdev->cfg.dev_endpoints; i++)
|
||||
{
|
||||
// USB_OTG_DEPCTL_TypeDef depctl;
|
||||
depctl.d32 = USB_OTG_READ_REG32(&pdev->regs.OUTEP_REGS[i]->DOEPCTL);
|
||||
if (depctl.b.epena)
|
||||
{
|
||||
@ -1395,7 +1396,7 @@ USB_OTG_STS USB_OTG_EnableDevInt(USB_OTG_CORE_HANDLE *pdev)
|
||||
intmsk.b.inepintr = 1;
|
||||
intmsk.b.outepintr = 1;
|
||||
intmsk.b.sofintr = 1;
|
||||
|
||||
|
||||
intmsk.b.incomplisoin = 1;
|
||||
intmsk.b.incomplisoout = 1;
|
||||
#ifdef VBUS_SENSING_ENABLED
|
||||
@ -1602,7 +1603,7 @@ USB_OTG_STS USB_OTG_EPStartXfer(USB_OTG_CORE_HANDLE *pdev , USB_OTG_EP *ep)
|
||||
*/
|
||||
deptsiz.b.xfersize = ep->xfer_len;
|
||||
deptsiz.b.pktcnt = (ep->xfer_len - 1 + ep->maxpacket) / ep->maxpacket;
|
||||
|
||||
|
||||
if (ep->type == EP_TYPE_ISOC)
|
||||
{
|
||||
deptsiz.b.mc = 1;
|
||||
@ -1646,7 +1647,7 @@ USB_OTG_STS USB_OTG_EPStartXfer(USB_OTG_CORE_HANDLE *pdev , USB_OTG_EP *ep)
|
||||
depctl.b.cnak = 1;
|
||||
depctl.b.epena = 1;
|
||||
USB_OTG_WRITE_REG32(&pdev->regs.INEP_REGS[ep->num]->DIEPCTL, depctl.d32);
|
||||
|
||||
|
||||
if (ep->type == EP_TYPE_ISOC)
|
||||
{
|
||||
USB_OTG_WritePacket(pdev, ep->xfer_buff, ep->num, ep->xfer_len);
|
||||
@ -2013,13 +2014,13 @@ void USB_OTG_StopDevice(USB_OTG_CORE_HANDLE *pdev)
|
||||
uint32_t i;
|
||||
|
||||
pdev->dev.device_status = 1;
|
||||
|
||||
|
||||
for (i = 0; i < pdev->cfg.dev_endpoints ; i++)
|
||||
{
|
||||
USB_OTG_WRITE_REG32( &pdev->regs.INEP_REGS[i]->DIEPINT, 0xFF);
|
||||
USB_OTG_WRITE_REG32( &pdev->regs.OUTEP_REGS[i]->DOEPINT, 0xFF);
|
||||
}
|
||||
|
||||
|
||||
USB_OTG_WRITE_REG32( &pdev->regs.DREGS->DIEPMSK, 0 );
|
||||
USB_OTG_WRITE_REG32( &pdev->regs.DREGS->DOEPMSK, 0 );
|
||||
USB_OTG_WRITE_REG32( &pdev->regs.DREGS->DAINTMSK, 0 );
|
||||
@ -2055,7 +2056,7 @@ uint32_t USB_OTG_GetEPStatus(USB_OTG_CORE_HANDLE *pdev ,USB_OTG_EP *ep)
|
||||
Status = USB_OTG_EP_TX_NAK;
|
||||
else
|
||||
Status = USB_OTG_EP_TX_VALID;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2086,7 +2087,7 @@ void USB_OTG_SetEPStatus (USB_OTG_CORE_HANDLE *pdev , USB_OTG_EP *ep , uint32_t
|
||||
__IO uint32_t *depctl_addr;
|
||||
|
||||
depctl.d32 = 0;
|
||||
|
||||
|
||||
/* Process for IN endpoint */
|
||||
if (ep->is_in == 1)
|
||||
{
|
||||
@ -2141,7 +2142,7 @@ void USB_OTG_SetEPStatus (USB_OTG_CORE_HANDLE *pdev , USB_OTG_EP *ep , uint32_t
|
||||
depctl.b.usbactep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
USB_OTG_WRITE_REG32(depctl_addr, depctl.d32);
|
||||
}
|
||||
|
||||
@ -2158,4 +2159,4 @@ void USB_OTG_SetEPStatus (USB_OTG_CORE_HANDLE *pdev , USB_OTG_EP *ep , uint32_t
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -6,7 +6,7 @@
|
||||
* @date 19-March-2012
|
||||
* @brief Peripheral Device Interface Layer
|
||||
******************************************************************************
|
||||
* @attention
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
@ -475,4 +475,4 @@ void DCD_SetEPStatus (USB_OTG_CORE_HANDLE *pdev , uint8_t epnum , uint32_t Statu
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -6,7 +6,7 @@
|
||||
* @date 19-March-2012
|
||||
* @brief Peripheral Device interrupt subroutines
|
||||
******************************************************************************
|
||||
* @attention
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
@ -426,7 +426,7 @@ static uint32_t DCD_HandleInEP_ISR(USB_OTG_CORE_HANDLE *pdev)
|
||||
|
||||
uint32_t ep_intr;
|
||||
uint32_t epnum = 0;
|
||||
// uint32_t fifoemptymsk;
|
||||
// uint32_t fifoemptymsk;
|
||||
diepint.d32 = 0;
|
||||
ep_intr = USB_OTG_ReadDevAllInEPItr(pdev);
|
||||
|
||||
@ -541,7 +541,7 @@ static uint32_t DCD_HandleOutEP_ISR(USB_OTG_CORE_HANDLE *pdev)
|
||||
/* Clear the bit in DOEPINTn for this interrupt */
|
||||
CLEAR_OUT_EP_INTR(epnum, epdisabled);
|
||||
}
|
||||
/* AHB Error */
|
||||
/* Setup Phase Done (control EPs) */
|
||||
if ( doepint.b.setup )
|
||||
{
|
||||
|
||||
@ -679,8 +679,8 @@ static uint32_t DCD_WriteEmptyTxFifo(USB_OTG_CORE_HANDLE *pdev, uint32_t epnum)
|
||||
|
||||
txstatus.d32 = USB_OTG_READ_REG32(&pdev->regs.INEP_REGS[epnum]->DTXFSTS);
|
||||
}
|
||||
uint32_t fifoemptymsk;
|
||||
// --- start fix (just before return 1)
|
||||
// --- start fix
|
||||
uint32_t fifoemptymsk;
|
||||
if (len < ep->maxpacket)
|
||||
{
|
||||
// FIFO empty
|
||||
@ -876,4 +876,4 @@ static uint32_t DCD_ReadDevInEP (USB_OTG_CORE_HANDLE *pdev, uint8_t epnum)
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -259,4 +259,4 @@ uint32_t HCD_SubmitRequest (USB_OTG_CORE_HANDLE *pdev , uint8_t hc_num)
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -31,60 +31,60 @@
|
||||
#include "usb_hcd_int.h"
|
||||
|
||||
#if defined (__CC_ARM) /*!< ARM Compiler */
|
||||
#pragma O0
|
||||
#pragma O0
|
||||
#elif defined (__GNUC__) /*!< GNU Compiler */
|
||||
#pragma GCC optimize ("O0")
|
||||
#pragma GCC optimize ("O0")
|
||||
#elif defined (__TASKING__) /*!< TASKING Compiler */
|
||||
#pragma optimize=0
|
||||
#pragma optimize=0
|
||||
|
||||
#endif /* __CC_ARM */
|
||||
|
||||
/** @addtogroup USB_OTG_DRIVER
|
||||
* @{
|
||||
*/
|
||||
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_HCD_INT
|
||||
* @brief This file contains the interrupt subroutines for the Host mode.
|
||||
* @{
|
||||
*/
|
||||
* @brief This file contains the interrupt subroutines for the Host mode.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_HCD_INT_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_HCD_INT_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USB_HCD_INT_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_HCD_INT_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_HCD_INT_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
* @{
|
||||
*/
|
||||
|
||||
static uint32_t USB_OTG_USBH_handle_sof_ISR(USB_OTG_CORE_HANDLE *pdev);
|
||||
static uint32_t USB_OTG_USBH_handle_port_ISR(USB_OTG_CORE_HANDLE *pdev);
|
||||
@ -100,20 +100,20 @@ static uint32_t USB_OTG_USBH_handle_Disconnect_ISR (USB_OTG_CORE_HANDLE *pdev);
|
||||
static uint32_t USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR (USB_OTG_CORE_HANDLE *pdev);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_HCD_INT_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief HOST_Handle_ISR
|
||||
* This function handles all USB Host Interrupts
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
* @brief HOST_Handle_ISR
|
||||
* This function handles all USB Host Interrupts
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
|
||||
uint32_t USBH_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
@ -167,22 +167,22 @@ uint32_t USBH_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev)
|
||||
|
||||
}
|
||||
|
||||
if (gintsts.b.incomplisoout)
|
||||
{
|
||||
retval |= USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR (pdev);
|
||||
}
|
||||
|
||||
if (gintsts.b.incomplisoout)
|
||||
{
|
||||
retval |= USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR (pdev);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_USBH_handle_hc_ISR
|
||||
* This function indicates that one or more host channels has a pending
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_USBH_handle_hc_ISR
|
||||
* This function indicates that one or more host channels has a pending
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
static uint32_t USB_OTG_USBH_handle_hc_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
USB_OTG_HAINT_TypeDef haint;
|
||||
@ -216,11 +216,11 @@ static uint32_t USB_OTG_USBH_handle_hc_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_otg_hcd_handle_sof_intr
|
||||
* Handles the start-of-frame interrupt in host mode.
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_otg_hcd_handle_sof_intr
|
||||
* Handles the start-of-frame interrupt in host mode.
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
static uint32_t USB_OTG_USBH_handle_sof_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
USB_OTG_GINTSTS_TypeDef gintsts;
|
||||
@ -236,11 +236,11 @@ static uint32_t USB_OTG_USBH_handle_sof_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_USBH_handle_Disconnect_ISR
|
||||
* Handles disconnect event.
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_USBH_handle_Disconnect_ISR
|
||||
* Handles disconnect event.
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
static uint32_t USB_OTG_USBH_handle_Disconnect_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
USB_OTG_GINTSTS_TypeDef gintsts;
|
||||
@ -259,11 +259,11 @@ static uint32_t USB_OTG_USBH_handle_Disconnect_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
#pragma optimize = none
|
||||
#endif /* __CC_ARM */
|
||||
/**
|
||||
* @brief USB_OTG_USBH_handle_nptxfempty_ISR
|
||||
* Handles non periodic tx fifo empty.
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_USBH_handle_nptxfempty_ISR
|
||||
* Handles non periodic tx fifo empty.
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
static uint32_t USB_OTG_USBH_handle_nptxfempty_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
USB_OTG_GINTMSK_TypeDef intmsk;
|
||||
@ -297,21 +297,21 @@ static uint32_t USB_OTG_USBH_handle_nptxfempty_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
pdev->host.hc[hnptxsts.b.nptxqtop.chnum].xfer_buff += len;
|
||||
pdev->host.hc[hnptxsts.b.nptxqtop.chnum].xfer_len -= len;
|
||||
pdev->host.hc[hnptxsts.b.nptxqtop.chnum].xfer_count += len;
|
||||
|
||||
|
||||
hnptxsts.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->HNPTXSTS);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma optimize = none
|
||||
#endif /* __CC_ARM */
|
||||
/**
|
||||
* @brief USB_OTG_USBH_handle_ptxfempty_ISR
|
||||
* Handles periodic tx fifo empty
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_USBH_handle_ptxfempty_ISR
|
||||
* Handles periodic tx fifo empty
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
static uint32_t USB_OTG_USBH_handle_ptxfempty_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
USB_OTG_GINTMSK_TypeDef intmsk;
|
||||
@ -344,7 +344,7 @@ static uint32_t USB_OTG_USBH_handle_ptxfempty_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
pdev->host.hc[hptxsts.b.ptxqtop.chnum].xfer_buff += len;
|
||||
pdev->host.hc[hptxsts.b.ptxqtop.chnum].xfer_len -= len;
|
||||
pdev->host.hc[hptxsts.b.ptxqtop.chnum].xfer_count += len;
|
||||
|
||||
|
||||
hptxsts.d32 = USB_OTG_READ_REG32(&pdev->regs.HREGS->HPTXSTS);
|
||||
}
|
||||
|
||||
@ -352,11 +352,11 @@ static uint32_t USB_OTG_USBH_handle_ptxfempty_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_USBH_handle_port_ISR
|
||||
* This function determines which interrupt conditions have occurred
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_USBH_handle_port_ISR
|
||||
* This function determines which interrupt conditions have occurred
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma optimize = none
|
||||
#endif /* __CC_ARM */
|
||||
@ -413,9 +413,9 @@ static uint32_t USB_OTG_USBH_handle_port_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
if (hcfg.b.fslspclksel != HCFG_6_MHZ)
|
||||
{
|
||||
if(pdev->cfg.phy_itface == USB_OTG_EMBEDDED_PHY)
|
||||
{
|
||||
{
|
||||
USB_OTG_InitFSLSPClkSel(pdev ,HCFG_6_MHZ );
|
||||
}
|
||||
}
|
||||
do_reset = 1;
|
||||
}
|
||||
}
|
||||
@ -455,12 +455,12 @@ static uint32_t USB_OTG_USBH_handle_port_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
#pragma optimize = none
|
||||
#endif /* __CC_ARM */
|
||||
/**
|
||||
* @brief USB_OTG_USBH_handle_hc_n_Out_ISR
|
||||
* Handles interrupt for a specific Host Channel
|
||||
* @param pdev: Selected device
|
||||
* @param hc_num: Channel number
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_USBH_handle_hc_n_Out_ISR
|
||||
* Handles interrupt for a specific Host Channel
|
||||
* @param pdev: Selected device
|
||||
* @param hc_num: Channel number
|
||||
* @retval status
|
||||
*/
|
||||
uint32_t USB_OTG_USBH_handle_hc_n_Out_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t num)
|
||||
{
|
||||
|
||||
@ -535,7 +535,7 @@ uint32_t USB_OTG_USBH_handle_hc_n_Out_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t
|
||||
}
|
||||
else if (hcint.b.datatglerr)
|
||||
{
|
||||
|
||||
|
||||
UNMASK_HOST_INT_CHH (num);
|
||||
USB_OTG_HC_Halt(pdev, num);
|
||||
CLEAR_HC_INT(hcreg , nak);
|
||||
@ -583,19 +583,19 @@ uint32_t USB_OTG_USBH_handle_hc_n_Out_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t
|
||||
CLEAR_HC_INT(hcreg , chhltd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma optimize = none
|
||||
#endif /* __CC_ARM */
|
||||
/**
|
||||
* @brief USB_OTG_USBH_handle_hc_n_In_ISR
|
||||
* Handles interrupt for a specific Host Channel
|
||||
* @param pdev: Selected device
|
||||
* @param hc_num: Channel number
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_USBH_handle_hc_n_In_ISR
|
||||
* Handles interrupt for a specific Host Channel
|
||||
* @param pdev: Selected device
|
||||
* @param hc_num: Channel number
|
||||
* @retval status
|
||||
*/
|
||||
uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t num)
|
||||
{
|
||||
USB_OTG_HCINTn_TypeDef hcint;
|
||||
@ -603,7 +603,7 @@ uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t n
|
||||
USB_OTG_HCCHAR_TypeDef hcchar;
|
||||
USB_OTG_HCTSIZn_TypeDef hctsiz;
|
||||
USB_OTG_HC_REGS *hcreg;
|
||||
|
||||
|
||||
|
||||
hcreg = pdev->regs.HC_REGS[num];
|
||||
hcint.d32 = USB_OTG_READ_REG32(&hcreg->HCINT);
|
||||
@ -631,16 +631,16 @@ uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t n
|
||||
CLEAR_HC_INT(hcreg , stall); /* Clear the STALL Condition */
|
||||
hcint.b.nak = 0; /* NOTE: When there is a 'stall', reset also nak,
|
||||
else, the pdev->host.HC_Status = HC_STALL
|
||||
will be overwritten by 'nak' in code below */
|
||||
will be overwritten by 'nak' in code below */
|
||||
USB_OTG_HC_Halt(pdev, num);
|
||||
}
|
||||
else if (hcint.b.datatglerr)
|
||||
{
|
||||
|
||||
UNMASK_HOST_INT_CHH (num);
|
||||
USB_OTG_HC_Halt(pdev, num);
|
||||
CLEAR_HC_INT(hcreg , nak);
|
||||
pdev->host.HC_Status[num] = HC_DATATGLERR;
|
||||
|
||||
UNMASK_HOST_INT_CHH (num);
|
||||
USB_OTG_HC_Halt(pdev, num);
|
||||
CLEAR_HC_INT(hcreg , nak);
|
||||
pdev->host.HC_Status[num] = HC_DATATGLERR;
|
||||
CLEAR_HC_INT(hcreg , datatglerr);
|
||||
}
|
||||
|
||||
@ -659,7 +659,7 @@ uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t n
|
||||
hctsiz.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[num]->HCTSIZ);
|
||||
pdev->host.XferCnt[num] = pdev->host.hc[num].xfer_len - hctsiz.b.xfersize;
|
||||
}
|
||||
|
||||
|
||||
pdev->host.HC_Status[num] = HC_XFRC;
|
||||
pdev->host.ErrCnt [num]= 0;
|
||||
CLEAR_HC_INT(hcreg , xfercompl);
|
||||
@ -671,7 +671,7 @@ uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t n
|
||||
USB_OTG_HC_Halt(pdev, num);
|
||||
CLEAR_HC_INT(hcreg , nak);
|
||||
pdev->host.hc[num].toggle_in ^= 1;
|
||||
|
||||
|
||||
}
|
||||
else if(hcchar.b.eptype == EP_TYPE_INTR)
|
||||
{
|
||||
@ -692,15 +692,15 @@ uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t n
|
||||
|
||||
else if (pdev->host.HC_Status[num] == HC_STALL)
|
||||
{
|
||||
pdev->host.URB_State[num] = URB_STALL;
|
||||
pdev->host.URB_State[num] = URB_STALL;
|
||||
}
|
||||
|
||||
else if((pdev->host.HC_Status[num] == HC_XACTERR) ||
|
||||
(pdev->host.HC_Status[num] == HC_DATATGLERR))
|
||||
{
|
||||
pdev->host.ErrCnt[num] = 0;
|
||||
pdev->host.URB_State[num] = URB_ERROR;
|
||||
|
||||
pdev->host.ErrCnt[num] = 0;
|
||||
pdev->host.URB_State[num] = URB_ERROR;
|
||||
|
||||
}
|
||||
else if(hcchar.b.eptype == EP_TYPE_INTR)
|
||||
{
|
||||
@ -726,8 +726,8 @@ uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t n
|
||||
UNMASK_HOST_INT_CHH (num);
|
||||
USB_OTG_HC_Halt(pdev, num);
|
||||
}
|
||||
else if ((hcchar.b.eptype == EP_TYPE_CTRL)||
|
||||
(hcchar.b.eptype == EP_TYPE_BULK))
|
||||
else if ((hcchar.b.eptype == EP_TYPE_CTRL)||
|
||||
(hcchar.b.eptype == EP_TYPE_BULK))
|
||||
{
|
||||
/* re-activate the channel */
|
||||
hcchar.b.chen = 1;
|
||||
@ -737,18 +737,18 @@ uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t n
|
||||
pdev->host.HC_Status[num] = HC_NAK;
|
||||
CLEAR_HC_INT(hcreg , nak);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_USBH_handle_rx_qlvl_ISR
|
||||
* Handles the Rx Status Queue Level Interrupt
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_USBH_handle_rx_qlvl_ISR
|
||||
* Handles the Rx Status Queue Level Interrupt
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma optimize = none
|
||||
#endif /* __CC_ARM */
|
||||
@ -782,7 +782,7 @@ static uint32_t USB_OTG_USBH_handle_rx_qlvl_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
pdev->host.hc[grxsts.b.chnum].xfer_buff += grxsts.b.bcnt;
|
||||
pdev->host.hc[grxsts.b.chnum].xfer_count += grxsts.b.bcnt;
|
||||
|
||||
|
||||
|
||||
count = pdev->host.hc[channelnum].xfer_count;
|
||||
pdev->host.XferCnt[channelnum] = count;
|
||||
|
||||
@ -797,9 +797,9 @@ static uint32_t USB_OTG_USBH_handle_rx_qlvl_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
}
|
||||
break;
|
||||
|
||||
case GRXSTS_PKTSTS_IN_XFER_COMP:
|
||||
|
||||
case GRXSTS_PKTSTS_DATA_TOGGLE_ERR:
|
||||
case GRXSTS_PKTSTS_IN_XFER_COMP:
|
||||
|
||||
case GRXSTS_PKTSTS_DATA_TOGGLE_ERR:
|
||||
case GRXSTS_PKTSTS_CH_HALTED:
|
||||
default:
|
||||
break;
|
||||
@ -812,34 +812,34 @@ static uint32_t USB_OTG_USBH_handle_rx_qlvl_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR
|
||||
* Handles the incomplete Periodic transfer Interrupt
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
* @brief USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR
|
||||
* Handles the incomplete Periodic transfer Interrupt
|
||||
* @param pdev: Selected device
|
||||
* @retval status
|
||||
*/
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma optimize = none
|
||||
#endif /* __CC_ARM */
|
||||
static uint32_t USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR (USB_OTG_CORE_HANDLE *pdev)
|
||||
{
|
||||
|
||||
USB_OTG_GINTSTS_TypeDef gintsts;
|
||||
USB_OTG_HCCHAR_TypeDef hcchar;
|
||||
|
||||
|
||||
|
||||
|
||||
hcchar.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[0]->HCCHAR);
|
||||
hcchar.b.chen = 1;
|
||||
hcchar.b.chdis = 1;
|
||||
USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[0]->HCCHAR, hcchar.d32);
|
||||
|
||||
gintsts.d32 = 0;
|
||||
/* Clear interrupt */
|
||||
gintsts.b.incomplisoout = 1;
|
||||
USB_OTG_WRITE_REG32(&pdev->regs.GREGS->GINTSTS, gintsts.d32);
|
||||
|
||||
return 1;
|
||||
USB_OTG_GINTSTS_TypeDef gintsts;
|
||||
USB_OTG_HCCHAR_TypeDef hcchar;
|
||||
|
||||
|
||||
|
||||
|
||||
hcchar.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[0]->HCCHAR);
|
||||
hcchar.b.chen = 1;
|
||||
hcchar.b.chdis = 1;
|
||||
USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[0]->HCCHAR, hcchar.d32);
|
||||
|
||||
gintsts.d32 = 0;
|
||||
/* Clear interrupt */
|
||||
gintsts.b.incomplisoout = 1;
|
||||
USB_OTG_WRITE_REG32(&pdev->regs.GREGS->GINTSTS, gintsts.d32);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -854,5 +854,5 @@ static uint32_t USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR (USB_OTG_CORE_HAN
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -415,4 +415,4 @@ uint32_t USB_OTG_GetCurrentState (USB_OTG_CORE_HANDLE *pdev)
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
Binary file not shown.
@ -2,11 +2,11 @@
|
||||
******************************************************************************
|
||||
* @file stm32f4xx.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.0.0
|
||||
* @date 30-September-2011
|
||||
* @version V1.1.0
|
||||
* @date 11-January-2013
|
||||
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer Header File.
|
||||
* This file contains all the peripheral register's definitions, bits
|
||||
* definitions and memory mapping for STM32F4xx devices.
|
||||
* definitions and memory mapping for STM32F4xx devices.
|
||||
*
|
||||
* The file is the unique include file that the application programmer
|
||||
* is using in the C source code, usually in main.c. This file contains:
|
||||
@ -25,14 +25,20 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@ -59,16 +65,18 @@
|
||||
application
|
||||
*/
|
||||
|
||||
#if !defined (STM32F4XX)
|
||||
#define STM32F4XX
|
||||
#if !defined (STM32F4XX) && !defined (STM32F40XX) && !defined (STM32F427X)
|
||||
/* #define STM32F40XX */ /*!< STM32F40xx/41xx Devices */
|
||||
/* #define STM32F427X */ /*!< STM32F427x/437x Devices*/
|
||||
#endif
|
||||
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to switch between these
|
||||
devices, you can define the device in your toolchain compiler preprocessor.
|
||||
*/
|
||||
|
||||
#if !defined (STM32F4XX)
|
||||
#error "Please select first the target STM32F4XX device used in your application (in stm32f4xx.h file)"
|
||||
#if !defined (STM32F4XX) && !defined (STM32F40XX) && !defined (STM32F427X)
|
||||
#error "Please select first the target STM32F4xx device used in your application (in stm32f4xx.h file)"
|
||||
#endif
|
||||
|
||||
#if !defined (USE_STDPERIPH_DRIVER)
|
||||
@ -77,7 +85,7 @@
|
||||
In this case, these drivers will not be included and the application code will
|
||||
be based on direct access to peripherals registers
|
||||
*/
|
||||
/*#define USE_STDPERIPH_DRIVER*/
|
||||
/*#define USE_STDPERIPH_DRIVER */
|
||||
#endif /* USE_STDPERIPH_DRIVER */
|
||||
|
||||
/**
|
||||
@ -105,10 +113,10 @@
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/**
|
||||
* @brief STM32F4XX Standard Peripherals Library version number V1.0.0
|
||||
* @brief STM32F4XX Standard Peripherals Library version number V1.1.0
|
||||
*/
|
||||
#define __STM32F4XX_STDPERIPH_VERSION_MAIN (0x01) /*!< [31:24] main version */
|
||||
#define __STM32F4XX_STDPERIPH_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
|
||||
#define __STM32F4XX_STDPERIPH_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */
|
||||
#define __STM32F4XX_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
|
||||
#define __STM32F4XX_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
||||
#define __STM32F4XX_STDPERIPH_VERSION ((__STM32F4XX_STDPERIPH_VERSION_MAIN << 24)\
|
||||
@ -220,7 +228,7 @@ typedef enum IRQn
|
||||
DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */
|
||||
DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */
|
||||
DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */
|
||||
USART6_IRQn = 71, /*!< USART6 global interrupt */
|
||||
USART6_IRQn = 71, /*!< USART6 global interrupt */
|
||||
I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */
|
||||
I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */
|
||||
OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */
|
||||
@ -229,8 +237,21 @@ typedef enum IRQn
|
||||
OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */
|
||||
DCMI_IRQn = 78, /*!< DCMI global interrupt */
|
||||
CRYP_IRQn = 79, /*!< CRYP crypto global interrupt */
|
||||
HASH_RNG_IRQn = 80, /*!< Hash and Rng global interrupt */
|
||||
HASH_RNG_IRQn = 80, /*!< Hash and Rng global interrupt */
|
||||
|
||||
#ifdef STM32F40XX
|
||||
FPU_IRQn = 81 /*!< FPU global interrupt */
|
||||
#endif /* STM32F40XX */
|
||||
|
||||
#ifdef STM32F427X
|
||||
FPU_IRQn = 81, /*!< FPU global interrupt */
|
||||
UART7_IRQn = 82, /*!< UART7 global interrupt */
|
||||
UART8_IRQn = 83, /*!< UART8 global interrupt */
|
||||
SPI4_IRQn = 84, /*!< SPI4 global Interrupt */
|
||||
SPI5_IRQn = 85, /*!< SPI5 global Interrupt */
|
||||
SPI6_IRQn = 86 /*!< SPI6 global Interrupt */
|
||||
#endif /* STM32F427X */
|
||||
|
||||
} IRQn_Type;
|
||||
|
||||
/**
|
||||
@ -575,12 +596,13 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */
|
||||
__IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */
|
||||
__IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */
|
||||
__IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */
|
||||
__IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */
|
||||
__IO uint32_t OPTCR; /*!< FLASH option control register, Address offset: 0x14 */
|
||||
__IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */
|
||||
__IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */
|
||||
__IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */
|
||||
__IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */
|
||||
__IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */
|
||||
__IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */
|
||||
__IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */
|
||||
} FLASH_TypeDef;
|
||||
|
||||
/**
|
||||
@ -697,6 +719,8 @@ typedef struct
|
||||
uint16_t RESERVED7; /*!< Reserved, 0x1E */
|
||||
__IO uint16_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */
|
||||
uint16_t RESERVED8; /*!< Reserved, 0x22 */
|
||||
__IO uint16_t FLTR; /*!< I2C FLTR register, Address offset: 0x24 */
|
||||
uint16_t RESERVED9; /*!< Reserved, 0x26 */
|
||||
} I2C_TypeDef;
|
||||
|
||||
/**
|
||||
@ -757,6 +781,12 @@ typedef struct
|
||||
uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */
|
||||
__IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */
|
||||
__IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */
|
||||
|
||||
#ifdef STM32F427X
|
||||
uint32_t RESERVED7; /*!< Reserved, 0x88 */
|
||||
__IO uint32_t DCKCFGR; /*!< RCC Dedicated Clocks configuration register, Address offset: 0x8C */
|
||||
#endif /* STM32F427X */
|
||||
|
||||
} RCC_TypeDef;
|
||||
|
||||
/**
|
||||
@ -944,26 +974,42 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t CR; /*!< CRYP control register, Address offset: 0x00 */
|
||||
__IO uint32_t SR; /*!< CRYP status register, Address offset: 0x04 */
|
||||
__IO uint32_t DR; /*!< CRYP data input register, Address offset: 0x08 */
|
||||
__IO uint32_t DOUT; /*!< CRYP data output register, Address offset: 0x0C */
|
||||
__IO uint32_t DMACR; /*!< CRYP DMA control register, Address offset: 0x10 */
|
||||
__IO uint32_t IMSCR; /*!< CRYP interrupt mask set/clear register, Address offset: 0x14 */
|
||||
__IO uint32_t RISR; /*!< CRYP raw interrupt status register, Address offset: 0x18 */
|
||||
__IO uint32_t MISR; /*!< CRYP masked interrupt status register, Address offset: 0x1C */
|
||||
__IO uint32_t K0LR; /*!< CRYP key left register 0, Address offset: 0x20 */
|
||||
__IO uint32_t K0RR; /*!< CRYP key right register 0, Address offset: 0x24 */
|
||||
__IO uint32_t K1LR; /*!< CRYP key left register 1, Address offset: 0x28 */
|
||||
__IO uint32_t K1RR; /*!< CRYP key right register 1, Address offset: 0x2C */
|
||||
__IO uint32_t K2LR; /*!< CRYP key left register 2, Address offset: 0x30 */
|
||||
__IO uint32_t K2RR; /*!< CRYP key right register 2, Address offset: 0x34 */
|
||||
__IO uint32_t K3LR; /*!< CRYP key left register 3, Address offset: 0x38 */
|
||||
__IO uint32_t K3RR; /*!< CRYP key right register 3, Address offset: 0x3C */
|
||||
__IO uint32_t IV0LR; /*!< CRYP initialization vector left-word register 0, Address offset: 0x40 */
|
||||
__IO uint32_t IV0RR; /*!< CRYP initialization vector right-word register 0, Address offset: 0x44 */
|
||||
__IO uint32_t IV1LR; /*!< CRYP initialization vector left-word register 1, Address offset: 0x48 */
|
||||
__IO uint32_t IV1RR; /*!< CRYP initialization vector right-word register 1, Address offset: 0x4C */
|
||||
__IO uint32_t CR; /*!< CRYP control register, Address offset: 0x00 */
|
||||
__IO uint32_t SR; /*!< CRYP status register, Address offset: 0x04 */
|
||||
__IO uint32_t DR; /*!< CRYP data input register, Address offset: 0x08 */
|
||||
__IO uint32_t DOUT; /*!< CRYP data output register, Address offset: 0x0C */
|
||||
__IO uint32_t DMACR; /*!< CRYP DMA control register, Address offset: 0x10 */
|
||||
__IO uint32_t IMSCR; /*!< CRYP interrupt mask set/clear register, Address offset: 0x14 */
|
||||
__IO uint32_t RISR; /*!< CRYP raw interrupt status register, Address offset: 0x18 */
|
||||
__IO uint32_t MISR; /*!< CRYP masked interrupt status register, Address offset: 0x1C */
|
||||
__IO uint32_t K0LR; /*!< CRYP key left register 0, Address offset: 0x20 */
|
||||
__IO uint32_t K0RR; /*!< CRYP key right register 0, Address offset: 0x24 */
|
||||
__IO uint32_t K1LR; /*!< CRYP key left register 1, Address offset: 0x28 */
|
||||
__IO uint32_t K1RR; /*!< CRYP key right register 1, Address offset: 0x2C */
|
||||
__IO uint32_t K2LR; /*!< CRYP key left register 2, Address offset: 0x30 */
|
||||
__IO uint32_t K2RR; /*!< CRYP key right register 2, Address offset: 0x34 */
|
||||
__IO uint32_t K3LR; /*!< CRYP key left register 3, Address offset: 0x38 */
|
||||
__IO uint32_t K3RR; /*!< CRYP key right register 3, Address offset: 0x3C */
|
||||
__IO uint32_t IV0LR; /*!< CRYP initialization vector left-word register 0, Address offset: 0x40 */
|
||||
__IO uint32_t IV0RR; /*!< CRYP initialization vector right-word register 0, Address offset: 0x44 */
|
||||
__IO uint32_t IV1LR; /*!< CRYP initialization vector left-word register 1, Address offset: 0x48 */
|
||||
__IO uint32_t IV1RR; /*!< CRYP initialization vector right-word register 1, Address offset: 0x4C */
|
||||
__IO uint32_t CSGCMCCM0R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 0, Address offset: 0x50 */
|
||||
__IO uint32_t CSGCMCCM1R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 1, Address offset: 0x54 */
|
||||
__IO uint32_t CSGCMCCM2R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 2, Address offset: 0x58 */
|
||||
__IO uint32_t CSGCMCCM3R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 3, Address offset: 0x5C */
|
||||
__IO uint32_t CSGCMCCM4R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 4, Address offset: 0x60 */
|
||||
__IO uint32_t CSGCMCCM5R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 5, Address offset: 0x64 */
|
||||
__IO uint32_t CSGCMCCM6R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 6, Address offset: 0x68 */
|
||||
__IO uint32_t CSGCMCCM7R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 7, Address offset: 0x6C */
|
||||
__IO uint32_t CSGCM0R; /*!< CRYP GCM/GMAC context swap register 0, Address offset: 0x70 */
|
||||
__IO uint32_t CSGCM1R; /*!< CRYP GCM/GMAC context swap register 1, Address offset: 0x74 */
|
||||
__IO uint32_t CSGCM2R; /*!< CRYP GCM/GMAC context swap register 2, Address offset: 0x78 */
|
||||
__IO uint32_t CSGCM3R; /*!< CRYP GCM/GMAC context swap register 3, Address offset: 0x7C */
|
||||
__IO uint32_t CSGCM4R; /*!< CRYP GCM/GMAC context swap register 4, Address offset: 0x80 */
|
||||
__IO uint32_t CSGCM5R; /*!< CRYP GCM/GMAC context swap register 5, Address offset: 0x84 */
|
||||
__IO uint32_t CSGCM6R; /*!< CRYP GCM/GMAC context swap register 6, Address offset: 0x88 */
|
||||
__IO uint32_t CSGCM7R; /*!< CRYP GCM/GMAC context swap register 7, Address offset: 0x8C */
|
||||
} CRYP_TypeDef;
|
||||
|
||||
/**
|
||||
@ -972,18 +1018,27 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t CR; /*!< HASH control register, Address offset: 0x00 */
|
||||
__IO uint32_t DIN; /*!< HASH data input register, Address offset: 0x04 */
|
||||
__IO uint32_t STR; /*!< HASH start register, Address offset: 0x08 */
|
||||
__IO uint32_t HR[5]; /*!< HASH digest registers, Address offset: 0x0C-0x1C */
|
||||
__IO uint32_t IMR; /*!< HASH interrupt enable register, Address offset: 0x20 */
|
||||
__IO uint32_t SR; /*!< HASH status register, Address offset: 0x24 */
|
||||
uint32_t RESERVED[52]; /*!< Reserved, 0x28-0xF4 */
|
||||
__IO uint32_t CSR[51]; /*!< HASH context swap registers, Address offset: 0x0F8-0x1C0 */
|
||||
__IO uint32_t CR; /*!< HASH control register, Address offset: 0x00 */
|
||||
__IO uint32_t DIN; /*!< HASH data input register, Address offset: 0x04 */
|
||||
__IO uint32_t STR; /*!< HASH start register, Address offset: 0x08 */
|
||||
__IO uint32_t HR[5]; /*!< HASH digest registers, Address offset: 0x0C-0x1C */
|
||||
__IO uint32_t IMR; /*!< HASH interrupt enable register, Address offset: 0x20 */
|
||||
__IO uint32_t SR; /*!< HASH status register, Address offset: 0x24 */
|
||||
uint32_t RESERVED[52]; /*!< Reserved, 0x28-0xF4 */
|
||||
__IO uint32_t CSR[54]; /*!< HASH context swap registers, Address offset: 0x0F8-0x1CC */
|
||||
} HASH_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief HASH
|
||||
* @brief HASH_DIGEST
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t HR[8]; /*!< HASH digest registers, Address offset: 0x310-0x32C */
|
||||
} HASH_DIGEST_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief RNG
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
@ -1004,6 +1059,7 @@ typedef struct
|
||||
#define CCMDATARAM_BASE ((uint32_t)0x10000000) /*!< CCM(core coupled memory) data RAM(64 KB) base address in the alias region */
|
||||
#define SRAM1_BASE ((uint32_t)0x20000000) /*!< SRAM1(112 KB) base address in the alias region */
|
||||
#define SRAM2_BASE ((uint32_t)0x2001C000) /*!< SRAM2(16 KB) base address in the alias region */
|
||||
#define SRAM3_BASE ((uint32_t)0x20020000) /*!< SRAM3(64 KB) base address in the alias region */
|
||||
#define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */
|
||||
#define BKPSRAM_BASE ((uint32_t)0x40024000) /*!< Backup SRAM(4 KB) base address in the alias region */
|
||||
#define FSMC_R_BASE ((uint32_t)0xA0000000) /*!< FSMC registers base address */
|
||||
@ -1011,6 +1067,7 @@ typedef struct
|
||||
#define CCMDATARAM_BB_BASE ((uint32_t)0x12000000) /*!< CCM(core coupled memory) data RAM(64 KB) base address in the bit-band region */
|
||||
#define SRAM1_BB_BASE ((uint32_t)0x22000000) /*!< SRAM1(112 KB) base address in the bit-band region */
|
||||
#define SRAM2_BB_BASE ((uint32_t)0x2201C000) /*!< SRAM2(16 KB) base address in the bit-band region */
|
||||
#define SRAM3_BB_BASE ((uint32_t)0x22020000) /*!< SRAM3(64 KB) base address in the bit-band region */
|
||||
#define PERIPH_BB_BASE ((uint32_t)0x42000000) /*!< Peripheral base address in the bit-band region */
|
||||
#define BKPSRAM_BB_BASE ((uint32_t)0x42024000) /*!< Backup SRAM(4 KB) base address in the bit-band region */
|
||||
|
||||
@ -1018,7 +1075,6 @@ typedef struct
|
||||
#define SRAM_BASE SRAM1_BASE
|
||||
#define SRAM_BB_BASE SRAM1_BB_BASE
|
||||
|
||||
|
||||
/*!< Peripheral memory map */
|
||||
#define APB1PERIPH_BASE PERIPH_BASE
|
||||
#define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000)
|
||||
@ -1053,6 +1109,8 @@ typedef struct
|
||||
#define CAN2_BASE (APB1PERIPH_BASE + 0x6800)
|
||||
#define PWR_BASE (APB1PERIPH_BASE + 0x7000)
|
||||
#define DAC_BASE (APB1PERIPH_BASE + 0x7400)
|
||||
#define UART7_BASE (APB1PERIPH_BASE + 0x7800)
|
||||
#define UART8_BASE (APB1PERIPH_BASE + 0x7C00)
|
||||
|
||||
/*!< APB2 peripherals */
|
||||
#define TIM1_BASE (APB2PERIPH_BASE + 0x0000)
|
||||
@ -1065,11 +1123,14 @@ typedef struct
|
||||
#define ADC_BASE (APB2PERIPH_BASE + 0x2300)
|
||||
#define SDIO_BASE (APB2PERIPH_BASE + 0x2C00)
|
||||
#define SPI1_BASE (APB2PERIPH_BASE + 0x3000)
|
||||
#define SPI4_BASE (APB2PERIPH_BASE + 0x3400)
|
||||
#define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800)
|
||||
#define EXTI_BASE (APB2PERIPH_BASE + 0x3C00)
|
||||
#define TIM9_BASE (APB2PERIPH_BASE + 0x4000)
|
||||
#define TIM10_BASE (APB2PERIPH_BASE + 0x4400)
|
||||
#define TIM11_BASE (APB2PERIPH_BASE + 0x4800)
|
||||
#define SPI5_BASE (APB2PERIPH_BASE + 0x5000)
|
||||
#define SPI6_BASE (APB2PERIPH_BASE + 0x5400)
|
||||
|
||||
/*!< AHB1 peripherals */
|
||||
#define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000)
|
||||
@ -1081,6 +1142,7 @@ typedef struct
|
||||
#define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800)
|
||||
#define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00)
|
||||
#define GPIOI_BASE (AHB1PERIPH_BASE + 0x2000)
|
||||
|
||||
#define CRC_BASE (AHB1PERIPH_BASE + 0x3000)
|
||||
#define RCC_BASE (AHB1PERIPH_BASE + 0x3800)
|
||||
#define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00)
|
||||
@ -1112,6 +1174,7 @@ typedef struct
|
||||
#define DCMI_BASE (AHB2PERIPH_BASE + 0x50000)
|
||||
#define CRYP_BASE (AHB2PERIPH_BASE + 0x60000)
|
||||
#define HASH_BASE (AHB2PERIPH_BASE + 0x60400)
|
||||
#define HASH_DIGEST_BASE (AHB2PERIPH_BASE + 0x60710)
|
||||
#define RNG_BASE (AHB2PERIPH_BASE + 0x60800)
|
||||
|
||||
/*!< FSMC Bankx registers base address */
|
||||
@ -1158,6 +1221,8 @@ typedef struct
|
||||
#define CAN2 ((CAN_TypeDef *) CAN2_BASE)
|
||||
#define PWR ((PWR_TypeDef *) PWR_BASE)
|
||||
#define DAC ((DAC_TypeDef *) DAC_BASE)
|
||||
#define UART7 ((USART_TypeDef *) UART7_BASE)
|
||||
#define UART8 ((USART_TypeDef *) UART8_BASE)
|
||||
#define TIM1 ((TIM_TypeDef *) TIM1_BASE)
|
||||
#define TIM8 ((TIM_TypeDef *) TIM8_BASE)
|
||||
#define USART1 ((USART_TypeDef *) USART1_BASE)
|
||||
@ -1167,12 +1232,16 @@ typedef struct
|
||||
#define ADC2 ((ADC_TypeDef *) ADC2_BASE)
|
||||
#define ADC3 ((ADC_TypeDef *) ADC3_BASE)
|
||||
#define SDIO ((SDIO_TypeDef *) SDIO_BASE)
|
||||
#define SPI1 ((SPI_TypeDef *) SPI1_BASE)
|
||||
#define SPI1 ((SPI_TypeDef *) SPI1_BASE)
|
||||
#define SPI4 ((SPI_TypeDef *) SPI4_BASE)
|
||||
#define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE)
|
||||
#define EXTI ((EXTI_TypeDef *) EXTI_BASE)
|
||||
#define TIM9 ((TIM_TypeDef *) TIM9_BASE)
|
||||
#define TIM10 ((TIM_TypeDef *) TIM10_BASE)
|
||||
#define TIM11 ((TIM_TypeDef *) TIM11_BASE)
|
||||
#define SPI5 ((SPI_TypeDef *) SPI5_BASE)
|
||||
#define SPI6 ((SPI_TypeDef *) SPI6_BASE)
|
||||
|
||||
#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE)
|
||||
#define GPIOB ((GPIO_TypeDef *) GPIOB_BASE)
|
||||
#define GPIOC ((GPIO_TypeDef *) GPIOC_BASE)
|
||||
@ -1182,6 +1251,7 @@ typedef struct
|
||||
#define GPIOG ((GPIO_TypeDef *) GPIOG_BASE)
|
||||
#define GPIOH ((GPIO_TypeDef *) GPIOH_BASE)
|
||||
#define GPIOI ((GPIO_TypeDef *) GPIOI_BASE)
|
||||
|
||||
#define CRC ((CRC_TypeDef *) CRC_BASE)
|
||||
#define RCC ((RCC_TypeDef *) RCC_BASE)
|
||||
#define FLASH ((FLASH_TypeDef *) FLASH_R_BASE)
|
||||
@ -1207,12 +1277,13 @@ typedef struct
|
||||
#define DCMI ((DCMI_TypeDef *) DCMI_BASE)
|
||||
#define CRYP ((CRYP_TypeDef *) CRYP_BASE)
|
||||
#define HASH ((HASH_TypeDef *) HASH_BASE)
|
||||
#define HASH_DIGEST ((HASH_DIGEST_TypeDef *) HASH_DIGEST_BASE)
|
||||
#define RNG ((RNG_TypeDef *) RNG_BASE)
|
||||
#define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE)
|
||||
#define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE)
|
||||
#define FSMC_Bank2 ((FSMC_Bank2_TypeDef *) FSMC_Bank2_R_BASE)
|
||||
#define FSMC_Bank3 ((FSMC_Bank3_TypeDef *) FSMC_Bank3_R_BASE)
|
||||
#define FSMC_Bank4 ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE)
|
||||
#define FSMC_Bank4 ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE)
|
||||
#define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE)
|
||||
|
||||
/**
|
||||
@ -2864,7 +2935,7 @@ typedef struct
|
||||
/******************* Bits definition for CRYP_CR register ********************/
|
||||
#define CRYP_CR_ALGODIR ((uint32_t)0x00000004)
|
||||
|
||||
#define CRYP_CR_ALGOMODE ((uint32_t)0x00000038)
|
||||
#define CRYP_CR_ALGOMODE ((uint32_t)0x00080038)
|
||||
#define CRYP_CR_ALGOMODE_0 ((uint32_t)0x00000008)
|
||||
#define CRYP_CR_ALGOMODE_1 ((uint32_t)0x00000010)
|
||||
#define CRYP_CR_ALGOMODE_2 ((uint32_t)0x00000020)
|
||||
@ -2885,6 +2956,12 @@ typedef struct
|
||||
#define CRYP_CR_KEYSIZE_1 ((uint32_t)0x00000200)
|
||||
#define CRYP_CR_FFLUSH ((uint32_t)0x00004000)
|
||||
#define CRYP_CR_CRYPEN ((uint32_t)0x00008000)
|
||||
|
||||
#define CRYP_CR_GCM_CCMPH ((uint32_t)0x00030000)
|
||||
#define CRYP_CR_GCM_CCMPH_0 ((uint32_t)0x00010000)
|
||||
#define CRYP_CR_GCM_CCMPH_1 ((uint32_t)0x00020000)
|
||||
#define CRYP_CR_ALGOMODE_3 ((uint32_t)0x00080000)
|
||||
|
||||
/****************** Bits definition for CRYP_SR register *********************/
|
||||
#define CRYP_SR_IFEM ((uint32_t)0x00000001)
|
||||
#define CRYP_SR_IFNF ((uint32_t)0x00000002)
|
||||
@ -3215,6 +3292,7 @@ typedef struct
|
||||
#define DMA_HIFCR_CDMEIF4 ((uint32_t)0x00000004)
|
||||
#define DMA_HIFCR_CFEIF4 ((uint32_t)0x00000001)
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* External Interrupt/Event Controller */
|
||||
@ -3358,7 +3436,7 @@ typedef struct
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/******************* Bits definition for FLASH_ACR register *****************/
|
||||
#define FLASH_ACR_LATENCY ((uint32_t)0x00000007)
|
||||
#define FLASH_ACR_LATENCY ((uint32_t)0x0000000F)
|
||||
#define FLASH_ACR_LATENCY_0WS ((uint32_t)0x00000000)
|
||||
#define FLASH_ACR_LATENCY_1WS ((uint32_t)0x00000001)
|
||||
#define FLASH_ACR_LATENCY_2WS ((uint32_t)0x00000002)
|
||||
@ -3389,45 +3467,68 @@ typedef struct
|
||||
#define FLASH_CR_PG ((uint32_t)0x00000001)
|
||||
#define FLASH_CR_SER ((uint32_t)0x00000002)
|
||||
#define FLASH_CR_MER ((uint32_t)0x00000004)
|
||||
#define FLASH_CR_MER1 FLASH_CR_MER
|
||||
#define FLASH_CR_SNB ((uint32_t)0x000000F8)
|
||||
#define FLASH_CR_SNB_0 ((uint32_t)0x00000008)
|
||||
#define FLASH_CR_SNB_1 ((uint32_t)0x00000010)
|
||||
#define FLASH_CR_SNB_2 ((uint32_t)0x00000020)
|
||||
#define FLASH_CR_SNB_3 ((uint32_t)0x00000040)
|
||||
#define FLASH_CR_SNB_4 ((uint32_t)0x00000040)
|
||||
#define FLASH_CR_PSIZE ((uint32_t)0x00000300)
|
||||
#define FLASH_CR_PSIZE_0 ((uint32_t)0x00000100)
|
||||
#define FLASH_CR_PSIZE_1 ((uint32_t)0x00000200)
|
||||
#define FLASH_CR_MER2 ((uint32_t)0x00008000)
|
||||
#define FLASH_CR_STRT ((uint32_t)0x00010000)
|
||||
#define FLASH_CR_EOPIE ((uint32_t)0x01000000)
|
||||
#define FLASH_CR_LOCK ((uint32_t)0x80000000)
|
||||
|
||||
/******************* Bits definition for FLASH_OPTCR register ***************/
|
||||
#define FLASH_OPTCR_OPTLOCK ((uint32_t)0x00000001)
|
||||
#define FLASH_OPTCR_OPTSTRT ((uint32_t)0x00000002)
|
||||
#define FLASH_OPTCR_BOR_LEV_0 ((uint32_t)0x00000004)
|
||||
#define FLASH_OPTCR_BOR_LEV_1 ((uint32_t)0x00000008)
|
||||
#define FLASH_OPTCR_BOR_LEV ((uint32_t)0x0000000C)
|
||||
#define FLASH_OPTCR_WDG_SW ((uint32_t)0x00000020)
|
||||
#define FLASH_OPTCR_nRST_STOP ((uint32_t)0x00000040)
|
||||
#define FLASH_OPTCR_nRST_STDBY ((uint32_t)0x00000080)
|
||||
#define FLASH_OPTCR_RDP_0 ((uint32_t)0x00000100)
|
||||
#define FLASH_OPTCR_RDP_1 ((uint32_t)0x00000200)
|
||||
#define FLASH_OPTCR_RDP_2 ((uint32_t)0x00000400)
|
||||
#define FLASH_OPTCR_RDP_3 ((uint32_t)0x00000800)
|
||||
#define FLASH_OPTCR_RDP_4 ((uint32_t)0x00001000)
|
||||
#define FLASH_OPTCR_RDP_5 ((uint32_t)0x00002000)
|
||||
#define FLASH_OPTCR_RDP_6 ((uint32_t)0x00004000)
|
||||
#define FLASH_OPTCR_RDP_7 ((uint32_t)0x00008000)
|
||||
#define FLASH_OPTCR_nWRP_0 ((uint32_t)0x00010000)
|
||||
#define FLASH_OPTCR_nWRP_1 ((uint32_t)0x00020000)
|
||||
#define FLASH_OPTCR_nWRP_2 ((uint32_t)0x00040000)
|
||||
#define FLASH_OPTCR_nWRP_3 ((uint32_t)0x00080000)
|
||||
#define FLASH_OPTCR_nWRP_4 ((uint32_t)0x00100000)
|
||||
#define FLASH_OPTCR_nWRP_5 ((uint32_t)0x00200000)
|
||||
#define FLASH_OPTCR_nWRP_6 ((uint32_t)0x00400000)
|
||||
#define FLASH_OPTCR_nWRP_7 ((uint32_t)0x00800000)
|
||||
#define FLASH_OPTCR_nWRP_8 ((uint32_t)0x01000000)
|
||||
#define FLASH_OPTCR_nWRP_9 ((uint32_t)0x02000000)
|
||||
#define FLASH_OPTCR_nWRP_10 ((uint32_t)0x04000000)
|
||||
#define FLASH_OPTCR_nWRP_11 ((uint32_t)0x08000000)
|
||||
#define FLASH_OPTCR_OPTLOCK ((uint32_t)0x00000001)
|
||||
#define FLASH_OPTCR_OPTSTRT ((uint32_t)0x00000002)
|
||||
#define FLASH_OPTCR_BOR_LEV_0 ((uint32_t)0x00000004)
|
||||
#define FLASH_OPTCR_BOR_LEV_1 ((uint32_t)0x00000008)
|
||||
#define FLASH_OPTCR_BOR_LEV ((uint32_t)0x0000000C)
|
||||
#define FLASH_OPTCR_WDG_SW ((uint32_t)0x00000020)
|
||||
#define FLASH_OPTCR_nRST_STOP ((uint32_t)0x00000040)
|
||||
#define FLASH_OPTCR_nRST_STDBY ((uint32_t)0x00000080)
|
||||
#define FLASH_OPTCR_RDP ((uint32_t)0x0000FF00)
|
||||
#define FLASH_OPTCR_RDP_0 ((uint32_t)0x00000100)
|
||||
#define FLASH_OPTCR_RDP_1 ((uint32_t)0x00000200)
|
||||
#define FLASH_OPTCR_RDP_2 ((uint32_t)0x00000400)
|
||||
#define FLASH_OPTCR_RDP_3 ((uint32_t)0x00000800)
|
||||
#define FLASH_OPTCR_RDP_4 ((uint32_t)0x00001000)
|
||||
#define FLASH_OPTCR_RDP_5 ((uint32_t)0x00002000)
|
||||
#define FLASH_OPTCR_RDP_6 ((uint32_t)0x00004000)
|
||||
#define FLASH_OPTCR_RDP_7 ((uint32_t)0x00008000)
|
||||
#define FLASH_OPTCR_nWRP ((uint32_t)0x0FFF0000)
|
||||
#define FLASH_OPTCR_nWRP_0 ((uint32_t)0x00010000)
|
||||
#define FLASH_OPTCR_nWRP_1 ((uint32_t)0x00020000)
|
||||
#define FLASH_OPTCR_nWRP_2 ((uint32_t)0x00040000)
|
||||
#define FLASH_OPTCR_nWRP_3 ((uint32_t)0x00080000)
|
||||
#define FLASH_OPTCR_nWRP_4 ((uint32_t)0x00100000)
|
||||
#define FLASH_OPTCR_nWRP_5 ((uint32_t)0x00200000)
|
||||
#define FLASH_OPTCR_nWRP_6 ((uint32_t)0x00400000)
|
||||
#define FLASH_OPTCR_nWRP_7 ((uint32_t)0x00800000)
|
||||
#define FLASH_OPTCR_nWRP_8 ((uint32_t)0x01000000)
|
||||
#define FLASH_OPTCR_nWRP_9 ((uint32_t)0x02000000)
|
||||
#define FLASH_OPTCR_nWRP_10 ((uint32_t)0x04000000)
|
||||
#define FLASH_OPTCR_nWRP_11 ((uint32_t)0x08000000)
|
||||
|
||||
/****************** Bits definition for FLASH_OPTCR1 register ***************/
|
||||
#define FLASH_OPTCR1_nWRP ((uint32_t)0x0FFF0000)
|
||||
#define FLASH_OPTCR1_nWRP_0 ((uint32_t)0x00010000)
|
||||
#define FLASH_OPTCR1_nWRP_1 ((uint32_t)0x00020000)
|
||||
#define FLASH_OPTCR1_nWRP_2 ((uint32_t)0x00040000)
|
||||
#define FLASH_OPTCR1_nWRP_3 ((uint32_t)0x00080000)
|
||||
#define FLASH_OPTCR1_nWRP_4 ((uint32_t)0x00100000)
|
||||
#define FLASH_OPTCR1_nWRP_5 ((uint32_t)0x00200000)
|
||||
#define FLASH_OPTCR1_nWRP_6 ((uint32_t)0x00400000)
|
||||
#define FLASH_OPTCR1_nWRP_7 ((uint32_t)0x00800000)
|
||||
#define FLASH_OPTCR1_nWRP_8 ((uint32_t)0x01000000)
|
||||
#define FLASH_OPTCR1_nWRP_9 ((uint32_t)0x02000000)
|
||||
#define FLASH_OPTCR1_nWRP_10 ((uint32_t)0x04000000)
|
||||
#define FLASH_OPTCR1_nWRP_11 ((uint32_t)0x08000000)
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
@ -3435,10 +3536,10 @@ typedef struct
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/****************** Bit definition for FSMC_BCR1 register *******************/
|
||||
#define FSMC_BCR1_MBKEN ((uint32_t)0x00000001) /*!<Memory bank enable bit */
|
||||
#define FSMC_BCR1_MUXEN ((uint32_t)0x00000002) /*!<Address/data multiplexing enable bit */
|
||||
#define FSMC_BCR1_MBKEN ((uint32_t)0x00000001) /*!<Memory bank enable bit */
|
||||
#define FSMC_BCR1_MUXEN ((uint32_t)0x00000002) /*!<Address/data multiplexing enable bit */
|
||||
|
||||
#define FSMC_BCR1_MTYP ((uint32_t)0x0000000C) /*!<MTYP[1:0] bits (Memory type) */
|
||||
#define FSMC_BCR1_MTYP ((uint32_t)0x0000000C) /*!<MTYP[1:0] bits (Memory type) */
|
||||
#define FSMC_BCR1_MTYP_0 ((uint32_t)0x00000004) /*!<Bit 0 */
|
||||
#define FSMC_BCR1_MTYP_1 ((uint32_t)0x00000008) /*!<Bit 1 */
|
||||
|
||||
@ -3446,22 +3547,22 @@ typedef struct
|
||||
#define FSMC_BCR1_MWID_0 ((uint32_t)0x00000010) /*!<Bit 0 */
|
||||
#define FSMC_BCR1_MWID_1 ((uint32_t)0x00000020) /*!<Bit 1 */
|
||||
|
||||
#define FSMC_BCR1_FACCEN ((uint32_t)0x00000040) /*!<Flash access enable */
|
||||
#define FSMC_BCR1_BURSTEN ((uint32_t)0x00000100) /*!<Burst enable bit */
|
||||
#define FSMC_BCR1_WAITPOL ((uint32_t)0x00000200) /*!<Wait signal polarity bit */
|
||||
#define FSMC_BCR1_WRAPMOD ((uint32_t)0x00000400) /*!<Wrapped burst mode support */
|
||||
#define FSMC_BCR1_WAITCFG ((uint32_t)0x00000800) /*!<Wait timing configuration */
|
||||
#define FSMC_BCR1_WREN ((uint32_t)0x00001000) /*!<Write enable bit */
|
||||
#define FSMC_BCR1_WAITEN ((uint32_t)0x00002000) /*!<Wait enable bit */
|
||||
#define FSMC_BCR1_EXTMOD ((uint32_t)0x00004000) /*!<Extended mode enable */
|
||||
#define FSMC_BCR1_ASYNCWAIT ((uint32_t)0x00008000) /*!<Asynchronous wait */
|
||||
#define FSMC_BCR1_CBURSTRW ((uint32_t)0x00080000) /*!<Write burst enable */
|
||||
#define FSMC_BCR1_FACCEN ((uint32_t)0x00000040) /*!<Flash access enable */
|
||||
#define FSMC_BCR1_BURSTEN ((uint32_t)0x00000100) /*!<Burst enable bit */
|
||||
#define FSMC_BCR1_WAITPOL ((uint32_t)0x00000200) /*!<Wait signal polarity bit */
|
||||
#define FSMC_BCR1_WRAPMOD ((uint32_t)0x00000400) /*!<Wrapped burst mode support */
|
||||
#define FSMC_BCR1_WAITCFG ((uint32_t)0x00000800) /*!<Wait timing configuration */
|
||||
#define FSMC_BCR1_WREN ((uint32_t)0x00001000) /*!<Write enable bit */
|
||||
#define FSMC_BCR1_WAITEN ((uint32_t)0x00002000) /*!<Wait enable bit */
|
||||
#define FSMC_BCR1_EXTMOD ((uint32_t)0x00004000) /*!<Extended mode enable */
|
||||
#define FSMC_BCR1_ASYNCWAIT ((uint32_t)0x00008000) /*!<Asynchronous wait */
|
||||
#define FSMC_BCR1_CBURSTRW ((uint32_t)0x00080000) /*!<Write burst enable */
|
||||
|
||||
/****************** Bit definition for FSMC_BCR2 register *******************/
|
||||
#define FSMC_BCR2_MBKEN ((uint32_t)0x00000001) /*!<Memory bank enable bit */
|
||||
#define FSMC_BCR2_MUXEN ((uint32_t)0x00000002) /*!<Address/data multiplexing enable bit */
|
||||
#define FSMC_BCR2_MBKEN ((uint32_t)0x00000001) /*!<Memory bank enable bit */
|
||||
#define FSMC_BCR2_MUXEN ((uint32_t)0x00000002) /*!<Address/data multiplexing enable bit */
|
||||
|
||||
#define FSMC_BCR2_MTYP ((uint32_t)0x0000000C) /*!<MTYP[1:0] bits (Memory type) */
|
||||
#define FSMC_BCR2_MTYP ((uint32_t)0x0000000C) /*!<MTYP[1:0] bits (Memory type) */
|
||||
#define FSMC_BCR2_MTYP_0 ((uint32_t)0x00000004) /*!<Bit 0 */
|
||||
#define FSMC_BCR2_MTYP_1 ((uint32_t)0x00000008) /*!<Bit 1 */
|
||||
|
||||
@ -3469,22 +3570,22 @@ typedef struct
|
||||
#define FSMC_BCR2_MWID_0 ((uint32_t)0x00000010) /*!<Bit 0 */
|
||||
#define FSMC_BCR2_MWID_1 ((uint32_t)0x00000020) /*!<Bit 1 */
|
||||
|
||||
#define FSMC_BCR2_FACCEN ((uint32_t)0x00000040) /*!<Flash access enable */
|
||||
#define FSMC_BCR2_BURSTEN ((uint32_t)0x00000100) /*!<Burst enable bit */
|
||||
#define FSMC_BCR2_WAITPOL ((uint32_t)0x00000200) /*!<Wait signal polarity bit */
|
||||
#define FSMC_BCR2_WRAPMOD ((uint32_t)0x00000400) /*!<Wrapped burst mode support */
|
||||
#define FSMC_BCR2_WAITCFG ((uint32_t)0x00000800) /*!<Wait timing configuration */
|
||||
#define FSMC_BCR2_WREN ((uint32_t)0x00001000) /*!<Write enable bit */
|
||||
#define FSMC_BCR2_WAITEN ((uint32_t)0x00002000) /*!<Wait enable bit */
|
||||
#define FSMC_BCR2_EXTMOD ((uint32_t)0x00004000) /*!<Extended mode enable */
|
||||
#define FSMC_BCR2_ASYNCWAIT ((uint32_t)0x00008000) /*!<Asynchronous wait */
|
||||
#define FSMC_BCR2_CBURSTRW ((uint32_t)0x00080000) /*!<Write burst enable */
|
||||
#define FSMC_BCR2_FACCEN ((uint32_t)0x00000040) /*!<Flash access enable */
|
||||
#define FSMC_BCR2_BURSTEN ((uint32_t)0x00000100) /*!<Burst enable bit */
|
||||
#define FSMC_BCR2_WAITPOL ((uint32_t)0x00000200) /*!<Wait signal polarity bit */
|
||||
#define FSMC_BCR2_WRAPMOD ((uint32_t)0x00000400) /*!<Wrapped burst mode support */
|
||||
#define FSMC_BCR2_WAITCFG ((uint32_t)0x00000800) /*!<Wait timing configuration */
|
||||
#define FSMC_BCR2_WREN ((uint32_t)0x00001000) /*!<Write enable bit */
|
||||
#define FSMC_BCR2_WAITEN ((uint32_t)0x00002000) /*!<Wait enable bit */
|
||||
#define FSMC_BCR2_EXTMOD ((uint32_t)0x00004000) /*!<Extended mode enable */
|
||||
#define FSMC_BCR2_ASYNCWAIT ((uint32_t)0x00008000) /*!<Asynchronous wait */
|
||||
#define FSMC_BCR2_CBURSTRW ((uint32_t)0x00080000) /*!<Write burst enable */
|
||||
|
||||
/****************** Bit definition for FSMC_BCR3 register *******************/
|
||||
#define FSMC_BCR3_MBKEN ((uint32_t)0x00000001) /*!<Memory bank enable bit */
|
||||
#define FSMC_BCR3_MUXEN ((uint32_t)0x00000002) /*!<Address/data multiplexing enable bit */
|
||||
#define FSMC_BCR3_MBKEN ((uint32_t)0x00000001) /*!<Memory bank enable bit */
|
||||
#define FSMC_BCR3_MUXEN ((uint32_t)0x00000002) /*!<Address/data multiplexing enable bit */
|
||||
|
||||
#define FSMC_BCR3_MTYP ((uint32_t)0x0000000C) /*!<MTYP[1:0] bits (Memory type) */
|
||||
#define FSMC_BCR3_MTYP ((uint32_t)0x0000000C) /*!<MTYP[1:0] bits (Memory type) */
|
||||
#define FSMC_BCR3_MTYP_0 ((uint32_t)0x00000004) /*!<Bit 0 */
|
||||
#define FSMC_BCR3_MTYP_1 ((uint32_t)0x00000008) /*!<Bit 1 */
|
||||
|
||||
@ -3492,22 +3593,22 @@ typedef struct
|
||||
#define FSMC_BCR3_MWID_0 ((uint32_t)0x00000010) /*!<Bit 0 */
|
||||
#define FSMC_BCR3_MWID_1 ((uint32_t)0x00000020) /*!<Bit 1 */
|
||||
|
||||
#define FSMC_BCR3_FACCEN ((uint32_t)0x00000040) /*!<Flash access enable */
|
||||
#define FSMC_BCR3_BURSTEN ((uint32_t)0x00000100) /*!<Burst enable bit */
|
||||
#define FSMC_BCR3_WAITPOL ((uint32_t)0x00000200) /*!<Wait signal polarity bit. */
|
||||
#define FSMC_BCR3_WRAPMOD ((uint32_t)0x00000400) /*!<Wrapped burst mode support */
|
||||
#define FSMC_BCR3_WAITCFG ((uint32_t)0x00000800) /*!<Wait timing configuration */
|
||||
#define FSMC_BCR3_WREN ((uint32_t)0x00001000) /*!<Write enable bit */
|
||||
#define FSMC_BCR3_WAITEN ((uint32_t)0x00002000) /*!<Wait enable bit */
|
||||
#define FSMC_BCR3_EXTMOD ((uint32_t)0x00004000) /*!<Extended mode enable */
|
||||
#define FSMC_BCR3_ASYNCWAIT ((uint32_t)0x00008000) /*!<Asynchronous wait */
|
||||
#define FSMC_BCR3_CBURSTRW ((uint32_t)0x00080000) /*!<Write burst enable */
|
||||
#define FSMC_BCR3_FACCEN ((uint32_t)0x00000040) /*!<Flash access enable */
|
||||
#define FSMC_BCR3_BURSTEN ((uint32_t)0x00000100) /*!<Burst enable bit */
|
||||
#define FSMC_BCR3_WAITPOL ((uint32_t)0x00000200) /*!<Wait signal polarity bit */
|
||||
#define FSMC_BCR3_WRAPMOD ((uint32_t)0x00000400) /*!<Wrapped burst mode support */
|
||||
#define FSMC_BCR3_WAITCFG ((uint32_t)0x00000800) /*!<Wait timing configuration */
|
||||
#define FSMC_BCR3_WREN ((uint32_t)0x00001000) /*!<Write enable bit */
|
||||
#define FSMC_BCR3_WAITEN ((uint32_t)0x00002000) /*!<Wait enable bit */
|
||||
#define FSMC_BCR3_EXTMOD ((uint32_t)0x00004000) /*!<Extended mode enable */
|
||||
#define FSMC_BCR3_ASYNCWAIT ((uint32_t)0x00008000) /*!<Asynchronous wait */
|
||||
#define FSMC_BCR3_CBURSTRW ((uint32_t)0x00080000) /*!<Write burst enable */
|
||||
|
||||
/****************** Bit definition for FSMC_BCR4 register *******************/
|
||||
#define FSMC_BCR4_MBKEN ((uint32_t)0x00000001) /*!<Memory bank enable bit */
|
||||
#define FSMC_BCR4_MUXEN ((uint32_t)0x00000002) /*!<Address/data multiplexing enable bit */
|
||||
#define FSMC_BCR4_MUXEN ((uint32_t)0x00000002) /*!<Address/data multiplexing enable bit */
|
||||
|
||||
#define FSMC_BCR4_MTYP ((uint32_t)0x0000000C) /*!<MTYP[1:0] bits (Memory type) */
|
||||
#define FSMC_BCR4_MTYP ((uint32_t)0x0000000C) /*!<MTYP[1:0] bits (Memory type) */
|
||||
#define FSMC_BCR4_MTYP_0 ((uint32_t)0x00000004) /*!<Bit 0 */
|
||||
#define FSMC_BCR4_MTYP_1 ((uint32_t)0x00000008) /*!<Bit 1 */
|
||||
|
||||
@ -3515,16 +3616,16 @@ typedef struct
|
||||
#define FSMC_BCR4_MWID_0 ((uint32_t)0x00000010) /*!<Bit 0 */
|
||||
#define FSMC_BCR4_MWID_1 ((uint32_t)0x00000020) /*!<Bit 1 */
|
||||
|
||||
#define FSMC_BCR4_FACCEN ((uint32_t)0x00000040) /*!<Flash access enable */
|
||||
#define FSMC_BCR4_BURSTEN ((uint32_t)0x00000100) /*!<Burst enable bit */
|
||||
#define FSMC_BCR4_WAITPOL ((uint32_t)0x00000200) /*!<Wait signal polarity bit */
|
||||
#define FSMC_BCR4_WRAPMOD ((uint32_t)0x00000400) /*!<Wrapped burst mode support */
|
||||
#define FSMC_BCR4_WAITCFG ((uint32_t)0x00000800) /*!<Wait timing configuration */
|
||||
#define FSMC_BCR4_WREN ((uint32_t)0x00001000) /*!<Write enable bit */
|
||||
#define FSMC_BCR4_WAITEN ((uint32_t)0x00002000) /*!<Wait enable bit */
|
||||
#define FSMC_BCR4_EXTMOD ((uint32_t)0x00004000) /*!<Extended mode enable */
|
||||
#define FSMC_BCR4_ASYNCWAIT ((uint32_t)0x00008000) /*!<Asynchronous wait */
|
||||
#define FSMC_BCR4_CBURSTRW ((uint32_t)0x00080000) /*!<Write burst enable */
|
||||
#define FSMC_BCR4_FACCEN ((uint32_t)0x00000040) /*!<Flash access enable */
|
||||
#define FSMC_BCR4_BURSTEN ((uint32_t)0x00000100) /*!<Burst enable bit */
|
||||
#define FSMC_BCR4_WAITPOL ((uint32_t)0x00000200) /*!<Wait signal polarity bit */
|
||||
#define FSMC_BCR4_WRAPMOD ((uint32_t)0x00000400) /*!<Wrapped burst mode support */
|
||||
#define FSMC_BCR4_WAITCFG ((uint32_t)0x00000800) /*!<Wait timing configuration */
|
||||
#define FSMC_BCR4_WREN ((uint32_t)0x00001000) /*!<Write enable bit */
|
||||
#define FSMC_BCR4_WAITEN ((uint32_t)0x00002000) /*!<Wait enable bit */
|
||||
#define FSMC_BCR4_EXTMOD ((uint32_t)0x00004000) /*!<Extended mode enable */
|
||||
#define FSMC_BCR4_ASYNCWAIT ((uint32_t)0x00008000) /*!<Asynchronous wait */
|
||||
#define FSMC_BCR4_CBURSTRW ((uint32_t)0x00080000) /*!<Write burst enable */
|
||||
|
||||
/****************** Bit definition for FSMC_BTR1 register ******************/
|
||||
#define FSMC_BTR1_ADDSET ((uint32_t)0x0000000F) /*!<ADDSET[3:0] bits (Address setup phase duration) */
|
||||
@ -3915,30 +4016,30 @@ typedef struct
|
||||
#define FSMC_PCR4_ECCPS_2 ((uint32_t)0x00080000) /*!<Bit 2 */
|
||||
|
||||
/******************* Bit definition for FSMC_SR2 register *******************/
|
||||
#define FSMC_SR2_IRS ((uint8_t)0x01) /*!<Interrupt Rising Edge status */
|
||||
#define FSMC_SR2_ILS ((uint8_t)0x02) /*!<Interrupt Level status */
|
||||
#define FSMC_SR2_IFS ((uint8_t)0x04) /*!<Interrupt Falling Edge status */
|
||||
#define FSMC_SR2_IREN ((uint8_t)0x08) /*!<Interrupt Rising Edge detection Enable bit */
|
||||
#define FSMC_SR2_ILEN ((uint8_t)0x10) /*!<Interrupt Level detection Enable bit */
|
||||
#define FSMC_SR2_IRS ((uint8_t)0x01) /*!<Interrupt Rising Edge status */
|
||||
#define FSMC_SR2_ILS ((uint8_t)0x02) /*!<Interrupt Level status */
|
||||
#define FSMC_SR2_IFS ((uint8_t)0x04) /*!<Interrupt Falling Edge status */
|
||||
#define FSMC_SR2_IREN ((uint8_t)0x08) /*!<Interrupt Rising Edge detection Enable bit */
|
||||
#define FSMC_SR2_ILEN ((uint8_t)0x10) /*!<Interrupt Level detection Enable bit */
|
||||
#define FSMC_SR2_IFEN ((uint8_t)0x20) /*!<Interrupt Falling Edge detection Enable bit */
|
||||
#define FSMC_SR2_FEMPT ((uint8_t)0x40) /*!<FIFO empty */
|
||||
|
||||
/******************* Bit definition for FSMC_SR3 register *******************/
|
||||
#define FSMC_SR3_IRS ((uint8_t)0x01) /*!<Interrupt Rising Edge status */
|
||||
#define FSMC_SR3_ILS ((uint8_t)0x02) /*!<Interrupt Level status */
|
||||
#define FSMC_SR3_IFS ((uint8_t)0x04) /*!<Interrupt Falling Edge status */
|
||||
#define FSMC_SR3_IREN ((uint8_t)0x08) /*!<Interrupt Rising Edge detection Enable bit */
|
||||
#define FSMC_SR3_ILEN ((uint8_t)0x10) /*!<Interrupt Level detection Enable bit */
|
||||
#define FSMC_SR3_IRS ((uint8_t)0x01) /*!<Interrupt Rising Edge status */
|
||||
#define FSMC_SR3_ILS ((uint8_t)0x02) /*!<Interrupt Level status */
|
||||
#define FSMC_SR3_IFS ((uint8_t)0x04) /*!<Interrupt Falling Edge status */
|
||||
#define FSMC_SR3_IREN ((uint8_t)0x08) /*!<Interrupt Rising Edge detection Enable bit */
|
||||
#define FSMC_SR3_ILEN ((uint8_t)0x10) /*!<Interrupt Level detection Enable bit */
|
||||
#define FSMC_SR3_IFEN ((uint8_t)0x20) /*!<Interrupt Falling Edge detection Enable bit */
|
||||
#define FSMC_SR3_FEMPT ((uint8_t)0x40) /*!<FIFO empty */
|
||||
|
||||
/******************* Bit definition for FSMC_SR4 register *******************/
|
||||
#define FSMC_SR4_IRS ((uint8_t)0x01) /*!<Interrupt Rising Edge status */
|
||||
#define FSMC_SR4_ILS ((uint8_t)0x02) /*!<Interrupt Level status */
|
||||
#define FSMC_SR4_IFS ((uint8_t)0x04) /*!<Interrupt Falling Edge status */
|
||||
#define FSMC_SR4_IREN ((uint8_t)0x08) /*!<Interrupt Rising Edge detection Enable bit */
|
||||
#define FSMC_SR4_ILEN ((uint8_t)0x10) /*!<Interrupt Level detection Enable bit */
|
||||
#define FSMC_SR4_IFEN ((uint8_t)0x20) /*!<Interrupt Falling Edge detection Enable bit */
|
||||
#define FSMC_SR4_IRS ((uint8_t)0x01) /*!<Interrupt Rising Edge status */
|
||||
#define FSMC_SR4_ILS ((uint8_t)0x02) /*!<Interrupt Level status */
|
||||
#define FSMC_SR4_IFS ((uint8_t)0x04) /*!<Interrupt Falling Edge status */
|
||||
#define FSMC_SR4_IREN ((uint8_t)0x08) /*!<Interrupt Rising Edge detection Enable bit */
|
||||
#define FSMC_SR4_ILEN ((uint8_t)0x10) /*!<Interrupt Level detection Enable bit */
|
||||
#define FSMC_SR4_IFEN ((uint8_t)0x20) /*!<Interrupt Falling Edge detection Enable bit */
|
||||
#define FSMC_SR4_FEMPT ((uint8_t)0x40) /*!<FIFO empty */
|
||||
|
||||
/****************** Bit definition for FSMC_PMEM2 register ******************/
|
||||
@ -4234,6 +4335,7 @@ typedef struct
|
||||
/****************** Bit definition for FSMC_ECCR3 register ******************/
|
||||
#define FSMC_ECCR3_ECC3 ((uint32_t)0xFFFFFFFF) /*!<ECC result */
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* General Purpose I/O */
|
||||
@ -4568,13 +4670,16 @@ typedef struct
|
||||
#define HASH_CR_DATATYPE_0 ((uint32_t)0x00000010)
|
||||
#define HASH_CR_DATATYPE_1 ((uint32_t)0x00000020)
|
||||
#define HASH_CR_MODE ((uint32_t)0x00000040)
|
||||
#define HASH_CR_ALGO ((uint32_t)0x00000080)
|
||||
#define HASH_CR_ALGO ((uint32_t)0x00040080)
|
||||
#define HASH_CR_ALGO_0 ((uint32_t)0x00000080)
|
||||
#define HASH_CR_ALGO_1 ((uint32_t)0x00040000)
|
||||
#define HASH_CR_NBW ((uint32_t)0x00000F00)
|
||||
#define HASH_CR_NBW_0 ((uint32_t)0x00000100)
|
||||
#define HASH_CR_NBW_1 ((uint32_t)0x00000200)
|
||||
#define HASH_CR_NBW_2 ((uint32_t)0x00000400)
|
||||
#define HASH_CR_NBW_3 ((uint32_t)0x00000800)
|
||||
#define HASH_CR_DINNE ((uint32_t)0x00001000)
|
||||
#define HASH_CR_MDMAT ((uint32_t)0x00002000)
|
||||
#define HASH_CR_LKEY ((uint32_t)0x00010000)
|
||||
|
||||
/****************** Bits definition for HASH_STR register *******************/
|
||||
@ -4602,23 +4707,23 @@ typedef struct
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/******************* Bit definition for I2C_CR1 register ********************/
|
||||
#define I2C_CR1_PE ((uint16_t)0x0001) /*!<Peripheral Enable */
|
||||
#define I2C_CR1_SMBUS ((uint16_t)0x0002) /*!<SMBus Mode */
|
||||
#define I2C_CR1_SMBTYPE ((uint16_t)0x0008) /*!<SMBus Type */
|
||||
#define I2C_CR1_ENARP ((uint16_t)0x0010) /*!<ARP Enable */
|
||||
#define I2C_CR1_ENPEC ((uint16_t)0x0020) /*!<PEC Enable */
|
||||
#define I2C_CR1_ENGC ((uint16_t)0x0040) /*!<General Call Enable */
|
||||
#define I2C_CR1_NOSTRETCH ((uint16_t)0x0080) /*!<Clock Stretching Disable (Slave mode) */
|
||||
#define I2C_CR1_START ((uint16_t)0x0100) /*!<Start Generation */
|
||||
#define I2C_CR1_STOP ((uint16_t)0x0200) /*!<Stop Generation */
|
||||
#define I2C_CR1_ACK ((uint16_t)0x0400) /*!<Acknowledge Enable */
|
||||
#define I2C_CR1_PE ((uint16_t)0x0001) /*!<Peripheral Enable */
|
||||
#define I2C_CR1_SMBUS ((uint16_t)0x0002) /*!<SMBus Mode */
|
||||
#define I2C_CR1_SMBTYPE ((uint16_t)0x0008) /*!<SMBus Type */
|
||||
#define I2C_CR1_ENARP ((uint16_t)0x0010) /*!<ARP Enable */
|
||||
#define I2C_CR1_ENPEC ((uint16_t)0x0020) /*!<PEC Enable */
|
||||
#define I2C_CR1_ENGC ((uint16_t)0x0040) /*!<General Call Enable */
|
||||
#define I2C_CR1_NOSTRETCH ((uint16_t)0x0080) /*!<Clock Stretching Disable (Slave mode) */
|
||||
#define I2C_CR1_START ((uint16_t)0x0100) /*!<Start Generation */
|
||||
#define I2C_CR1_STOP ((uint16_t)0x0200) /*!<Stop Generation */
|
||||
#define I2C_CR1_ACK ((uint16_t)0x0400) /*!<Acknowledge Enable */
|
||||
#define I2C_CR1_POS ((uint16_t)0x0800) /*!<Acknowledge/PEC Position (for data reception) */
|
||||
#define I2C_CR1_PEC ((uint16_t)0x1000) /*!<Packet Error Checking */
|
||||
#define I2C_CR1_ALERT ((uint16_t)0x2000) /*!<SMBus Alert */
|
||||
#define I2C_CR1_SWRST ((uint16_t)0x8000) /*!<Software Reset */
|
||||
#define I2C_CR1_PEC ((uint16_t)0x1000) /*!<Packet Error Checking */
|
||||
#define I2C_CR1_ALERT ((uint16_t)0x2000) /*!<SMBus Alert */
|
||||
#define I2C_CR1_SWRST ((uint16_t)0x8000) /*!<Software Reset */
|
||||
|
||||
/******************* Bit definition for I2C_CR2 register ********************/
|
||||
#define I2C_CR2_FREQ ((uint16_t)0x003F) /*!<FREQ[5:0] bits (Peripheral Clock Frequency) */
|
||||
#define I2C_CR2_FREQ ((uint16_t)0x003F) /*!<FREQ[5:0] bits (Peripheral Clock Frequency) */
|
||||
#define I2C_CR2_FREQ_0 ((uint16_t)0x0001) /*!<Bit 0 */
|
||||
#define I2C_CR2_FREQ_1 ((uint16_t)0x0002) /*!<Bit 1 */
|
||||
#define I2C_CR2_FREQ_2 ((uint16_t)0x0004) /*!<Bit 2 */
|
||||
@ -4626,11 +4731,11 @@ typedef struct
|
||||
#define I2C_CR2_FREQ_4 ((uint16_t)0x0010) /*!<Bit 4 */
|
||||
#define I2C_CR2_FREQ_5 ((uint16_t)0x0020) /*!<Bit 5 */
|
||||
|
||||
#define I2C_CR2_ITERREN ((uint16_t)0x0100) /*!<Error Interrupt Enable */
|
||||
#define I2C_CR2_ITEVTEN ((uint16_t)0x0200) /*!<Event Interrupt Enable */
|
||||
#define I2C_CR2_ITERREN ((uint16_t)0x0100) /*!<Error Interrupt Enable */
|
||||
#define I2C_CR2_ITEVTEN ((uint16_t)0x0200) /*!<Event Interrupt Enable */
|
||||
#define I2C_CR2_ITBUFEN ((uint16_t)0x0400) /*!<Buffer Interrupt Enable */
|
||||
#define I2C_CR2_DMAEN ((uint16_t)0x0800) /*!<DMA Requests Enable */
|
||||
#define I2C_CR2_LAST ((uint16_t)0x1000) /*!<DMA Last Transfer */
|
||||
#define I2C_CR2_DMAEN ((uint16_t)0x0800) /*!<DMA Requests Enable */
|
||||
#define I2C_CR2_LAST ((uint16_t)0x1000) /*!<DMA Last Transfer */
|
||||
|
||||
/******************* Bit definition for I2C_OAR1 register *******************/
|
||||
#define I2C_OAR1_ADD1_7 ((uint16_t)0x00FE) /*!<Interface Address */
|
||||
@ -4651,108 +4756,119 @@ typedef struct
|
||||
|
||||
/******************* Bit definition for I2C_OAR2 register *******************/
|
||||
#define I2C_OAR2_ENDUAL ((uint8_t)0x01) /*!<Dual addressing mode enable */
|
||||
#define I2C_OAR2_ADD2 ((uint8_t)0xFE) /*!<Interface address */
|
||||
#define I2C_OAR2_ADD2 ((uint8_t)0xFE) /*!<Interface address */
|
||||
|
||||
/******************** Bit definition for I2C_DR register ********************/
|
||||
#define I2C_DR_DR ((uint8_t)0xFF) /*!<8-bit Data Register */
|
||||
#define I2C_DR_DR ((uint8_t)0xFF) /*!<8-bit Data Register */
|
||||
|
||||
/******************* Bit definition for I2C_SR1 register ********************/
|
||||
#define I2C_SR1_SB ((uint16_t)0x0001) /*!<Start Bit (Master mode) */
|
||||
#define I2C_SR1_SB ((uint16_t)0x0001) /*!<Start Bit (Master mode) */
|
||||
#define I2C_SR1_ADDR ((uint16_t)0x0002) /*!<Address sent (master mode)/matched (slave mode) */
|
||||
#define I2C_SR1_BTF ((uint16_t)0x0004) /*!<Byte Transfer Finished */
|
||||
#define I2C_SR1_ADD10 ((uint16_t)0x0008) /*!<10-bit header sent (Master mode) */
|
||||
#define I2C_SR1_STOPF ((uint16_t)0x0010) /*!<Stop detection (Slave mode) */
|
||||
#define I2C_SR1_RXNE ((uint16_t)0x0040) /*!<Data Register not Empty (receivers) */
|
||||
#define I2C_SR1_TXE ((uint16_t)0x0080) /*!<Data Register Empty (transmitters) */
|
||||
#define I2C_SR1_BERR ((uint16_t)0x0100) /*!<Bus Error */
|
||||
#define I2C_SR1_ARLO ((uint16_t)0x0200) /*!<Arbitration Lost (master mode) */
|
||||
#define I2C_SR1_AF ((uint16_t)0x0400) /*!<Acknowledge Failure */
|
||||
#define I2C_SR1_OVR ((uint16_t)0x0800) /*!<Overrun/Underrun */
|
||||
#define I2C_SR1_PECERR ((uint16_t)0x1000) /*!<PEC Error in reception */
|
||||
#define I2C_SR1_TIMEOUT ((uint16_t)0x4000) /*!<Timeout or Tlow Error */
|
||||
#define I2C_SR1_SMBALERT ((uint16_t)0x8000) /*!<SMBus Alert */
|
||||
#define I2C_SR1_BTF ((uint16_t)0x0004) /*!<Byte Transfer Finished */
|
||||
#define I2C_SR1_ADD10 ((uint16_t)0x0008) /*!<10-bit header sent (Master mode) */
|
||||
#define I2C_SR1_STOPF ((uint16_t)0x0010) /*!<Stop detection (Slave mode) */
|
||||
#define I2C_SR1_RXNE ((uint16_t)0x0040) /*!<Data Register not Empty (receivers) */
|
||||
#define I2C_SR1_TXE ((uint16_t)0x0080) /*!<Data Register Empty (transmitters) */
|
||||
#define I2C_SR1_BERR ((uint16_t)0x0100) /*!<Bus Error */
|
||||
#define I2C_SR1_ARLO ((uint16_t)0x0200) /*!<Arbitration Lost (master mode) */
|
||||
#define I2C_SR1_AF ((uint16_t)0x0400) /*!<Acknowledge Failure */
|
||||
#define I2C_SR1_OVR ((uint16_t)0x0800) /*!<Overrun/Underrun */
|
||||
#define I2C_SR1_PECERR ((uint16_t)0x1000) /*!<PEC Error in reception */
|
||||
#define I2C_SR1_TIMEOUT ((uint16_t)0x4000) /*!<Timeout or Tlow Error */
|
||||
#define I2C_SR1_SMBALERT ((uint16_t)0x8000) /*!<SMBus Alert */
|
||||
|
||||
/******************* Bit definition for I2C_SR2 register ********************/
|
||||
#define I2C_SR2_MSL ((uint16_t)0x0001) /*!<Master/Slave */
|
||||
#define I2C_SR2_BUSY ((uint16_t)0x0002) /*!<Bus Busy */
|
||||
#define I2C_SR2_TRA ((uint16_t)0x0004) /*!<Transmitter/Receiver */
|
||||
#define I2C_SR2_GENCALL ((uint16_t)0x0010) /*!<General Call Address (Slave mode) */
|
||||
#define I2C_SR2_MSL ((uint16_t)0x0001) /*!<Master/Slave */
|
||||
#define I2C_SR2_BUSY ((uint16_t)0x0002) /*!<Bus Busy */
|
||||
#define I2C_SR2_TRA ((uint16_t)0x0004) /*!<Transmitter/Receiver */
|
||||
#define I2C_SR2_GENCALL ((uint16_t)0x0010) /*!<General Call Address (Slave mode) */
|
||||
#define I2C_SR2_SMBDEFAULT ((uint16_t)0x0020) /*!<SMBus Device Default Address (Slave mode) */
|
||||
#define I2C_SR2_SMBHOST ((uint16_t)0x0040) /*!<SMBus Host Header (Slave mode) */
|
||||
#define I2C_SR2_DUALF ((uint16_t)0x0080) /*!<Dual Flag (Slave mode) */
|
||||
#define I2C_SR2_PEC ((uint16_t)0xFF00) /*!<Packet Error Checking Register */
|
||||
#define I2C_SR2_SMBHOST ((uint16_t)0x0040) /*!<SMBus Host Header (Slave mode) */
|
||||
#define I2C_SR2_DUALF ((uint16_t)0x0080) /*!<Dual Flag (Slave mode) */
|
||||
#define I2C_SR2_PEC ((uint16_t)0xFF00) /*!<Packet Error Checking Register */
|
||||
|
||||
/******************* Bit definition for I2C_CCR register ********************/
|
||||
#define I2C_CCR_CCR ((uint16_t)0x0FFF) /*!<Clock Control Register in Fast/Standard mode (Master mode) */
|
||||
#define I2C_CCR_DUTY ((uint16_t)0x4000) /*!<Fast Mode Duty Cycle */
|
||||
#define I2C_CCR_FS ((uint16_t)0x8000) /*!<I2C Master Mode Selection */
|
||||
#define I2C_CCR_DUTY ((uint16_t)0x4000) /*!<Fast Mode Duty Cycle */
|
||||
#define I2C_CCR_FS ((uint16_t)0x8000) /*!<I2C Master Mode Selection */
|
||||
|
||||
/****************** Bit definition for I2C_TRISE register *******************/
|
||||
#define I2C_TRISE_TRISE ((uint8_t)0x3F) /*!<Maximum Rise Time in Fast/Standard mode (Master mode) */
|
||||
|
||||
/****************** Bit definition for I2C_FLTR register *******************/
|
||||
#define I2C_FLTR_DNF ((uint8_t)0x0F) /*!<Digital Noise Filter */
|
||||
#define I2C_FLTR_ANOFF ((uint8_t)0x10) /*!<Analog Noise Filter OFF */
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* Independent WATCHDOG */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/******************* Bit definition for IWDG_KR register ********************/
|
||||
#define IWDG_KR_KEY ((uint16_t)0xFFFF) /*!<Key value (write only, read 0000h) */
|
||||
#define IWDG_KR_KEY ((uint16_t)0xFFFF) /*!<Key value (write only, read 0000h) */
|
||||
|
||||
/******************* Bit definition for IWDG_PR register ********************/
|
||||
#define IWDG_PR_PR ((uint8_t)0x07) /*!<PR[2:0] (Prescaler divider) */
|
||||
#define IWDG_PR_PR ((uint8_t)0x07) /*!<PR[2:0] (Prescaler divider) */
|
||||
#define IWDG_PR_PR_0 ((uint8_t)0x01) /*!<Bit 0 */
|
||||
#define IWDG_PR_PR_1 ((uint8_t)0x02) /*!<Bit 1 */
|
||||
#define IWDG_PR_PR_2 ((uint8_t)0x04) /*!<Bit 2 */
|
||||
|
||||
/******************* Bit definition for IWDG_RLR register *******************/
|
||||
#define IWDG_RLR_RL ((uint16_t)0x0FFF) /*!<Watchdog counter reload value */
|
||||
#define IWDG_RLR_RL ((uint16_t)0x0FFF) /*!<Watchdog counter reload value */
|
||||
|
||||
/******************* Bit definition for IWDG_SR register ********************/
|
||||
#define IWDG_SR_PVU ((uint8_t)0x01) /*!<Watchdog prescaler value update */
|
||||
#define IWDG_SR_PVU ((uint8_t)0x01) /*!<Watchdog prescaler value update */
|
||||
#define IWDG_SR_RVU ((uint8_t)0x02) /*!<Watchdog counter reload value update */
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* Power Control */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/******************** Bit definition for PWR_CR register ********************/
|
||||
#define PWR_CR_LPDS ((uint16_t)0x0001) /*!< Low-Power Deepsleep */
|
||||
#define PWR_CR_PDDS ((uint16_t)0x0002) /*!< Power Down Deepsleep */
|
||||
#define PWR_CR_CWUF ((uint16_t)0x0004) /*!< Clear Wakeup Flag */
|
||||
#define PWR_CR_CSBF ((uint16_t)0x0008) /*!< Clear Standby Flag */
|
||||
#define PWR_CR_PVDE ((uint16_t)0x0010) /*!< Power Voltage Detector Enable */
|
||||
|
||||
#define PWR_CR_PLS ((uint16_t)0x00E0) /*!< PLS[2:0] bits (PVD Level Selection) */
|
||||
#define PWR_CR_PLS_0 ((uint16_t)0x0020) /*!< Bit 0 */
|
||||
#define PWR_CR_PLS_1 ((uint16_t)0x0040) /*!< Bit 1 */
|
||||
#define PWR_CR_PLS_2 ((uint16_t)0x0080) /*!< Bit 2 */
|
||||
#define PWR_CR_LPDS ((uint32_t)0x00000001) /*!< Low-Power Deepsleep */
|
||||
#define PWR_CR_PDDS ((uint32_t)0x00000002) /*!< Power Down Deepsleep */
|
||||
#define PWR_CR_CWUF ((uint32_t)0x00000004) /*!< Clear Wakeup Flag */
|
||||
#define PWR_CR_CSBF ((uint32_t)0x00000008) /*!< Clear Standby Flag */
|
||||
#define PWR_CR_PVDE ((uint32_t)0x00000010) /*!< Power Voltage Detector Enable */
|
||||
|
||||
#define PWR_CR_PLS ((uint32_t)0x000000E0) /*!< PLS[2:0] bits (PVD Level Selection) */
|
||||
#define PWR_CR_PLS_0 ((uint32_t)0x00000020) /*!< Bit 0 */
|
||||
#define PWR_CR_PLS_1 ((uint32_t)0x00000040) /*!< Bit 1 */
|
||||
#define PWR_CR_PLS_2 ((uint32_t)0x00000080) /*!< Bit 2 */
|
||||
|
||||
/*!< PVD level configuration */
|
||||
#define PWR_CR_PLS_LEV0 ((uint16_t)0x0000) /*!< PVD level 0 */
|
||||
#define PWR_CR_PLS_LEV1 ((uint16_t)0x0020) /*!< PVD level 1 */
|
||||
#define PWR_CR_PLS_LEV2 ((uint16_t)0x0040) /*!< PVD level 2 */
|
||||
#define PWR_CR_PLS_LEV3 ((uint16_t)0x0060) /*!< PVD level 3 */
|
||||
#define PWR_CR_PLS_LEV4 ((uint16_t)0x0080) /*!< PVD level 4 */
|
||||
#define PWR_CR_PLS_LEV5 ((uint16_t)0x00A0) /*!< PVD level 5 */
|
||||
#define PWR_CR_PLS_LEV6 ((uint16_t)0x00C0) /*!< PVD level 6 */
|
||||
#define PWR_CR_PLS_LEV7 ((uint16_t)0x00E0) /*!< PVD level 7 */
|
||||
#define PWR_CR_PLS_LEV0 ((uint32_t)0x00000000) /*!< PVD level 0 */
|
||||
#define PWR_CR_PLS_LEV1 ((uint32_t)0x00000020) /*!< PVD level 1 */
|
||||
#define PWR_CR_PLS_LEV2 ((uint32_t)0x00000040) /*!< PVD level 2 */
|
||||
#define PWR_CR_PLS_LEV3 ((uint32_t)0x00000060) /*!< PVD level 3 */
|
||||
#define PWR_CR_PLS_LEV4 ((uint32_t)0x00000080) /*!< PVD level 4 */
|
||||
#define PWR_CR_PLS_LEV5 ((uint32_t)0x000000A0) /*!< PVD level 5 */
|
||||
#define PWR_CR_PLS_LEV6 ((uint32_t)0x000000C0) /*!< PVD level 6 */
|
||||
#define PWR_CR_PLS_LEV7 ((uint32_t)0x000000E0) /*!< PVD level 7 */
|
||||
|
||||
#define PWR_CR_DBP ((uint32_t)0x00000100) /*!< Disable Backup Domain write protection */
|
||||
#define PWR_CR_FPDS ((uint32_t)0x00000200) /*!< Flash power down in Stop mode */
|
||||
#define PWR_CR_LPLVDS ((uint32_t)0x00000400) /*!< Low-Power Regulator Low Voltage Scaling in Stop mode */
|
||||
#define PWR_CR_MRLVDS ((uint32_t)0x00000800) /*!< Main regulator Low Voltage Scaling in Stop mode */
|
||||
|
||||
#define PWR_CR_VOS ((uint32_t)0x0000C000) /*!< VOS[1:0] bits (Regulator voltage scaling output selection) */
|
||||
#define PWR_CR_VOS_0 ((uint32_t)0x00004000) /*!< Bit 0 */
|
||||
#define PWR_CR_VOS_1 ((uint32_t)0x00008000) /*!< Bit 1 */
|
||||
|
||||
#define PWR_CR_DBP ((uint16_t)0x0100) /*!< Disable Backup Domain write protection */
|
||||
#define PWR_CR_FPDS ((uint16_t)0x0200) /*!< Flash power down in Stop mode */
|
||||
#define PWR_CR_VOS ((uint16_t)0x4000) /*!< Regulator voltage scaling output selection */
|
||||
/* Legacy define */
|
||||
#define PWR_CR_PMODE PWR_CR_VOS
|
||||
|
||||
/******************* Bit definition for PWR_CSR register ********************/
|
||||
#define PWR_CSR_WUF ((uint16_t)0x0001) /*!< Wakeup Flag */
|
||||
#define PWR_CSR_SBF ((uint16_t)0x0002) /*!< Standby Flag */
|
||||
#define PWR_CSR_PVDO ((uint16_t)0x0004) /*!< PVD Output */
|
||||
#define PWR_CSR_BRR ((uint16_t)0x0008) /*!< Backup regulator ready */
|
||||
#define PWR_CSR_EWUP ((uint16_t)0x0100) /*!< Enable WKUP pin */
|
||||
#define PWR_CSR_BRE ((uint16_t)0x0200) /*!< Backup regulator enable */
|
||||
#define PWR_CSR_VOSRDY ((uint16_t)0x4000) /*!< Regulator voltage scaling output selection ready */
|
||||
#define PWR_CSR_WUF ((uint32_t)0x00000001) /*!< Wakeup Flag */
|
||||
#define PWR_CSR_SBF ((uint32_t)0x00000002) /*!< Standby Flag */
|
||||
#define PWR_CSR_PVDO ((uint32_t)0x00000004) /*!< PVD Output */
|
||||
#define PWR_CSR_BRR ((uint32_t)0x00000008) /*!< Backup regulator ready */
|
||||
#define PWR_CSR_EWUP ((uint32_t)0x00000100) /*!< Enable WKUP pin */
|
||||
#define PWR_CSR_BRE ((uint32_t)0x00000200) /*!< Backup regulator enable */
|
||||
#define PWR_CSR_VOSRDY ((uint32_t)0x00004000) /*!< Regulator voltage scaling output selection ready */
|
||||
|
||||
/* Legacy define */
|
||||
#define PWR_CSR_REGRDY PWR_CSR_VOSRDY
|
||||
|
||||
@ -4791,6 +4907,7 @@ typedef struct
|
||||
#define RCC_CR_PLLI2SON ((uint32_t)0x04000000)
|
||||
#define RCC_CR_PLLI2SRDY ((uint32_t)0x08000000)
|
||||
|
||||
|
||||
/******************** Bit definition for RCC_PLLCFGR register ***************/
|
||||
#define RCC_PLLCFGR_PLLM ((uint32_t)0x0000003F)
|
||||
#define RCC_PLLCFGR_PLLM_0 ((uint32_t)0x00000001)
|
||||
@ -4955,7 +5072,9 @@ typedef struct
|
||||
/******************** Bit definition for RCC_AHB2RSTR register **************/
|
||||
#define RCC_AHB2RSTR_DCMIRST ((uint32_t)0x00000001)
|
||||
#define RCC_AHB2RSTR_CRYPRST ((uint32_t)0x00000010)
|
||||
#define RCC_AHB2RSTR_HSAHRST ((uint32_t)0x00000020)
|
||||
#define RCC_AHB2RSTR_HASHRST ((uint32_t)0x00000020)
|
||||
/* maintained for legacy purpose */
|
||||
#define RCC_AHB2RSTR_HSAHRST RCC_AHB2RSTR_HASHRST
|
||||
#define RCC_AHB2RSTR_RNGRST ((uint32_t)0x00000040)
|
||||
#define RCC_AHB2RSTR_OTGFSRST ((uint32_t)0x00000080)
|
||||
|
||||
@ -4972,9 +5091,9 @@ typedef struct
|
||||
#define RCC_APB1RSTR_TIM12RST ((uint32_t)0x00000040)
|
||||
#define RCC_APB1RSTR_TIM13RST ((uint32_t)0x00000080)
|
||||
#define RCC_APB1RSTR_TIM14RST ((uint32_t)0x00000100)
|
||||
#define RCC_APB1RSTR_WWDGEN ((uint32_t)0x00000800)
|
||||
#define RCC_APB1RSTR_SPI2RST ((uint32_t)0x00008000)
|
||||
#define RCC_APB1RSTR_SPI3RST ((uint32_t)0x00010000)
|
||||
#define RCC_APB1RSTR_WWDGRST ((uint32_t)0x00000800)
|
||||
#define RCC_APB1RSTR_SPI2RST ((uint32_t)0x00004000)
|
||||
#define RCC_APB1RSTR_SPI3RST ((uint32_t)0x00008000)
|
||||
#define RCC_APB1RSTR_USART2RST ((uint32_t)0x00020000)
|
||||
#define RCC_APB1RSTR_USART3RST ((uint32_t)0x00040000)
|
||||
#define RCC_APB1RSTR_UART4RST ((uint32_t)0x00080000)
|
||||
@ -4986,6 +5105,8 @@ typedef struct
|
||||
#define RCC_APB1RSTR_CAN2RST ((uint32_t)0x04000000)
|
||||
#define RCC_APB1RSTR_PWRRST ((uint32_t)0x10000000)
|
||||
#define RCC_APB1RSTR_DACRST ((uint32_t)0x20000000)
|
||||
#define RCC_APB1RSTR_UART7RST ((uint32_t)0x40000000)
|
||||
#define RCC_APB1RSTR_UART8RST ((uint32_t)0x80000000)
|
||||
|
||||
/******************** Bit definition for RCC_APB2RSTR register **************/
|
||||
#define RCC_APB2RSTR_TIM1RST ((uint32_t)0x00000001)
|
||||
@ -4995,10 +5116,14 @@ typedef struct
|
||||
#define RCC_APB2RSTR_ADCRST ((uint32_t)0x00000100)
|
||||
#define RCC_APB2RSTR_SDIORST ((uint32_t)0x00000800)
|
||||
#define RCC_APB2RSTR_SPI1RST ((uint32_t)0x00001000)
|
||||
#define RCC_APB2RSTR_SPI4RST ((uint32_t)0x00002000)
|
||||
#define RCC_APB2RSTR_SYSCFGRST ((uint32_t)0x00004000)
|
||||
#define RCC_APB2RSTR_TIM9RST ((uint32_t)0x00010000)
|
||||
#define RCC_APB2RSTR_TIM10RST ((uint32_t)0x00020000)
|
||||
#define RCC_APB2RSTR_TIM11RST ((uint32_t)0x00040000)
|
||||
#define RCC_APB2RSTR_SPI5RST ((uint32_t)0x00100000)
|
||||
#define RCC_APB2RSTR_SPI6RST ((uint32_t)0x00200000)
|
||||
|
||||
/* Old SPI1RST bit definition, maintained for legacy purpose */
|
||||
#define RCC_APB2RSTR_SPI1 RCC_APB2RSTR_SPI1RST
|
||||
|
||||
@ -5058,6 +5183,8 @@ typedef struct
|
||||
#define RCC_APB1ENR_CAN2EN ((uint32_t)0x04000000)
|
||||
#define RCC_APB1ENR_PWREN ((uint32_t)0x10000000)
|
||||
#define RCC_APB1ENR_DACEN ((uint32_t)0x20000000)
|
||||
#define RCC_APB1ENR_UART7EN ((uint32_t)0x40000000)
|
||||
#define RCC_APB1ENR_UART8EN ((uint32_t)0x80000000)
|
||||
|
||||
/******************** Bit definition for RCC_APB2ENR register ***************/
|
||||
#define RCC_APB2ENR_TIM1EN ((uint32_t)0x00000001)
|
||||
@ -5069,10 +5196,13 @@ typedef struct
|
||||
#define RCC_APB2ENR_ADC3EN ((uint32_t)0x00000400)
|
||||
#define RCC_APB2ENR_SDIOEN ((uint32_t)0x00000800)
|
||||
#define RCC_APB2ENR_SPI1EN ((uint32_t)0x00001000)
|
||||
#define RCC_APB2ENR_SPI4EN ((uint32_t)0x00002000)
|
||||
#define RCC_APB2ENR_SYSCFGEN ((uint32_t)0x00004000)
|
||||
#define RCC_APB2ENR_TIM11EN ((uint32_t)0x00040000)
|
||||
#define RCC_APB2ENR_TIM10EN ((uint32_t)0x00020000)
|
||||
#define RCC_APB2ENR_TIM9EN ((uint32_t)0x00010000)
|
||||
#define RCC_APB2ENR_TIM10EN ((uint32_t)0x00020000)
|
||||
#define RCC_APB2ENR_TIM11EN ((uint32_t)0x00040000)
|
||||
#define RCC_APB2ENR_SPI5EN ((uint32_t)0x00100000)
|
||||
#define RCC_APB2ENR_SPI6EN ((uint32_t)0x00200000)
|
||||
|
||||
/******************** Bit definition for RCC_AHB1LPENR register *************/
|
||||
#define RCC_AHB1LPENR_GPIOALPEN ((uint32_t)0x00000001)
|
||||
@ -5089,6 +5219,7 @@ typedef struct
|
||||
#define RCC_AHB1LPENR_SRAM1LPEN ((uint32_t)0x00010000)
|
||||
#define RCC_AHB1LPENR_SRAM2LPEN ((uint32_t)0x00020000)
|
||||
#define RCC_AHB1LPENR_BKPSRAMLPEN ((uint32_t)0x00040000)
|
||||
#define RCC_AHB1LPENR_SRAM3LPEN ((uint32_t)0x00080000)
|
||||
#define RCC_AHB1LPENR_DMA1LPEN ((uint32_t)0x00200000)
|
||||
#define RCC_AHB1LPENR_DMA2LPEN ((uint32_t)0x00400000)
|
||||
#define RCC_AHB1LPENR_ETHMACLPEN ((uint32_t)0x02000000)
|
||||
@ -5132,6 +5263,8 @@ typedef struct
|
||||
#define RCC_APB1LPENR_CAN2LPEN ((uint32_t)0x04000000)
|
||||
#define RCC_APB1LPENR_PWRLPEN ((uint32_t)0x10000000)
|
||||
#define RCC_APB1LPENR_DACLPEN ((uint32_t)0x20000000)
|
||||
#define RCC_APB1LPENR_UART7LPEN ((uint32_t)0x40000000)
|
||||
#define RCC_APB1LPENR_UART8LPEN ((uint32_t)0x80000000)
|
||||
|
||||
/******************** Bit definition for RCC_APB2LPENR register *************/
|
||||
#define RCC_APB2LPENR_TIM1LPEN ((uint32_t)0x00000001)
|
||||
@ -5143,10 +5276,13 @@ typedef struct
|
||||
#define RCC_APB2LPENR_ADC3LPEN ((uint32_t)0x00000400)
|
||||
#define RCC_APB2LPENR_SDIOLPEN ((uint32_t)0x00000800)
|
||||
#define RCC_APB2LPENR_SPI1LPEN ((uint32_t)0x00001000)
|
||||
#define RCC_APB2LPENR_SPI4LPEN ((uint32_t)0x00002000)
|
||||
#define RCC_APB2LPENR_SYSCFGLPEN ((uint32_t)0x00004000)
|
||||
#define RCC_APB2LPENR_TIM9LPEN ((uint32_t)0x00010000)
|
||||
#define RCC_APB2LPENR_TIM10LPEN ((uint32_t)0x00020000)
|
||||
#define RCC_APB2LPENR_TIM11LPEN ((uint32_t)0x00040000)
|
||||
#define RCC_APB2LPENR_SPI5LPEN ((uint32_t)0x00100000)
|
||||
#define RCC_APB2LPENR_SPI6LPEN ((uint32_t)0x00200000)
|
||||
|
||||
/******************** Bit definition for RCC_BDCR register ******************/
|
||||
#define RCC_BDCR_LSEON ((uint32_t)0x00000001)
|
||||
@ -5182,6 +5318,10 @@ typedef struct
|
||||
#define RCC_PLLI2SCFGR_PLLI2SN ((uint32_t)0x00007FC0)
|
||||
#define RCC_PLLI2SCFGR_PLLI2SR ((uint32_t)0x70000000)
|
||||
|
||||
/******************** Bit definition for RCC_DCKCFGR register ***************/
|
||||
#define RCC_DCKCFGR_TIMPRE ((uint32_t)0x01000000)
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* RNG */
|
||||
@ -5575,6 +5715,7 @@ typedef struct
|
||||
/******************** Bits definition for RTC_BKP19R register ***************/
|
||||
#define RTC_BKP19R ((uint32_t)0xFFFFFFFF)
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* SD host Interface */
|
||||
@ -5586,9 +5727,9 @@ typedef struct
|
||||
#define SDIO_POWER_PWRCTRL_1 ((uint8_t)0x02) /*!<Bit 1 */
|
||||
|
||||
/****************** Bit definition for SDIO_CLKCR register ******************/
|
||||
#define SDIO_CLKCR_CLKDIV ((uint16_t)0x00FF) /*!<Clock divide factor */
|
||||
#define SDIO_CLKCR_CLKEN ((uint16_t)0x0100) /*!<Clock enable bit */
|
||||
#define SDIO_CLKCR_PWRSAV ((uint16_t)0x0200) /*!<Power saving configuration bit */
|
||||
#define SDIO_CLKCR_CLKDIV ((uint16_t)0x00FF) /*!<Clock divide factor */
|
||||
#define SDIO_CLKCR_CLKEN ((uint16_t)0x0100) /*!<Clock enable bit */
|
||||
#define SDIO_CLKCR_PWRSAV ((uint16_t)0x0200) /*!<Power saving configuration bit */
|
||||
#define SDIO_CLKCR_BYPASS ((uint16_t)0x0400) /*!<Clock divider bypass enable bit */
|
||||
|
||||
#define SDIO_CLKCR_WIDBUS ((uint16_t)0x1800) /*!<WIDBUS[1:0] bits (Wide bus mode enable bit) */
|
||||
@ -5596,25 +5737,25 @@ typedef struct
|
||||
#define SDIO_CLKCR_WIDBUS_1 ((uint16_t)0x1000) /*!<Bit 1 */
|
||||
|
||||
#define SDIO_CLKCR_NEGEDGE ((uint16_t)0x2000) /*!<SDIO_CK dephasing selection bit */
|
||||
#define SDIO_CLKCR_HWFC_EN ((uint16_t)0x4000) /*!<HW Flow Control enable */
|
||||
#define SDIO_CLKCR_HWFC_EN ((uint16_t)0x4000) /*!<HW Flow Control enable */
|
||||
|
||||
/******************* Bit definition for SDIO_ARG register *******************/
|
||||
#define SDIO_ARG_CMDARG ((uint32_t)0xFFFFFFFF) /*!<Command argument */
|
||||
|
||||
/******************* Bit definition for SDIO_CMD register *******************/
|
||||
#define SDIO_CMD_CMDINDEX ((uint16_t)0x003F) /*!<Command Index */
|
||||
#define SDIO_CMD_CMDINDEX ((uint16_t)0x003F) /*!<Command Index */
|
||||
|
||||
#define SDIO_CMD_WAITRESP ((uint16_t)0x00C0) /*!<WAITRESP[1:0] bits (Wait for response bits) */
|
||||
#define SDIO_CMD_WAITRESP_0 ((uint16_t)0x0040) /*!< Bit 0 */
|
||||
#define SDIO_CMD_WAITRESP_1 ((uint16_t)0x0080) /*!< Bit 1 */
|
||||
|
||||
#define SDIO_CMD_WAITINT ((uint16_t)0x0100) /*!<CPSM Waits for Interrupt Request */
|
||||
#define SDIO_CMD_WAITINT ((uint16_t)0x0100) /*!<CPSM Waits for Interrupt Request */
|
||||
#define SDIO_CMD_WAITPEND ((uint16_t)0x0200) /*!<CPSM Waits for ends of data transfer (CmdPend internal signal) */
|
||||
#define SDIO_CMD_CPSMEN ((uint16_t)0x0400) /*!<Command path state machine (CPSM) Enable bit */
|
||||
#define SDIO_CMD_SDIOSUSPEND ((uint16_t)0x0800) /*!<SD I/O suspend command */
|
||||
#define SDIO_CMD_ENCMDCOMPL ((uint16_t)0x1000) /*!<Enable CMD completion */
|
||||
#define SDIO_CMD_CPSMEN ((uint16_t)0x0400) /*!<Command path state machine (CPSM) Enable bit */
|
||||
#define SDIO_CMD_SDIOSUSPEND ((uint16_t)0x0800) /*!<SD I/O suspend command */
|
||||
#define SDIO_CMD_ENCMDCOMPL ((uint16_t)0x1000) /*!<Enable CMD completion */
|
||||
#define SDIO_CMD_NIEN ((uint16_t)0x2000) /*!<Not Interrupt Enable */
|
||||
#define SDIO_CMD_CEATACMD ((uint16_t)0x4000) /*!<CE-ATA command */
|
||||
#define SDIO_CMD_CEATACMD ((uint16_t)0x4000) /*!<CE-ATA command */
|
||||
|
||||
/***************** Bit definition for SDIO_RESPCMD register *****************/
|
||||
#define SDIO_RESPCMD_RESPCMD ((uint8_t)0x3F) /*!<Response command index */
|
||||
@ -5638,13 +5779,13 @@ typedef struct
|
||||
#define SDIO_DTIMER_DATATIME ((uint32_t)0xFFFFFFFF) /*!<Data timeout period. */
|
||||
|
||||
/****************** Bit definition for SDIO_DLEN register *******************/
|
||||
#define SDIO_DLEN_DATALENGTH ((uint32_t)0x01FFFFFF) /*!<Data length value */
|
||||
#define SDIO_DLEN_DATALENGTH ((uint32_t)0x01FFFFFF) /*!<Data length value */
|
||||
|
||||
/****************** Bit definition for SDIO_DCTRL register ******************/
|
||||
#define SDIO_DCTRL_DTEN ((uint16_t)0x0001) /*!<Data transfer enabled bit */
|
||||
#define SDIO_DCTRL_DTEN ((uint16_t)0x0001) /*!<Data transfer enabled bit */
|
||||
#define SDIO_DCTRL_DTDIR ((uint16_t)0x0002) /*!<Data transfer direction selection */
|
||||
#define SDIO_DCTRL_DTMODE ((uint16_t)0x0004) /*!<Data transfer mode selection */
|
||||
#define SDIO_DCTRL_DMAEN ((uint16_t)0x0008) /*!<DMA enabled bit */
|
||||
#define SDIO_DCTRL_DTMODE ((uint16_t)0x0004) /*!<Data transfer mode selection */
|
||||
#define SDIO_DCTRL_DMAEN ((uint16_t)0x0008) /*!<DMA enabled bit */
|
||||
|
||||
#define SDIO_DCTRL_DBLOCKSIZE ((uint16_t)0x00F0) /*!<DBLOCKSIZE[3:0] bits (Data block size) */
|
||||
#define SDIO_DCTRL_DBLOCKSIZE_0 ((uint16_t)0x0010) /*!<Bit 0 */
|
||||
@ -5652,38 +5793,38 @@ typedef struct
|
||||
#define SDIO_DCTRL_DBLOCKSIZE_2 ((uint16_t)0x0040) /*!<Bit 2 */
|
||||
#define SDIO_DCTRL_DBLOCKSIZE_3 ((uint16_t)0x0080) /*!<Bit 3 */
|
||||
|
||||
#define SDIO_DCTRL_RWSTART ((uint16_t)0x0100) /*!<Read wait start */
|
||||
#define SDIO_DCTRL_RWSTOP ((uint16_t)0x0200) /*!<Read wait stop */
|
||||
#define SDIO_DCTRL_RWMOD ((uint16_t)0x0400) /*!<Read wait mode */
|
||||
#define SDIO_DCTRL_RWSTART ((uint16_t)0x0100) /*!<Read wait start */
|
||||
#define SDIO_DCTRL_RWSTOP ((uint16_t)0x0200) /*!<Read wait stop */
|
||||
#define SDIO_DCTRL_RWMOD ((uint16_t)0x0400) /*!<Read wait mode */
|
||||
#define SDIO_DCTRL_SDIOEN ((uint16_t)0x0800) /*!<SD I/O enable functions */
|
||||
|
||||
/****************** Bit definition for SDIO_DCOUNT register *****************/
|
||||
#define SDIO_DCOUNT_DATACOUNT ((uint32_t)0x01FFFFFF) /*!<Data count value */
|
||||
|
||||
/****************** Bit definition for SDIO_STA register ********************/
|
||||
#define SDIO_STA_CCRCFAIL ((uint32_t)0x00000001) /*!<Command response received (CRC check failed) */
|
||||
#define SDIO_STA_DCRCFAIL ((uint32_t)0x00000002) /*!<Data block sent/received (CRC check failed) */
|
||||
#define SDIO_STA_CTIMEOUT ((uint32_t)0x00000004) /*!<Command response timeout */
|
||||
#define SDIO_STA_DTIMEOUT ((uint32_t)0x00000008) /*!<Data timeout */
|
||||
#define SDIO_STA_TXUNDERR ((uint32_t)0x00000010) /*!<Transmit FIFO underrun error */
|
||||
#define SDIO_STA_RXOVERR ((uint32_t)0x00000020) /*!<Received FIFO overrun error */
|
||||
#define SDIO_STA_CMDREND ((uint32_t)0x00000040) /*!<Command response received (CRC check passed) */
|
||||
#define SDIO_STA_CMDSENT ((uint32_t)0x00000080) /*!<Command sent (no response required) */
|
||||
#define SDIO_STA_DATAEND ((uint32_t)0x00000100) /*!<Data end (data counter, SDIDCOUNT, is zero) */
|
||||
#define SDIO_STA_CCRCFAIL ((uint32_t)0x00000001) /*!<Command response received (CRC check failed) */
|
||||
#define SDIO_STA_DCRCFAIL ((uint32_t)0x00000002) /*!<Data block sent/received (CRC check failed) */
|
||||
#define SDIO_STA_CTIMEOUT ((uint32_t)0x00000004) /*!<Command response timeout */
|
||||
#define SDIO_STA_DTIMEOUT ((uint32_t)0x00000008) /*!<Data timeout */
|
||||
#define SDIO_STA_TXUNDERR ((uint32_t)0x00000010) /*!<Transmit FIFO underrun error */
|
||||
#define SDIO_STA_RXOVERR ((uint32_t)0x00000020) /*!<Received FIFO overrun error */
|
||||
#define SDIO_STA_CMDREND ((uint32_t)0x00000040) /*!<Command response received (CRC check passed) */
|
||||
#define SDIO_STA_CMDSENT ((uint32_t)0x00000080) /*!<Command sent (no response required) */
|
||||
#define SDIO_STA_DATAEND ((uint32_t)0x00000100) /*!<Data end (data counter, SDIDCOUNT, is zero) */
|
||||
#define SDIO_STA_STBITERR ((uint32_t)0x00000200) /*!<Start bit not detected on all data signals in wide bus mode */
|
||||
#define SDIO_STA_DBCKEND ((uint32_t)0x00000400) /*!<Data block sent/received (CRC check passed) */
|
||||
#define SDIO_STA_CMDACT ((uint32_t)0x00000800) /*!<Command transfer in progress */
|
||||
#define SDIO_STA_TXACT ((uint32_t)0x00001000) /*!<Data transmit in progress */
|
||||
#define SDIO_STA_RXACT ((uint32_t)0x00002000) /*!<Data receive in progress */
|
||||
#define SDIO_STA_DBCKEND ((uint32_t)0x00000400) /*!<Data block sent/received (CRC check passed) */
|
||||
#define SDIO_STA_CMDACT ((uint32_t)0x00000800) /*!<Command transfer in progress */
|
||||
#define SDIO_STA_TXACT ((uint32_t)0x00001000) /*!<Data transmit in progress */
|
||||
#define SDIO_STA_RXACT ((uint32_t)0x00002000) /*!<Data receive in progress */
|
||||
#define SDIO_STA_TXFIFOHE ((uint32_t)0x00004000) /*!<Transmit FIFO Half Empty: at least 8 words can be written into the FIFO */
|
||||
#define SDIO_STA_RXFIFOHF ((uint32_t)0x00008000) /*!<Receive FIFO Half Full: there are at least 8 words in the FIFO */
|
||||
#define SDIO_STA_TXFIFOF ((uint32_t)0x00010000) /*!<Transmit FIFO full */
|
||||
#define SDIO_STA_RXFIFOF ((uint32_t)0x00020000) /*!<Receive FIFO full */
|
||||
#define SDIO_STA_TXFIFOE ((uint32_t)0x00040000) /*!<Transmit FIFO empty */
|
||||
#define SDIO_STA_RXFIFOE ((uint32_t)0x00080000) /*!<Receive FIFO empty */
|
||||
#define SDIO_STA_TXDAVL ((uint32_t)0x00100000) /*!<Data available in transmit FIFO */
|
||||
#define SDIO_STA_RXDAVL ((uint32_t)0x00200000) /*!<Data available in receive FIFO */
|
||||
#define SDIO_STA_SDIOIT ((uint32_t)0x00400000) /*!<SDIO interrupt received */
|
||||
#define SDIO_STA_TXFIFOF ((uint32_t)0x00010000) /*!<Transmit FIFO full */
|
||||
#define SDIO_STA_RXFIFOF ((uint32_t)0x00020000) /*!<Receive FIFO full */
|
||||
#define SDIO_STA_TXFIFOE ((uint32_t)0x00040000) /*!<Transmit FIFO empty */
|
||||
#define SDIO_STA_RXFIFOE ((uint32_t)0x00080000) /*!<Receive FIFO empty */
|
||||
#define SDIO_STA_TXDAVL ((uint32_t)0x00100000) /*!<Data available in transmit FIFO */
|
||||
#define SDIO_STA_RXDAVL ((uint32_t)0x00200000) /*!<Data available in receive FIFO */
|
||||
#define SDIO_STA_SDIOIT ((uint32_t)0x00400000) /*!<SDIO interrupt received */
|
||||
#define SDIO_STA_CEATAEND ((uint32_t)0x00800000) /*!<CE-ATA command completion signal received for CMD61 */
|
||||
|
||||
/******************* Bit definition for SDIO_ICR register *******************/
|
||||
@ -5692,36 +5833,36 @@ typedef struct
|
||||
#define SDIO_ICR_CTIMEOUTC ((uint32_t)0x00000004) /*!<CTIMEOUT flag clear bit */
|
||||
#define SDIO_ICR_DTIMEOUTC ((uint32_t)0x00000008) /*!<DTIMEOUT flag clear bit */
|
||||
#define SDIO_ICR_TXUNDERRC ((uint32_t)0x00000010) /*!<TXUNDERR flag clear bit */
|
||||
#define SDIO_ICR_RXOVERRC ((uint32_t)0x00000020) /*!<RXOVERR flag clear bit */
|
||||
#define SDIO_ICR_CMDRENDC ((uint32_t)0x00000040) /*!<CMDREND flag clear bit */
|
||||
#define SDIO_ICR_CMDSENTC ((uint32_t)0x00000080) /*!<CMDSENT flag clear bit */
|
||||
#define SDIO_ICR_DATAENDC ((uint32_t)0x00000100) /*!<DATAEND flag clear bit */
|
||||
#define SDIO_ICR_RXOVERRC ((uint32_t)0x00000020) /*!<RXOVERR flag clear bit */
|
||||
#define SDIO_ICR_CMDRENDC ((uint32_t)0x00000040) /*!<CMDREND flag clear bit */
|
||||
#define SDIO_ICR_CMDSENTC ((uint32_t)0x00000080) /*!<CMDSENT flag clear bit */
|
||||
#define SDIO_ICR_DATAENDC ((uint32_t)0x00000100) /*!<DATAEND flag clear bit */
|
||||
#define SDIO_ICR_STBITERRC ((uint32_t)0x00000200) /*!<STBITERR flag clear bit */
|
||||
#define SDIO_ICR_DBCKENDC ((uint32_t)0x00000400) /*!<DBCKEND flag clear bit */
|
||||
#define SDIO_ICR_SDIOITC ((uint32_t)0x00400000) /*!<SDIOIT flag clear bit */
|
||||
#define SDIO_ICR_DBCKENDC ((uint32_t)0x00000400) /*!<DBCKEND flag clear bit */
|
||||
#define SDIO_ICR_SDIOITC ((uint32_t)0x00400000) /*!<SDIOIT flag clear bit */
|
||||
#define SDIO_ICR_CEATAENDC ((uint32_t)0x00800000) /*!<CEATAEND flag clear bit */
|
||||
|
||||
/****************** Bit definition for SDIO_MASK register *******************/
|
||||
#define SDIO_MASK_CCRCFAILIE ((uint32_t)0x00000001) /*!<Command CRC Fail Interrupt Enable */
|
||||
#define SDIO_MASK_DCRCFAILIE ((uint32_t)0x00000002) /*!<Data CRC Fail Interrupt Enable */
|
||||
#define SDIO_MASK_CTIMEOUTIE ((uint32_t)0x00000004) /*!<Command TimeOut Interrupt Enable */
|
||||
#define SDIO_MASK_DTIMEOUTIE ((uint32_t)0x00000008) /*!<Data TimeOut Interrupt Enable */
|
||||
#define SDIO_MASK_TXUNDERRIE ((uint32_t)0x00000010) /*!<Tx FIFO UnderRun Error Interrupt Enable */
|
||||
#define SDIO_MASK_RXOVERRIE ((uint32_t)0x00000020) /*!<Rx FIFO OverRun Error Interrupt Enable */
|
||||
#define SDIO_MASK_CCRCFAILIE ((uint32_t)0x00000001) /*!<Command CRC Fail Interrupt Enable */
|
||||
#define SDIO_MASK_DCRCFAILIE ((uint32_t)0x00000002) /*!<Data CRC Fail Interrupt Enable */
|
||||
#define SDIO_MASK_CTIMEOUTIE ((uint32_t)0x00000004) /*!<Command TimeOut Interrupt Enable */
|
||||
#define SDIO_MASK_DTIMEOUTIE ((uint32_t)0x00000008) /*!<Data TimeOut Interrupt Enable */
|
||||
#define SDIO_MASK_TXUNDERRIE ((uint32_t)0x00000010) /*!<Tx FIFO UnderRun Error Interrupt Enable */
|
||||
#define SDIO_MASK_RXOVERRIE ((uint32_t)0x00000020) /*!<Rx FIFO OverRun Error Interrupt Enable */
|
||||
#define SDIO_MASK_CMDRENDIE ((uint32_t)0x00000040) /*!<Command Response Received Interrupt Enable */
|
||||
#define SDIO_MASK_CMDSENTIE ((uint32_t)0x00000080) /*!<Command Sent Interrupt Enable */
|
||||
#define SDIO_MASK_DATAENDIE ((uint32_t)0x00000100) /*!<Data End Interrupt Enable */
|
||||
#define SDIO_MASK_STBITERRIE ((uint32_t)0x00000200) /*!<Start Bit Error Interrupt Enable */
|
||||
#define SDIO_MASK_DBCKENDIE ((uint32_t)0x00000400) /*!<Data Block End Interrupt Enable */
|
||||
#define SDIO_MASK_CMDACTIE ((uint32_t)0x00000800) /*!<CCommand Acting Interrupt Enable */
|
||||
#define SDIO_MASK_TXACTIE ((uint32_t)0x00001000) /*!<Data Transmit Acting Interrupt Enable */
|
||||
#define SDIO_MASK_RXACTIE ((uint32_t)0x00002000) /*!<Data receive acting interrupt enabled */
|
||||
#define SDIO_MASK_TXFIFOHEIE ((uint32_t)0x00004000) /*!<Tx FIFO Half Empty interrupt Enable */
|
||||
#define SDIO_MASK_RXFIFOHFIE ((uint32_t)0x00008000) /*!<Rx FIFO Half Full interrupt Enable */
|
||||
#define SDIO_MASK_TXFIFOFIE ((uint32_t)0x00010000) /*!<Tx FIFO Full interrupt Enable */
|
||||
#define SDIO_MASK_RXFIFOFIE ((uint32_t)0x00020000) /*!<Rx FIFO Full interrupt Enable */
|
||||
#define SDIO_MASK_TXFIFOEIE ((uint32_t)0x00040000) /*!<Tx FIFO Empty interrupt Enable */
|
||||
#define SDIO_MASK_RXFIFOEIE ((uint32_t)0x00080000) /*!<Rx FIFO Empty interrupt Enable */
|
||||
#define SDIO_MASK_CMDSENTIE ((uint32_t)0x00000080) /*!<Command Sent Interrupt Enable */
|
||||
#define SDIO_MASK_DATAENDIE ((uint32_t)0x00000100) /*!<Data End Interrupt Enable */
|
||||
#define SDIO_MASK_STBITERRIE ((uint32_t)0x00000200) /*!<Start Bit Error Interrupt Enable */
|
||||
#define SDIO_MASK_DBCKENDIE ((uint32_t)0x00000400) /*!<Data Block End Interrupt Enable */
|
||||
#define SDIO_MASK_CMDACTIE ((uint32_t)0x00000800) /*!<CCommand Acting Interrupt Enable */
|
||||
#define SDIO_MASK_TXACTIE ((uint32_t)0x00001000) /*!<Data Transmit Acting Interrupt Enable */
|
||||
#define SDIO_MASK_RXACTIE ((uint32_t)0x00002000) /*!<Data receive acting interrupt enabled */
|
||||
#define SDIO_MASK_TXFIFOHEIE ((uint32_t)0x00004000) /*!<Tx FIFO Half Empty interrupt Enable */
|
||||
#define SDIO_MASK_RXFIFOHFIE ((uint32_t)0x00008000) /*!<Rx FIFO Half Full interrupt Enable */
|
||||
#define SDIO_MASK_TXFIFOFIE ((uint32_t)0x00010000) /*!<Tx FIFO Full interrupt Enable */
|
||||
#define SDIO_MASK_RXFIFOFIE ((uint32_t)0x00020000) /*!<Rx FIFO Full interrupt Enable */
|
||||
#define SDIO_MASK_TXFIFOEIE ((uint32_t)0x00040000) /*!<Tx FIFO Empty interrupt Enable */
|
||||
#define SDIO_MASK_RXFIFOEIE ((uint32_t)0x00080000) /*!<Rx FIFO Empty interrupt Enable */
|
||||
#define SDIO_MASK_TXDAVLIE ((uint32_t)0x00100000) /*!<Data available in Tx FIFO interrupt Enable */
|
||||
#define SDIO_MASK_RXDAVLIE ((uint32_t)0x00200000) /*!<Data available in Rx FIFO interrupt Enable */
|
||||
#define SDIO_MASK_SDIOITIE ((uint32_t)0x00400000) /*!<SDIO Mode Interrupt Received interrupt Enable */
|
||||
@ -5739,8 +5880,8 @@ typedef struct
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/******************* Bit definition for SPI_CR1 register ********************/
|
||||
#define SPI_CR1_CPHA ((uint16_t)0x0001) /*!<Clock Phase */
|
||||
#define SPI_CR1_CPOL ((uint16_t)0x0002) /*!<Clock Polarity */
|
||||
#define SPI_CR1_CPHA ((uint16_t)0x0001) /*!<Clock Phase */
|
||||
#define SPI_CR1_CPOL ((uint16_t)0x0002) /*!<Clock Polarity */
|
||||
#define SPI_CR1_MSTR ((uint16_t)0x0004) /*!<Master Selection */
|
||||
|
||||
#define SPI_CR1_BR ((uint16_t)0x0038) /*!<BR[2:0] bits (Baud Rate Control) */
|
||||
@ -5748,73 +5889,73 @@ typedef struct
|
||||
#define SPI_CR1_BR_1 ((uint16_t)0x0010) /*!<Bit 1 */
|
||||
#define SPI_CR1_BR_2 ((uint16_t)0x0020) /*!<Bit 2 */
|
||||
|
||||
#define SPI_CR1_SPE ((uint16_t)0x0040) /*!<SPI Enable */
|
||||
#define SPI_CR1_LSBFIRST ((uint16_t)0x0080) /*!<Frame Format */
|
||||
#define SPI_CR1_SSI ((uint16_t)0x0100) /*!<Internal slave select */
|
||||
#define SPI_CR1_SSM ((uint16_t)0x0200) /*!<Software slave management */
|
||||
#define SPI_CR1_RXONLY ((uint16_t)0x0400) /*!<Receive only */
|
||||
#define SPI_CR1_DFF ((uint16_t)0x0800) /*!<Data Frame Format */
|
||||
#define SPI_CR1_CRCNEXT ((uint16_t)0x1000) /*!<Transmit CRC next */
|
||||
#define SPI_CR1_CRCEN ((uint16_t)0x2000) /*!<Hardware CRC calculation enable */
|
||||
#define SPI_CR1_SPE ((uint16_t)0x0040) /*!<SPI Enable */
|
||||
#define SPI_CR1_LSBFIRST ((uint16_t)0x0080) /*!<Frame Format */
|
||||
#define SPI_CR1_SSI ((uint16_t)0x0100) /*!<Internal slave select */
|
||||
#define SPI_CR1_SSM ((uint16_t)0x0200) /*!<Software slave management */
|
||||
#define SPI_CR1_RXONLY ((uint16_t)0x0400) /*!<Receive only */
|
||||
#define SPI_CR1_DFF ((uint16_t)0x0800) /*!<Data Frame Format */
|
||||
#define SPI_CR1_CRCNEXT ((uint16_t)0x1000) /*!<Transmit CRC next */
|
||||
#define SPI_CR1_CRCEN ((uint16_t)0x2000) /*!<Hardware CRC calculation enable */
|
||||
#define SPI_CR1_BIDIOE ((uint16_t)0x4000) /*!<Output enable in bidirectional mode */
|
||||
#define SPI_CR1_BIDIMODE ((uint16_t)0x8000) /*!<Bidirectional data mode enable */
|
||||
#define SPI_CR1_BIDIMODE ((uint16_t)0x8000) /*!<Bidirectional data mode enable */
|
||||
|
||||
/******************* Bit definition for SPI_CR2 register ********************/
|
||||
#define SPI_CR2_RXDMAEN ((uint8_t)0x01) /*!<Rx Buffer DMA Enable */
|
||||
#define SPI_CR2_TXDMAEN ((uint8_t)0x02) /*!<Tx Buffer DMA Enable */
|
||||
#define SPI_CR2_SSOE ((uint8_t)0x04) /*!<SS Output Enable */
|
||||
#define SPI_CR2_ERRIE ((uint8_t)0x20) /*!<Error Interrupt Enable */
|
||||
#define SPI_CR2_RXDMAEN ((uint8_t)0x01) /*!<Rx Buffer DMA Enable */
|
||||
#define SPI_CR2_TXDMAEN ((uint8_t)0x02) /*!<Tx Buffer DMA Enable */
|
||||
#define SPI_CR2_SSOE ((uint8_t)0x04) /*!<SS Output Enable */
|
||||
#define SPI_CR2_ERRIE ((uint8_t)0x20) /*!<Error Interrupt Enable */
|
||||
#define SPI_CR2_RXNEIE ((uint8_t)0x40) /*!<RX buffer Not Empty Interrupt Enable */
|
||||
#define SPI_CR2_TXEIE ((uint8_t)0x80) /*!<Tx buffer Empty Interrupt Enable */
|
||||
#define SPI_CR2_TXEIE ((uint8_t)0x80) /*!<Tx buffer Empty Interrupt Enable */
|
||||
|
||||
/******************** Bit definition for SPI_SR register ********************/
|
||||
#define SPI_SR_RXNE ((uint8_t)0x01) /*!<Receive buffer Not Empty */
|
||||
#define SPI_SR_TXE ((uint8_t)0x02) /*!<Transmit buffer Empty */
|
||||
#define SPI_SR_CHSIDE ((uint8_t)0x04) /*!<Channel side */
|
||||
#define SPI_SR_UDR ((uint8_t)0x08) /*!<Underrun flag */
|
||||
#define SPI_SR_CRCERR ((uint8_t)0x10) /*!<CRC Error flag */
|
||||
#define SPI_SR_MODF ((uint8_t)0x20) /*!<Mode fault */
|
||||
#define SPI_SR_OVR ((uint8_t)0x40) /*!<Overrun flag */
|
||||
#define SPI_SR_BSY ((uint8_t)0x80) /*!<Busy flag */
|
||||
#define SPI_SR_TXE ((uint8_t)0x02) /*!<Transmit buffer Empty */
|
||||
#define SPI_SR_CHSIDE ((uint8_t)0x04) /*!<Channel side */
|
||||
#define SPI_SR_UDR ((uint8_t)0x08) /*!<Underrun flag */
|
||||
#define SPI_SR_CRCERR ((uint8_t)0x10) /*!<CRC Error flag */
|
||||
#define SPI_SR_MODF ((uint8_t)0x20) /*!<Mode fault */
|
||||
#define SPI_SR_OVR ((uint8_t)0x40) /*!<Overrun flag */
|
||||
#define SPI_SR_BSY ((uint8_t)0x80) /*!<Busy flag */
|
||||
|
||||
/******************** Bit definition for SPI_DR register ********************/
|
||||
#define SPI_DR_DR ((uint16_t)0xFFFF) /*!<Data Register */
|
||||
#define SPI_DR_DR ((uint16_t)0xFFFF) /*!<Data Register */
|
||||
|
||||
/******************* Bit definition for SPI_CRCPR register ******************/
|
||||
#define SPI_CRCPR_CRCPOLY ((uint16_t)0xFFFF) /*!<CRC polynomial register */
|
||||
|
||||
/****************** Bit definition for SPI_RXCRCR register ******************/
|
||||
#define SPI_RXCRCR_RXCRC ((uint16_t)0xFFFF) /*!<Rx CRC Register */
|
||||
#define SPI_RXCRCR_RXCRC ((uint16_t)0xFFFF) /*!<Rx CRC Register */
|
||||
|
||||
/****************** Bit definition for SPI_TXCRCR register ******************/
|
||||
#define SPI_TXCRCR_TXCRC ((uint16_t)0xFFFF) /*!<Tx CRC Register */
|
||||
#define SPI_TXCRCR_TXCRC ((uint16_t)0xFFFF) /*!<Tx CRC Register */
|
||||
|
||||
/****************** Bit definition for SPI_I2SCFGR register *****************/
|
||||
#define SPI_I2SCFGR_CHLEN ((uint16_t)0x0001) /*!<Channel length (number of bits per audio channel) */
|
||||
|
||||
#define SPI_I2SCFGR_DATLEN ((uint16_t)0x0006) /*!<DATLEN[1:0] bits (Data length to be transferred) */
|
||||
#define SPI_I2SCFGR_DATLEN ((uint16_t)0x0006) /*!<DATLEN[1:0] bits (Data length to be transferred) */
|
||||
#define SPI_I2SCFGR_DATLEN_0 ((uint16_t)0x0002) /*!<Bit 0 */
|
||||
#define SPI_I2SCFGR_DATLEN_1 ((uint16_t)0x0004) /*!<Bit 1 */
|
||||
|
||||
#define SPI_I2SCFGR_CKPOL ((uint16_t)0x0008) /*!<steady state clock polarity */
|
||||
#define SPI_I2SCFGR_CKPOL ((uint16_t)0x0008) /*!<steady state clock polarity */
|
||||
|
||||
#define SPI_I2SCFGR_I2SSTD ((uint16_t)0x0030) /*!<I2SSTD[1:0] bits (I2S standard selection) */
|
||||
#define SPI_I2SCFGR_I2SSTD_0 ((uint16_t)0x0010) /*!<Bit 0 */
|
||||
#define SPI_I2SCFGR_I2SSTD_1 ((uint16_t)0x0020) /*!<Bit 1 */
|
||||
|
||||
#define SPI_I2SCFGR_PCMSYNC ((uint16_t)0x0080) /*!<PCM frame synchronization */
|
||||
#define SPI_I2SCFGR_PCMSYNC ((uint16_t)0x0080) /*!<PCM frame synchronization */
|
||||
|
||||
#define SPI_I2SCFGR_I2SCFG ((uint16_t)0x0300) /*!<I2SCFG[1:0] bits (I2S configuration mode) */
|
||||
#define SPI_I2SCFGR_I2SCFG_0 ((uint16_t)0x0100) /*!<Bit 0 */
|
||||
#define SPI_I2SCFGR_I2SCFG_1 ((uint16_t)0x0200) /*!<Bit 1 */
|
||||
|
||||
#define SPI_I2SCFGR_I2SE ((uint16_t)0x0400) /*!<I2S Enable */
|
||||
#define SPI_I2SCFGR_I2SE ((uint16_t)0x0400) /*!<I2S Enable */
|
||||
#define SPI_I2SCFGR_I2SMOD ((uint16_t)0x0800) /*!<I2S mode selection */
|
||||
|
||||
/****************** Bit definition for SPI_I2SPR register *******************/
|
||||
#define SPI_I2SPR_I2SDIV ((uint16_t)0x00FF) /*!<I2S Linear prescaler */
|
||||
#define SPI_I2SPR_I2SDIV ((uint16_t)0x00FF) /*!<I2S Linear prescaler */
|
||||
#define SPI_I2SPR_ODD ((uint16_t)0x0100) /*!<Odd factor for the prescaler */
|
||||
#define SPI_I2SPR_MCKOE ((uint16_t)0x0200) /*!<Master Clock Output Enable */
|
||||
#define SPI_I2SPR_MCKOE ((uint16_t)0x0200) /*!<Master Clock Output Enable */
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
@ -5822,9 +5963,12 @@ typedef struct
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/****************** Bit definition for SYSCFG_MEMRMP register ***************/
|
||||
#define SYSCFG_MEMRMP_MEM_MODE ((uint32_t)0x00000003) /*!<SYSCFG_Memory Remap Config */
|
||||
#define SYSCFG_MEMRMP_MEM_MODE ((uint32_t)0x00000007) /*!< SYSCFG_Memory Remap Config */
|
||||
#define SYSCFG_MEMRMP_MEM_MODE_0 ((uint32_t)0x00000001)
|
||||
#define SYSCFG_MEMRMP_MEM_MODE_1 ((uint32_t)0x00000002)
|
||||
#define SYSCFG_MEMRMP_MEM_MODE_2 ((uint32_t)0x00000004)
|
||||
|
||||
#define SYSCFG_MEMRMP_UFB_MODE ((uint32_t)0x00000100) /*!< User Flash Bank mode */
|
||||
|
||||
/****************** Bit definition for SYSCFG_PMC register ******************/
|
||||
#define SYSCFG_PMC_MII_RMII_SEL ((uint32_t)0x00800000) /*!<Ethernet PHY interface selection */
|
||||
@ -5848,6 +5992,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR1_EXTI0_PG ((uint16_t)0x0006) /*!<PG[0] pin */
|
||||
#define SYSCFG_EXTICR1_EXTI0_PH ((uint16_t)0x0007) /*!<PH[0] pin */
|
||||
#define SYSCFG_EXTICR1_EXTI0_PI ((uint16_t)0x0008) /*!<PI[0] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI1 configuration
|
||||
*/
|
||||
@ -5860,6 +6005,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR1_EXTI1_PG ((uint16_t)0x0060) /*!<PG[1] pin */
|
||||
#define SYSCFG_EXTICR1_EXTI1_PH ((uint16_t)0x0070) /*!<PH[1] pin */
|
||||
#define SYSCFG_EXTICR1_EXTI1_PI ((uint16_t)0x0080) /*!<PI[1] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI2 configuration
|
||||
*/
|
||||
@ -5872,6 +6018,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR1_EXTI2_PG ((uint16_t)0x0600) /*!<PG[2] pin */
|
||||
#define SYSCFG_EXTICR1_EXTI2_PH ((uint16_t)0x0700) /*!<PH[2] pin */
|
||||
#define SYSCFG_EXTICR1_EXTI2_PI ((uint16_t)0x0800) /*!<PI[2] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI3 configuration
|
||||
*/
|
||||
@ -5902,6 +6049,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR2_EXTI4_PG ((uint16_t)0x0006) /*!<PG[4] pin */
|
||||
#define SYSCFG_EXTICR2_EXTI4_PH ((uint16_t)0x0007) /*!<PH[4] pin */
|
||||
#define SYSCFG_EXTICR2_EXTI4_PI ((uint16_t)0x0008) /*!<PI[4] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI5 configuration
|
||||
*/
|
||||
@ -5914,6 +6062,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR2_EXTI5_PG ((uint16_t)0x0060) /*!<PG[5] pin */
|
||||
#define SYSCFG_EXTICR2_EXTI5_PH ((uint16_t)0x0070) /*!<PH[5] pin */
|
||||
#define SYSCFG_EXTICR2_EXTI5_PI ((uint16_t)0x0080) /*!<PI[5] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI6 configuration
|
||||
*/
|
||||
@ -5926,6 +6075,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR2_EXTI6_PG ((uint16_t)0x0600) /*!<PG[6] pin */
|
||||
#define SYSCFG_EXTICR2_EXTI6_PH ((uint16_t)0x0700) /*!<PH[6] pin */
|
||||
#define SYSCFG_EXTICR2_EXTI6_PI ((uint16_t)0x0800) /*!<PI[6] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI7 configuration
|
||||
*/
|
||||
@ -5957,6 +6107,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR3_EXTI8_PG ((uint16_t)0x0006) /*!<PG[8] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI8_PH ((uint16_t)0x0007) /*!<PH[8] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI8_PI ((uint16_t)0x0008) /*!<PI[8] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI9 configuration
|
||||
*/
|
||||
@ -5969,6 +6120,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR3_EXTI9_PG ((uint16_t)0x0060) /*!<PG[9] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI9_PH ((uint16_t)0x0070) /*!<PH[9] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI9_PI ((uint16_t)0x0080) /*!<PI[9] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI10 configuration
|
||||
*/
|
||||
@ -5981,6 +6133,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR3_EXTI10_PG ((uint16_t)0x0600) /*!<PG[10] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI10_PH ((uint16_t)0x0700) /*!<PH[10] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI10_PI ((uint16_t)0x0800) /*!<PI[10] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI11 configuration
|
||||
*/
|
||||
@ -6009,7 +6162,8 @@ typedef struct
|
||||
#define SYSCFG_EXTICR4_EXTI12_PE ((uint16_t)0x0004) /*!<PE[12] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI12_PF ((uint16_t)0x0005) /*!<PF[12] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI12_PG ((uint16_t)0x0006) /*!<PG[12] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI12_PH ((uint16_t)0x0007) /*!<PH[12] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI12_PH ((uint16_t)0x0007) /*!<PH[12] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI13 configuration
|
||||
*/
|
||||
@ -6020,7 +6174,8 @@ typedef struct
|
||||
#define SYSCFG_EXTICR4_EXTI13_PE ((uint16_t)0x0040) /*!<PE[13] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI13_PF ((uint16_t)0x0050) /*!<PF[13] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI13_PG ((uint16_t)0x0060) /*!<PG[13] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI13_PH ((uint16_t)0x0070) /*!<PH[13] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI13_PH ((uint16_t)0x0070) /*!<PH[13] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI14 configuration
|
||||
*/
|
||||
@ -6031,7 +6186,8 @@ typedef struct
|
||||
#define SYSCFG_EXTICR4_EXTI14_PE ((uint16_t)0x0400) /*!<PE[14] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI14_PF ((uint16_t)0x0500) /*!<PF[14] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI14_PG ((uint16_t)0x0600) /*!<PG[14] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI14_PH ((uint16_t)0x0700) /*!<PH[14] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI14_PH ((uint16_t)0x0700) /*!<PH[14] pin */
|
||||
|
||||
/**
|
||||
* @brief EXTI15 configuration
|
||||
*/
|
||||
@ -6042,7 +6198,7 @@ typedef struct
|
||||
#define SYSCFG_EXTICR4_EXTI15_PE ((uint16_t)0x4000) /*!<PE[15] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI15_PF ((uint16_t)0x5000) /*!<PF[15] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI15_PG ((uint16_t)0x6000) /*!<PG[15] pin */
|
||||
#define SYSCFG_EXTICR3_EXTI15_PH ((uint16_t)0x7000) /*!<PH[15] pin */
|
||||
#define SYSCFG_EXTICR4_EXTI15_PH ((uint16_t)0x7000) /*!<PH[15] pin */
|
||||
|
||||
/****************** Bit definition for SYSCFG_CMPCR register ****************/
|
||||
#define SYSCFG_CMPCR_CMP_PD ((uint32_t)0x00000001) /*!<Compensation cell ready flag */
|
||||
@ -6054,26 +6210,26 @@ typedef struct
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/******************* Bit definition for TIM_CR1 register ********************/
|
||||
#define TIM_CR1_CEN ((uint16_t)0x0001) /*!<Counter enable */
|
||||
#define TIM_CR1_UDIS ((uint16_t)0x0002) /*!<Update disable */
|
||||
#define TIM_CR1_CEN ((uint16_t)0x0001) /*!<Counter enable */
|
||||
#define TIM_CR1_UDIS ((uint16_t)0x0002) /*!<Update disable */
|
||||
#define TIM_CR1_URS ((uint16_t)0x0004) /*!<Update request source */
|
||||
#define TIM_CR1_OPM ((uint16_t)0x0008) /*!<One pulse mode */
|
||||
#define TIM_CR1_DIR ((uint16_t)0x0010) /*!<Direction */
|
||||
#define TIM_CR1_OPM ((uint16_t)0x0008) /*!<One pulse mode */
|
||||
#define TIM_CR1_DIR ((uint16_t)0x0010) /*!<Direction */
|
||||
|
||||
#define TIM_CR1_CMS ((uint16_t)0x0060) /*!<CMS[1:0] bits (Center-aligned mode selection) */
|
||||
#define TIM_CR1_CMS_0 ((uint16_t)0x0020) /*!<Bit 0 */
|
||||
#define TIM_CR1_CMS_1 ((uint16_t)0x0040) /*!<Bit 1 */
|
||||
|
||||
#define TIM_CR1_ARPE ((uint16_t)0x0080) /*!<Auto-reload preload enable */
|
||||
#define TIM_CR1_ARPE ((uint16_t)0x0080) /*!<Auto-reload preload enable */
|
||||
|
||||
#define TIM_CR1_CKD ((uint16_t)0x0300) /*!<CKD[1:0] bits (clock division) */
|
||||
#define TIM_CR1_CKD_0 ((uint16_t)0x0100) /*!<Bit 0 */
|
||||
#define TIM_CR1_CKD_1 ((uint16_t)0x0200) /*!<Bit 1 */
|
||||
|
||||
/******************* Bit definition for TIM_CR2 register ********************/
|
||||
#define TIM_CR2_CCPC ((uint16_t)0x0001) /*!<Capture/Compare Preloaded Control */
|
||||
#define TIM_CR2_CCPC ((uint16_t)0x0001) /*!<Capture/Compare Preloaded Control */
|
||||
#define TIM_CR2_CCUS ((uint16_t)0x0004) /*!<Capture/Compare Control Update Selection */
|
||||
#define TIM_CR2_CCDS ((uint16_t)0x0008) /*!<Capture/Compare DMA Selection */
|
||||
#define TIM_CR2_CCDS ((uint16_t)0x0008) /*!<Capture/Compare DMA Selection */
|
||||
|
||||
#define TIM_CR2_MMS ((uint16_t)0x0070) /*!<MMS[2:0] bits (Master Mode Selection) */
|
||||
#define TIM_CR2_MMS_0 ((uint16_t)0x0010) /*!<Bit 0 */
|
||||
@ -6081,26 +6237,26 @@ typedef struct
|
||||
#define TIM_CR2_MMS_2 ((uint16_t)0x0040) /*!<Bit 2 */
|
||||
|
||||
#define TIM_CR2_TI1S ((uint16_t)0x0080) /*!<TI1 Selection */
|
||||
#define TIM_CR2_OIS1 ((uint16_t)0x0100) /*!<Output Idle state 1 (OC1 output) */
|
||||
#define TIM_CR2_OIS1 ((uint16_t)0x0100) /*!<Output Idle state 1 (OC1 output) */
|
||||
#define TIM_CR2_OIS1N ((uint16_t)0x0200) /*!<Output Idle state 1 (OC1N output) */
|
||||
#define TIM_CR2_OIS2 ((uint16_t)0x0400) /*!<Output Idle state 2 (OC2 output) */
|
||||
#define TIM_CR2_OIS2 ((uint16_t)0x0400) /*!<Output Idle state 2 (OC2 output) */
|
||||
#define TIM_CR2_OIS2N ((uint16_t)0x0800) /*!<Output Idle state 2 (OC2N output) */
|
||||
#define TIM_CR2_OIS3 ((uint16_t)0x1000) /*!<Output Idle state 3 (OC3 output) */
|
||||
#define TIM_CR2_OIS3 ((uint16_t)0x1000) /*!<Output Idle state 3 (OC3 output) */
|
||||
#define TIM_CR2_OIS3N ((uint16_t)0x2000) /*!<Output Idle state 3 (OC3N output) */
|
||||
#define TIM_CR2_OIS4 ((uint16_t)0x4000) /*!<Output Idle state 4 (OC4 output) */
|
||||
#define TIM_CR2_OIS4 ((uint16_t)0x4000) /*!<Output Idle state 4 (OC4 output) */
|
||||
|
||||
/******************* Bit definition for TIM_SMCR register *******************/
|
||||
#define TIM_SMCR_SMS ((uint16_t)0x0007) /*!<SMS[2:0] bits (Slave mode selection) */
|
||||
#define TIM_SMCR_SMS ((uint16_t)0x0007) /*!<SMS[2:0] bits (Slave mode selection) */
|
||||
#define TIM_SMCR_SMS_0 ((uint16_t)0x0001) /*!<Bit 0 */
|
||||
#define TIM_SMCR_SMS_1 ((uint16_t)0x0002) /*!<Bit 1 */
|
||||
#define TIM_SMCR_SMS_2 ((uint16_t)0x0004) /*!<Bit 2 */
|
||||
|
||||
#define TIM_SMCR_TS ((uint16_t)0x0070) /*!<TS[2:0] bits (Trigger selection) */
|
||||
#define TIM_SMCR_TS ((uint16_t)0x0070) /*!<TS[2:0] bits (Trigger selection) */
|
||||
#define TIM_SMCR_TS_0 ((uint16_t)0x0010) /*!<Bit 0 */
|
||||
#define TIM_SMCR_TS_1 ((uint16_t)0x0020) /*!<Bit 1 */
|
||||
#define TIM_SMCR_TS_2 ((uint16_t)0x0040) /*!<Bit 2 */
|
||||
|
||||
#define TIM_SMCR_MSM ((uint16_t)0x0080) /*!<Master/slave mode */
|
||||
#define TIM_SMCR_MSM ((uint16_t)0x0080) /*!<Master/slave mode */
|
||||
|
||||
#define TIM_SMCR_ETF ((uint16_t)0x0F00) /*!<ETF[3:0] bits (External trigger filter) */
|
||||
#define TIM_SMCR_ETF_0 ((uint16_t)0x0100) /*!<Bit 0 */
|
||||
@ -6112,73 +6268,73 @@ typedef struct
|
||||
#define TIM_SMCR_ETPS_0 ((uint16_t)0x1000) /*!<Bit 0 */
|
||||
#define TIM_SMCR_ETPS_1 ((uint16_t)0x2000) /*!<Bit 1 */
|
||||
|
||||
#define TIM_SMCR_ECE ((uint16_t)0x4000) /*!<External clock enable */
|
||||
#define TIM_SMCR_ECE ((uint16_t)0x4000) /*!<External clock enable */
|
||||
#define TIM_SMCR_ETP ((uint16_t)0x8000) /*!<External trigger polarity */
|
||||
|
||||
/******************* Bit definition for TIM_DIER register *******************/
|
||||
#define TIM_DIER_UIE ((uint16_t)0x0001) /*!<Update interrupt enable */
|
||||
#define TIM_DIER_CC1IE ((uint16_t)0x0002) /*!<Capture/Compare 1 interrupt enable */
|
||||
#define TIM_DIER_CC2IE ((uint16_t)0x0004) /*!<Capture/Compare 2 interrupt enable */
|
||||
#define TIM_DIER_CC3IE ((uint16_t)0x0008) /*!<Capture/Compare 3 interrupt enable */
|
||||
#define TIM_DIER_CC4IE ((uint16_t)0x0010) /*!<Capture/Compare 4 interrupt enable */
|
||||
#define TIM_DIER_COMIE ((uint16_t)0x0020) /*!<COM interrupt enable */
|
||||
#define TIM_DIER_TIE ((uint16_t)0x0040) /*!<Trigger interrupt enable */
|
||||
#define TIM_DIER_BIE ((uint16_t)0x0080) /*!<Break interrupt enable */
|
||||
#define TIM_DIER_UDE ((uint16_t)0x0100) /*!<Update DMA request enable */
|
||||
#define TIM_DIER_CC1IE ((uint16_t)0x0002) /*!<Capture/Compare 1 interrupt enable */
|
||||
#define TIM_DIER_CC2IE ((uint16_t)0x0004) /*!<Capture/Compare 2 interrupt enable */
|
||||
#define TIM_DIER_CC3IE ((uint16_t)0x0008) /*!<Capture/Compare 3 interrupt enable */
|
||||
#define TIM_DIER_CC4IE ((uint16_t)0x0010) /*!<Capture/Compare 4 interrupt enable */
|
||||
#define TIM_DIER_COMIE ((uint16_t)0x0020) /*!<COM interrupt enable */
|
||||
#define TIM_DIER_TIE ((uint16_t)0x0040) /*!<Trigger interrupt enable */
|
||||
#define TIM_DIER_BIE ((uint16_t)0x0080) /*!<Break interrupt enable */
|
||||
#define TIM_DIER_UDE ((uint16_t)0x0100) /*!<Update DMA request enable */
|
||||
#define TIM_DIER_CC1DE ((uint16_t)0x0200) /*!<Capture/Compare 1 DMA request enable */
|
||||
#define TIM_DIER_CC2DE ((uint16_t)0x0400) /*!<Capture/Compare 2 DMA request enable */
|
||||
#define TIM_DIER_CC3DE ((uint16_t)0x0800) /*!<Capture/Compare 3 DMA request enable */
|
||||
#define TIM_DIER_CC4DE ((uint16_t)0x1000) /*!<Capture/Compare 4 DMA request enable */
|
||||
#define TIM_DIER_COMDE ((uint16_t)0x2000) /*!<COM DMA request enable */
|
||||
#define TIM_DIER_TDE ((uint16_t)0x4000) /*!<Trigger DMA request enable */
|
||||
#define TIM_DIER_COMDE ((uint16_t)0x2000) /*!<COM DMA request enable */
|
||||
#define TIM_DIER_TDE ((uint16_t)0x4000) /*!<Trigger DMA request enable */
|
||||
|
||||
/******************** Bit definition for TIM_SR register ********************/
|
||||
#define TIM_SR_UIF ((uint16_t)0x0001) /*!<Update interrupt Flag */
|
||||
#define TIM_SR_CC1IF ((uint16_t)0x0002) /*!<Capture/Compare 1 interrupt Flag */
|
||||
#define TIM_SR_CC2IF ((uint16_t)0x0004) /*!<Capture/Compare 2 interrupt Flag */
|
||||
#define TIM_SR_CC3IF ((uint16_t)0x0008) /*!<Capture/Compare 3 interrupt Flag */
|
||||
#define TIM_SR_CC4IF ((uint16_t)0x0010) /*!<Capture/Compare 4 interrupt Flag */
|
||||
#define TIM_SR_COMIF ((uint16_t)0x0020) /*!<COM interrupt Flag */
|
||||
#define TIM_SR_TIF ((uint16_t)0x0040) /*!<Trigger interrupt Flag */
|
||||
#define TIM_SR_BIF ((uint16_t)0x0080) /*!<Break interrupt Flag */
|
||||
#define TIM_SR_UIF ((uint16_t)0x0001) /*!<Update interrupt Flag */
|
||||
#define TIM_SR_CC1IF ((uint16_t)0x0002) /*!<Capture/Compare 1 interrupt Flag */
|
||||
#define TIM_SR_CC2IF ((uint16_t)0x0004) /*!<Capture/Compare 2 interrupt Flag */
|
||||
#define TIM_SR_CC3IF ((uint16_t)0x0008) /*!<Capture/Compare 3 interrupt Flag */
|
||||
#define TIM_SR_CC4IF ((uint16_t)0x0010) /*!<Capture/Compare 4 interrupt Flag */
|
||||
#define TIM_SR_COMIF ((uint16_t)0x0020) /*!<COM interrupt Flag */
|
||||
#define TIM_SR_TIF ((uint16_t)0x0040) /*!<Trigger interrupt Flag */
|
||||
#define TIM_SR_BIF ((uint16_t)0x0080) /*!<Break interrupt Flag */
|
||||
#define TIM_SR_CC1OF ((uint16_t)0x0200) /*!<Capture/Compare 1 Overcapture Flag */
|
||||
#define TIM_SR_CC2OF ((uint16_t)0x0400) /*!<Capture/Compare 2 Overcapture Flag */
|
||||
#define TIM_SR_CC3OF ((uint16_t)0x0800) /*!<Capture/Compare 3 Overcapture Flag */
|
||||
#define TIM_SR_CC4OF ((uint16_t)0x1000) /*!<Capture/Compare 4 Overcapture Flag */
|
||||
|
||||
/******************* Bit definition for TIM_EGR register ********************/
|
||||
#define TIM_EGR_UG ((uint8_t)0x01) /*!<Update Generation */
|
||||
#define TIM_EGR_CC1G ((uint8_t)0x02) /*!<Capture/Compare 1 Generation */
|
||||
#define TIM_EGR_CC2G ((uint8_t)0x04) /*!<Capture/Compare 2 Generation */
|
||||
#define TIM_EGR_CC3G ((uint8_t)0x08) /*!<Capture/Compare 3 Generation */
|
||||
#define TIM_EGR_CC4G ((uint8_t)0x10) /*!<Capture/Compare 4 Generation */
|
||||
#define TIM_EGR_UG ((uint8_t)0x01) /*!<Update Generation */
|
||||
#define TIM_EGR_CC1G ((uint8_t)0x02) /*!<Capture/Compare 1 Generation */
|
||||
#define TIM_EGR_CC2G ((uint8_t)0x04) /*!<Capture/Compare 2 Generation */
|
||||
#define TIM_EGR_CC3G ((uint8_t)0x08) /*!<Capture/Compare 3 Generation */
|
||||
#define TIM_EGR_CC4G ((uint8_t)0x10) /*!<Capture/Compare 4 Generation */
|
||||
#define TIM_EGR_COMG ((uint8_t)0x20) /*!<Capture/Compare Control Update Generation */
|
||||
#define TIM_EGR_TG ((uint8_t)0x40) /*!<Trigger Generation */
|
||||
#define TIM_EGR_BG ((uint8_t)0x80) /*!<Break Generation */
|
||||
#define TIM_EGR_TG ((uint8_t)0x40) /*!<Trigger Generation */
|
||||
#define TIM_EGR_BG ((uint8_t)0x80) /*!<Break Generation */
|
||||
|
||||
/****************** Bit definition for TIM_CCMR1 register *******************/
|
||||
#define TIM_CCMR1_CC1S ((uint16_t)0x0003) /*!<CC1S[1:0] bits (Capture/Compare 1 Selection) */
|
||||
#define TIM_CCMR1_CC1S_0 ((uint16_t)0x0001) /*!<Bit 0 */
|
||||
#define TIM_CCMR1_CC1S_1 ((uint16_t)0x0002) /*!<Bit 1 */
|
||||
|
||||
#define TIM_CCMR1_OC1FE ((uint16_t)0x0004) /*!<Output Compare 1 Fast enable */
|
||||
#define TIM_CCMR1_OC1PE ((uint16_t)0x0008) /*!<Output Compare 1 Preload enable */
|
||||
#define TIM_CCMR1_OC1FE ((uint16_t)0x0004) /*!<Output Compare 1 Fast enable */
|
||||
#define TIM_CCMR1_OC1PE ((uint16_t)0x0008) /*!<Output Compare 1 Preload enable */
|
||||
|
||||
#define TIM_CCMR1_OC1M ((uint16_t)0x0070) /*!<OC1M[2:0] bits (Output Compare 1 Mode) */
|
||||
#define TIM_CCMR1_OC1M ((uint16_t)0x0070) /*!<OC1M[2:0] bits (Output Compare 1 Mode) */
|
||||
#define TIM_CCMR1_OC1M_0 ((uint16_t)0x0010) /*!<Bit 0 */
|
||||
#define TIM_CCMR1_OC1M_1 ((uint16_t)0x0020) /*!<Bit 1 */
|
||||
#define TIM_CCMR1_OC1M_2 ((uint16_t)0x0040) /*!<Bit 2 */
|
||||
|
||||
#define TIM_CCMR1_OC1CE ((uint16_t)0x0080) /*!<Output Compare 1Clear Enable */
|
||||
#define TIM_CCMR1_OC1CE ((uint16_t)0x0080) /*!<Output Compare 1Clear Enable */
|
||||
|
||||
#define TIM_CCMR1_CC2S ((uint16_t)0x0300) /*!<CC2S[1:0] bits (Capture/Compare 2 Selection) */
|
||||
#define TIM_CCMR1_CC2S_0 ((uint16_t)0x0100) /*!<Bit 0 */
|
||||
#define TIM_CCMR1_CC2S_1 ((uint16_t)0x0200) /*!<Bit 1 */
|
||||
|
||||
#define TIM_CCMR1_OC2FE ((uint16_t)0x0400) /*!<Output Compare 2 Fast enable */
|
||||
#define TIM_CCMR1_OC2PE ((uint16_t)0x0800) /*!<Output Compare 2 Preload enable */
|
||||
#define TIM_CCMR1_OC2FE ((uint16_t)0x0400) /*!<Output Compare 2 Fast enable */
|
||||
#define TIM_CCMR1_OC2PE ((uint16_t)0x0800) /*!<Output Compare 2 Preload enable */
|
||||
|
||||
#define TIM_CCMR1_OC2M ((uint16_t)0x7000) /*!<OC2M[2:0] bits (Output Compare 2 Mode) */
|
||||
#define TIM_CCMR1_OC2M ((uint16_t)0x7000) /*!<OC2M[2:0] bits (Output Compare 2 Mode) */
|
||||
#define TIM_CCMR1_OC2M_0 ((uint16_t)0x1000) /*!<Bit 0 */
|
||||
#define TIM_CCMR1_OC2M_1 ((uint16_t)0x2000) /*!<Bit 1 */
|
||||
#define TIM_CCMR1_OC2M_2 ((uint16_t)0x4000) /*!<Bit 2 */
|
||||
@ -6191,29 +6347,29 @@ typedef struct
|
||||
#define TIM_CCMR1_IC1PSC_0 ((uint16_t)0x0004) /*!<Bit 0 */
|
||||
#define TIM_CCMR1_IC1PSC_1 ((uint16_t)0x0008) /*!<Bit 1 */
|
||||
|
||||
#define TIM_CCMR1_IC1F ((uint16_t)0x00F0) /*!<IC1F[3:0] bits (Input Capture 1 Filter) */
|
||||
#define TIM_CCMR1_IC1F ((uint16_t)0x00F0) /*!<IC1F[3:0] bits (Input Capture 1 Filter) */
|
||||
#define TIM_CCMR1_IC1F_0 ((uint16_t)0x0010) /*!<Bit 0 */
|
||||
#define TIM_CCMR1_IC1F_1 ((uint16_t)0x0020) /*!<Bit 1 */
|
||||
#define TIM_CCMR1_IC1F_2 ((uint16_t)0x0040) /*!<Bit 2 */
|
||||
#define TIM_CCMR1_IC1F_3 ((uint16_t)0x0080) /*!<Bit 3 */
|
||||
|
||||
#define TIM_CCMR1_IC2PSC ((uint16_t)0x0C00) /*!<IC2PSC[1:0] bits (Input Capture 2 Prescaler) */
|
||||
#define TIM_CCMR1_IC2PSC ((uint16_t)0x0C00) /*!<IC2PSC[1:0] bits (Input Capture 2 Prescaler) */
|
||||
#define TIM_CCMR1_IC2PSC_0 ((uint16_t)0x0400) /*!<Bit 0 */
|
||||
#define TIM_CCMR1_IC2PSC_1 ((uint16_t)0x0800) /*!<Bit 1 */
|
||||
|
||||
#define TIM_CCMR1_IC2F ((uint16_t)0xF000) /*!<IC2F[3:0] bits (Input Capture 2 Filter) */
|
||||
#define TIM_CCMR1_IC2F ((uint16_t)0xF000) /*!<IC2F[3:0] bits (Input Capture 2 Filter) */
|
||||
#define TIM_CCMR1_IC2F_0 ((uint16_t)0x1000) /*!<Bit 0 */
|
||||
#define TIM_CCMR1_IC2F_1 ((uint16_t)0x2000) /*!<Bit 1 */
|
||||
#define TIM_CCMR1_IC2F_2 ((uint16_t)0x4000) /*!<Bit 2 */
|
||||
#define TIM_CCMR1_IC2F_3 ((uint16_t)0x8000) /*!<Bit 3 */
|
||||
|
||||
/****************** Bit definition for TIM_CCMR2 register *******************/
|
||||
#define TIM_CCMR2_CC3S ((uint16_t)0x0003) /*!<CC3S[1:0] bits (Capture/Compare 3 Selection) */
|
||||
#define TIM_CCMR2_CC3S ((uint16_t)0x0003) /*!<CC3S[1:0] bits (Capture/Compare 3 Selection) */
|
||||
#define TIM_CCMR2_CC3S_0 ((uint16_t)0x0001) /*!<Bit 0 */
|
||||
#define TIM_CCMR2_CC3S_1 ((uint16_t)0x0002) /*!<Bit 1 */
|
||||
|
||||
#define TIM_CCMR2_OC3FE ((uint16_t)0x0004) /*!<Output Compare 3 Fast enable */
|
||||
#define TIM_CCMR2_OC3PE ((uint16_t)0x0008) /*!<Output Compare 3 Preload enable */
|
||||
#define TIM_CCMR2_OC3FE ((uint16_t)0x0004) /*!<Output Compare 3 Fast enable */
|
||||
#define TIM_CCMR2_OC3PE ((uint16_t)0x0008) /*!<Output Compare 3 Preload enable */
|
||||
|
||||
#define TIM_CCMR2_OC3M ((uint16_t)0x0070) /*!<OC3M[2:0] bits (Output Compare 3 Mode) */
|
||||
#define TIM_CCMR2_OC3M_0 ((uint16_t)0x0010) /*!<Bit 0 */
|
||||
@ -6226,7 +6382,7 @@ typedef struct
|
||||
#define TIM_CCMR2_CC4S_0 ((uint16_t)0x0100) /*!<Bit 0 */
|
||||
#define TIM_CCMR2_CC4S_1 ((uint16_t)0x0200) /*!<Bit 1 */
|
||||
|
||||
#define TIM_CCMR2_OC4FE ((uint16_t)0x0400) /*!<Output Compare 4 Fast enable */
|
||||
#define TIM_CCMR2_OC4FE ((uint16_t)0x0400) /*!<Output Compare 4 Fast enable */
|
||||
#define TIM_CCMR2_OC4PE ((uint16_t)0x0800) /*!<Output Compare 4 Preload enable */
|
||||
|
||||
#define TIM_CCMR2_OC4M ((uint16_t)0x7000) /*!<OC4M[2:0] bits (Output Compare 4 Mode) */
|
||||
@ -6259,27 +6415,27 @@ typedef struct
|
||||
#define TIM_CCMR2_IC4F_3 ((uint16_t)0x8000) /*!<Bit 3 */
|
||||
|
||||
/******************* Bit definition for TIM_CCER register *******************/
|
||||
#define TIM_CCER_CC1E ((uint16_t)0x0001) /*!<Capture/Compare 1 output enable */
|
||||
#define TIM_CCER_CC1P ((uint16_t)0x0002) /*!<Capture/Compare 1 output Polarity */
|
||||
#define TIM_CCER_CC1NE ((uint16_t)0x0004) /*!<Capture/Compare 1 Complementary output enable */
|
||||
#define TIM_CCER_CC1E ((uint16_t)0x0001) /*!<Capture/Compare 1 output enable */
|
||||
#define TIM_CCER_CC1P ((uint16_t)0x0002) /*!<Capture/Compare 1 output Polarity */
|
||||
#define TIM_CCER_CC1NE ((uint16_t)0x0004) /*!<Capture/Compare 1 Complementary output enable */
|
||||
#define TIM_CCER_CC1NP ((uint16_t)0x0008) /*!<Capture/Compare 1 Complementary output Polarity */
|
||||
#define TIM_CCER_CC2E ((uint16_t)0x0010) /*!<Capture/Compare 2 output enable */
|
||||
#define TIM_CCER_CC2P ((uint16_t)0x0020) /*!<Capture/Compare 2 output Polarity */
|
||||
#define TIM_CCER_CC2NE ((uint16_t)0x0040) /*!<Capture/Compare 2 Complementary output enable */
|
||||
#define TIM_CCER_CC2E ((uint16_t)0x0010) /*!<Capture/Compare 2 output enable */
|
||||
#define TIM_CCER_CC2P ((uint16_t)0x0020) /*!<Capture/Compare 2 output Polarity */
|
||||
#define TIM_CCER_CC2NE ((uint16_t)0x0040) /*!<Capture/Compare 2 Complementary output enable */
|
||||
#define TIM_CCER_CC2NP ((uint16_t)0x0080) /*!<Capture/Compare 2 Complementary output Polarity */
|
||||
#define TIM_CCER_CC3E ((uint16_t)0x0100) /*!<Capture/Compare 3 output enable */
|
||||
#define TIM_CCER_CC3P ((uint16_t)0x0200) /*!<Capture/Compare 3 output Polarity */
|
||||
#define TIM_CCER_CC3NE ((uint16_t)0x0400) /*!<Capture/Compare 3 Complementary output enable */
|
||||
#define TIM_CCER_CC3E ((uint16_t)0x0100) /*!<Capture/Compare 3 output enable */
|
||||
#define TIM_CCER_CC3P ((uint16_t)0x0200) /*!<Capture/Compare 3 output Polarity */
|
||||
#define TIM_CCER_CC3NE ((uint16_t)0x0400) /*!<Capture/Compare 3 Complementary output enable */
|
||||
#define TIM_CCER_CC3NP ((uint16_t)0x0800) /*!<Capture/Compare 3 Complementary output Polarity */
|
||||
#define TIM_CCER_CC4E ((uint16_t)0x1000) /*!<Capture/Compare 4 output enable */
|
||||
#define TIM_CCER_CC4P ((uint16_t)0x2000) /*!<Capture/Compare 4 output Polarity */
|
||||
#define TIM_CCER_CC4E ((uint16_t)0x1000) /*!<Capture/Compare 4 output enable */
|
||||
#define TIM_CCER_CC4P ((uint16_t)0x2000) /*!<Capture/Compare 4 output Polarity */
|
||||
#define TIM_CCER_CC4NP ((uint16_t)0x8000) /*!<Capture/Compare 4 Complementary output Polarity */
|
||||
|
||||
/******************* Bit definition for TIM_CNT register ********************/
|
||||
#define TIM_CNT_CNT ((uint16_t)0xFFFF) /*!<Counter Value */
|
||||
#define TIM_CNT_CNT ((uint16_t)0xFFFF) /*!<Counter Value */
|
||||
|
||||
/******************* Bit definition for TIM_PSC register ********************/
|
||||
#define TIM_PSC_PSC ((uint16_t)0xFFFF) /*!<Prescaler Value */
|
||||
#define TIM_PSC_PSC ((uint16_t)0xFFFF) /*!<Prescaler Value */
|
||||
|
||||
/******************* Bit definition for TIM_ARR register ********************/
|
||||
#define TIM_ARR_ARR ((uint16_t)0xFFFF) /*!<actual auto-reload Value */
|
||||
@ -6288,16 +6444,16 @@ typedef struct
|
||||
#define TIM_RCR_REP ((uint8_t)0xFF) /*!<Repetition Counter Value */
|
||||
|
||||
/******************* Bit definition for TIM_CCR1 register *******************/
|
||||
#define TIM_CCR1_CCR1 ((uint16_t)0xFFFF) /*!<Capture/Compare 1 Value */
|
||||
#define TIM_CCR1_CCR1 ((uint16_t)0xFFFF) /*!<Capture/Compare 1 Value */
|
||||
|
||||
/******************* Bit definition for TIM_CCR2 register *******************/
|
||||
#define TIM_CCR2_CCR2 ((uint16_t)0xFFFF) /*!<Capture/Compare 2 Value */
|
||||
#define TIM_CCR2_CCR2 ((uint16_t)0xFFFF) /*!<Capture/Compare 2 Value */
|
||||
|
||||
/******************* Bit definition for TIM_CCR3 register *******************/
|
||||
#define TIM_CCR3_CCR3 ((uint16_t)0xFFFF) /*!<Capture/Compare 3 Value */
|
||||
#define TIM_CCR3_CCR3 ((uint16_t)0xFFFF) /*!<Capture/Compare 3 Value */
|
||||
|
||||
/******************* Bit definition for TIM_CCR4 register *******************/
|
||||
#define TIM_CCR4_CCR4 ((uint16_t)0xFFFF) /*!<Capture/Compare 4 Value */
|
||||
#define TIM_CCR4_CCR4 ((uint16_t)0xFFFF) /*!<Capture/Compare 4 Value */
|
||||
|
||||
/******************* Bit definition for TIM_BDTR register *******************/
|
||||
#define TIM_BDTR_DTG ((uint16_t)0x00FF) /*!<DTG[0:7] bits (Dead-Time Generator set-up) */
|
||||
@ -6315,11 +6471,11 @@ typedef struct
|
||||
#define TIM_BDTR_LOCK_1 ((uint16_t)0x0200) /*!<Bit 1 */
|
||||
|
||||
#define TIM_BDTR_OSSI ((uint16_t)0x0400) /*!<Off-State Selection for Idle mode */
|
||||
#define TIM_BDTR_OSSR ((uint16_t)0x0800) /*!<Off-State Selection for Run mode */
|
||||
#define TIM_BDTR_BKE ((uint16_t)0x1000) /*!<Break enable */
|
||||
#define TIM_BDTR_BKP ((uint16_t)0x2000) /*!<Break Polarity */
|
||||
#define TIM_BDTR_AOE ((uint16_t)0x4000) /*!<Automatic Output enable */
|
||||
#define TIM_BDTR_MOE ((uint16_t)0x8000) /*!<Main Output enable */
|
||||
#define TIM_BDTR_OSSR ((uint16_t)0x0800) /*!<Off-State Selection for Run mode */
|
||||
#define TIM_BDTR_BKE ((uint16_t)0x1000) /*!<Break enable */
|
||||
#define TIM_BDTR_BKP ((uint16_t)0x2000) /*!<Break Polarity */
|
||||
#define TIM_BDTR_AOE ((uint16_t)0x4000) /*!<Automatic Output enable */
|
||||
#define TIM_BDTR_MOE ((uint16_t)0x8000) /*!<Main Output enable */
|
||||
|
||||
/******************* Bit definition for TIM_DCR register ********************/
|
||||
#define TIM_DCR_DBA ((uint16_t)0x001F) /*!<DBA[4:0] bits (DMA Base Address) */
|
||||
@ -6337,10 +6493,10 @@ typedef struct
|
||||
#define TIM_DCR_DBL_4 ((uint16_t)0x1000) /*!<Bit 4 */
|
||||
|
||||
/******************* Bit definition for TIM_DMAR register *******************/
|
||||
#define TIM_DMAR_DMAB ((uint16_t)0xFFFF) /*!<DMA register for burst accesses */
|
||||
#define TIM_DMAR_DMAB ((uint16_t)0xFFFF) /*!<DMA register for burst accesses */
|
||||
|
||||
/******************* Bit definition for TIM_OR register *********************/
|
||||
#define TIM_OR_TI4_RMP ((uint16_t)0x00C0) /*!<TI4_RMP[1:0] bits (TIM5 Input 4 remap) */
|
||||
#define TIM_OR_TI4_RMP ((uint16_t)0x00C0) /*!<TI4_RMP[1:0] bits (TIM5 Input 4 remap) */
|
||||
#define TIM_OR_TI4_RMP_0 ((uint16_t)0x0040) /*!<Bit 0 */
|
||||
#define TIM_OR_TI4_RMP_1 ((uint16_t)0x0080) /*!<Bit 1 */
|
||||
#define TIM_OR_ITR1_RMP ((uint16_t)0x0C00) /*!<ITR1_RMP[1:0] bits (TIM2 Internal trigger 1 remap) */
|
||||
@ -6354,16 +6510,16 @@ typedef struct
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/******************* Bit definition for USART_SR register *******************/
|
||||
#define USART_SR_PE ((uint16_t)0x0001) /*!<Parity Error */
|
||||
#define USART_SR_FE ((uint16_t)0x0002) /*!<Framing Error */
|
||||
#define USART_SR_NE ((uint16_t)0x0004) /*!<Noise Error Flag */
|
||||
#define USART_SR_ORE ((uint16_t)0x0008) /*!<OverRun Error */
|
||||
#define USART_SR_IDLE ((uint16_t)0x0010) /*!<IDLE line detected */
|
||||
#define USART_SR_PE ((uint16_t)0x0001) /*!<Parity Error */
|
||||
#define USART_SR_FE ((uint16_t)0x0002) /*!<Framing Error */
|
||||
#define USART_SR_NE ((uint16_t)0x0004) /*!<Noise Error Flag */
|
||||
#define USART_SR_ORE ((uint16_t)0x0008) /*!<OverRun Error */
|
||||
#define USART_SR_IDLE ((uint16_t)0x0010) /*!<IDLE line detected */
|
||||
#define USART_SR_RXNE ((uint16_t)0x0020) /*!<Read Data Register Not Empty */
|
||||
#define USART_SR_TC ((uint16_t)0x0040) /*!<Transmission Complete */
|
||||
#define USART_SR_TC ((uint16_t)0x0040) /*!<Transmission Complete */
|
||||
#define USART_SR_TXE ((uint16_t)0x0080) /*!<Transmit Data Register Empty */
|
||||
#define USART_SR_LBD ((uint16_t)0x0100) /*!<LIN Break Detection Flag */
|
||||
#define USART_SR_CTS ((uint16_t)0x0200) /*!<CTS Flag */
|
||||
#define USART_SR_LBD ((uint16_t)0x0100) /*!<LIN Break Detection Flag */
|
||||
#define USART_SR_CTS ((uint16_t)0x0200) /*!<CTS Flag */
|
||||
|
||||
/******************* Bit definition for USART_DR register *******************/
|
||||
#define USART_DR_DR ((uint16_t)0x01FF) /*!<Data value */
|
||||
@ -6373,30 +6529,30 @@ typedef struct
|
||||
#define USART_BRR_DIV_Mantissa ((uint16_t)0xFFF0) /*!<Mantissa of USARTDIV */
|
||||
|
||||
/****************** Bit definition for USART_CR1 register *******************/
|
||||
#define USART_CR1_SBK ((uint16_t)0x0001) /*!<Send Break */
|
||||
#define USART_CR1_RWU ((uint16_t)0x0002) /*!<Receiver wakeup */
|
||||
#define USART_CR1_RE ((uint16_t)0x0004) /*!<Receiver Enable */
|
||||
#define USART_CR1_TE ((uint16_t)0x0008) /*!<Transmitter Enable */
|
||||
#define USART_CR1_IDLEIE ((uint16_t)0x0010) /*!<IDLE Interrupt Enable */
|
||||
#define USART_CR1_RXNEIE ((uint16_t)0x0020) /*!<RXNE Interrupt Enable */
|
||||
#define USART_CR1_SBK ((uint16_t)0x0001) /*!<Send Break */
|
||||
#define USART_CR1_RWU ((uint16_t)0x0002) /*!<Receiver wakeup */
|
||||
#define USART_CR1_RE ((uint16_t)0x0004) /*!<Receiver Enable */
|
||||
#define USART_CR1_TE ((uint16_t)0x0008) /*!<Transmitter Enable */
|
||||
#define USART_CR1_IDLEIE ((uint16_t)0x0010) /*!<IDLE Interrupt Enable */
|
||||
#define USART_CR1_RXNEIE ((uint16_t)0x0020) /*!<RXNE Interrupt Enable */
|
||||
#define USART_CR1_TCIE ((uint16_t)0x0040) /*!<Transmission Complete Interrupt Enable */
|
||||
#define USART_CR1_TXEIE ((uint16_t)0x0080) /*!<PE Interrupt Enable */
|
||||
#define USART_CR1_PEIE ((uint16_t)0x0100) /*!<PE Interrupt Enable */
|
||||
#define USART_CR1_PS ((uint16_t)0x0200) /*!<Parity Selection */
|
||||
#define USART_CR1_PCE ((uint16_t)0x0400) /*!<Parity Control Enable */
|
||||
#define USART_CR1_WAKE ((uint16_t)0x0800) /*!<Wakeup method */
|
||||
#define USART_CR1_M ((uint16_t)0x1000) /*!<Word length */
|
||||
#define USART_CR1_UE ((uint16_t)0x2000) /*!<USART Enable */
|
||||
#define USART_CR1_OVER8 ((uint16_t)0x8000) /*!<USART Oversampling by 8 enable */
|
||||
#define USART_CR1_TXEIE ((uint16_t)0x0080) /*!<PE Interrupt Enable */
|
||||
#define USART_CR1_PEIE ((uint16_t)0x0100) /*!<PE Interrupt Enable */
|
||||
#define USART_CR1_PS ((uint16_t)0x0200) /*!<Parity Selection */
|
||||
#define USART_CR1_PCE ((uint16_t)0x0400) /*!<Parity Control Enable */
|
||||
#define USART_CR1_WAKE ((uint16_t)0x0800) /*!<Wakeup method */
|
||||
#define USART_CR1_M ((uint16_t)0x1000) /*!<Word length */
|
||||
#define USART_CR1_UE ((uint16_t)0x2000) /*!<USART Enable */
|
||||
#define USART_CR1_OVER8 ((uint16_t)0x8000) /*!<USART Oversampling by 8 enable */
|
||||
|
||||
/****************** Bit definition for USART_CR2 register *******************/
|
||||
#define USART_CR2_ADD ((uint16_t)0x000F) /*!<Address of the USART node */
|
||||
#define USART_CR2_LBDL ((uint16_t)0x0020) /*!<LIN Break Detection Length */
|
||||
#define USART_CR2_ADD ((uint16_t)0x000F) /*!<Address of the USART node */
|
||||
#define USART_CR2_LBDL ((uint16_t)0x0020) /*!<LIN Break Detection Length */
|
||||
#define USART_CR2_LBDIE ((uint16_t)0x0040) /*!<LIN Break Detection Interrupt Enable */
|
||||
#define USART_CR2_LBCL ((uint16_t)0x0100) /*!<Last Bit Clock pulse */
|
||||
#define USART_CR2_CPHA ((uint16_t)0x0200) /*!<Clock Phase */
|
||||
#define USART_CR2_CPOL ((uint16_t)0x0400) /*!<Clock Polarity */
|
||||
#define USART_CR2_CLKEN ((uint16_t)0x0800) /*!<Clock Enable */
|
||||
#define USART_CR2_LBCL ((uint16_t)0x0100) /*!<Last Bit Clock pulse */
|
||||
#define USART_CR2_CPHA ((uint16_t)0x0200) /*!<Clock Phase */
|
||||
#define USART_CR2_CPOL ((uint16_t)0x0400) /*!<Clock Polarity */
|
||||
#define USART_CR2_CLKEN ((uint16_t)0x0800) /*!<Clock Enable */
|
||||
|
||||
#define USART_CR2_STOP ((uint16_t)0x3000) /*!<STOP[1:0] bits (STOP bits) */
|
||||
#define USART_CR2_STOP_0 ((uint16_t)0x1000) /*!<Bit 0 */
|
||||
@ -6405,17 +6561,17 @@ typedef struct
|
||||
#define USART_CR2_LINEN ((uint16_t)0x4000) /*!<LIN mode enable */
|
||||
|
||||
/****************** Bit definition for USART_CR3 register *******************/
|
||||
#define USART_CR3_EIE ((uint16_t)0x0001) /*!<Error Interrupt Enable */
|
||||
#define USART_CR3_IREN ((uint16_t)0x0002) /*!<IrDA mode Enable */
|
||||
#define USART_CR3_IRLP ((uint16_t)0x0004) /*!<IrDA Low-Power */
|
||||
#define USART_CR3_HDSEL ((uint16_t)0x0008) /*!<Half-Duplex Selection */
|
||||
#define USART_CR3_NACK ((uint16_t)0x0010) /*!<Smartcard NACK enable */
|
||||
#define USART_CR3_SCEN ((uint16_t)0x0020) /*!<Smartcard mode enable */
|
||||
#define USART_CR3_DMAR ((uint16_t)0x0040) /*!<DMA Enable Receiver */
|
||||
#define USART_CR3_DMAT ((uint16_t)0x0080) /*!<DMA Enable Transmitter */
|
||||
#define USART_CR3_RTSE ((uint16_t)0x0100) /*!<RTS Enable */
|
||||
#define USART_CR3_CTSE ((uint16_t)0x0200) /*!<CTS Enable */
|
||||
#define USART_CR3_CTSIE ((uint16_t)0x0400) /*!<CTS Interrupt Enable */
|
||||
#define USART_CR3_EIE ((uint16_t)0x0001) /*!<Error Interrupt Enable */
|
||||
#define USART_CR3_IREN ((uint16_t)0x0002) /*!<IrDA mode Enable */
|
||||
#define USART_CR3_IRLP ((uint16_t)0x0004) /*!<IrDA Low-Power */
|
||||
#define USART_CR3_HDSEL ((uint16_t)0x0008) /*!<Half-Duplex Selection */
|
||||
#define USART_CR3_NACK ((uint16_t)0x0010) /*!<Smartcard NACK enable */
|
||||
#define USART_CR3_SCEN ((uint16_t)0x0020) /*!<Smartcard mode enable */
|
||||
#define USART_CR3_DMAR ((uint16_t)0x0040) /*!<DMA Enable Receiver */
|
||||
#define USART_CR3_DMAT ((uint16_t)0x0080) /*!<DMA Enable Transmitter */
|
||||
#define USART_CR3_RTSE ((uint16_t)0x0100) /*!<RTS Enable */
|
||||
#define USART_CR3_CTSE ((uint16_t)0x0200) /*!<CTS Enable */
|
||||
#define USART_CR3_CTSIE ((uint16_t)0x0400) /*!<CTS Interrupt Enable */
|
||||
#define USART_CR3_ONEBIT ((uint16_t)0x0800) /*!<USART One bit method enable */
|
||||
|
||||
/****************** Bit definition for USART_GTPR register ******************/
|
||||
@ -6949,7 +7105,7 @@ typedef struct
|
||||
#define ETH_DMACHRBAR_HRBAP ((uint32_t)0xFFFFFFFF) /* Host receive buffer address pointer */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -6996,4 +7152,4 @@ typedef struct
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -2,20 +2,26 @@
|
||||
******************************************************************************
|
||||
* @file system_stm32f4xx.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.0.0
|
||||
* @date 30-September-2011
|
||||
* @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices.
|
||||
* @version V1.1.0
|
||||
* @date 11-January-2013
|
||||
* @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@ -96,4 +102,4 @@ extern void SystemCoreClockUpdate(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,515 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file startup_stm32f40xx.s
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 11-January-2013
|
||||
* @brief STM32F40xx/41xx Devices vector table for RIDE7 toolchain.
|
||||
* This module performs:
|
||||
* - Set the initial SP
|
||||
* - Set the initial PC == Reset_Handler,
|
||||
* - Set the vector table entries with the exceptions ISR address
|
||||
* - Configure the clock system and the external SRAM mounted on
|
||||
* STM324xG-EVAL board to be used as data memory (optional,
|
||||
* to be enabled by user)
|
||||
* - Branches to main in the C library (which eventually
|
||||
* calls main()).
|
||||
* After Reset the Cortex-M4 processor is in Thread mode,
|
||||
* priority is Privileged, and the Stack is set to Main.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.cpu cortex-m3
|
||||
.fpu softvfp
|
||||
.thumb
|
||||
|
||||
.global g_pfnVectors
|
||||
.global Default_Handler
|
||||
|
||||
/* start address for the initialization values of the .data section.
|
||||
defined in linker script */
|
||||
.word _sidata
|
||||
/* start address for the .data section. defined in linker script */
|
||||
.word _sdata
|
||||
/* end address for the .data section. defined in linker script */
|
||||
.word _edata
|
||||
/* start address for the .bss section. defined in linker script */
|
||||
.word _sbss
|
||||
/* end address for the .bss section. defined in linker script */
|
||||
.word _ebss
|
||||
/* stack used for SystemInit_ExtMemCtl; always internal RAM used */
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor first
|
||||
* starts execution following a reset event. Only the absolutely
|
||||
* necessary set is performed, after which the application
|
||||
* supplied main() routine is called.
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
|
||||
.section .text.Reset_Handler
|
||||
.weak Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
|
||||
/* Copy the data segment initializers from flash to SRAM */
|
||||
movs r1, #0
|
||||
b LoopCopyDataInit
|
||||
|
||||
CopyDataInit:
|
||||
ldr r3, =_sidata
|
||||
ldr r3, [r3, r1]
|
||||
str r3, [r0, r1]
|
||||
adds r1, r1, #4
|
||||
|
||||
LoopCopyDataInit:
|
||||
ldr r0, =_sdata
|
||||
ldr r3, =_edata
|
||||
adds r2, r0, r1
|
||||
cmp r2, r3
|
||||
bcc CopyDataInit
|
||||
ldr r2, =_sbss
|
||||
b LoopFillZerobss
|
||||
/* Zero fill the bss segment. */
|
||||
FillZerobss:
|
||||
movs r3, #0
|
||||
str r3, [r2], #4
|
||||
|
||||
LoopFillZerobss:
|
||||
ldr r3, = _ebss
|
||||
cmp r2, r3
|
||||
bcc FillZerobss
|
||||
|
||||
/* Call the clock system intitialization function.*/
|
||||
bl SystemInit
|
||||
/* Call the application's entry point.*/
|
||||
bl main
|
||||
bx lr
|
||||
.size Reset_Handler, .-Reset_Handler
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor receives an
|
||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
||||
* the system state for examination by a debugger.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
.section .text.Default_Handler,"ax",%progbits
|
||||
Default_Handler:
|
||||
Infinite_Loop:
|
||||
b Infinite_Loop
|
||||
.size Default_Handler, .-Default_Handler
|
||||
/******************************************************************************
|
||||
*
|
||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
||||
* must be placed on this to ensure that it ends up at physical address
|
||||
* 0x0000.0000.
|
||||
*
|
||||
*******************************************************************************/
|
||||
.section .isr_vector,"a",%progbits
|
||||
.type g_pfnVectors, %object
|
||||
.size g_pfnVectors, .-g_pfnVectors
|
||||
|
||||
|
||||
g_pfnVectors:
|
||||
.word _estack
|
||||
.word Reset_Handler
|
||||
.word NMI_Handler
|
||||
.word HardFault_Handler
|
||||
.word MemManage_Handler
|
||||
.word BusFault_Handler
|
||||
.word UsageFault_Handler
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word SVC_Handler
|
||||
.word DebugMon_Handler
|
||||
.word 0
|
||||
.word PendSV_Handler
|
||||
.word SysTick_Handler
|
||||
|
||||
/* External Interrupts */
|
||||
.word WWDG_IRQHandler /* Window WatchDog */
|
||||
.word PVD_IRQHandler /* PVD through EXTI Line detection */
|
||||
.word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */
|
||||
.word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */
|
||||
.word FLASH_IRQHandler /* FLASH */
|
||||
.word RCC_IRQHandler /* RCC */
|
||||
.word EXTI0_IRQHandler /* EXTI Line0 */
|
||||
.word EXTI1_IRQHandler /* EXTI Line1 */
|
||||
.word EXTI2_IRQHandler /* EXTI Line2 */
|
||||
.word EXTI3_IRQHandler /* EXTI Line3 */
|
||||
.word EXTI4_IRQHandler /* EXTI Line4 */
|
||||
.word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */
|
||||
.word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */
|
||||
.word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */
|
||||
.word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */
|
||||
.word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */
|
||||
.word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */
|
||||
.word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */
|
||||
.word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */
|
||||
.word CAN1_TX_IRQHandler /* CAN1 TX */
|
||||
.word CAN1_RX0_IRQHandler /* CAN1 RX0 */
|
||||
.word CAN1_RX1_IRQHandler /* CAN1 RX1 */
|
||||
.word CAN1_SCE_IRQHandler /* CAN1 SCE */
|
||||
.word EXTI9_5_IRQHandler /* External Line[9:5]s */
|
||||
.word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */
|
||||
.word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */
|
||||
.word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */
|
||||
.word TIM1_CC_IRQHandler /* TIM1 Capture Compare */
|
||||
.word TIM2_IRQHandler /* TIM2 */
|
||||
.word TIM3_IRQHandler /* TIM3 */
|
||||
.word TIM4_IRQHandler /* TIM4 */
|
||||
.word I2C1_EV_IRQHandler /* I2C1 Event */
|
||||
.word I2C1_ER_IRQHandler /* I2C1 Error */
|
||||
.word I2C2_EV_IRQHandler /* I2C2 Event */
|
||||
.word I2C2_ER_IRQHandler /* I2C2 Error */
|
||||
.word SPI1_IRQHandler /* SPI1 */
|
||||
.word SPI2_IRQHandler /* SPI2 */
|
||||
.word USART1_IRQHandler /* USART1 */
|
||||
.word USART2_IRQHandler /* USART2 */
|
||||
.word USART3_IRQHandler /* USART3 */
|
||||
.word EXTI15_10_IRQHandler /* External Line[15:10]s */
|
||||
.word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */
|
||||
.word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */
|
||||
.word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */
|
||||
.word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */
|
||||
.word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */
|
||||
.word TIM8_CC_IRQHandler /* TIM8 Capture Compare */
|
||||
.word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */
|
||||
.word FSMC_IRQHandler /* FSMC */
|
||||
.word SDIO_IRQHandler /* SDIO */
|
||||
.word TIM5_IRQHandler /* TIM5 */
|
||||
.word SPI3_IRQHandler /* SPI3 */
|
||||
.word UART4_IRQHandler /* UART4 */
|
||||
.word UART5_IRQHandler /* UART5 */
|
||||
.word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */
|
||||
.word TIM7_IRQHandler /* TIM7 */
|
||||
.word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */
|
||||
.word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */
|
||||
.word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */
|
||||
.word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */
|
||||
.word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */
|
||||
.word ETH_IRQHandler /* Ethernet */
|
||||
.word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */
|
||||
.word CAN2_TX_IRQHandler /* CAN2 TX */
|
||||
.word CAN2_RX0_IRQHandler /* CAN2 RX0 */
|
||||
.word CAN2_RX1_IRQHandler /* CAN2 RX1 */
|
||||
.word CAN2_SCE_IRQHandler /* CAN2 SCE */
|
||||
.word OTG_FS_IRQHandler /* USB OTG FS */
|
||||
.word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */
|
||||
.word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */
|
||||
.word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */
|
||||
.word USART6_IRQHandler /* USART6 */
|
||||
.word I2C3_EV_IRQHandler /* I2C3 event */
|
||||
.word I2C3_ER_IRQHandler /* I2C3 error */
|
||||
.word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */
|
||||
.word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */
|
||||
.word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */
|
||||
.word OTG_HS_IRQHandler /* USB OTG HS */
|
||||
.word DCMI_IRQHandler /* DCMI */
|
||||
.word CRYP_IRQHandler /* CRYP crypto */
|
||||
.word HASH_RNG_IRQHandler /* Hash and Rng */
|
||||
.word FPU_IRQHandler /* FPU */
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
||||
* As they are weak aliases, any function with the same name will override
|
||||
* this definition.
|
||||
*
|
||||
*******************************************************************************/
|
||||
.weak NMI_Handler
|
||||
.thumb_set NMI_Handler,Default_Handler
|
||||
|
||||
.weak HardFault_Handler
|
||||
.thumb_set HardFault_Handler,Default_Handler
|
||||
|
||||
.weak MemManage_Handler
|
||||
.thumb_set MemManage_Handler,Default_Handler
|
||||
|
||||
.weak BusFault_Handler
|
||||
.thumb_set BusFault_Handler,Default_Handler
|
||||
|
||||
.weak UsageFault_Handler
|
||||
.thumb_set UsageFault_Handler,Default_Handler
|
||||
|
||||
.weak SVC_Handler
|
||||
.thumb_set SVC_Handler,Default_Handler
|
||||
|
||||
.weak DebugMon_Handler
|
||||
.thumb_set DebugMon_Handler,Default_Handler
|
||||
|
||||
.weak PendSV_Handler
|
||||
.thumb_set PendSV_Handler,Default_Handler
|
||||
|
||||
.weak SysTick_Handler
|
||||
.thumb_set SysTick_Handler,Default_Handler
|
||||
|
||||
.weak WWDG_IRQHandler
|
||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
||||
|
||||
.weak PVD_IRQHandler
|
||||
.thumb_set PVD_IRQHandler,Default_Handler
|
||||
|
||||
.weak TAMP_STAMP_IRQHandler
|
||||
.thumb_set TAMP_STAMP_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_WKUP_IRQHandler
|
||||
.thumb_set RTC_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak FLASH_IRQHandler
|
||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
||||
|
||||
.weak RCC_IRQHandler
|
||||
.thumb_set RCC_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI0_IRQHandler
|
||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI1_IRQHandler
|
||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI2_IRQHandler
|
||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI3_IRQHandler
|
||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI4_IRQHandler
|
||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream0_IRQHandler
|
||||
.thumb_set DMA1_Stream0_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream1_IRQHandler
|
||||
.thumb_set DMA1_Stream1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream2_IRQHandler
|
||||
.thumb_set DMA1_Stream2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream3_IRQHandler
|
||||
.thumb_set DMA1_Stream3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream4_IRQHandler
|
||||
.thumb_set DMA1_Stream4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream5_IRQHandler
|
||||
.thumb_set DMA1_Stream5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream6_IRQHandler
|
||||
.thumb_set DMA1_Stream6_IRQHandler,Default_Handler
|
||||
|
||||
.weak ADC_IRQHandler
|
||||
.thumb_set ADC_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN1_TX_IRQHandler
|
||||
.thumb_set CAN1_TX_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN1_RX0_IRQHandler
|
||||
.thumb_set CAN1_RX0_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN1_RX1_IRQHandler
|
||||
.thumb_set CAN1_RX1_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN1_SCE_IRQHandler
|
||||
.thumb_set CAN1_SCE_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI9_5_IRQHandler
|
||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_BRK_TIM9_IRQHandler
|
||||
.thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_UP_TIM10_IRQHandler
|
||||
.thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_TRG_COM_TIM11_IRQHandler
|
||||
.thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_CC_IRQHandler
|
||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM2_IRQHandler
|
||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM3_IRQHandler
|
||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM4_IRQHandler
|
||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_EV_IRQHandler
|
||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_ER_IRQHandler
|
||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_EV_IRQHandler
|
||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_ER_IRQHandler
|
||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI1_IRQHandler
|
||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI2_IRQHandler
|
||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART1_IRQHandler
|
||||
.thumb_set USART1_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART2_IRQHandler
|
||||
.thumb_set USART2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART3_IRQHandler
|
||||
.thumb_set USART3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI15_10_IRQHandler
|
||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_Alarm_IRQHandler
|
||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_FS_WKUP_IRQHandler
|
||||
.thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_BRK_TIM12_IRQHandler
|
||||
.thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_UP_TIM13_IRQHandler
|
||||
.thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_TRG_COM_TIM14_IRQHandler
|
||||
.thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_CC_IRQHandler
|
||||
.thumb_set TIM8_CC_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream7_IRQHandler
|
||||
.thumb_set DMA1_Stream7_IRQHandler,Default_Handler
|
||||
|
||||
.weak FSMC_IRQHandler
|
||||
.thumb_set FSMC_IRQHandler,Default_Handler
|
||||
|
||||
.weak SDIO_IRQHandler
|
||||
.thumb_set SDIO_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM5_IRQHandler
|
||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI3_IRQHandler
|
||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART4_IRQHandler
|
||||
.thumb_set UART4_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART5_IRQHandler
|
||||
.thumb_set UART5_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM6_DAC_IRQHandler
|
||||
.thumb_set TIM6_DAC_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM7_IRQHandler
|
||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream0_IRQHandler
|
||||
.thumb_set DMA2_Stream0_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream1_IRQHandler
|
||||
.thumb_set DMA2_Stream1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream2_IRQHandler
|
||||
.thumb_set DMA2_Stream2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream3_IRQHandler
|
||||
.thumb_set DMA2_Stream3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream4_IRQHandler
|
||||
.thumb_set DMA2_Stream4_IRQHandler,Default_Handler
|
||||
|
||||
.weak ETH_IRQHandler
|
||||
.thumb_set ETH_IRQHandler,Default_Handler
|
||||
|
||||
.weak ETH_WKUP_IRQHandler
|
||||
.thumb_set ETH_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN2_TX_IRQHandler
|
||||
.thumb_set CAN2_TX_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN2_RX0_IRQHandler
|
||||
.thumb_set CAN2_RX0_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN2_RX1_IRQHandler
|
||||
.thumb_set CAN2_RX1_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN2_SCE_IRQHandler
|
||||
.thumb_set CAN2_SCE_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_FS_IRQHandler
|
||||
.thumb_set OTG_FS_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream5_IRQHandler
|
||||
.thumb_set DMA2_Stream5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream6_IRQHandler
|
||||
.thumb_set DMA2_Stream6_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream7_IRQHandler
|
||||
.thumb_set DMA2_Stream7_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART6_IRQHandler
|
||||
.thumb_set USART6_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_EV_IRQHandler
|
||||
.thumb_set I2C3_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_ER_IRQHandler
|
||||
.thumb_set I2C3_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_EP1_OUT_IRQHandler
|
||||
.thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_EP1_IN_IRQHandler
|
||||
.thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_WKUP_IRQHandler
|
||||
.thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_IRQHandler
|
||||
.thumb_set OTG_HS_IRQHandler,Default_Handler
|
||||
|
||||
.weak DCMI_IRQHandler
|
||||
.thumb_set DCMI_IRQHandler,Default_Handler
|
||||
|
||||
.weak CRYP_IRQHandler
|
||||
.thumb_set CRYP_IRQHandler,Default_Handler
|
||||
|
||||
.weak HASH_RNG_IRQHandler
|
||||
.thumb_set HASH_RNG_IRQHandler,Default_Handler
|
||||
|
||||
.weak FPU_IRQHandler
|
||||
.thumb_set FPU_IRQHandler,Default_Handler
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,535 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file startup_stm32f427x.s
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 11-January-2013
|
||||
* @brief STM32F427x/437x Devices vector table for RIDE7 toolchain.
|
||||
* This module performs:
|
||||
* - Set the initial SP
|
||||
* - Set the initial PC == Reset_Handler,
|
||||
* - Set the vector table entries with the exceptions ISR address
|
||||
* - Configure the clock system and the external SRAM mounted on
|
||||
* STM324x7I-EVAL board to be used as data memory (optional,
|
||||
* to be enabled by user)
|
||||
* - Branches to main in the C library (which eventually
|
||||
* calls main()).
|
||||
* After Reset the Cortex-M4 processor is in Thread mode,
|
||||
* priority is Privileged, and the Stack is set to Main.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.cpu cortex-m3
|
||||
.fpu softvfp
|
||||
.thumb
|
||||
|
||||
.global g_pfnVectors
|
||||
.global Default_Handler
|
||||
|
||||
/* start address for the initialization values of the .data section.
|
||||
defined in linker script */
|
||||
.word _sidata
|
||||
/* start address for the .data section. defined in linker script */
|
||||
.word _sdata
|
||||
/* end address for the .data section. defined in linker script */
|
||||
.word _edata
|
||||
/* start address for the .bss section. defined in linker script */
|
||||
.word _sbss
|
||||
/* end address for the .bss section. defined in linker script */
|
||||
.word _ebss
|
||||
/* stack used for SystemInit_ExtMemCtl; always internal RAM used */
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor first
|
||||
* starts execution following a reset event. Only the absolutely
|
||||
* necessary set is performed, after which the application
|
||||
* supplied main() routine is called.
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
|
||||
.section .text.Reset_Handler
|
||||
.weak Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
|
||||
/* Copy the data segment initializers from flash to SRAM */
|
||||
movs r1, #0
|
||||
b LoopCopyDataInit
|
||||
|
||||
CopyDataInit:
|
||||
ldr r3, =_sidata
|
||||
ldr r3, [r3, r1]
|
||||
str r3, [r0, r1]
|
||||
adds r1, r1, #4
|
||||
|
||||
LoopCopyDataInit:
|
||||
ldr r0, =_sdata
|
||||
ldr r3, =_edata
|
||||
adds r2, r0, r1
|
||||
cmp r2, r3
|
||||
bcc CopyDataInit
|
||||
ldr r2, =_sbss
|
||||
b LoopFillZerobss
|
||||
/* Zero fill the bss segment. */
|
||||
FillZerobss:
|
||||
movs r3, #0
|
||||
str r3, [r2], #4
|
||||
|
||||
LoopFillZerobss:
|
||||
ldr r3, = _ebss
|
||||
cmp r2, r3
|
||||
bcc FillZerobss
|
||||
|
||||
/* Call the clock system intitialization function.*/
|
||||
bl SystemInit
|
||||
/* Call the application's entry point.*/
|
||||
bl main
|
||||
bx lr
|
||||
.size Reset_Handler, .-Reset_Handler
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor receives an
|
||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
||||
* the system state for examination by a debugger.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
.section .text.Default_Handler,"ax",%progbits
|
||||
Default_Handler:
|
||||
Infinite_Loop:
|
||||
b Infinite_Loop
|
||||
.size Default_Handler, .-Default_Handler
|
||||
/******************************************************************************
|
||||
*
|
||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
||||
* must be placed on this to ensure that it ends up at physical address
|
||||
* 0x0000.0000.
|
||||
*
|
||||
*******************************************************************************/
|
||||
.section .isr_vector,"a",%progbits
|
||||
.type g_pfnVectors, %object
|
||||
.size g_pfnVectors, .-g_pfnVectors
|
||||
|
||||
|
||||
g_pfnVectors:
|
||||
.word _estack
|
||||
.word Reset_Handler
|
||||
.word NMI_Handler
|
||||
.word HardFault_Handler
|
||||
.word MemManage_Handler
|
||||
.word BusFault_Handler
|
||||
.word UsageFault_Handler
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word SVC_Handler
|
||||
.word DebugMon_Handler
|
||||
.word 0
|
||||
.word PendSV_Handler
|
||||
.word SysTick_Handler
|
||||
|
||||
/* External Interrupts */
|
||||
.word WWDG_IRQHandler /* Window WatchDog */
|
||||
.word PVD_IRQHandler /* PVD through EXTI Line detection */
|
||||
.word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */
|
||||
.word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */
|
||||
.word FLASH_IRQHandler /* FLASH */
|
||||
.word RCC_IRQHandler /* RCC */
|
||||
.word EXTI0_IRQHandler /* EXTI Line0 */
|
||||
.word EXTI1_IRQHandler /* EXTI Line1 */
|
||||
.word EXTI2_IRQHandler /* EXTI Line2 */
|
||||
.word EXTI3_IRQHandler /* EXTI Line3 */
|
||||
.word EXTI4_IRQHandler /* EXTI Line4 */
|
||||
.word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */
|
||||
.word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */
|
||||
.word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */
|
||||
.word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */
|
||||
.word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */
|
||||
.word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */
|
||||
.word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */
|
||||
.word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */
|
||||
.word CAN1_TX_IRQHandler /* CAN1 TX */
|
||||
.word CAN1_RX0_IRQHandler /* CAN1 RX0 */
|
||||
.word CAN1_RX1_IRQHandler /* CAN1 RX1 */
|
||||
.word CAN1_SCE_IRQHandler /* CAN1 SCE */
|
||||
.word EXTI9_5_IRQHandler /* External Line[9:5]s */
|
||||
.word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */
|
||||
.word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */
|
||||
.word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */
|
||||
.word TIM1_CC_IRQHandler /* TIM1 Capture Compare */
|
||||
.word TIM2_IRQHandler /* TIM2 */
|
||||
.word TIM3_IRQHandler /* TIM3 */
|
||||
.word TIM4_IRQHandler /* TIM4 */
|
||||
.word I2C1_EV_IRQHandler /* I2C1 Event */
|
||||
.word I2C1_ER_IRQHandler /* I2C1 Error */
|
||||
.word I2C2_EV_IRQHandler /* I2C2 Event */
|
||||
.word I2C2_ER_IRQHandler /* I2C2 Error */
|
||||
.word SPI1_IRQHandler /* SPI1 */
|
||||
.word SPI2_IRQHandler /* SPI2 */
|
||||
.word USART1_IRQHandler /* USART1 */
|
||||
.word USART2_IRQHandler /* USART2 */
|
||||
.word USART3_IRQHandler /* USART3 */
|
||||
.word EXTI15_10_IRQHandler /* External Line[15:10]s */
|
||||
.word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */
|
||||
.word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */
|
||||
.word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */
|
||||
.word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */
|
||||
.word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */
|
||||
.word TIM8_CC_IRQHandler /* TIM8 Capture Compare */
|
||||
.word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */
|
||||
.word FSMC_IRQHandler /* FSMC */
|
||||
.word SDIO_IRQHandler /* SDIO */
|
||||
.word TIM5_IRQHandler /* TIM5 */
|
||||
.word SPI3_IRQHandler /* SPI3 */
|
||||
.word UART4_IRQHandler /* UART4 */
|
||||
.word UART5_IRQHandler /* UART5 */
|
||||
.word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */
|
||||
.word TIM7_IRQHandler /* TIM7 */
|
||||
.word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */
|
||||
.word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */
|
||||
.word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */
|
||||
.word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */
|
||||
.word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */
|
||||
.word ETH_IRQHandler /* Ethernet */
|
||||
.word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */
|
||||
.word CAN2_TX_IRQHandler /* CAN2 TX */
|
||||
.word CAN2_RX0_IRQHandler /* CAN2 RX0 */
|
||||
.word CAN2_RX1_IRQHandler /* CAN2 RX1 */
|
||||
.word CAN2_SCE_IRQHandler /* CAN2 SCE */
|
||||
.word OTG_FS_IRQHandler /* USB OTG FS */
|
||||
.word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */
|
||||
.word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */
|
||||
.word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */
|
||||
.word USART6_IRQHandler /* USART6 */
|
||||
.word I2C3_EV_IRQHandler /* I2C3 event */
|
||||
.word I2C3_ER_IRQHandler /* I2C3 error */
|
||||
.word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */
|
||||
.word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */
|
||||
.word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */
|
||||
.word OTG_HS_IRQHandler /* USB OTG HS */
|
||||
.word DCMI_IRQHandler /* DCMI */
|
||||
.word CRYP_IRQHandler /* CRYP crypto */
|
||||
.word HASH_RNG_IRQHandler /* Hash and Rng */
|
||||
.word FPU_IRQHandler /* FPU */
|
||||
.word UART7_IRQHandler /* UART7 */
|
||||
.word UART8_IRQHandler /* UART8 */
|
||||
.word SPI4_IRQHandler /* SPI4 */
|
||||
.word SPI5_IRQHandler /* SPI5 */
|
||||
.word SPI6_IRQHandler /* SPI6 */
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
||||
* As they are weak aliases, any function with the same name will override
|
||||
* this definition.
|
||||
*
|
||||
*******************************************************************************/
|
||||
.weak NMI_Handler
|
||||
.thumb_set NMI_Handler,Default_Handler
|
||||
|
||||
.weak HardFault_Handler
|
||||
.thumb_set HardFault_Handler,Default_Handler
|
||||
|
||||
.weak MemManage_Handler
|
||||
.thumb_set MemManage_Handler,Default_Handler
|
||||
|
||||
.weak BusFault_Handler
|
||||
.thumb_set BusFault_Handler,Default_Handler
|
||||
|
||||
.weak UsageFault_Handler
|
||||
.thumb_set UsageFault_Handler,Default_Handler
|
||||
|
||||
.weak SVC_Handler
|
||||
.thumb_set SVC_Handler,Default_Handler
|
||||
|
||||
.weak DebugMon_Handler
|
||||
.thumb_set DebugMon_Handler,Default_Handler
|
||||
|
||||
.weak PendSV_Handler
|
||||
.thumb_set PendSV_Handler,Default_Handler
|
||||
|
||||
.weak SysTick_Handler
|
||||
.thumb_set SysTick_Handler,Default_Handler
|
||||
|
||||
.weak WWDG_IRQHandler
|
||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
||||
|
||||
.weak PVD_IRQHandler
|
||||
.thumb_set PVD_IRQHandler,Default_Handler
|
||||
|
||||
.weak TAMP_STAMP_IRQHandler
|
||||
.thumb_set TAMP_STAMP_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_WKUP_IRQHandler
|
||||
.thumb_set RTC_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak FLASH_IRQHandler
|
||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
||||
|
||||
.weak RCC_IRQHandler
|
||||
.thumb_set RCC_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI0_IRQHandler
|
||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI1_IRQHandler
|
||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI2_IRQHandler
|
||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI3_IRQHandler
|
||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI4_IRQHandler
|
||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream0_IRQHandler
|
||||
.thumb_set DMA1_Stream0_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream1_IRQHandler
|
||||
.thumb_set DMA1_Stream1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream2_IRQHandler
|
||||
.thumb_set DMA1_Stream2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream3_IRQHandler
|
||||
.thumb_set DMA1_Stream3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream4_IRQHandler
|
||||
.thumb_set DMA1_Stream4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream5_IRQHandler
|
||||
.thumb_set DMA1_Stream5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream6_IRQHandler
|
||||
.thumb_set DMA1_Stream6_IRQHandler,Default_Handler
|
||||
|
||||
.weak ADC_IRQHandler
|
||||
.thumb_set ADC_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN1_TX_IRQHandler
|
||||
.thumb_set CAN1_TX_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN1_RX0_IRQHandler
|
||||
.thumb_set CAN1_RX0_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN1_RX1_IRQHandler
|
||||
.thumb_set CAN1_RX1_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN1_SCE_IRQHandler
|
||||
.thumb_set CAN1_SCE_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI9_5_IRQHandler
|
||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_BRK_TIM9_IRQHandler
|
||||
.thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_UP_TIM10_IRQHandler
|
||||
.thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_TRG_COM_TIM11_IRQHandler
|
||||
.thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_CC_IRQHandler
|
||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM2_IRQHandler
|
||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM3_IRQHandler
|
||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM4_IRQHandler
|
||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_EV_IRQHandler
|
||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_ER_IRQHandler
|
||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_EV_IRQHandler
|
||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_ER_IRQHandler
|
||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI1_IRQHandler
|
||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI2_IRQHandler
|
||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART1_IRQHandler
|
||||
.thumb_set USART1_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART2_IRQHandler
|
||||
.thumb_set USART2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART3_IRQHandler
|
||||
.thumb_set USART3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI15_10_IRQHandler
|
||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_Alarm_IRQHandler
|
||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_FS_WKUP_IRQHandler
|
||||
.thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_BRK_TIM12_IRQHandler
|
||||
.thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_UP_TIM13_IRQHandler
|
||||
.thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_TRG_COM_TIM14_IRQHandler
|
||||
.thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_CC_IRQHandler
|
||||
.thumb_set TIM8_CC_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream7_IRQHandler
|
||||
.thumb_set DMA1_Stream7_IRQHandler,Default_Handler
|
||||
|
||||
.weak FSMC_IRQHandler
|
||||
.thumb_set FSMC_IRQHandler,Default_Handler
|
||||
|
||||
.weak SDIO_IRQHandler
|
||||
.thumb_set SDIO_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM5_IRQHandler
|
||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI3_IRQHandler
|
||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART4_IRQHandler
|
||||
.thumb_set UART4_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART5_IRQHandler
|
||||
.thumb_set UART5_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM6_DAC_IRQHandler
|
||||
.thumb_set TIM6_DAC_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM7_IRQHandler
|
||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream0_IRQHandler
|
||||
.thumb_set DMA2_Stream0_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream1_IRQHandler
|
||||
.thumb_set DMA2_Stream1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream2_IRQHandler
|
||||
.thumb_set DMA2_Stream2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream3_IRQHandler
|
||||
.thumb_set DMA2_Stream3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream4_IRQHandler
|
||||
.thumb_set DMA2_Stream4_IRQHandler,Default_Handler
|
||||
|
||||
.weak ETH_IRQHandler
|
||||
.thumb_set ETH_IRQHandler,Default_Handler
|
||||
|
||||
.weak ETH_WKUP_IRQHandler
|
||||
.thumb_set ETH_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN2_TX_IRQHandler
|
||||
.thumb_set CAN2_TX_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN2_RX0_IRQHandler
|
||||
.thumb_set CAN2_RX0_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN2_RX1_IRQHandler
|
||||
.thumb_set CAN2_RX1_IRQHandler,Default_Handler
|
||||
|
||||
.weak CAN2_SCE_IRQHandler
|
||||
.thumb_set CAN2_SCE_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_FS_IRQHandler
|
||||
.thumb_set OTG_FS_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream5_IRQHandler
|
||||
.thumb_set DMA2_Stream5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream6_IRQHandler
|
||||
.thumb_set DMA2_Stream6_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream7_IRQHandler
|
||||
.thumb_set DMA2_Stream7_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART6_IRQHandler
|
||||
.thumb_set USART6_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_EV_IRQHandler
|
||||
.thumb_set I2C3_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_ER_IRQHandler
|
||||
.thumb_set I2C3_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_EP1_OUT_IRQHandler
|
||||
.thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_EP1_IN_IRQHandler
|
||||
.thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_WKUP_IRQHandler
|
||||
.thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_IRQHandler
|
||||
.thumb_set OTG_HS_IRQHandler,Default_Handler
|
||||
|
||||
.weak DCMI_IRQHandler
|
||||
.thumb_set DCMI_IRQHandler,Default_Handler
|
||||
|
||||
.weak CRYP_IRQHandler
|
||||
.thumb_set CRYP_IRQHandler,Default_Handler
|
||||
|
||||
.weak HASH_RNG_IRQHandler
|
||||
.thumb_set HASH_RNG_IRQHandler,Default_Handler
|
||||
|
||||
.weak FPU_IRQHandler
|
||||
.thumb_set FPU_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART7_IRQHandler
|
||||
.thumb_set UART7_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART8_IRQHandler
|
||||
.thumb_set UART8_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI4_IRQHandler
|
||||
.thumb_set SPI4_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI5_IRQHandler
|
||||
.thumb_set SPI5_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI6_IRQHandler
|
||||
.thumb_set SPI6_IRQHandler,Default_Handler
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -0,0 +1,561 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file system_stm32f4xx.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 11-January-2013
|
||||
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
|
||||
* This file contains the system clock configuration for STM32F4xx devices,
|
||||
* and is generated by the clock configuration tool
|
||||
* stm32f4xx_Clock_Configuration_V1.1.0.xls
|
||||
*
|
||||
* 1. This file provides two functions and one global variable to be called from
|
||||
* user application:
|
||||
* - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
|
||||
* and Divider factors, AHB/APBx prescalers and Flash settings),
|
||||
* depending on the configuration made in the clock xls tool.
|
||||
* This function is called at startup just after reset and
|
||||
* before branch to main program. This call is made inside
|
||||
* the "startup_stm32f4xx.s" file.
|
||||
*
|
||||
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
|
||||
* by the user application to setup the SysTick
|
||||
* timer or configure other parameters.
|
||||
*
|
||||
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
|
||||
* be called whenever the core clock is changed
|
||||
* during program execution.
|
||||
*
|
||||
* 2. After each device reset the HSI (16 MHz) is used as system clock source.
|
||||
* Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to
|
||||
* configure the system clock before to branch to main program.
|
||||
*
|
||||
* 3. If the system clock source selected by user fails to startup, the SystemInit()
|
||||
* function will do nothing and HSI still used as system clock source. User can
|
||||
* add some code to deal with this issue inside the SetSysClock() function.
|
||||
*
|
||||
* 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define
|
||||
* in "stm32f4xx.h" file. When HSE is used as system clock source, directly or
|
||||
* through PLL, and you are using different crystal you have to adapt the HSE
|
||||
* value to your own configuration.
|
||||
*
|
||||
* 5. This file configures the system clock as follows:
|
||||
*=============================================================================
|
||||
*=============================================================================
|
||||
* Supported STM32F40xx/41xx/427x/437x devices
|
||||
*-----------------------------------------------------------------------------
|
||||
* System Clock source | PLL (HSE)
|
||||
*-----------------------------------------------------------------------------
|
||||
* SYSCLK(Hz) | 168000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* HCLK(Hz) | 168000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* AHB Prescaler | 1
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB1 Prescaler | 4
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB2 Prescaler | 2
|
||||
*-----------------------------------------------------------------------------
|
||||
* HSE Frequency(Hz) | 25000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_M | 25
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_N | 336
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_P | 2
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_Q | 7
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLI2S_N | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLI2S_R | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* I2S input clock | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* VDD(V) | 3.3
|
||||
*-----------------------------------------------------------------------------
|
||||
* Main regulator output voltage | Scale1 mode
|
||||
*-----------------------------------------------------------------------------
|
||||
* Flash Latency(WS) | 5
|
||||
*-----------------------------------------------------------------------------
|
||||
* Prefetch Buffer | ON
|
||||
*-----------------------------------------------------------------------------
|
||||
* Instruction cache | ON
|
||||
*-----------------------------------------------------------------------------
|
||||
* Data cache | ON
|
||||
*-----------------------------------------------------------------------------
|
||||
* Require 48MHz for USB OTG FS, | Disabled
|
||||
* SDIO and RNG clock |
|
||||
*-----------------------------------------------------------------------------
|
||||
*=============================================================================
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup stm32f4xx_system
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F4xx_System_Private_Includes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "stm32f4xx.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F4xx_System_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/************************* Miscellaneous Configuration ************************/
|
||||
/*!< Uncomment the following line if you need to use external SRAM mounted
|
||||
on STM324xG_EVAL/STM324x7I_EVAL boards as data memory */
|
||||
/* #define DATA_IN_ExtSRAM */
|
||||
|
||||
/*!< Uncomment the following line if you need to relocate your vector Table in
|
||||
Internal SRAM. */
|
||||
/* #define VECT_TAB_SRAM */
|
||||
#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x200. */
|
||||
/******************************************************************************/
|
||||
|
||||
/************************* PLL Parameters *************************************/
|
||||
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
|
||||
#define PLL_M 25
|
||||
#define PLL_N 336
|
||||
|
||||
/* SYSCLK = PLL_VCO / PLL_P */
|
||||
#define PLL_P 2
|
||||
|
||||
/* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */
|
||||
#define PLL_Q 7
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F4xx_System_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F4xx_System_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint32_t SystemCoreClock = 168000000;
|
||||
|
||||
__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
static void SetSysClock(void);
|
||||
#ifdef DATA_IN_ExtSRAM
|
||||
static void SystemInit_ExtMemCtl(void);
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F4xx_System_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Setup the microcontroller system
|
||||
* Initialize the Embedded Flash Interface, the PLL and update the
|
||||
* SystemFrequency variable.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* FPU settings ------------------------------------------------------------*/
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
|
||||
#endif
|
||||
/* Reset the RCC clock configuration to the default reset state ------------*/
|
||||
/* Set HSION bit */
|
||||
RCC->CR |= (uint32_t)0x00000001;
|
||||
|
||||
/* Reset CFGR register */
|
||||
RCC->CFGR = 0x00000000;
|
||||
|
||||
/* Reset HSEON, CSSON and PLLON bits */
|
||||
RCC->CR &= (uint32_t)0xFEF6FFFF;
|
||||
|
||||
/* Reset PLLCFGR register */
|
||||
RCC->PLLCFGR = 0x24003010;
|
||||
|
||||
/* Reset HSEBYP bit */
|
||||
RCC->CR &= (uint32_t)0xFFFBFFFF;
|
||||
|
||||
/* Disable all interrupts */
|
||||
RCC->CIR = 0x00000000;
|
||||
|
||||
#ifdef DATA_IN_ExtSRAM
|
||||
SystemInit_ExtMemCtl();
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
|
||||
/* Configure the System clock source, PLL Multiplier and Divider factors,
|
||||
AHB/APBx prescalers and Flash settings ----------------------------------*/
|
||||
SetSysClock();
|
||||
|
||||
/* Configure the Vector Table location add offset address ------------------*/
|
||||
#ifdef VECT_TAB_SRAM
|
||||
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
|
||||
#else
|
||||
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update SystemCoreClock variable according to Clock Register Values.
|
||||
* The SystemCoreClock variable contains the core clock (HCLK), it can
|
||||
* be used by the user application to setup the SysTick timer or configure
|
||||
* other parameters.
|
||||
*
|
||||
* @note Each time the core clock (HCLK) changes, this function must be called
|
||||
* to update SystemCoreClock variable value. Otherwise, any configuration
|
||||
* based on this variable will be incorrect.
|
||||
*
|
||||
* @note - The system frequency computed by this function is not the real
|
||||
* frequency in the chip. It is calculated based on the predefined
|
||||
* constant and the selected clock source:
|
||||
*
|
||||
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
|
||||
*
|
||||
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
|
||||
*
|
||||
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
|
||||
* or HSI_VALUE(*) multiplied/divided by the PLL factors.
|
||||
*
|
||||
* (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value
|
||||
* 16 MHz) but the real value may vary depending on the variations
|
||||
* in voltage and temperature.
|
||||
*
|
||||
* (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value
|
||||
* 25 MHz), user has to ensure that HSE_VALUE is same as the real
|
||||
* frequency of the crystal used. Otherwise, this function may
|
||||
* have wrong result.
|
||||
*
|
||||
* - The result of this function could be not correct when using fractional
|
||||
* value for HSE crystal.
|
||||
*
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemCoreClockUpdate(void)
|
||||
{
|
||||
uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
|
||||
|
||||
/* Get SYSCLK source -------------------------------------------------------*/
|
||||
tmp = RCC->CFGR & RCC_CFGR_SWS;
|
||||
|
||||
switch (tmp)
|
||||
{
|
||||
case 0x00: /* HSI used as system clock source */
|
||||
SystemCoreClock = HSI_VALUE;
|
||||
break;
|
||||
case 0x04: /* HSE used as system clock source */
|
||||
SystemCoreClock = HSE_VALUE;
|
||||
break;
|
||||
case 0x08: /* PLL used as system clock source */
|
||||
|
||||
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
|
||||
SYSCLK = PLL_VCO / PLL_P
|
||||
*/
|
||||
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
|
||||
pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
|
||||
|
||||
if (pllsource != 0)
|
||||
{
|
||||
/* HSE used as PLL clock source */
|
||||
pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* HSI used as PLL clock source */
|
||||
pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
|
||||
}
|
||||
|
||||
pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
|
||||
SystemCoreClock = pllvco/pllp;
|
||||
break;
|
||||
default:
|
||||
SystemCoreClock = HSI_VALUE;
|
||||
break;
|
||||
}
|
||||
/* Compute HCLK frequency --------------------------------------------------*/
|
||||
/* Get HCLK prescaler */
|
||||
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
|
||||
/* HCLK frequency */
|
||||
SystemCoreClock >>= tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the System clock source, PLL Multiplier and Divider factors,
|
||||
* AHB/APBx prescalers and Flash settings
|
||||
* @Note This function should be called only once the RCC clock configuration
|
||||
* is reset to the default reset state (done in SystemInit() function).
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void SetSysClock(void)
|
||||
{
|
||||
/******************************************************************************/
|
||||
/* PLL (clocked by HSE) used as System clock source */
|
||||
/******************************************************************************/
|
||||
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
|
||||
|
||||
/* Enable HSE */
|
||||
RCC->CR |= ((uint32_t)RCC_CR_HSEON);
|
||||
|
||||
/* Wait till HSE is ready and if Time out is reached exit */
|
||||
do
|
||||
{
|
||||
HSEStatus = RCC->CR & RCC_CR_HSERDY;
|
||||
StartUpCounter++;
|
||||
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
|
||||
|
||||
if ((RCC->CR & RCC_CR_HSERDY) != RESET)
|
||||
{
|
||||
HSEStatus = (uint32_t)0x01;
|
||||
}
|
||||
else
|
||||
{
|
||||
HSEStatus = (uint32_t)0x00;
|
||||
}
|
||||
|
||||
if (HSEStatus == (uint32_t)0x01)
|
||||
{
|
||||
/* Select regulator voltage output Scale 1 mode, System frequency up to 168 MHz */
|
||||
RCC->APB1ENR |= RCC_APB1ENR_PWREN;
|
||||
PWR->CR |= PWR_CR_VOS;
|
||||
|
||||
/* HCLK = SYSCLK / 1*/
|
||||
RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
|
||||
|
||||
/* PCLK2 = HCLK / 2*/
|
||||
RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
|
||||
|
||||
/* PCLK1 = HCLK / 4*/
|
||||
RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
|
||||
|
||||
/* Configure the main PLL */
|
||||
RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
|
||||
(RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
|
||||
|
||||
/* Enable the main PLL */
|
||||
RCC->CR |= RCC_CR_PLLON;
|
||||
|
||||
/* Wait till the main PLL is ready */
|
||||
while((RCC->CR & RCC_CR_PLLRDY) == 0)
|
||||
{
|
||||
}
|
||||
|
||||
/* Configure Flash prefetch, Instruction cache, Data cache and wait state */
|
||||
FLASH->ACR = FLASH_ACR_PRFTEN |FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
|
||||
|
||||
/* Select the main PLL as system clock source */
|
||||
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
|
||||
RCC->CFGR |= RCC_CFGR_SW_PLL;
|
||||
|
||||
/* Wait till the main PLL is used as system clock source */
|
||||
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* If HSE fails to start-up, the application will have wrong clock
|
||||
configuration. User can add here some code to deal with this error */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Setup the external memory controller. Called in startup_stm32f4xx.s
|
||||
* before jump to __main
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
#ifdef DATA_IN_ExtSRAM
|
||||
/**
|
||||
* @brief Setup the external memory controller.
|
||||
* Called in startup_stm32f4xx.s before jump to main.
|
||||
* This function configures the external SRAM mounted on STM324xG_EVAL/STM324x7I boards
|
||||
* This SRAM will be used as program data memory (including heap and stack).
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemInit_ExtMemCtl(void)
|
||||
{
|
||||
/*-- GPIOs Configuration -----------------------------------------------------*/
|
||||
/*
|
||||
+-------------------+--------------------+------------------+------------------+
|
||||
+ SRAM pins assignment +
|
||||
+-------------------+--------------------+------------------+------------------+
|
||||
| PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 |
|
||||
| PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 |
|
||||
| PD4 <-> FSMC_NOE | PE2 <-> FSMC_A23 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
|
||||
| PD5 <-> FSMC_NWE | PE3 <-> FSMC_A19 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
|
||||
| PD8 <-> FSMC_D13 | PE4 <-> FSMC_A20 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
|
||||
| PD9 <-> FSMC_D14 | PE5 <-> FSMC_A21 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
|
||||
| PD10 <-> FSMC_D15 | PE6 <-> FSMC_A22 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
|
||||
| PD11 <-> FSMC_A16 | PE7 <-> FSMC_D4 | PF13 <-> FSMC_A7 |------------------+
|
||||
| PD12 <-> FSMC_A17 | PE8 <-> FSMC_D5 | PF14 <-> FSMC_A8 |
|
||||
| PD13 <-> FSMC_A18 | PE9 <-> FSMC_D6 | PF15 <-> FSMC_A9 |
|
||||
| PD14 <-> FSMC_D0 | PE10 <-> FSMC_D7 |------------------+
|
||||
| PD15 <-> FSMC_D1 | PE11 <-> FSMC_D8 |
|
||||
+-------------------| PE12 <-> FSMC_D9 |
|
||||
| PE13 <-> FSMC_D10 |
|
||||
| PE14 <-> FSMC_D11 |
|
||||
| PE15 <-> FSMC_D12 |
|
||||
+--------------------+
|
||||
*/
|
||||
/* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
|
||||
RCC->AHB1ENR |= 0x00000078;
|
||||
|
||||
/* Connect PDx pins to FSMC Alternate function */
|
||||
GPIOD->AFR[0] = 0x00cc00cc;
|
||||
GPIOD->AFR[1] = 0xcccccccc;
|
||||
/* Configure PDx pins in Alternate function mode */
|
||||
GPIOD->MODER = 0xaaaa0a0a;
|
||||
/* Configure PDx pins speed to 100 MHz */
|
||||
GPIOD->OSPEEDR = 0xffff0f0f;
|
||||
/* Configure PDx pins Output type to push-pull */
|
||||
GPIOD->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PDx pins */
|
||||
GPIOD->PUPDR = 0x00000000;
|
||||
|
||||
/* Connect PEx pins to FSMC Alternate function */
|
||||
GPIOE->AFR[0] = 0xcccccccc;
|
||||
GPIOE->AFR[1] = 0xcccccccc;
|
||||
/* Configure PEx pins in Alternate function mode */
|
||||
GPIOE->MODER = 0xaaaaaaaa;
|
||||
/* Configure PEx pins speed to 100 MHz */
|
||||
GPIOE->OSPEEDR = 0xffffffff;
|
||||
/* Configure PEx pins Output type to push-pull */
|
||||
GPIOE->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PEx pins */
|
||||
GPIOE->PUPDR = 0x00000000;
|
||||
|
||||
/* Connect PFx pins to FSMC Alternate function */
|
||||
GPIOF->AFR[0] = 0x00cccccc;
|
||||
GPIOF->AFR[1] = 0xcccc0000;
|
||||
/* Configure PFx pins in Alternate function mode */
|
||||
GPIOF->MODER = 0xaa000aaa;
|
||||
/* Configure PFx pins speed to 100 MHz */
|
||||
GPIOF->OSPEEDR = 0xff000fff;
|
||||
/* Configure PFx pins Output type to push-pull */
|
||||
GPIOF->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PFx pins */
|
||||
GPIOF->PUPDR = 0x00000000;
|
||||
|
||||
/* Connect PGx pins to FSMC Alternate function */
|
||||
GPIOG->AFR[0] = 0x00cccccc;
|
||||
GPIOG->AFR[1] = 0x000000c0;
|
||||
/* Configure PGx pins in Alternate function mode */
|
||||
GPIOG->MODER = 0x00080aaa;
|
||||
/* Configure PGx pins speed to 100 MHz */
|
||||
GPIOG->OSPEEDR = 0x000c0fff;
|
||||
/* Configure PGx pins Output type to push-pull */
|
||||
GPIOG->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PGx pins */
|
||||
GPIOG->PUPDR = 0x00000000;
|
||||
|
||||
/*-- FSMC Configuration ------------------------------------------------------*/
|
||||
/* Enable the FSMC interface clock */
|
||||
RCC->AHB3ENR |= 0x00000001;
|
||||
|
||||
/* Configure and enable Bank1_SRAM2 */
|
||||
FSMC_Bank1->BTCR[2] = 0x00001011;
|
||||
FSMC_Bank1->BTCR[3] = 0x00000201;
|
||||
FSMC_Bank1E->BWTR[2] = 0x0fffffff;
|
||||
/*
|
||||
Bank1_SRAM2 is configured as follow:
|
||||
|
||||
p.FSMC_AddressSetupTime = 1;
|
||||
p.FSMC_AddressHoldTime = 0;
|
||||
p.FSMC_DataSetupTime = 2;
|
||||
p.FSMC_BusTurnAroundDuration = 0;
|
||||
p.FSMC_CLKDivision = 0;
|
||||
p.FSMC_DataLatency = 0;
|
||||
p.FSMC_AccessMode = FSMC_AccessMode_A;
|
||||
|
||||
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
|
||||
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
|
||||
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
|
||||
*/
|
||||
}
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -2,12 +2,12 @@
|
||||
******************************************************************************
|
||||
* @file system_stm32f4xx.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.0.0
|
||||
* @date 30-September-2011
|
||||
* @version V1.1.0
|
||||
* @date 11-January-2013
|
||||
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
|
||||
* This file contains the system clock configuration for STM32F4xx devices,
|
||||
* and is generated by the clock configuration tool
|
||||
* stm32f4xx_Clock_Configuration_V1.0.0.xls
|
||||
* stm32f4xx_Clock_Configuration_V1.1.0.xls
|
||||
*
|
||||
* 1. This file provides two functions and one global variable to be called from
|
||||
* user application:
|
||||
@ -42,7 +42,7 @@
|
||||
* 5. This file configures the system clock as follows:
|
||||
*=============================================================================
|
||||
*=============================================================================
|
||||
* Supported STM32F4xx device revision | Rev A
|
||||
* Supported STM32F40xx/41xx/427x/437x devices
|
||||
*-----------------------------------------------------------------------------
|
||||
* System Clock source | PLL (HSE)
|
||||
*-----------------------------------------------------------------------------
|
||||
@ -91,14 +91,20 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@ -134,7 +140,7 @@
|
||||
|
||||
/************************* Miscellaneous Configuration ************************/
|
||||
/*!< Uncomment the following line if you need to use external SRAM mounted
|
||||
on STM324xG_EVAL board as data memory */
|
||||
on STM324xG_EVAL/STM324x7I_EVAL boards as data memory */
|
||||
/* #define DATA_IN_ExtSRAM */
|
||||
|
||||
/*!< Uncomment the following line if you need to relocate your vector Table in
|
||||
@ -211,7 +217,6 @@ void SystemInit(void)
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
|
||||
#endif
|
||||
|
||||
/* Reset the RCC clock configuration to the default reset state ------------*/
|
||||
/* Set HSION bit */
|
||||
RCC->CR |= (uint32_t)0x00000001;
|
||||
@ -421,7 +426,7 @@ static void SetSysClock(void)
|
||||
/**
|
||||
* @brief Setup the external memory controller.
|
||||
* Called in startup_stm32f4xx.s before jump to main.
|
||||
* This function configures the external SRAM mounted on STM324xG_EVAL board
|
||||
* This function configures the external SRAM mounted on STM324xG_EVAL/STM324x7I boards
|
||||
* This SRAM will be used as program data memory (including heap and stack).
|
||||
* @param None
|
||||
* @retval None
|
||||
@ -435,25 +440,28 @@ void SystemInit_ExtMemCtl(void)
|
||||
+-------------------+--------------------+------------------+------------------+
|
||||
| PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 |
|
||||
| PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 |
|
||||
| PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
|
||||
| PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
|
||||
| PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
|
||||
| PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
|
||||
| PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
|
||||
| PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+
|
||||
| PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 |
|
||||
| PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 |
|
||||
| PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+
|
||||
| PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 |
|
||||
| | PE15 <-> FSMC_D12 |
|
||||
+-------------------+--------------------+
|
||||
| PD4 <-> FSMC_NOE | PE2 <-> FSMC_A23 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
|
||||
| PD5 <-> FSMC_NWE | PE3 <-> FSMC_A19 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
|
||||
| PD8 <-> FSMC_D13 | PE4 <-> FSMC_A20 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
|
||||
| PD9 <-> FSMC_D14 | PE5 <-> FSMC_A21 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
|
||||
| PD10 <-> FSMC_D15 | PE6 <-> FSMC_A22 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
|
||||
| PD11 <-> FSMC_A16 | PE7 <-> FSMC_D4 | PF13 <-> FSMC_A7 |------------------+
|
||||
| PD12 <-> FSMC_A17 | PE8 <-> FSMC_D5 | PF14 <-> FSMC_A8 |
|
||||
| PD13 <-> FSMC_A18 | PE9 <-> FSMC_D6 | PF15 <-> FSMC_A9 |
|
||||
| PD14 <-> FSMC_D0 | PE10 <-> FSMC_D7 |------------------+
|
||||
| PD15 <-> FSMC_D1 | PE11 <-> FSMC_D8 |
|
||||
+-------------------| PE12 <-> FSMC_D9 |
|
||||
| PE13 <-> FSMC_D10 |
|
||||
| PE14 <-> FSMC_D11 |
|
||||
| PE15 <-> FSMC_D12 |
|
||||
+--------------------+
|
||||
*/
|
||||
/* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
|
||||
RCC->AHB1ENR = 0x00000078;
|
||||
RCC->AHB1ENR |= 0x00000078;
|
||||
|
||||
/* Connect PDx pins to FSMC Alternate function */
|
||||
GPIOD->AFR[0] = 0x00cc00cc;
|
||||
GPIOD->AFR[1] = 0xcc0ccccc;
|
||||
GPIOD->AFR[1] = 0xcccccccc;
|
||||
/* Configure PDx pins in Alternate function mode */
|
||||
GPIOD->MODER = 0xaaaa0a0a;
|
||||
/* Configure PDx pins speed to 100 MHz */
|
||||
@ -464,12 +472,12 @@ void SystemInit_ExtMemCtl(void)
|
||||
GPIOD->PUPDR = 0x00000000;
|
||||
|
||||
/* Connect PEx pins to FSMC Alternate function */
|
||||
GPIOE->AFR[0] = 0xc00cc0cc;
|
||||
GPIOE->AFR[0] = 0xcccccccc;
|
||||
GPIOE->AFR[1] = 0xcccccccc;
|
||||
/* Configure PEx pins in Alternate function mode */
|
||||
GPIOE->MODER = 0xaaaa828a;
|
||||
GPIOE->MODER = 0xaaaaaaaa;
|
||||
/* Configure PEx pins speed to 100 MHz */
|
||||
GPIOE->OSPEEDR = 0xffffc3cf;
|
||||
GPIOE->OSPEEDR = 0xffffffff;
|
||||
/* Configure PEx pins Output type to push-pull */
|
||||
GPIOE->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PEx pins */
|
||||
@ -501,26 +509,26 @@ void SystemInit_ExtMemCtl(void)
|
||||
|
||||
/*-- FSMC Configuration ------------------------------------------------------*/
|
||||
/* Enable the FSMC interface clock */
|
||||
RCC->AHB3ENR = 0x00000001;
|
||||
RCC->AHB3ENR |= 0x00000001;
|
||||
|
||||
/* Configure and enable Bank1_SRAM2 */
|
||||
FSMC_Bank1->BTCR[2] = 0x00001015;
|
||||
FSMC_Bank1->BTCR[3] = 0x00010603;
|
||||
FSMC_Bank1->BTCR[2] = 0x00001011;
|
||||
FSMC_Bank1->BTCR[3] = 0x00000201;
|
||||
FSMC_Bank1E->BWTR[2] = 0x0fffffff;
|
||||
/*
|
||||
Bank1_SRAM2 is configured as follow:
|
||||
|
||||
p.FSMC_AddressSetupTime = 3;
|
||||
p.FSMC_AddressSetupTime = 1;
|
||||
p.FSMC_AddressHoldTime = 0;
|
||||
p.FSMC_DataSetupTime = 6;
|
||||
p.FSMC_BusTurnAroundDuration = 1;
|
||||
p.FSMC_DataSetupTime = 2;
|
||||
p.FSMC_BusTurnAroundDuration = 0;
|
||||
p.FSMC_CLKDivision = 0;
|
||||
p.FSMC_DataLatency = 0;
|
||||
p.FSMC_AccessMode = FSMC_AccessMode_A;
|
||||
|
||||
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
|
||||
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
|
||||
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
|
||||
@ -534,7 +542,6 @@ void SystemInit_ExtMemCtl(void)
|
||||
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
|
||||
*/
|
||||
|
||||
}
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
|
@ -2,12 +2,12 @@
|
||||
******************************************************************************
|
||||
* @file system_stm32f4xx.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.0.0
|
||||
* @date 30-September-2011
|
||||
* @version V1.1.0
|
||||
* @date 11-January-2013
|
||||
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
|
||||
* This file contains the system clock configuration for STM32F4xx devices,
|
||||
* and is generated by the clock configuration tool
|
||||
* stm32f4xx_Clock_Configuration_V1.0.0.xls
|
||||
* stm32f4xx_Clock_Configuration_V1.1.0.xls
|
||||
*
|
||||
* 1. This file provides two functions and one global variable to be called from
|
||||
* user application:
|
||||
@ -42,7 +42,7 @@
|
||||
* 5. This file configures the system clock as follows:
|
||||
*=============================================================================
|
||||
*=============================================================================
|
||||
* Supported STM32F4xx device revision | Rev A
|
||||
* Supported STM32F40xx/41xx/427x/437x devices
|
||||
*-----------------------------------------------------------------------------
|
||||
* System Clock source | PLL (HSE)
|
||||
*-----------------------------------------------------------------------------
|
||||
@ -78,7 +78,7 @@
|
||||
*-----------------------------------------------------------------------------
|
||||
* Flash Latency(WS) | 5
|
||||
*-----------------------------------------------------------------------------
|
||||
* Prefetch Buffer | OFF
|
||||
* Prefetch Buffer | ON
|
||||
*-----------------------------------------------------------------------------
|
||||
* Instruction cache | ON
|
||||
*-----------------------------------------------------------------------------
|
||||
@ -91,14 +91,20 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@ -134,7 +140,7 @@
|
||||
|
||||
/************************* Miscellaneous Configuration ************************/
|
||||
/*!< Uncomment the following line if you need to use external SRAM mounted
|
||||
on STM324xG_EVAL board as data memory */
|
||||
on STM324xG_EVAL/STM324x7I_EVAL boards as data memory */
|
||||
/* #define DATA_IN_ExtSRAM */
|
||||
|
||||
/*!< Uncomment the following line if you need to relocate your vector Table in
|
||||
@ -211,7 +217,6 @@ void SystemInit(void)
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
|
||||
#endif
|
||||
|
||||
/* Reset the RCC clock configuration to the default reset state ------------*/
|
||||
/* Set HSION bit */
|
||||
RCC->CR |= (uint32_t)0x00000001;
|
||||
@ -421,7 +426,7 @@ static void SetSysClock(void)
|
||||
/**
|
||||
* @brief Setup the external memory controller.
|
||||
* Called in startup_stm32f4xx.s before jump to main.
|
||||
* This function configures the external SRAM mounted on STM324xG_EVAL board
|
||||
* This function configures the external SRAM mounted on STM324xG_EVAL/STM324x7I boards
|
||||
* This SRAM will be used as program data memory (including heap and stack).
|
||||
* @param None
|
||||
* @retval None
|
||||
@ -435,25 +440,28 @@ void SystemInit_ExtMemCtl(void)
|
||||
+-------------------+--------------------+------------------+------------------+
|
||||
| PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 |
|
||||
| PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 |
|
||||
| PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
|
||||
| PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
|
||||
| PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
|
||||
| PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
|
||||
| PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
|
||||
| PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+
|
||||
| PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 |
|
||||
| PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 |
|
||||
| PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+
|
||||
| PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 |
|
||||
| | PE15 <-> FSMC_D12 |
|
||||
+-------------------+--------------------+
|
||||
| PD4 <-> FSMC_NOE | PE2 <-> FSMC_A23 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
|
||||
| PD5 <-> FSMC_NWE | PE3 <-> FSMC_A19 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
|
||||
| PD8 <-> FSMC_D13 | PE4 <-> FSMC_A20 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
|
||||
| PD9 <-> FSMC_D14 | PE5 <-> FSMC_A21 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
|
||||
| PD10 <-> FSMC_D15 | PE6 <-> FSMC_A22 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
|
||||
| PD11 <-> FSMC_A16 | PE7 <-> FSMC_D4 | PF13 <-> FSMC_A7 |------------------+
|
||||
| PD12 <-> FSMC_A17 | PE8 <-> FSMC_D5 | PF14 <-> FSMC_A8 |
|
||||
| PD13 <-> FSMC_A18 | PE9 <-> FSMC_D6 | PF15 <-> FSMC_A9 |
|
||||
| PD14 <-> FSMC_D0 | PE10 <-> FSMC_D7 |------------------+
|
||||
| PD15 <-> FSMC_D1 | PE11 <-> FSMC_D8 |
|
||||
+-------------------| PE12 <-> FSMC_D9 |
|
||||
| PE13 <-> FSMC_D10 |
|
||||
| PE14 <-> FSMC_D11 |
|
||||
| PE15 <-> FSMC_D12 |
|
||||
+--------------------+
|
||||
*/
|
||||
/* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
|
||||
RCC->AHB1ENR = 0x00000078;
|
||||
RCC->AHB1ENR |= 0x00000078;
|
||||
|
||||
/* Connect PDx pins to FSMC Alternate function */
|
||||
GPIOD->AFR[0] = 0x00cc00cc;
|
||||
GPIOD->AFR[1] = 0xcc0ccccc;
|
||||
GPIOD->AFR[1] = 0xcccccccc;
|
||||
/* Configure PDx pins in Alternate function mode */
|
||||
GPIOD->MODER = 0xaaaa0a0a;
|
||||
/* Configure PDx pins speed to 100 MHz */
|
||||
@ -464,12 +472,12 @@ void SystemInit_ExtMemCtl(void)
|
||||
GPIOD->PUPDR = 0x00000000;
|
||||
|
||||
/* Connect PEx pins to FSMC Alternate function */
|
||||
GPIOE->AFR[0] = 0xc00cc0cc;
|
||||
GPIOE->AFR[0] = 0xcccccccc;
|
||||
GPIOE->AFR[1] = 0xcccccccc;
|
||||
/* Configure PEx pins in Alternate function mode */
|
||||
GPIOE->MODER = 0xaaaa828a;
|
||||
GPIOE->MODER = 0xaaaaaaaa;
|
||||
/* Configure PEx pins speed to 100 MHz */
|
||||
GPIOE->OSPEEDR = 0xffffc3cf;
|
||||
GPIOE->OSPEEDR = 0xffffffff;
|
||||
/* Configure PEx pins Output type to push-pull */
|
||||
GPIOE->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PEx pins */
|
||||
@ -501,26 +509,26 @@ void SystemInit_ExtMemCtl(void)
|
||||
|
||||
/*-- FSMC Configuration ------------------------------------------------------*/
|
||||
/* Enable the FSMC interface clock */
|
||||
RCC->AHB3ENR = 0x00000001;
|
||||
RCC->AHB3ENR |= 0x00000001;
|
||||
|
||||
/* Configure and enable Bank1_SRAM2 */
|
||||
FSMC_Bank1->BTCR[2] = 0x00001015;
|
||||
FSMC_Bank1->BTCR[3] = 0x00010603;
|
||||
FSMC_Bank1->BTCR[2] = 0x00001011;
|
||||
FSMC_Bank1->BTCR[3] = 0x00000201;
|
||||
FSMC_Bank1E->BWTR[2] = 0x0fffffff;
|
||||
/*
|
||||
Bank1_SRAM2 is configured as follow:
|
||||
|
||||
p.FSMC_AddressSetupTime = 3;
|
||||
p.FSMC_AddressSetupTime = 1;
|
||||
p.FSMC_AddressHoldTime = 0;
|
||||
p.FSMC_DataSetupTime = 6;
|
||||
p.FSMC_BusTurnAroundDuration = 1;
|
||||
p.FSMC_DataSetupTime = 2;
|
||||
p.FSMC_BusTurnAroundDuration = 0;
|
||||
p.FSMC_CLKDivision = 0;
|
||||
p.FSMC_DataLatency = 0;
|
||||
p.FSMC_AccessMode = FSMC_AccessMode_A;
|
||||
|
||||
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
|
||||
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
|
||||
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
|
||||
@ -534,7 +542,6 @@ void SystemInit_ExtMemCtl(void)
|
||||
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
|
||||
*/
|
||||
|
||||
}
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
|
@ -2,12 +2,12 @@
|
||||
******************************************************************************
|
||||
* @file system_stm32f4xx.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.0.0
|
||||
* @date 30-September-2011
|
||||
* @version V1.1.0
|
||||
* @date 11-January-2013
|
||||
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
|
||||
* This file contains the system clock configuration for STM32F4xx devices,
|
||||
* and is generated by the clock configuration tool
|
||||
* stm32f4xx_Clock_Configuration_V1.0.0.xls
|
||||
* stm32f4xx_Clock_Configuration_V1.1.0.xls
|
||||
*
|
||||
* 1. This file provides two functions and one global variable to be called from
|
||||
* user application:
|
||||
@ -42,7 +42,7 @@
|
||||
* 5. This file configures the system clock as follows:
|
||||
*=============================================================================
|
||||
*=============================================================================
|
||||
* Supported STM32F4xx device revision | Rev A
|
||||
* Supported STM32F40xx/41xx/427x/437x devices
|
||||
*-----------------------------------------------------------------------------
|
||||
* System Clock source | PLL (HSE)
|
||||
*-----------------------------------------------------------------------------
|
||||
@ -91,14 +91,20 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@ -134,7 +140,7 @@
|
||||
|
||||
/************************* Miscellaneous Configuration ************************/
|
||||
/*!< Uncomment the following line if you need to use external SRAM mounted
|
||||
on STM324xG_EVAL board as data memory */
|
||||
on STM324xG_EVAL/STM324x7I_EVAL boards as data memory */
|
||||
/* #define DATA_IN_ExtSRAM */
|
||||
|
||||
/*!< Uncomment the following line if you need to relocate your vector Table in
|
||||
@ -211,7 +217,6 @@ void SystemInit(void)
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
|
||||
#endif
|
||||
|
||||
/* Reset the RCC clock configuration to the default reset state ------------*/
|
||||
/* Set HSION bit */
|
||||
RCC->CR |= (uint32_t)0x00000001;
|
||||
@ -421,7 +426,7 @@ static void SetSysClock(void)
|
||||
/**
|
||||
* @brief Setup the external memory controller.
|
||||
* Called in startup_stm32f4xx.s before jump to main.
|
||||
* This function configures the external SRAM mounted on STM324xG_EVAL board
|
||||
* This function configures the external SRAM mounted on STM324xG_EVAL/STM324x7I boards
|
||||
* This SRAM will be used as program data memory (including heap and stack).
|
||||
* @param None
|
||||
* @retval None
|
||||
@ -435,25 +440,28 @@ void SystemInit_ExtMemCtl(void)
|
||||
+-------------------+--------------------+------------------+------------------+
|
||||
| PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 |
|
||||
| PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 |
|
||||
| PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
|
||||
| PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
|
||||
| PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
|
||||
| PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
|
||||
| PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
|
||||
| PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+
|
||||
| PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 |
|
||||
| PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 |
|
||||
| PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+
|
||||
| PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 |
|
||||
| | PE15 <-> FSMC_D12 |
|
||||
+-------------------+--------------------+
|
||||
| PD4 <-> FSMC_NOE | PE2 <-> FSMC_A23 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
|
||||
| PD5 <-> FSMC_NWE | PE3 <-> FSMC_A19 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
|
||||
| PD8 <-> FSMC_D13 | PE4 <-> FSMC_A20 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
|
||||
| PD9 <-> FSMC_D14 | PE5 <-> FSMC_A21 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
|
||||
| PD10 <-> FSMC_D15 | PE6 <-> FSMC_A22 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
|
||||
| PD11 <-> FSMC_A16 | PE7 <-> FSMC_D4 | PF13 <-> FSMC_A7 |------------------+
|
||||
| PD12 <-> FSMC_A17 | PE8 <-> FSMC_D5 | PF14 <-> FSMC_A8 |
|
||||
| PD13 <-> FSMC_A18 | PE9 <-> FSMC_D6 | PF15 <-> FSMC_A9 |
|
||||
| PD14 <-> FSMC_D0 | PE10 <-> FSMC_D7 |------------------+
|
||||
| PD15 <-> FSMC_D1 | PE11 <-> FSMC_D8 |
|
||||
+-------------------| PE12 <-> FSMC_D9 |
|
||||
| PE13 <-> FSMC_D10 |
|
||||
| PE14 <-> FSMC_D11 |
|
||||
| PE15 <-> FSMC_D12 |
|
||||
+--------------------+
|
||||
*/
|
||||
/* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
|
||||
RCC->AHB1ENR = 0x00000078;
|
||||
RCC->AHB1ENR |= 0x00000078;
|
||||
|
||||
/* Connect PDx pins to FSMC Alternate function */
|
||||
GPIOD->AFR[0] = 0x00cc00cc;
|
||||
GPIOD->AFR[1] = 0xcc0ccccc;
|
||||
GPIOD->AFR[1] = 0xcccccccc;
|
||||
/* Configure PDx pins in Alternate function mode */
|
||||
GPIOD->MODER = 0xaaaa0a0a;
|
||||
/* Configure PDx pins speed to 100 MHz */
|
||||
@ -464,12 +472,12 @@ void SystemInit_ExtMemCtl(void)
|
||||
GPIOD->PUPDR = 0x00000000;
|
||||
|
||||
/* Connect PEx pins to FSMC Alternate function */
|
||||
GPIOE->AFR[0] = 0xc00cc0cc;
|
||||
GPIOE->AFR[0] = 0xcccccccc;
|
||||
GPIOE->AFR[1] = 0xcccccccc;
|
||||
/* Configure PEx pins in Alternate function mode */
|
||||
GPIOE->MODER = 0xaaaa828a;
|
||||
GPIOE->MODER = 0xaaaaaaaa;
|
||||
/* Configure PEx pins speed to 100 MHz */
|
||||
GPIOE->OSPEEDR = 0xffffc3cf;
|
||||
GPIOE->OSPEEDR = 0xffffffff;
|
||||
/* Configure PEx pins Output type to push-pull */
|
||||
GPIOE->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PEx pins */
|
||||
@ -501,26 +509,26 @@ void SystemInit_ExtMemCtl(void)
|
||||
|
||||
/*-- FSMC Configuration ------------------------------------------------------*/
|
||||
/* Enable the FSMC interface clock */
|
||||
RCC->AHB3ENR = 0x00000001;
|
||||
RCC->AHB3ENR |= 0x00000001;
|
||||
|
||||
/* Configure and enable Bank1_SRAM2 */
|
||||
FSMC_Bank1->BTCR[2] = 0x00001015;
|
||||
FSMC_Bank1->BTCR[3] = 0x00010603;
|
||||
FSMC_Bank1->BTCR[2] = 0x00001011;
|
||||
FSMC_Bank1->BTCR[3] = 0x00000201;
|
||||
FSMC_Bank1E->BWTR[2] = 0x0fffffff;
|
||||
/*
|
||||
Bank1_SRAM2 is configured as follow:
|
||||
|
||||
p.FSMC_AddressSetupTime = 3;
|
||||
p.FSMC_AddressSetupTime = 1;
|
||||
p.FSMC_AddressHoldTime = 0;
|
||||
p.FSMC_DataSetupTime = 6;
|
||||
p.FSMC_BusTurnAroundDuration = 1;
|
||||
p.FSMC_DataSetupTime = 2;
|
||||
p.FSMC_BusTurnAroundDuration = 0;
|
||||
p.FSMC_CLKDivision = 0;
|
||||
p.FSMC_DataLatency = 0;
|
||||
p.FSMC_AccessMode = FSMC_AccessMode_A;
|
||||
|
||||
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
|
||||
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
|
||||
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
|
||||
@ -534,7 +542,6 @@ void SystemInit_ExtMemCtl(void)
|
||||
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
|
||||
*/
|
||||
|
||||
}
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
|
37
flight/pios/stm32f4xx/libraries/CMSIS/README.txt
Normal file
37
flight/pios/stm32f4xx/libraries/CMSIS/README.txt
Normal file
@ -0,0 +1,37 @@
|
||||
* -------------------------------------------------------------------
|
||||
* Copyright (C) 2011-2012 ARM Limited. All rights reserved.
|
||||
*
|
||||
* Date: 07 March 2012
|
||||
* Revision: V3.01
|
||||
*
|
||||
* Project: Cortex Microcontroller Software Interface Standard (CMSIS)
|
||||
* Title: Release Note for CMSIS
|
||||
*
|
||||
* -------------------------------------------------------------------
|
||||
|
||||
|
||||
NOTE - Open the index.html file to access CMSIS documentation
|
||||
|
||||
|
||||
The Cortex Microcontroller Software Interface Standard (CMSIS) provides a single standard across all
|
||||
Cortex-Mx processor series vendors. It enables code re-use and code sharing across software projects
|
||||
and reduces time-to-market for new embedded applications.
|
||||
|
||||
CMSIS is released under the terms of the end user license agreement ("CMSIS END USER LICENCE AGREEMENT.pdf").
|
||||
Any user of the software package is bound to the terms and conditions of the end user license agreement.
|
||||
|
||||
|
||||
You will find the following sub-directories:
|
||||
|
||||
Documentation - Contains CMSIS documentation.
|
||||
|
||||
DSP_Lib - MDK project files, Examples and source files etc.. to build the
|
||||
CMSIS DSP Software Library for Cortex-M0, Cortex-M3, Cortex-M4 processors.
|
||||
|
||||
Include - CMSIS Core Support and CMSIS DSP Include Files.
|
||||
|
||||
Lib - CMSIS DSP Libraries.
|
||||
|
||||
RTOS - CMSIS RTOS API template header file.
|
||||
|
||||
SVD - CMSIS SVD Schema files and Conversion Utility.
|
@ -28,7 +28,7 @@ EXTRAINCDIRS += $(PIOS_DEVLIB)inc
|
||||
|
||||
# CMSIS for the F4
|
||||
include $(PIOSCOMMON)/libraries/CMSIS/library.mk
|
||||
CMSIS_DEVICEDIR := $(PIOS_DEVLIB)libraries/CMSIS2/Device/ST/STM32F4xx
|
||||
CMSIS_DEVICEDIR := $(PIOS_DEVLIB)libraries/CMSIS/Device/ST/STM32F4xx
|
||||
SRC += $(sort $(wildcard $(CMSIS_DEVICEDIR)/Source/$(BOARD_NAME)/*.c))
|
||||
EXTRAINCDIRS += $(CMSIS_DEVICEDIR)/Include
|
||||
|
||||
@ -38,13 +38,13 @@ SRC += $(sort $(wildcard $(PERIPHLIB)/src/*.c))
|
||||
EXTRAINCDIRS += $(PERIPHLIB)/inc
|
||||
|
||||
# ST USB OTG library
|
||||
USBOTGLIB = $(PIOS_DEVLIB)libraries/STM32_USB_OTG_Driver
|
||||
USBOTGLIB = $(PIOSCOMMON)/libraries/STM32_USB_OTG_Driver
|
||||
USBOTGLIB_SRC = usb_core.c usb_dcd.c usb_dcd_int.c
|
||||
SRC += $(addprefix $(USBOTGLIB)/src/,$(USBOTGLIB_SRC))
|
||||
EXTRAINCDIRS += $(USBOTGLIB)/inc
|
||||
|
||||
# ST USB Device library
|
||||
USBDEVLIB = $(PIOS_DEVLIB)libraries/STM32_USB_Device_Library
|
||||
USBDEVLIB = $(PIOSCOMMON)/libraries/STM32_USB_Device_Library
|
||||
SRC += $(sort $(wildcard $(USBDEVLIB)/Core/src/*.c))
|
||||
EXTRAINCDIRS += $(USBDEVLIB)/Core/inc
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user