stm32f072_usb_mouse_keyboard: create project
This commit is contained in:
parent
72e5fc5746
commit
011a94b870
File diff suppressed because one or more lines are too long
@ -13,7 +13,7 @@
|
|||||||
* in the root directory of this software component.
|
* in the root directory of this software component.
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
|
|
||||||
23
stm32f072_usb_mouse_keyboard/Core/Inc/usb_config.h
Normal file
23
stm32f072_usb_mouse_keyboard/Core/Inc/usb_config.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef CHERRYUSB_CONFIG_H
|
||||||
|
#define CHERRYUSB_CONFIG_H
|
||||||
|
|
||||||
|
#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
|
||||||
|
#define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
|
||||||
|
#define CONFIG_USB_PRINTF_COLOR_ENABLE
|
||||||
|
|
||||||
|
#define CONFIG_USB_ALIGN_SIZE 4
|
||||||
|
#define USB_NOCACHE_RAM_SECTION
|
||||||
|
|
||||||
|
/* ================ USB Device Port Configuration ================*/
|
||||||
|
|
||||||
|
#define CONFIG_USBDEV_MAX_BUS 1
|
||||||
|
#define CONFIG_USBDEV_EP_NUM 8
|
||||||
|
|
||||||
|
/* ================= USB Device Stack Configuration ================ */
|
||||||
|
|
||||||
|
#define CONFIG_USBDEV_REQUEST_BUFFER_LEN 256
|
||||||
|
|
||||||
|
/* ---------------- FSDEV Configuration ---------------- */
|
||||||
|
#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 1
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
#include "usbd_core.h"
|
#include <stdio.h>
|
||||||
#include "usb_hid.h"
|
#include "usb_hid.h"
|
||||||
#include "bsp_key.h"
|
#include "bsp_key.h"
|
||||||
#include "hid_keyboard_mouse.h"
|
#include "hid_keyboard_mouse.h"
|
||||||
@ -62,20 +62,7 @@ static void MX_TIM6_Init(void);
|
|||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
void usb_dc_low_level_init(void)
|
|
||||||
{
|
|
||||||
__HAL_RCC_USB_CLK_ENABLE();
|
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(USB_IRQn, 0, 0);
|
|
||||||
HAL_NVIC_EnableIRQ(USB_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
int fputc(int c, FILE *f)
|
|
||||||
{
|
|
||||||
uint8_t ch = c;
|
|
||||||
HAL_UART_Transmit(&huart1, &ch, 1, 10);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,8 +103,7 @@ int main(void)
|
|||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
bsp_key_number_e key;
|
bsp_key_number_e key;
|
||||||
bsp_key_event_type_e event;
|
bsp_key_event_type_e event;
|
||||||
bsp_key_get_event(&key, &event);
|
bsp_key_get_event(&key, &event);
|
||||||
@ -148,7 +134,6 @@ int main(void)
|
|||||||
} else {
|
} else {
|
||||||
__WFI();
|
__WFI();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
@ -319,7 +304,12 @@ static void MX_GPIO_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
|
int fputc(int c, FILE *f)
|
||||||
|
{
|
||||||
|
uint8_t ch = c;
|
||||||
|
HAL_UART_Transmit(&huart1, &ch, 1, 10);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
/* USER CODE BEGIN Header */
|
/* USER CODE BEGIN Header */
|
||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
@ -98,6 +99,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
|
|||||||
/* USER CODE BEGIN TIM6_MspInit 1 */
|
/* USER CODE BEGIN TIM6_MspInit 1 */
|
||||||
|
|
||||||
/* USER CODE END TIM6_MspInit 1 */
|
/* USER CODE END TIM6_MspInit 1 */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -159,6 +161,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
|||||||
/* USER CODE BEGIN USART1_MspInit 1 */
|
/* USER CODE BEGIN USART1_MspInit 1 */
|
||||||
|
|
||||||
/* USER CODE END USART1_MspInit 1 */
|
/* USER CODE END USART1_MspInit 1 */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -193,5 +196,18 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
void usb_dc_low_level_init(void)
|
||||||
|
{
|
||||||
|
__HAL_RCC_USB_CLK_ENABLE();
|
||||||
|
|
||||||
|
HAL_NVIC_SetPriority(USB_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(USB_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void usb_dc_low_level_deinit(void)
|
||||||
|
{
|
||||||
|
__HAL_RCC_USB_CLK_DISABLE();
|
||||||
|
|
||||||
|
HAL_NVIC_DisableIRQ(USB_IRQn);
|
||||||
|
}
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
@ -22,6 +22,7 @@
|
|||||||
#include "stm32f0xx_it.h"
|
#include "stm32f0xx_it.h"
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@ -159,5 +160,5 @@ void TIM6_DAC_IRQHandler(void)
|
|||||||
void USB_IRQHandler(void)
|
void USB_IRQHandler(void)
|
||||||
{
|
{
|
||||||
USBD_IRQHandler(0);
|
USBD_IRQHandler(0);
|
||||||
}
|
}
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
@ -7,7 +7,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @attention
|
* @attention
|
||||||
*
|
*
|
||||||
* Copyright (c) 2023 STMicroelectronics.
|
* Copyright (c) 2021 STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
@ -37,16 +37,12 @@ extern "C" {
|
|||||||
#define AES_CLEARFLAG_CCF CRYP_CLEARFLAG_CCF
|
#define AES_CLEARFLAG_CCF CRYP_CLEARFLAG_CCF
|
||||||
#define AES_CLEARFLAG_RDERR CRYP_CLEARFLAG_RDERR
|
#define AES_CLEARFLAG_RDERR CRYP_CLEARFLAG_RDERR
|
||||||
#define AES_CLEARFLAG_WRERR CRYP_CLEARFLAG_WRERR
|
#define AES_CLEARFLAG_WRERR CRYP_CLEARFLAG_WRERR
|
||||||
#if defined(STM32U5) || defined(STM32H7) || defined(STM32MP1)
|
#if defined(STM32H7) || defined(STM32MP1)
|
||||||
#define CRYP_DATATYPE_32B CRYP_NO_SWAP
|
#define CRYP_DATATYPE_32B CRYP_NO_SWAP
|
||||||
#define CRYP_DATATYPE_16B CRYP_HALFWORD_SWAP
|
#define CRYP_DATATYPE_16B CRYP_HALFWORD_SWAP
|
||||||
#define CRYP_DATATYPE_8B CRYP_BYTE_SWAP
|
#define CRYP_DATATYPE_8B CRYP_BYTE_SWAP
|
||||||
#define CRYP_DATATYPE_1B CRYP_BIT_SWAP
|
#define CRYP_DATATYPE_1B CRYP_BIT_SWAP
|
||||||
#if defined(STM32U5)
|
#endif /* STM32H7 || STM32MP1 */
|
||||||
#define CRYP_CCF_CLEAR CRYP_CLEAR_CCF
|
|
||||||
#define CRYP_ERR_CLEAR CRYP_CLEAR_RWEIF
|
|
||||||
#endif /* STM32U5 */
|
|
||||||
#endif /* STM32U5 || STM32H7 || STM32MP1 */
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@ -279,7 +275,7 @@ extern "C" {
|
|||||||
#define DAC_WAVEGENERATION_NOISE DAC_WAVE_NOISE
|
#define DAC_WAVEGENERATION_NOISE DAC_WAVE_NOISE
|
||||||
#define DAC_WAVEGENERATION_TRIANGLE DAC_WAVE_TRIANGLE
|
#define DAC_WAVEGENERATION_TRIANGLE DAC_WAVE_TRIANGLE
|
||||||
|
|
||||||
#if defined(STM32G4) || defined(STM32L5) || defined(STM32H7) || defined (STM32U5)
|
#if defined(STM32G4) || defined(STM32H7) || defined (STM32U5)
|
||||||
#define DAC_CHIPCONNECT_DISABLE DAC_CHIPCONNECT_EXTERNAL
|
#define DAC_CHIPCONNECT_DISABLE DAC_CHIPCONNECT_EXTERNAL
|
||||||
#define DAC_CHIPCONNECT_ENABLE DAC_CHIPCONNECT_INTERNAL
|
#define DAC_CHIPCONNECT_ENABLE DAC_CHIPCONNECT_INTERNAL
|
||||||
#endif
|
#endif
|
||||||
@ -552,6 +548,16 @@ extern "C" {
|
|||||||
#define OB_SRAM134_RST_ERASE OB_SRAM_RST_ERASE
|
#define OB_SRAM134_RST_ERASE OB_SRAM_RST_ERASE
|
||||||
#define OB_SRAM134_RST_NOT_ERASE OB_SRAM_RST_NOT_ERASE
|
#define OB_SRAM134_RST_NOT_ERASE OB_SRAM_RST_NOT_ERASE
|
||||||
#endif /* STM32U5 */
|
#endif /* STM32U5 */
|
||||||
|
#if defined(STM32U0)
|
||||||
|
#define OB_USER_nRST_STOP OB_USER_NRST_STOP
|
||||||
|
#define OB_USER_nRST_STDBY OB_USER_NRST_STDBY
|
||||||
|
#define OB_USER_nRST_SHDW OB_USER_NRST_SHDW
|
||||||
|
#define OB_USER_nBOOT_SEL OB_USER_NBOOT_SEL
|
||||||
|
#define OB_USER_nBOOT0 OB_USER_NBOOT0
|
||||||
|
#define OB_USER_nBOOT1 OB_USER_NBOOT1
|
||||||
|
#define OB_nBOOT0_RESET OB_NBOOT0_RESET
|
||||||
|
#define OB_nBOOT0_SET OB_NBOOT0_SET
|
||||||
|
#endif /* STM32U0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
@ -1243,10 +1249,10 @@ extern "C" {
|
|||||||
#define RTC_TAMPERPIN_PA0 RTC_TAMPERPIN_POS1
|
#define RTC_TAMPERPIN_PA0 RTC_TAMPERPIN_POS1
|
||||||
#define RTC_TAMPERPIN_PI8 RTC_TAMPERPIN_POS1
|
#define RTC_TAMPERPIN_PI8 RTC_TAMPERPIN_POS1
|
||||||
|
|
||||||
#if defined(STM32H5)
|
#if defined(STM32H5) || defined(STM32H7RS)
|
||||||
#define TAMP_SECRETDEVICE_ERASE_NONE TAMP_DEVICESECRETS_ERASE_NONE
|
#define TAMP_SECRETDEVICE_ERASE_NONE TAMP_DEVICESECRETS_ERASE_NONE
|
||||||
#define TAMP_SECRETDEVICE_ERASE_BKP_SRAM TAMP_DEVICESECRETS_ERASE_BKPSRAM
|
#define TAMP_SECRETDEVICE_ERASE_BKP_SRAM TAMP_DEVICESECRETS_ERASE_BKPSRAM
|
||||||
#endif /* STM32H5 */
|
#endif /* STM32H5 || STM32H7RS */
|
||||||
|
|
||||||
#if defined(STM32WBA)
|
#if defined(STM32WBA)
|
||||||
#define TAMP_SECRETDEVICE_ERASE_NONE TAMP_DEVICESECRETS_ERASE_NONE
|
#define TAMP_SECRETDEVICE_ERASE_NONE TAMP_DEVICESECRETS_ERASE_NONE
|
||||||
@ -1258,10 +1264,10 @@ extern "C" {
|
|||||||
#define TAMP_SECRETDEVICE_ERASE_ALL TAMP_DEVICESECRETS_ERASE_ALL
|
#define TAMP_SECRETDEVICE_ERASE_ALL TAMP_DEVICESECRETS_ERASE_ALL
|
||||||
#endif /* STM32WBA */
|
#endif /* STM32WBA */
|
||||||
|
|
||||||
#if defined(STM32H5) || defined(STM32WBA)
|
#if defined(STM32H5) || defined(STM32WBA) || defined(STM32H7RS)
|
||||||
#define TAMP_SECRETDEVICE_ERASE_DISABLE TAMP_DEVICESECRETS_ERASE_NONE
|
#define TAMP_SECRETDEVICE_ERASE_DISABLE TAMP_DEVICESECRETS_ERASE_NONE
|
||||||
#define TAMP_SECRETDEVICE_ERASE_ENABLE TAMP_SECRETDEVICE_ERASE_ALL
|
#define TAMP_SECRETDEVICE_ERASE_ENABLE TAMP_SECRETDEVICE_ERASE_ALL
|
||||||
#endif /* STM32H5 || STM32WBA */
|
#endif /* STM32H5 || STM32WBA || STM32H7RS */
|
||||||
|
|
||||||
#if defined(STM32F7)
|
#if defined(STM32F7)
|
||||||
#define RTC_TAMPCR_TAMPXE RTC_TAMPER_ENABLE_BITS_MASK
|
#define RTC_TAMPCR_TAMPXE RTC_TAMPER_ENABLE_BITS_MASK
|
||||||
@ -1599,6 +1605,8 @@ extern "C" {
|
|||||||
#define ETH_MAC_SMALL_FIFO_RW_ACTIVE 0x00000006U /* MAC small FIFO read / write controllers active */
|
#define ETH_MAC_SMALL_FIFO_RW_ACTIVE 0x00000006U /* MAC small FIFO read / write controllers active */
|
||||||
#define ETH_MAC_MII_RECEIVE_PROTOCOL_ACTIVE 0x00000001U /* MAC MII receive protocol engine active */
|
#define ETH_MAC_MII_RECEIVE_PROTOCOL_ACTIVE 0x00000001U /* MAC MII receive protocol engine active */
|
||||||
|
|
||||||
|
#define ETH_TxPacketConfig ETH_TxPacketConfigTypeDef /* Transmit Packet Configuration structure definition */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@ -1991,12 +1999,12 @@ extern "C" {
|
|||||||
/** @defgroup HAL_RTC_Aliased_Functions HAL RTC Aliased Functions maintained for legacy purpose
|
/** @defgroup HAL_RTC_Aliased_Functions HAL RTC Aliased Functions maintained for legacy purpose
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#if defined(STM32H5) || defined(STM32WBA)
|
#if defined(STM32H5) || defined(STM32WBA) || defined(STM32H7RS)
|
||||||
#define HAL_RTCEx_SetBoothardwareKey HAL_RTCEx_LockBootHardwareKey
|
#define HAL_RTCEx_SetBoothardwareKey HAL_RTCEx_LockBootHardwareKey
|
||||||
#define HAL_RTCEx_BKUPBlock_Enable HAL_RTCEx_BKUPBlock
|
#define HAL_RTCEx_BKUPBlock_Enable HAL_RTCEx_BKUPBlock
|
||||||
#define HAL_RTCEx_BKUPBlock_Disable HAL_RTCEx_BKUPUnblock
|
#define HAL_RTCEx_BKUPBlock_Disable HAL_RTCEx_BKUPUnblock
|
||||||
#define HAL_RTCEx_Erase_SecretDev_Conf HAL_RTCEx_ConfigEraseDeviceSecrets
|
#define HAL_RTCEx_Erase_SecretDev_Conf HAL_RTCEx_ConfigEraseDeviceSecrets
|
||||||
#endif /* STM32H5 || STM32WBA */
|
#endif /* STM32H5 || STM32WBA || STM32H7RS */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
@ -2311,8 +2319,8 @@ extern "C" {
|
|||||||
#define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (((__FLAG__) == COMP_EXTI_LINE_COMP2) ? __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() : \
|
#define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (((__FLAG__) == COMP_EXTI_LINE_COMP2) ? __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() : \
|
||||||
((__FLAG__) == COMP_EXTI_LINE_COMP4) ? __HAL_COMP_COMP4_EXTI_CLEAR_FLAG() : \
|
((__FLAG__) == COMP_EXTI_LINE_COMP4) ? __HAL_COMP_COMP4_EXTI_CLEAR_FLAG() : \
|
||||||
__HAL_COMP_COMP6_EXTI_CLEAR_FLAG())
|
__HAL_COMP_COMP6_EXTI_CLEAR_FLAG())
|
||||||
# endif
|
#endif
|
||||||
# if defined(STM32F302xE) || defined(STM32F302xC)
|
#if defined(STM32F302xE) || defined(STM32F302xC)
|
||||||
#define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() : \
|
#define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() : \
|
||||||
((__EXTILINE__) == COMP_EXTI_LINE_COMP2) ? __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() : \
|
((__EXTILINE__) == COMP_EXTI_LINE_COMP2) ? __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() : \
|
||||||
((__EXTILINE__) == COMP_EXTI_LINE_COMP4) ? __HAL_COMP_COMP4_EXTI_ENABLE_RISING_EDGE() : \
|
((__EXTILINE__) == COMP_EXTI_LINE_COMP4) ? __HAL_COMP_COMP4_EXTI_ENABLE_RISING_EDGE() : \
|
||||||
@ -2345,8 +2353,8 @@ extern "C" {
|
|||||||
((__FLAG__) == COMP_EXTI_LINE_COMP2) ? __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() : \
|
((__FLAG__) == COMP_EXTI_LINE_COMP2) ? __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() : \
|
||||||
((__FLAG__) == COMP_EXTI_LINE_COMP4) ? __HAL_COMP_COMP4_EXTI_CLEAR_FLAG() : \
|
((__FLAG__) == COMP_EXTI_LINE_COMP4) ? __HAL_COMP_COMP4_EXTI_CLEAR_FLAG() : \
|
||||||
__HAL_COMP_COMP6_EXTI_CLEAR_FLAG())
|
__HAL_COMP_COMP6_EXTI_CLEAR_FLAG())
|
||||||
# endif
|
#endif
|
||||||
# if defined(STM32F303xE) || defined(STM32F398xx) || defined(STM32F303xC) || defined(STM32F358xx)
|
#if defined(STM32F303xE) || defined(STM32F398xx) || defined(STM32F303xC) || defined(STM32F358xx)
|
||||||
#define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() : \
|
#define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() : \
|
||||||
((__EXTILINE__) == COMP_EXTI_LINE_COMP2) ? __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() : \
|
((__EXTILINE__) == COMP_EXTI_LINE_COMP2) ? __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() : \
|
||||||
((__EXTILINE__) == COMP_EXTI_LINE_COMP3) ? __HAL_COMP_COMP3_EXTI_ENABLE_RISING_EDGE() : \
|
((__EXTILINE__) == COMP_EXTI_LINE_COMP3) ? __HAL_COMP_COMP3_EXTI_ENABLE_RISING_EDGE() : \
|
||||||
@ -2403,8 +2411,8 @@ extern "C" {
|
|||||||
((__FLAG__) == COMP_EXTI_LINE_COMP5) ? __HAL_COMP_COMP5_EXTI_CLEAR_FLAG() : \
|
((__FLAG__) == COMP_EXTI_LINE_COMP5) ? __HAL_COMP_COMP5_EXTI_CLEAR_FLAG() : \
|
||||||
((__FLAG__) == COMP_EXTI_LINE_COMP6) ? __HAL_COMP_COMP6_EXTI_CLEAR_FLAG() : \
|
((__FLAG__) == COMP_EXTI_LINE_COMP6) ? __HAL_COMP_COMP6_EXTI_CLEAR_FLAG() : \
|
||||||
__HAL_COMP_COMP7_EXTI_CLEAR_FLAG())
|
__HAL_COMP_COMP7_EXTI_CLEAR_FLAG())
|
||||||
# endif
|
#endif
|
||||||
# if defined(STM32F373xC) ||defined(STM32F378xx)
|
#if defined(STM32F373xC) ||defined(STM32F378xx)
|
||||||
#define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() : \
|
#define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() : \
|
||||||
__HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE())
|
__HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE())
|
||||||
#define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() : \
|
#define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() : \
|
||||||
@ -2421,7 +2429,7 @@ extern "C" {
|
|||||||
__HAL_COMP_COMP2_EXTI_GET_FLAG())
|
__HAL_COMP_COMP2_EXTI_GET_FLAG())
|
||||||
#define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (((__FLAG__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() : \
|
#define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (((__FLAG__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() : \
|
||||||
__HAL_COMP_COMP2_EXTI_CLEAR_FLAG())
|
__HAL_COMP_COMP2_EXTI_CLEAR_FLAG())
|
||||||
# endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() : \
|
#define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (((__EXTILINE__) == COMP_EXTI_LINE_COMP1) ? __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() : \
|
||||||
__HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE())
|
__HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE())
|
||||||
@ -2723,6 +2731,12 @@ extern "C" {
|
|||||||
#define __APB1_RELEASE_RESET __HAL_RCC_APB1_RELEASE_RESET
|
#define __APB1_RELEASE_RESET __HAL_RCC_APB1_RELEASE_RESET
|
||||||
#define __APB2_FORCE_RESET __HAL_RCC_APB2_FORCE_RESET
|
#define __APB2_FORCE_RESET __HAL_RCC_APB2_FORCE_RESET
|
||||||
#define __APB2_RELEASE_RESET __HAL_RCC_APB2_RELEASE_RESET
|
#define __APB2_RELEASE_RESET __HAL_RCC_APB2_RELEASE_RESET
|
||||||
|
#if defined(STM32C0)
|
||||||
|
#define __HAL_RCC_APB1_FORCE_RESET __HAL_RCC_APB1_GRP1_FORCE_RESET
|
||||||
|
#define __HAL_RCC_APB1_RELEASE_RESET __HAL_RCC_APB1_GRP1_RELEASE_RESET
|
||||||
|
#define __HAL_RCC_APB2_FORCE_RESET __HAL_RCC_APB1_GRP2_FORCE_RESET
|
||||||
|
#define __HAL_RCC_APB2_RELEASE_RESET __HAL_RCC_APB1_GRP2_RELEASE_RESET
|
||||||
|
#endif /* STM32C0 */
|
||||||
#define __BKP_CLK_DISABLE __HAL_RCC_BKP_CLK_DISABLE
|
#define __BKP_CLK_DISABLE __HAL_RCC_BKP_CLK_DISABLE
|
||||||
#define __BKP_CLK_ENABLE __HAL_RCC_BKP_CLK_ENABLE
|
#define __BKP_CLK_ENABLE __HAL_RCC_BKP_CLK_ENABLE
|
||||||
#define __BKP_FORCE_RESET __HAL_RCC_BKP_FORCE_RESET
|
#define __BKP_FORCE_RESET __HAL_RCC_BKP_FORCE_RESET
|
||||||
@ -3646,8 +3660,12 @@ extern "C" {
|
|||||||
#define RCC_MCOSOURCE_PLLCLK_NODIV RCC_MCO1SOURCE_PLLCLK
|
#define RCC_MCOSOURCE_PLLCLK_NODIV RCC_MCO1SOURCE_PLLCLK
|
||||||
#define RCC_MCOSOURCE_PLLCLK_DIV2 RCC_MCO1SOURCE_PLLCLK_DIV2
|
#define RCC_MCOSOURCE_PLLCLK_DIV2 RCC_MCO1SOURCE_PLLCLK_DIV2
|
||||||
|
|
||||||
|
#if defined(STM32U0)
|
||||||
|
#define RCC_SYSCLKSOURCE_STATUS_PLLR RCC_SYSCLKSOURCE_STATUS_PLLCLK
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(STM32L4) || defined(STM32WB) || defined(STM32G0) || defined(STM32G4) || defined(STM32L5) || \
|
#if defined(STM32L4) || defined(STM32WB) || defined(STM32G0) || defined(STM32G4) || defined(STM32L5) || \
|
||||||
defined(STM32WL) || defined(STM32C0)
|
defined(STM32WL) || defined(STM32C0) || defined(STM32H7RS) || defined(STM32U0)
|
||||||
#define RCC_RTCCLKSOURCE_NO_CLK RCC_RTCCLKSOURCE_NONE
|
#define RCC_RTCCLKSOURCE_NO_CLK RCC_RTCCLKSOURCE_NONE
|
||||||
#else
|
#else
|
||||||
#define RCC_RTCCLKSOURCE_NONE RCC_RTCCLKSOURCE_NO_CLK
|
#define RCC_RTCCLKSOURCE_NONE RCC_RTCCLKSOURCE_NO_CLK
|
||||||
@ -3749,8 +3767,10 @@ extern "C" {
|
|||||||
#define __HAL_RCC_GET_DFSDM_SOURCE __HAL_RCC_GET_DFSDM1_SOURCE
|
#define __HAL_RCC_GET_DFSDM_SOURCE __HAL_RCC_GET_DFSDM1_SOURCE
|
||||||
#define RCC_DFSDM1CLKSOURCE_PCLK RCC_DFSDM1CLKSOURCE_PCLK2
|
#define RCC_DFSDM1CLKSOURCE_PCLK RCC_DFSDM1CLKSOURCE_PCLK2
|
||||||
#define RCC_SWPMI1CLKSOURCE_PCLK RCC_SWPMI1CLKSOURCE_PCLK1
|
#define RCC_SWPMI1CLKSOURCE_PCLK RCC_SWPMI1CLKSOURCE_PCLK1
|
||||||
|
#if !defined(STM32U0)
|
||||||
#define RCC_LPTIM1CLKSOURCE_PCLK RCC_LPTIM1CLKSOURCE_PCLK1
|
#define RCC_LPTIM1CLKSOURCE_PCLK RCC_LPTIM1CLKSOURCE_PCLK1
|
||||||
#define RCC_LPTIM2CLKSOURCE_PCLK RCC_LPTIM2CLKSOURCE_PCLK1
|
#define RCC_LPTIM2CLKSOURCE_PCLK RCC_LPTIM2CLKSOURCE_PCLK1
|
||||||
|
#endif
|
||||||
|
|
||||||
#define RCC_DFSDM1AUDIOCLKSOURCE_I2SAPB1 RCC_DFSDM1AUDIOCLKSOURCE_I2S1
|
#define RCC_DFSDM1AUDIOCLKSOURCE_I2SAPB1 RCC_DFSDM1AUDIOCLKSOURCE_I2S1
|
||||||
#define RCC_DFSDM1AUDIOCLKSOURCE_I2SAPB2 RCC_DFSDM1AUDIOCLKSOURCE_I2S2
|
#define RCC_DFSDM1AUDIOCLKSOURCE_I2SAPB2 RCC_DFSDM1AUDIOCLKSOURCE_I2S2
|
||||||
@ -3896,7 +3916,8 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#if defined (STM32G0) || defined (STM32L5) || defined (STM32L412xx) || defined (STM32L422xx) || \
|
#if defined (STM32G0) || defined (STM32L5) || defined (STM32L412xx) || defined (STM32L422xx) || \
|
||||||
defined (STM32L4P5xx)|| defined (STM32L4Q5xx) || defined (STM32G4) || defined (STM32WL) || defined (STM32U5) || \
|
defined (STM32L4P5xx)|| defined (STM32L4Q5xx) || defined (STM32G4) || defined (STM32WL) || defined (STM32U5) || \
|
||||||
defined (STM32WBA) || defined (STM32H5) || defined (STM32C0)
|
defined (STM32WBA) || defined (STM32H5) || \
|
||||||
|
defined (STM32C0) || defined (STM32H7RS) || defined (STM32U0)
|
||||||
#else
|
#else
|
||||||
#define __HAL_RTC_CLEAR_FLAG __HAL_RTC_EXTI_CLEAR_FLAG
|
#define __HAL_RTC_CLEAR_FLAG __HAL_RTC_EXTI_CLEAR_FLAG
|
||||||
#endif
|
#endif
|
||||||
@ -3931,6 +3952,13 @@ extern "C" {
|
|||||||
__HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT()))
|
__HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT()))
|
||||||
#endif /* STM32F1 */
|
#endif /* STM32F1 */
|
||||||
|
|
||||||
|
#if defined (STM32F0) || defined (STM32F2) || defined (STM32F3) || defined (STM32F4) || defined (STM32F7) || \
|
||||||
|
defined (STM32H7) || \
|
||||||
|
defined (STM32L0) || defined (STM32L1) || \
|
||||||
|
defined (STM32WB)
|
||||||
|
#define __HAL_RTC_TAMPER_GET_IT __HAL_RTC_TAMPER_GET_FLAG
|
||||||
|
#endif
|
||||||
|
|
||||||
#define IS_ALARM IS_RTC_ALARM
|
#define IS_ALARM IS_RTC_ALARM
|
||||||
#define IS_ALARM_MASK IS_RTC_ALARM_MASK
|
#define IS_ALARM_MASK IS_RTC_ALARM_MASK
|
||||||
#define IS_TAMPER IS_RTC_TAMPER
|
#define IS_TAMPER IS_RTC_TAMPER
|
||||||
@ -4212,6 +4240,9 @@ extern "C" {
|
|||||||
#define __HAL_TIM_GetCompare __HAL_TIM_GET_COMPARE
|
#define __HAL_TIM_GetCompare __HAL_TIM_GET_COMPARE
|
||||||
|
|
||||||
#define TIM_BREAKINPUTSOURCE_DFSDM TIM_BREAKINPUTSOURCE_DFSDM1
|
#define TIM_BREAKINPUTSOURCE_DFSDM TIM_BREAKINPUTSOURCE_DFSDM1
|
||||||
|
|
||||||
|
#define TIM_OCMODE_ASSYMETRIC_PWM1 TIM_OCMODE_ASYMMETRIC_PWM1
|
||||||
|
#define TIM_OCMODE_ASSYMETRIC_PWM2 TIM_OCMODE_ASYMMETRIC_PWM2
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@ -236,8 +236,8 @@ typedef enum
|
|||||||
*/
|
*/
|
||||||
#define IS_GPIO_PIN_ACTION(ACTION) (((ACTION) == GPIO_PIN_RESET) || ((ACTION) == GPIO_PIN_SET))
|
#define IS_GPIO_PIN_ACTION(ACTION) (((ACTION) == GPIO_PIN_RESET) || ((ACTION) == GPIO_PIN_SET))
|
||||||
|
|
||||||
#define IS_GPIO_PIN(__PIN__) (((((uint32_t)__PIN__) & GPIO_PIN_MASK) != 0x00U) &&\
|
#define IS_GPIO_PIN(__PIN__) (((((uint32_t)(__PIN__)) & GPIO_PIN_MASK) != 0x00U) &&\
|
||||||
((((uint32_t)__PIN__) & ~GPIO_PIN_MASK) == 0x00U))
|
((((uint32_t)(__PIN__)) & ~GPIO_PIN_MASK) == 0x00U))
|
||||||
|
|
||||||
#define IS_GPIO_MODE(__MODE__) (((__MODE__) == GPIO_MODE_INPUT) ||\
|
#define IS_GPIO_MODE(__MODE__) (((__MODE__) == GPIO_MODE_INPUT) ||\
|
||||||
((__MODE__) == GPIO_MODE_OUTPUT_PP) ||\
|
((__MODE__) == GPIO_MODE_OUTPUT_PP) ||\
|
||||||
@ -118,8 +118,6 @@ typedef enum
|
|||||||
HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
|
HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
|
||||||
process is ongoing */
|
process is ongoing */
|
||||||
HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
|
HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
|
||||||
HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
|
|
||||||
HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */
|
|
||||||
|
|
||||||
} HAL_I2C_StateTypeDef;
|
} HAL_I2C_StateTypeDef;
|
||||||
|
|
||||||
@ -385,29 +385,28 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
HAL_TIM_BASE_MSPINIT_CB_ID = 0x00U /*!< TIM Base MspInit Callback ID */
|
HAL_TIM_BASE_MSPINIT_CB_ID = 0x00U /*!< TIM Base MspInit Callback ID */
|
||||||
, HAL_TIM_BASE_MSPDEINIT_CB_ID = 0x01U /*!< TIM Base MspDeInit Callback ID */
|
, HAL_TIM_BASE_MSPDEINIT_CB_ID = 0x01U /*!< TIM Base MspDeInit Callback ID */
|
||||||
, HAL_TIM_IC_MSPINIT_CB_ID = 0x02U /*!< TIM IC MspInit Callback ID */
|
, HAL_TIM_IC_MSPINIT_CB_ID = 0x02U /*!< TIM IC MspInit Callback ID */
|
||||||
, HAL_TIM_IC_MSPDEINIT_CB_ID = 0x03U /*!< TIM IC MspDeInit Callback ID */
|
, HAL_TIM_IC_MSPDEINIT_CB_ID = 0x03U /*!< TIM IC MspDeInit Callback ID */
|
||||||
, HAL_TIM_OC_MSPINIT_CB_ID = 0x04U /*!< TIM OC MspInit Callback ID */
|
, HAL_TIM_OC_MSPINIT_CB_ID = 0x04U /*!< TIM OC MspInit Callback ID */
|
||||||
, HAL_TIM_OC_MSPDEINIT_CB_ID = 0x05U /*!< TIM OC MspDeInit Callback ID */
|
, HAL_TIM_OC_MSPDEINIT_CB_ID = 0x05U /*!< TIM OC MspDeInit Callback ID */
|
||||||
, HAL_TIM_PWM_MSPINIT_CB_ID = 0x06U /*!< TIM PWM MspInit Callback ID */
|
, HAL_TIM_PWM_MSPINIT_CB_ID = 0x06U /*!< TIM PWM MspInit Callback ID */
|
||||||
, HAL_TIM_PWM_MSPDEINIT_CB_ID = 0x07U /*!< TIM PWM MspDeInit Callback ID */
|
, HAL_TIM_PWM_MSPDEINIT_CB_ID = 0x07U /*!< TIM PWM MspDeInit Callback ID */
|
||||||
, HAL_TIM_ONE_PULSE_MSPINIT_CB_ID = 0x08U /*!< TIM One Pulse MspInit Callback ID */
|
, HAL_TIM_ONE_PULSE_MSPINIT_CB_ID = 0x08U /*!< TIM One Pulse MspInit Callback ID */
|
||||||
, HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID = 0x09U /*!< TIM One Pulse MspDeInit Callback ID */
|
, HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID = 0x09U /*!< TIM One Pulse MspDeInit Callback ID */
|
||||||
, HAL_TIM_ENCODER_MSPINIT_CB_ID = 0x0AU /*!< TIM Encoder MspInit Callback ID */
|
, HAL_TIM_ENCODER_MSPINIT_CB_ID = 0x0AU /*!< TIM Encoder MspInit Callback ID */
|
||||||
, HAL_TIM_ENCODER_MSPDEINIT_CB_ID = 0x0BU /*!< TIM Encoder MspDeInit Callback ID */
|
, HAL_TIM_ENCODER_MSPDEINIT_CB_ID = 0x0BU /*!< TIM Encoder MspDeInit Callback ID */
|
||||||
, HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID = 0x0CU /*!< TIM Hall Sensor MspDeInit Callback ID */
|
, HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID = 0x0CU /*!< TIM Hall Sensor MspDeInit Callback ID */
|
||||||
, HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID = 0x0DU /*!< TIM Hall Sensor MspDeInit Callback ID */
|
, HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID = 0x0DU /*!< TIM Hall Sensor MspDeInit Callback ID */
|
||||||
, HAL_TIM_PERIOD_ELAPSED_CB_ID = 0x0EU /*!< TIM Period Elapsed Callback ID */
|
, HAL_TIM_PERIOD_ELAPSED_CB_ID = 0x0EU /*!< TIM Period Elapsed Callback ID */
|
||||||
, HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID = 0x0FU /*!< TIM Period Elapsed half complete Callback ID */
|
, HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID = 0x0FU /*!< TIM Period Elapsed half complete Callback ID */
|
||||||
, HAL_TIM_TRIGGER_CB_ID = 0x10U /*!< TIM Trigger Callback ID */
|
, HAL_TIM_TRIGGER_CB_ID = 0x10U /*!< TIM Trigger Callback ID */
|
||||||
, HAL_TIM_TRIGGER_HALF_CB_ID = 0x11U /*!< TIM Trigger half complete Callback ID */
|
, HAL_TIM_TRIGGER_HALF_CB_ID = 0x11U /*!< TIM Trigger half complete Callback ID */
|
||||||
|
|
||||||
, HAL_TIM_IC_CAPTURE_CB_ID = 0x12U /*!< TIM Input Capture Callback ID */
|
, HAL_TIM_IC_CAPTURE_CB_ID = 0x12U /*!< TIM Input Capture Callback ID */
|
||||||
, HAL_TIM_IC_CAPTURE_HALF_CB_ID = 0x13U /*!< TIM Input Capture half complete Callback ID */
|
, HAL_TIM_IC_CAPTURE_HALF_CB_ID = 0x13U /*!< TIM Input Capture half complete Callback ID */
|
||||||
, HAL_TIM_OC_DELAY_ELAPSED_CB_ID = 0x14U /*!< TIM Output Compare Delay Elapsed Callback ID */
|
, HAL_TIM_OC_DELAY_ELAPSED_CB_ID = 0x14U /*!< TIM Output Compare Delay Elapsed Callback ID */
|
||||||
, HAL_TIM_PWM_PULSE_FINISHED_CB_ID = 0x15U /*!< TIM PWM Pulse Finished Callback ID */
|
, HAL_TIM_PWM_PULSE_FINISHED_CB_ID = 0x15U /*!< TIM PWM Pulse Finished Callback ID */
|
||||||
, HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID = 0x16U /*!< TIM PWM Pulse Finished half complete Callback ID */
|
, HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID = 0x16U /*!< TIM PWM Pulse Finished half complete Callback ID */
|
||||||
, HAL_TIM_ERROR_CB_ID = 0x17U /*!< TIM Error Callback ID */
|
, HAL_TIM_ERROR_CB_ID = 0x17U /*!< TIM Error Callback ID */
|
||||||
, HAL_TIM_COMMUTATION_CB_ID = 0x18U /*!< TIM Commutation Callback ID */
|
, HAL_TIM_COMMUTATION_CB_ID = 0x18U /*!< TIM Commutation Callback ID */
|
||||||
@ -1656,8 +1655,9 @@ typedef void (*pTIM_CallbackTypeDef)(TIM_HandleTypeDef *htim); /*!< pointer to
|
|||||||
#define IS_TIM_OPM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
#define IS_TIM_OPM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2))
|
((__CHANNEL__) == TIM_CHANNEL_2))
|
||||||
|
|
||||||
#define IS_TIM_PERIOD(__HANDLE__, __PERIOD__) \
|
#define IS_TIM_PERIOD(__HANDLE__, __PERIOD__) ((IS_TIM_32B_COUNTER_INSTANCE(((__HANDLE__)->Instance)) == 0U) ? \
|
||||||
((IS_TIM_32B_COUNTER_INSTANCE(((__HANDLE__)->Instance)) == 0U) ? (((__PERIOD__) > 0U) && ((__PERIOD__) <= 0x0000FFFFU)) : ((__PERIOD__) > 0U))
|
(((__PERIOD__) > 0U) && ((__PERIOD__) <= 0x0000FFFFU)) : \
|
||||||
|
((__PERIOD__) > 0U))
|
||||||
|
|
||||||
#define IS_TIM_COMPLEMENTARY_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
#define IS_TIM_COMPLEMENTARY_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2) || \
|
((__CHANNEL__) == TIM_CHANNEL_2) || \
|
||||||
@ -1710,7 +1710,6 @@ typedef void (*pTIM_CallbackTypeDef)(TIM_HandleTypeDef *htim); /*!< pointer to
|
|||||||
|
|
||||||
#define IS_TIM_BREAK_FILTER(__BRKFILTER__) ((__BRKFILTER__) <= 0xFUL)
|
#define IS_TIM_BREAK_FILTER(__BRKFILTER__) ((__BRKFILTER__) <= 0xFUL)
|
||||||
|
|
||||||
|
|
||||||
#define IS_TIM_BREAK_STATE(__STATE__) (((__STATE__) == TIM_BREAK_ENABLE) || \
|
#define IS_TIM_BREAK_STATE(__STATE__) (((__STATE__) == TIM_BREAK_ENABLE) || \
|
||||||
((__STATE__) == TIM_BREAK_DISABLE))
|
((__STATE__) == TIM_BREAK_DISABLE))
|
||||||
|
|
||||||
@ -2048,7 +2047,8 @@ HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_S
|
|||||||
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro(TIM_HandleTypeDef *htim, const TIM_SlaveConfigTypeDef *sSlaveConfig);
|
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro(TIM_HandleTypeDef *htim, const TIM_SlaveConfigTypeDef *sSlaveConfig);
|
||||||
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro_IT(TIM_HandleTypeDef *htim, const TIM_SlaveConfigTypeDef *sSlaveConfig);
|
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro_IT(TIM_HandleTypeDef *htim, const TIM_SlaveConfigTypeDef *sSlaveConfig);
|
||||||
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
||||||
uint32_t BurstRequestSrc, const uint32_t *BurstBuffer, uint32_t BurstLength);
|
uint32_t BurstRequestSrc, const uint32_t *BurstBuffer,
|
||||||
|
uint32_t BurstLength);
|
||||||
HAL_StatusTypeDef HAL_TIM_DMABurst_MultiWriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
HAL_StatusTypeDef HAL_TIM_DMABurst_MultiWriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
||||||
uint32_t BurstRequestSrc, const uint32_t *BurstBuffer,
|
uint32_t BurstRequestSrc, const uint32_t *BurstBuffer,
|
||||||
uint32_t BurstLength, uint32_t DataLength);
|
uint32_t BurstLength, uint32_t DataLength);
|
||||||
@ -145,7 +145,7 @@ HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle(UART_HandleTypeDef *huart, uint8_t *p
|
|||||||
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
|
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
|
||||||
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
|
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
|
||||||
|
|
||||||
HAL_UART_RxEventTypeTypeDef HAL_UARTEx_GetRxEventType(UART_HandleTypeDef *huart);
|
HAL_UART_RxEventTypeTypeDef HAL_UARTEx_GetRxEventType(const UART_HandleTypeDef *huart);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -559,10 +559,10 @@ typedef struct
|
|||||||
/** @defgroup TIM_LL_EC_COUNTERMODE Counter Mode
|
/** @defgroup TIM_LL_EC_COUNTERMODE Counter Mode
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define LL_TIM_COUNTERMODE_UP 0x00000000U /*!<Counter used as upcounter */
|
#define LL_TIM_COUNTERMODE_UP 0x00000000U /*!< Counter used as upcounter */
|
||||||
#define LL_TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as downcounter */
|
#define LL_TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as downcounter */
|
||||||
#define LL_TIM_COUNTERMODE_CENTER_DOWN TIM_CR1_CMS_0 /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting down. */
|
#define LL_TIM_COUNTERMODE_CENTER_DOWN TIM_CR1_CMS_0 /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting down. */
|
||||||
#define LL_TIM_COUNTERMODE_CENTER_UP TIM_CR1_CMS_1 /*!<The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up */
|
#define LL_TIM_COUNTERMODE_CENTER_UP TIM_CR1_CMS_1 /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up */
|
||||||
#define LL_TIM_COUNTERMODE_CENTER_UP_DOWN TIM_CR1_CMS /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up or down. */
|
#define LL_TIM_COUNTERMODE_CENTER_UP_DOWN TIM_CR1_CMS /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up or down. */
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
@ -822,11 +822,11 @@ typedef struct
|
|||||||
#define LL_TIM_ETR_FILTER_FDIV2_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/2, N=8 */
|
#define LL_TIM_ETR_FILTER_FDIV2_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/2, N=8 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV4_N6 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/4, N=6 */
|
#define LL_TIM_ETR_FILTER_FDIV4_N6 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/4, N=6 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV4_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/4, N=8 */
|
#define LL_TIM_ETR_FILTER_FDIV4_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/4, N=8 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV8_N6 TIM_SMCR_ETF_3 /*!< fSAMPLING=fDTS/8, N=8 */
|
#define LL_TIM_ETR_FILTER_FDIV8_N6 TIM_SMCR_ETF_3 /*!< fSAMPLING=fDTS/8, N=6 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV8_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=5 */
|
#define LL_TIM_ETR_FILTER_FDIV8_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=8 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV16_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/16, N=6 */
|
#define LL_TIM_ETR_FILTER_FDIV16_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/16, N=5 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV16_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=8 */
|
#define LL_TIM_ETR_FILTER_FDIV16_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=6 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV16_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2) /*!< fSAMPLING=fDTS/16, N=5 */
|
#define LL_TIM_ETR_FILTER_FDIV16_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2) /*!< fSAMPLING=fDTS/16, N=8 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV32_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/32, N=5 */
|
#define LL_TIM_ETR_FILTER_FDIV32_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/32, N=5 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV32_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/32, N=6 */
|
#define LL_TIM_ETR_FILTER_FDIV32_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/32, N=6 */
|
||||||
#define LL_TIM_ETR_FILTER_FDIV32_N8 TIM_SMCR_ETF /*!< fSAMPLING=fDTS/32, N=8 */
|
#define LL_TIM_ETR_FILTER_FDIV32_N8 TIM_SMCR_ETF /*!< fSAMPLING=fDTS/32, N=8 */
|
||||||
@ -1473,6 +1473,17 @@ __STATIC_INLINE void LL_TIM_CC_DisablePreload(TIM_TypeDef *TIMx)
|
|||||||
CLEAR_BIT(TIMx->CR2, TIM_CR2_CCPC);
|
CLEAR_BIT(TIMx->CR2, TIM_CR2_CCPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Indicates whether the capture/compare control bits (CCxE, CCxNE and OCxM) preload is enabled.
|
||||||
|
* @rmtoll CR2 CCPC LL_TIM_CC_IsEnabledPreload
|
||||||
|
* @param TIMx Timer instance
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_TIM_CC_IsEnabledPreload(const TIM_TypeDef *TIMx)
|
||||||
|
{
|
||||||
|
return ((READ_BIT(TIMx->CR2, TIM_CR2_CCPC) == (TIM_CR2_CCPC)) ? 1UL : 0UL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the updated source of the capture/compare control bits (CCxE, CCxNE and OCxM).
|
* @brief Set the updated source of the capture/compare control bits (CCxE, CCxNE and OCxM).
|
||||||
* @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
|
* @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
|
||||||
@ -213,7 +213,7 @@ __STATIC_INLINE uint32_t LL_GetFlashSize(void)
|
|||||||
* @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro)
|
* @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro)
|
||||||
* @note When a RTOS is used, it is recommended to avoid changing the SysTick
|
* @note When a RTOS is used, it is recommended to avoid changing the SysTick
|
||||||
* configuration by calling this function, for a delay use rather osDelay RTOS service.
|
* configuration by calling this function, for a delay use rather osDelay RTOS service.
|
||||||
* @param Ticks Number of ticks
|
* @param Ticks Frequency of Ticks (Hz)
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
__STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks)
|
__STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks)
|
||||||
@ -56,7 +56,7 @@
|
|||||||
*/
|
*/
|
||||||
#define __STM32F0xx_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */
|
#define __STM32F0xx_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */
|
||||||
#define __STM32F0xx_HAL_VERSION_SUB1 (0x07U) /*!< [23:16] sub1 version */
|
#define __STM32F0xx_HAL_VERSION_SUB1 (0x07U) /*!< [23:16] sub1 version */
|
||||||
#define __STM32F0xx_HAL_VERSION_SUB2 (0x07U) /*!< [15:8] sub2 version */
|
#define __STM32F0xx_HAL_VERSION_SUB2 (0x08U) /*!< [15:8] sub2 version */
|
||||||
#define __STM32F0xx_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */
|
#define __STM32F0xx_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */
|
||||||
#define __STM32F0xx_HAL_VERSION ((__STM32F0xx_HAL_VERSION_MAIN << 24U)\
|
#define __STM32F0xx_HAL_VERSION ((__STM32F0xx_HAL_VERSION_MAIN << 24U)\
|
||||||
|(__STM32F0xx_HAL_VERSION_SUB1 << 16U)\
|
|(__STM32F0xx_HAL_VERSION_SUB1 << 16U)\
|
||||||
@ -133,10 +133,13 @@
|
|||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
|
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
|
||||||
{
|
{
|
||||||
/* Check the parameters */
|
/* Check the parameters */
|
||||||
assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority));
|
assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority));
|
||||||
NVIC_SetPriority(IRQn,PreemptPriority);
|
NVIC_SetPriority(IRQn,PreemptPriority);
|
||||||
|
|
||||||
|
/* Prevent unused argument(s) compilation warning */
|
||||||
|
UNUSED(SubPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +64,7 @@
|
|||||||
(++) Provide exiting handle as parameter.
|
(++) Provide exiting handle as parameter.
|
||||||
(++) Provide pointer on EXTI_ConfigTypeDef structure as second parameter.
|
(++) Provide pointer on EXTI_ConfigTypeDef structure as second parameter.
|
||||||
|
|
||||||
(#) Clear Exti configuration of a dedicated line using HAL_EXTI_GetConfigLine().
|
(#) Clear Exti configuration of a dedicated line using HAL_EXTI_ClearConfigLine().
|
||||||
(++) Provide exiting handle as parameter.
|
(++) Provide exiting handle as parameter.
|
||||||
|
|
||||||
(#) Register callback to treat Exti interrupts using HAL_EXTI_RegisterCallback().
|
(#) Register callback to treat Exti interrupts using HAL_EXTI_RegisterCallback().
|
||||||
@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
(#) Get interrupt pending bit using HAL_EXTI_GetPending().
|
(#) Get interrupt pending bit using HAL_EXTI_GetPending().
|
||||||
|
|
||||||
(#) Clear interrupt pending bit using HAL_EXTI_GetPending().
|
(#) Clear interrupt pending bit using HAL_EXTI_ClearPending().
|
||||||
|
|
||||||
(#) Generate software interrupt using HAL_EXTI_GenerateSWI().
|
(#) Generate software interrupt using HAL_EXTI_GenerateSWI().
|
||||||
|
|
||||||
@ -456,7 +456,7 @@ void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
|
|||||||
* until the next reset.
|
* until the next reset.
|
||||||
* @param GPIOx where x can be (A..F) to select the GPIO peripheral for STM32F0 family
|
* @param GPIOx where x can be (A..F) to select the GPIO peripheral for STM32F0 family
|
||||||
* @param GPIO_Pin specifies the port bits to be locked.
|
* @param GPIO_Pin specifies the port bits to be locked.
|
||||||
* This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
|
* This parameter can be any combination of GPIO_PIN_x where x can be (0..15).
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
|
HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
|
||||||
@ -90,7 +90,7 @@
|
|||||||
add their own code by customization of function pointer HAL_I2C_SlaveRxCpltCallback()
|
add their own code by customization of function pointer HAL_I2C_SlaveRxCpltCallback()
|
||||||
(+) In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and users can
|
(+) In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and users can
|
||||||
add their own code by customization of function pointer HAL_I2C_ErrorCallback()
|
add their own code by customization of function pointer HAL_I2C_ErrorCallback()
|
||||||
(+) Abort a master I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT()
|
(+) Abort a master or memory I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT()
|
||||||
(+) End of abort process, HAL_I2C_AbortCpltCallback() is executed and users can
|
(+) End of abort process, HAL_I2C_AbortCpltCallback() is executed and users can
|
||||||
add their own code by customization of function pointer HAL_I2C_AbortCpltCallback()
|
add their own code by customization of function pointer HAL_I2C_AbortCpltCallback()
|
||||||
(+) Discard a slave I2C process communication using __HAL_I2C_GENERATE_NACK() macro.
|
(+) Discard a slave I2C process communication using __HAL_I2C_GENERATE_NACK() macro.
|
||||||
@ -156,7 +156,7 @@
|
|||||||
HAL_I2C_Master_Seq_Receive_IT() or using HAL_I2C_Master_Seq_Receive_DMA()
|
HAL_I2C_Master_Seq_Receive_IT() or using HAL_I2C_Master_Seq_Receive_DMA()
|
||||||
(+++) At reception end of current frame transfer, HAL_I2C_MasterRxCpltCallback() is executed and users can
|
(+++) At reception end of current frame transfer, HAL_I2C_MasterRxCpltCallback() is executed and users can
|
||||||
add their own code by customization of function pointer HAL_I2C_MasterRxCpltCallback()
|
add their own code by customization of function pointer HAL_I2C_MasterRxCpltCallback()
|
||||||
(++) Abort a master IT or DMA I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT()
|
(++) Abort a master or memory IT or DMA I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT()
|
||||||
(+++) End of abort process, HAL_I2C_AbortCpltCallback() is executed and users can
|
(+++) End of abort process, HAL_I2C_AbortCpltCallback() is executed and users can
|
||||||
add their own code by customization of function pointer HAL_I2C_AbortCpltCallback()
|
add their own code by customization of function pointer HAL_I2C_AbortCpltCallback()
|
||||||
(++) Enable/disable the Address listen mode in slave I2C mode using HAL_I2C_EnableListen_IT()
|
(++) Enable/disable the Address listen mode in slave I2C mode using HAL_I2C_EnableListen_IT()
|
||||||
@ -214,7 +214,7 @@
|
|||||||
add their own code by customization of function pointer HAL_I2C_SlaveRxCpltCallback()
|
add their own code by customization of function pointer HAL_I2C_SlaveRxCpltCallback()
|
||||||
(+) In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and users can
|
(+) In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and users can
|
||||||
add their own code by customization of function pointer HAL_I2C_ErrorCallback()
|
add their own code by customization of function pointer HAL_I2C_ErrorCallback()
|
||||||
(+) Abort a master I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT()
|
(+) Abort a master or memory I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT()
|
||||||
(+) End of abort process, HAL_I2C_AbortCpltCallback() is executed and users can
|
(+) End of abort process, HAL_I2C_AbortCpltCallback() is executed and users can
|
||||||
add their own code by customization of function pointer HAL_I2C_AbortCpltCallback()
|
add their own code by customization of function pointer HAL_I2C_AbortCpltCallback()
|
||||||
(+) Discard a slave I2C process communication using __HAL_I2C_GENERATE_NACK() macro.
|
(+) Discard a slave I2C process communication using __HAL_I2C_GENERATE_NACK() macro.
|
||||||
@ -608,7 +608,12 @@ HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c)
|
|||||||
/* Configure I2Cx: Addressing Master mode */
|
/* Configure I2Cx: Addressing Master mode */
|
||||||
if (hi2c->Init.AddressingMode == I2C_ADDRESSINGMODE_10BIT)
|
if (hi2c->Init.AddressingMode == I2C_ADDRESSINGMODE_10BIT)
|
||||||
{
|
{
|
||||||
hi2c->Instance->CR2 = (I2C_CR2_ADD10);
|
SET_BIT(hi2c->Instance->CR2, I2C_CR2_ADD10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Clear the I2C ADD10 bit */
|
||||||
|
CLEAR_BIT(hi2c->Instance->CR2, I2C_CR2_ADD10);
|
||||||
}
|
}
|
||||||
/* Enable the AUTOEND by default, and enable NACK (should be disable only during Slave process */
|
/* Enable the AUTOEND by default, and enable NACK (should be disable only during Slave process */
|
||||||
hi2c->Instance->CR2 |= (I2C_CR2_AUTOEND | I2C_CR2_NACK);
|
hi2c->Instance->CR2 |= (I2C_CR2_AUTOEND | I2C_CR2_NACK);
|
||||||
@ -1115,6 +1120,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevA
|
|||||||
uint16_t Size, uint32_t Timeout)
|
uint16_t Size, uint32_t Timeout)
|
||||||
{
|
{
|
||||||
uint32_t tickstart;
|
uint32_t tickstart;
|
||||||
|
uint32_t xfermode;
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
if (hi2c->State == HAL_I2C_STATE_READY)
|
||||||
{
|
{
|
||||||
@ -1138,18 +1144,39 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevA
|
|||||||
hi2c->XferCount = Size;
|
hi2c->XferCount = Size;
|
||||||
hi2c->XferISR = NULL;
|
hi2c->XferISR = NULL;
|
||||||
|
|
||||||
/* Send Slave Address */
|
|
||||||
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
hi2c->XferSize = MAX_NBYTE_SIZE;
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, I2C_RELOAD_MODE,
|
xfermode = I2C_RELOAD_MODE;
|
||||||
I2C_GENERATE_START_WRITE);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hi2c->XferSize = hi2c->XferCount;
|
hi2c->XferSize = hi2c->XferCount;
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, I2C_AUTOEND_MODE,
|
xfermode = I2C_AUTOEND_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hi2c->XferSize > 0U)
|
||||||
|
{
|
||||||
|
/* Preload TX register */
|
||||||
|
/* Write data to TXDR */
|
||||||
|
hi2c->Instance->TXDR = *hi2c->pBuffPtr;
|
||||||
|
|
||||||
|
/* Increment Buffer pointer */
|
||||||
|
hi2c->pBuffPtr++;
|
||||||
|
|
||||||
|
hi2c->XferCount--;
|
||||||
|
hi2c->XferSize--;
|
||||||
|
|
||||||
|
/* Send Slave Address */
|
||||||
|
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)(hi2c->XferSize + 1U), xfermode,
|
||||||
|
I2C_GENERATE_START_WRITE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Send Slave Address */
|
||||||
|
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, xfermode,
|
||||||
I2C_GENERATE_START_WRITE);
|
I2C_GENERATE_START_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1261,7 +1288,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAd
|
|||||||
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
hi2c->XferSize = 1U;
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, I2C_RELOAD_MODE,
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, I2C_RELOAD_MODE,
|
||||||
I2C_GENERATE_START_READ);
|
I2C_GENERATE_START_READ);
|
||||||
}
|
}
|
||||||
@ -1352,6 +1379,8 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData
|
|||||||
uint32_t Timeout)
|
uint32_t Timeout)
|
||||||
{
|
{
|
||||||
uint32_t tickstart;
|
uint32_t tickstart;
|
||||||
|
uint16_t tmpXferCount;
|
||||||
|
HAL_StatusTypeDef error;
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
if (hi2c->State == HAL_I2C_STATE_READY)
|
||||||
{
|
{
|
||||||
@ -1378,14 +1407,6 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData
|
|||||||
/* Enable Address Acknowledge */
|
/* Enable Address Acknowledge */
|
||||||
hi2c->Instance->CR2 &= ~I2C_CR2_NACK;
|
hi2c->Instance->CR2 &= ~I2C_CR2_NACK;
|
||||||
|
|
||||||
/* Wait until ADDR flag is set */
|
|
||||||
if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_ADDR, RESET, Timeout, tickstart) != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Disable Address Acknowledge */
|
|
||||||
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Preload TX data if no stretch enable */
|
/* Preload TX data if no stretch enable */
|
||||||
if (hi2c->Init.NoStretchMode == I2C_NOSTRETCH_ENABLE)
|
if (hi2c->Init.NoStretchMode == I2C_NOSTRETCH_ENABLE)
|
||||||
{
|
{
|
||||||
@ -1399,6 +1420,18 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData
|
|||||||
hi2c->XferCount--;
|
hi2c->XferCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wait until ADDR flag is set */
|
||||||
|
if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_ADDR, RESET, Timeout, tickstart) != HAL_OK)
|
||||||
|
{
|
||||||
|
/* Disable Address Acknowledge */
|
||||||
|
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
||||||
|
|
||||||
|
/* Flush TX register */
|
||||||
|
I2C_Flush_TXDR(hi2c);
|
||||||
|
|
||||||
|
return HAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear ADDR flag */
|
/* Clear ADDR flag */
|
||||||
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_ADDR);
|
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_ADDR);
|
||||||
|
|
||||||
@ -1410,6 +1443,10 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData
|
|||||||
{
|
{
|
||||||
/* Disable Address Acknowledge */
|
/* Disable Address Acknowledge */
|
||||||
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
||||||
|
|
||||||
|
/* Flush TX register */
|
||||||
|
I2C_Flush_TXDR(hi2c);
|
||||||
|
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1422,6 +1459,10 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData
|
|||||||
{
|
{
|
||||||
/* Disable Address Acknowledge */
|
/* Disable Address Acknowledge */
|
||||||
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
||||||
|
|
||||||
|
/* Flush TX register */
|
||||||
|
I2C_Flush_TXDR(hi2c);
|
||||||
|
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1445,31 +1486,48 @@ HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Wait until AF flag is set */
|
/* Wait until AF flag is set */
|
||||||
if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_AF, RESET, Timeout, tickstart) != HAL_OK)
|
error = I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_AF, RESET, Timeout, tickstart);
|
||||||
|
|
||||||
|
if (error != HAL_OK)
|
||||||
{
|
{
|
||||||
/* Disable Address Acknowledge */
|
/* Check that I2C transfer finished */
|
||||||
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
/* if yes, normal use case, a NACK is sent by the MASTER when Transfer is finished */
|
||||||
return HAL_ERROR;
|
/* Mean XferCount == 0 */
|
||||||
|
|
||||||
|
tmpXferCount = hi2c->XferCount;
|
||||||
|
if ((hi2c->ErrorCode == HAL_I2C_ERROR_AF) && (tmpXferCount == 0U))
|
||||||
|
{
|
||||||
|
/* Reset ErrorCode to NONE */
|
||||||
|
hi2c->ErrorCode = HAL_I2C_ERROR_NONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Disable Address Acknowledge */
|
||||||
|
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
||||||
|
return HAL_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* Flush TX register */
|
|
||||||
I2C_Flush_TXDR(hi2c);
|
|
||||||
|
|
||||||
/* Clear AF flag */
|
|
||||||
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_AF);
|
|
||||||
|
|
||||||
/* Wait until STOP flag is set */
|
|
||||||
if (I2C_WaitOnSTOPFlagUntilTimeout(hi2c, Timeout, tickstart) != HAL_OK)
|
|
||||||
{
|
{
|
||||||
/* Disable Address Acknowledge */
|
/* Flush TX register */
|
||||||
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
I2C_Flush_TXDR(hi2c);
|
||||||
|
|
||||||
return HAL_ERROR;
|
/* Clear AF flag */
|
||||||
|
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_AF);
|
||||||
|
|
||||||
|
/* Wait until STOP flag is set */
|
||||||
|
if (I2C_WaitOnSTOPFlagUntilTimeout(hi2c, Timeout, tickstart) != HAL_OK)
|
||||||
|
{
|
||||||
|
/* Disable Address Acknowledge */
|
||||||
|
hi2c->Instance->CR2 |= I2C_CR2_NACK;
|
||||||
|
|
||||||
|
return HAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear STOP flag */
|
||||||
|
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear STOP flag */
|
|
||||||
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF);
|
|
||||||
|
|
||||||
/* Wait until BUSY flag is reset */
|
/* Wait until BUSY flag is reset */
|
||||||
if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_BUSY, SET, Timeout, tickstart) != HAL_OK)
|
if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_BUSY, SET, Timeout, tickstart) != HAL_OK)
|
||||||
{
|
{
|
||||||
@ -1672,7 +1730,26 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t D
|
|||||||
|
|
||||||
/* Send Slave Address */
|
/* Send Slave Address */
|
||||||
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE */
|
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE */
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, xfermode, I2C_GENERATE_START_WRITE);
|
if (hi2c->XferSize > 0U)
|
||||||
|
{
|
||||||
|
/* Preload TX register */
|
||||||
|
/* Write data to TXDR */
|
||||||
|
hi2c->Instance->TXDR = *hi2c->pBuffPtr;
|
||||||
|
|
||||||
|
/* Increment Buffer pointer */
|
||||||
|
hi2c->pBuffPtr++;
|
||||||
|
|
||||||
|
hi2c->XferCount--;
|
||||||
|
hi2c->XferSize--;
|
||||||
|
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)(hi2c->XferSize + 1U), xfermode,
|
||||||
|
I2C_GENERATE_START_WRITE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, xfermode,
|
||||||
|
I2C_GENERATE_START_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
/* Process Unlocked */
|
/* Process Unlocked */
|
||||||
__HAL_UNLOCK(hi2c);
|
__HAL_UNLOCK(hi2c);
|
||||||
@ -1732,7 +1809,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t De
|
|||||||
|
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
hi2c->XferSize = 1U;
|
||||||
xfermode = I2C_RELOAD_MODE;
|
xfermode = I2C_RELOAD_MODE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1895,6 +1972,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t
|
|||||||
{
|
{
|
||||||
uint32_t xfermode;
|
uint32_t xfermode;
|
||||||
HAL_StatusTypeDef dmaxferstatus;
|
HAL_StatusTypeDef dmaxferstatus;
|
||||||
|
uint32_t sizetoxfer = 0U;
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
if (hi2c->State == HAL_I2C_STATE_READY)
|
||||||
{
|
{
|
||||||
@ -1927,6 +2005,20 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t
|
|||||||
xfermode = I2C_AUTOEND_MODE;
|
xfermode = I2C_AUTOEND_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hi2c->XferSize > 0U)
|
||||||
|
{
|
||||||
|
/* Preload TX register */
|
||||||
|
/* Write data to TXDR */
|
||||||
|
hi2c->Instance->TXDR = *hi2c->pBuffPtr;
|
||||||
|
|
||||||
|
/* Increment Buffer pointer */
|
||||||
|
hi2c->pBuffPtr++;
|
||||||
|
|
||||||
|
sizetoxfer = hi2c->XferSize;
|
||||||
|
hi2c->XferCount--;
|
||||||
|
hi2c->XferSize--;
|
||||||
|
}
|
||||||
|
|
||||||
if (hi2c->XferSize > 0U)
|
if (hi2c->XferSize > 0U)
|
||||||
{
|
{
|
||||||
if (hi2c->hdmatx != NULL)
|
if (hi2c->hdmatx != NULL)
|
||||||
@ -1942,8 +2034,8 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t
|
|||||||
hi2c->hdmatx->XferAbortCallback = NULL;
|
hi2c->hdmatx->XferAbortCallback = NULL;
|
||||||
|
|
||||||
/* Enable the DMA channel */
|
/* Enable the DMA channel */
|
||||||
dmaxferstatus = HAL_DMA_Start_IT(hi2c->hdmatx, (uint32_t)pData, (uint32_t)&hi2c->Instance->TXDR,
|
dmaxferstatus = HAL_DMA_Start_IT(hi2c->hdmatx, (uint32_t)hi2c->pBuffPtr,
|
||||||
hi2c->XferSize);
|
(uint32_t)&hi2c->Instance->TXDR, hi2c->XferSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1964,7 +2056,8 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t
|
|||||||
{
|
{
|
||||||
/* Send Slave Address */
|
/* Send Slave Address */
|
||||||
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, xfermode, I2C_GENERATE_START_WRITE);
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)(hi2c->XferSize + 1U),
|
||||||
|
xfermode, I2C_GENERATE_START_WRITE);
|
||||||
|
|
||||||
/* Update XferCount value */
|
/* Update XferCount value */
|
||||||
hi2c->XferCount -= hi2c->XferSize;
|
hi2c->XferCount -= hi2c->XferSize;
|
||||||
@ -2003,7 +2096,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t
|
|||||||
|
|
||||||
/* Send Slave Address */
|
/* Send Slave Address */
|
||||||
/* Set NBYTES to write and generate START condition */
|
/* Set NBYTES to write and generate START condition */
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, I2C_AUTOEND_MODE,
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)sizetoxfer, I2C_AUTOEND_MODE,
|
||||||
I2C_GENERATE_START_WRITE);
|
I2C_GENERATE_START_WRITE);
|
||||||
|
|
||||||
/* Process Unlocked */
|
/* Process Unlocked */
|
||||||
@ -2065,7 +2158,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t D
|
|||||||
|
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
hi2c->XferSize = 1U;
|
||||||
xfermode = I2C_RELOAD_MODE;
|
xfermode = I2C_RELOAD_MODE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2159,11 +2252,11 @@ HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t D
|
|||||||
/* Note : The I2C interrupts must be enabled after unlocking current process
|
/* Note : The I2C interrupts must be enabled after unlocking current process
|
||||||
to avoid the risk of I2C interrupt handle execution before current
|
to avoid the risk of I2C interrupt handle execution before current
|
||||||
process unlock */
|
process unlock */
|
||||||
/* Enable ERR, TC, STOP, NACK, TXI interrupt */
|
/* Enable ERR, TC, STOP, NACK, RXI interrupt */
|
||||||
/* possible to enable all of these */
|
/* possible to enable all of these */
|
||||||
/* I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI |
|
/* I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI |
|
||||||
I2C_IT_ADDRI | I2C_IT_RXI | I2C_IT_TXI */
|
I2C_IT_ADDRI | I2C_IT_RXI | I2C_IT_TXI */
|
||||||
I2C_Enable_IRQ(hi2c, I2C_XFER_TX_IT);
|
I2C_Enable_IRQ(hi2c, I2C_XFER_RX_IT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return HAL_OK;
|
return HAL_OK;
|
||||||
@ -2612,7 +2705,7 @@ HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress,
|
|||||||
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
hi2c->XferSize = 1U;
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, I2C_RELOAD_MODE,
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, I2C_RELOAD_MODE,
|
||||||
I2C_GENERATE_START_READ);
|
I2C_GENERATE_START_READ);
|
||||||
}
|
}
|
||||||
@ -2650,7 +2743,7 @@ HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress,
|
|||||||
|
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
hi2c->XferSize = 1U;
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t) hi2c->XferSize, I2C_RELOAD_MODE,
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t) hi2c->XferSize, I2C_RELOAD_MODE,
|
||||||
I2C_NO_STARTSTOP);
|
I2C_NO_STARTSTOP);
|
||||||
}
|
}
|
||||||
@ -2728,6 +2821,7 @@ HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddr
|
|||||||
hi2c->ErrorCode = HAL_I2C_ERROR_NONE;
|
hi2c->ErrorCode = HAL_I2C_ERROR_NONE;
|
||||||
|
|
||||||
/* Prepare transfer parameters */
|
/* Prepare transfer parameters */
|
||||||
|
hi2c->XferSize = 0U;
|
||||||
hi2c->pBuffPtr = pData;
|
hi2c->pBuffPtr = pData;
|
||||||
hi2c->XferCount = Size;
|
hi2c->XferCount = Size;
|
||||||
hi2c->XferOptions = I2C_NO_OPTION_FRAME;
|
hi2c->XferOptions = I2C_NO_OPTION_FRAME;
|
||||||
@ -2849,11 +2943,11 @@ HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddre
|
|||||||
to avoid the risk of I2C interrupt handle execution before current
|
to avoid the risk of I2C interrupt handle execution before current
|
||||||
process unlock */
|
process unlock */
|
||||||
|
|
||||||
/* Enable ERR, TC, STOP, NACK, RXI interrupt */
|
/* Enable ERR, TC, STOP, NACK, TXI interrupt */
|
||||||
/* possible to enable all of these */
|
/* possible to enable all of these */
|
||||||
/* I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI |
|
/* I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI |
|
||||||
I2C_IT_ADDRI | I2C_IT_RXI | I2C_IT_TXI */
|
I2C_IT_ADDRI | I2C_IT_RXI | I2C_IT_TXI */
|
||||||
I2C_Enable_IRQ(hi2c, (I2C_XFER_TX_IT | I2C_XFER_RX_IT));
|
I2C_Enable_IRQ(hi2c, I2C_XFER_TX_IT);
|
||||||
|
|
||||||
return HAL_OK;
|
return HAL_OK;
|
||||||
}
|
}
|
||||||
@ -3259,22 +3353,6 @@ HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAdd
|
|||||||
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF);
|
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the maximum allowed number of trials has been reached */
|
|
||||||
if (I2C_Trials == Trials)
|
|
||||||
{
|
|
||||||
/* Generate Stop */
|
|
||||||
hi2c->Instance->CR2 |= I2C_CR2_STOP;
|
|
||||||
|
|
||||||
/* Wait until STOPF flag is reset */
|
|
||||||
if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_STOPF, RESET, Timeout, tickstart) != HAL_OK)
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear STOP Flag */
|
|
||||||
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Increment Trials */
|
/* Increment Trials */
|
||||||
I2C_Trials++;
|
I2C_Trials++;
|
||||||
} while (I2C_Trials < Trials);
|
} while (I2C_Trials < Trials);
|
||||||
@ -3313,6 +3391,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16
|
|||||||
{
|
{
|
||||||
uint32_t xfermode;
|
uint32_t xfermode;
|
||||||
uint32_t xferrequest = I2C_GENERATE_START_WRITE;
|
uint32_t xferrequest = I2C_GENERATE_START_WRITE;
|
||||||
|
uint32_t sizetoxfer = 0U;
|
||||||
|
|
||||||
/* Check the parameters */
|
/* Check the parameters */
|
||||||
assert_param(IS_I2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
|
assert_param(IS_I2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
|
||||||
@ -3344,6 +3423,21 @@ HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16
|
|||||||
xfermode = hi2c->XferOptions;
|
xfermode = hi2c->XferOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((hi2c->XferSize > 0U) && ((XferOptions == I2C_FIRST_FRAME) || \
|
||||||
|
(XferOptions == I2C_FIRST_AND_LAST_FRAME)))
|
||||||
|
{
|
||||||
|
/* Preload TX register */
|
||||||
|
/* Write data to TXDR */
|
||||||
|
hi2c->Instance->TXDR = *hi2c->pBuffPtr;
|
||||||
|
|
||||||
|
/* Increment Buffer pointer */
|
||||||
|
hi2c->pBuffPtr++;
|
||||||
|
|
||||||
|
sizetoxfer = hi2c->XferSize;
|
||||||
|
hi2c->XferCount--;
|
||||||
|
hi2c->XferSize--;
|
||||||
|
}
|
||||||
|
|
||||||
/* If transfer direction not change and there is no request to start another frame,
|
/* If transfer direction not change and there is no request to start another frame,
|
||||||
do not generate Restart Condition */
|
do not generate Restart Condition */
|
||||||
/* Mean Previous state is same as current state */
|
/* Mean Previous state is same as current state */
|
||||||
@ -3365,7 +3459,14 @@ HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send Slave Address and set NBYTES to write */
|
/* Send Slave Address and set NBYTES to write */
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, xfermode, xferrequest);
|
if ((XferOptions == I2C_FIRST_FRAME) || (XferOptions == I2C_FIRST_AND_LAST_FRAME))
|
||||||
|
{
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)sizetoxfer, xfermode, xferrequest);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, xfermode, xferrequest);
|
||||||
|
}
|
||||||
|
|
||||||
/* Process Unlocked */
|
/* Process Unlocked */
|
||||||
__HAL_UNLOCK(hi2c);
|
__HAL_UNLOCK(hi2c);
|
||||||
@ -3405,6 +3506,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint1
|
|||||||
uint32_t xfermode;
|
uint32_t xfermode;
|
||||||
uint32_t xferrequest = I2C_GENERATE_START_WRITE;
|
uint32_t xferrequest = I2C_GENERATE_START_WRITE;
|
||||||
HAL_StatusTypeDef dmaxferstatus;
|
HAL_StatusTypeDef dmaxferstatus;
|
||||||
|
uint32_t sizetoxfer = 0U;
|
||||||
|
|
||||||
/* Check the parameters */
|
/* Check the parameters */
|
||||||
assert_param(IS_I2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
|
assert_param(IS_I2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
|
||||||
@ -3436,6 +3538,21 @@ HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint1
|
|||||||
xfermode = hi2c->XferOptions;
|
xfermode = hi2c->XferOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((hi2c->XferSize > 0U) && ((XferOptions == I2C_FIRST_FRAME) || \
|
||||||
|
(XferOptions == I2C_FIRST_AND_LAST_FRAME)))
|
||||||
|
{
|
||||||
|
/* Preload TX register */
|
||||||
|
/* Write data to TXDR */
|
||||||
|
hi2c->Instance->TXDR = *hi2c->pBuffPtr;
|
||||||
|
|
||||||
|
/* Increment Buffer pointer */
|
||||||
|
hi2c->pBuffPtr++;
|
||||||
|
|
||||||
|
sizetoxfer = hi2c->XferSize;
|
||||||
|
hi2c->XferCount--;
|
||||||
|
hi2c->XferSize--;
|
||||||
|
}
|
||||||
|
|
||||||
/* If transfer direction not change and there is no request to start another frame,
|
/* If transfer direction not change and there is no request to start another frame,
|
||||||
do not generate Restart Condition */
|
do not generate Restart Condition */
|
||||||
/* Mean Previous state is same as current state */
|
/* Mean Previous state is same as current state */
|
||||||
@ -3471,8 +3588,8 @@ HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint1
|
|||||||
hi2c->hdmatx->XferAbortCallback = NULL;
|
hi2c->hdmatx->XferAbortCallback = NULL;
|
||||||
|
|
||||||
/* Enable the DMA channel */
|
/* Enable the DMA channel */
|
||||||
dmaxferstatus = HAL_DMA_Start_IT(hi2c->hdmatx, (uint32_t)pData, (uint32_t)&hi2c->Instance->TXDR,
|
dmaxferstatus = HAL_DMA_Start_IT(hi2c->hdmatx, (uint32_t)hi2c->pBuffPtr,
|
||||||
hi2c->XferSize);
|
(uint32_t)&hi2c->Instance->TXDR, hi2c->XferSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3492,7 +3609,14 @@ HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint1
|
|||||||
if (dmaxferstatus == HAL_OK)
|
if (dmaxferstatus == HAL_OK)
|
||||||
{
|
{
|
||||||
/* Send Slave Address and set NBYTES to write */
|
/* Send Slave Address and set NBYTES to write */
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, xfermode, xferrequest);
|
if ((XferOptions == I2C_FIRST_FRAME) || (XferOptions == I2C_FIRST_AND_LAST_FRAME))
|
||||||
|
{
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)sizetoxfer, xfermode, xferrequest);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, xfermode, xferrequest);
|
||||||
|
}
|
||||||
|
|
||||||
/* Update XferCount value */
|
/* Update XferCount value */
|
||||||
hi2c->XferCount -= hi2c->XferSize;
|
hi2c->XferCount -= hi2c->XferSize;
|
||||||
@ -3531,8 +3655,14 @@ HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint1
|
|||||||
|
|
||||||
/* Send Slave Address */
|
/* Send Slave Address */
|
||||||
/* Set NBYTES to write and generate START condition */
|
/* Set NBYTES to write and generate START condition */
|
||||||
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, I2C_AUTOEND_MODE,
|
if ((XferOptions == I2C_FIRST_FRAME) || (XferOptions == I2C_FIRST_AND_LAST_FRAME))
|
||||||
I2C_GENERATE_START_WRITE);
|
{
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)sizetoxfer, xfermode, xferrequest);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
I2C_TransferConfig(hi2c, DevAddress, (uint8_t)hi2c->XferSize, xfermode, xferrequest);
|
||||||
|
}
|
||||||
|
|
||||||
/* Process Unlocked */
|
/* Process Unlocked */
|
||||||
__HAL_UNLOCK(hi2c);
|
__HAL_UNLOCK(hi2c);
|
||||||
@ -3795,11 +3925,11 @@ HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16
|
|||||||
/* Note : The I2C interrupts must be enabled after unlocking current process
|
/* Note : The I2C interrupts must be enabled after unlocking current process
|
||||||
to avoid the risk of I2C interrupt handle execution before current
|
to avoid the risk of I2C interrupt handle execution before current
|
||||||
process unlock */
|
process unlock */
|
||||||
/* Enable ERR, TC, STOP, NACK, TXI interrupt */
|
/* Enable ERR, TC, STOP, NACK, RXI interrupt */
|
||||||
/* possible to enable all of these */
|
/* possible to enable all of these */
|
||||||
/* I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI |
|
/* I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI |
|
||||||
I2C_IT_ADDRI | I2C_IT_RXI | I2C_IT_TXI */
|
I2C_IT_ADDRI | I2C_IT_RXI | I2C_IT_TXI */
|
||||||
I2C_Enable_IRQ(hi2c, I2C_XFER_TX_IT);
|
I2C_Enable_IRQ(hi2c, I2C_XFER_RX_IT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return HAL_OK;
|
return HAL_OK;
|
||||||
@ -4434,7 +4564,7 @@ HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Abort a master I2C IT or DMA process communication with Interrupt.
|
* @brief Abort a master or memory I2C IT or DMA process communication with Interrupt.
|
||||||
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
||||||
* the configuration information for the specified I2C.
|
* the configuration information for the specified I2C.
|
||||||
* @param DevAddress Target device address: The device 7 bits address value
|
* @param DevAddress Target device address: The device 7 bits address value
|
||||||
@ -4443,7 +4573,9 @@ HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c)
|
|||||||
*/
|
*/
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress)
|
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress)
|
||||||
{
|
{
|
||||||
if (hi2c->Mode == HAL_I2C_MODE_MASTER)
|
HAL_I2C_ModeTypeDef tmp_mode = hi2c->Mode;
|
||||||
|
|
||||||
|
if ((tmp_mode == HAL_I2C_MODE_MASTER) || (tmp_mode == HAL_I2C_MODE_MEM))
|
||||||
{
|
{
|
||||||
/* Process Locked */
|
/* Process Locked */
|
||||||
__HAL_LOCK(hi2c);
|
__HAL_LOCK(hi2c);
|
||||||
@ -4842,17 +4974,22 @@ static HAL_StatusTypeDef I2C_Master_ISR_IT(struct __I2C_HandleTypeDef *hi2c, uin
|
|||||||
hi2c->XferSize--;
|
hi2c->XferSize--;
|
||||||
hi2c->XferCount--;
|
hi2c->XferCount--;
|
||||||
}
|
}
|
||||||
else if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_TXIS) != RESET) && \
|
else if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_TC) == RESET) && \
|
||||||
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TXI) != RESET))
|
((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_TXIS) != RESET) && \
|
||||||
|
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TXI) != RESET)))
|
||||||
{
|
{
|
||||||
/* Write data to TXDR */
|
/* Write data to TXDR */
|
||||||
hi2c->Instance->TXDR = *hi2c->pBuffPtr;
|
if (hi2c->XferCount != 0U)
|
||||||
|
{
|
||||||
|
/* Write data to TXDR */
|
||||||
|
hi2c->Instance->TXDR = *hi2c->pBuffPtr;
|
||||||
|
|
||||||
/* Increment Buffer pointer */
|
/* Increment Buffer pointer */
|
||||||
hi2c->pBuffPtr++;
|
hi2c->pBuffPtr++;
|
||||||
|
|
||||||
hi2c->XferSize--;
|
hi2c->XferSize--;
|
||||||
hi2c->XferCount--;
|
hi2c->XferCount--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_TCR) != RESET) && \
|
else if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_TCR) != RESET) && \
|
||||||
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TCI) != RESET))
|
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TCI) != RESET))
|
||||||
@ -4863,7 +5000,15 @@ static HAL_StatusTypeDef I2C_Master_ISR_IT(struct __I2C_HandleTypeDef *hi2c, uin
|
|||||||
|
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
/* Errata workaround 170323 */
|
||||||
|
if (I2C_GET_DIR(hi2c) == I2C_DIRECTION_RECEIVE)
|
||||||
|
{
|
||||||
|
hi2c->XferSize = 1U;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hi2c->XferSize = MAX_NBYTE_SIZE;
|
||||||
|
}
|
||||||
I2C_TransferConfig(hi2c, devaddress, (uint8_t)hi2c->XferSize, I2C_RELOAD_MODE, I2C_NO_STARTSTOP);
|
I2C_TransferConfig(hi2c, devaddress, (uint8_t)hi2c->XferSize, I2C_RELOAD_MODE, I2C_NO_STARTSTOP);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -5018,7 +5163,15 @@ static HAL_StatusTypeDef I2C_Mem_ISR_IT(struct __I2C_HandleTypeDef *hi2c, uint32
|
|||||||
{
|
{
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
/* Errata workaround 170323 */
|
||||||
|
if (I2C_GET_DIR(hi2c) == I2C_DIRECTION_RECEIVE)
|
||||||
|
{
|
||||||
|
hi2c->XferSize = 1U;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hi2c->XferSize = MAX_NBYTE_SIZE;
|
||||||
|
}
|
||||||
I2C_TransferConfig(hi2c, (uint16_t)hi2c->Devaddress, (uint8_t)hi2c->XferSize,
|
I2C_TransferConfig(hi2c, (uint16_t)hi2c->Devaddress, (uint8_t)hi2c->XferSize,
|
||||||
I2C_RELOAD_MODE, I2C_NO_STARTSTOP);
|
I2C_RELOAD_MODE, I2C_NO_STARTSTOP);
|
||||||
}
|
}
|
||||||
@ -5039,6 +5192,12 @@ static HAL_StatusTypeDef I2C_Mem_ISR_IT(struct __I2C_HandleTypeDef *hi2c, uint32
|
|||||||
else if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_TC) != RESET) && \
|
else if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_TC) != RESET) && \
|
||||||
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TCI) != RESET))
|
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TCI) != RESET))
|
||||||
{
|
{
|
||||||
|
/* Disable Interrupt related to address step */
|
||||||
|
I2C_Disable_IRQ(hi2c, I2C_XFER_TX_IT);
|
||||||
|
|
||||||
|
/* Enable ERR, TC, STOP, NACK and RXI interrupts */
|
||||||
|
I2C_Enable_IRQ(hi2c, I2C_XFER_RX_IT);
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_BUSY_RX)
|
if (hi2c->State == HAL_I2C_STATE_BUSY_RX)
|
||||||
{
|
{
|
||||||
direction = I2C_GENERATE_START_READ;
|
direction = I2C_GENERATE_START_READ;
|
||||||
@ -5046,7 +5205,15 @@ static HAL_StatusTypeDef I2C_Mem_ISR_IT(struct __I2C_HandleTypeDef *hi2c, uint32
|
|||||||
|
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
/* Errata workaround 170323 */
|
||||||
|
if (I2C_GET_DIR(hi2c) == I2C_DIRECTION_RECEIVE)
|
||||||
|
{
|
||||||
|
hi2c->XferSize = 1U;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hi2c->XferSize = MAX_NBYTE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
||||||
I2C_TransferConfig(hi2c, (uint16_t)hi2c->Devaddress, (uint8_t)hi2c->XferSize,
|
I2C_TransferConfig(hi2c, (uint16_t)hi2c->Devaddress, (uint8_t)hi2c->XferSize,
|
||||||
@ -5103,9 +5270,8 @@ static HAL_StatusTypeDef I2C_Slave_ISR_IT(struct __I2C_HandleTypeDef *hi2c, uint
|
|||||||
/* Call I2C Slave complete process */
|
/* Call I2C Slave complete process */
|
||||||
I2C_ITSlaveCplt(hi2c, tmpITFlags);
|
I2C_ITSlaveCplt(hi2c, tmpITFlags);
|
||||||
}
|
}
|
||||||
|
else if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_AF) != RESET) && \
|
||||||
if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_AF) != RESET) && \
|
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_NACKI) != RESET))
|
||||||
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_NACKI) != RESET))
|
|
||||||
{
|
{
|
||||||
/* Check that I2C transfer finished */
|
/* Check that I2C transfer finished */
|
||||||
/* if yes, normal use case, a NACK is sent by the MASTER when Transfer is finished */
|
/* if yes, normal use case, a NACK is sent by the MASTER when Transfer is finished */
|
||||||
@ -5268,7 +5434,15 @@ static HAL_StatusTypeDef I2C_Master_ISR_DMA(struct __I2C_HandleTypeDef *hi2c, ui
|
|||||||
/* Prepare the new XferSize to transfer */
|
/* Prepare the new XferSize to transfer */
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
/* Errata workaround 170323 */
|
||||||
|
if (I2C_GET_DIR(hi2c) == I2C_DIRECTION_RECEIVE)
|
||||||
|
{
|
||||||
|
hi2c->XferSize = 1U;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hi2c->XferSize = MAX_NBYTE_SIZE;
|
||||||
|
}
|
||||||
xfermode = I2C_RELOAD_MODE;
|
xfermode = I2C_RELOAD_MODE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -5405,6 +5579,9 @@ static HAL_StatusTypeDef I2C_Mem_ISR_DMA(struct __I2C_HandleTypeDef *hi2c, uint3
|
|||||||
else if ((I2C_CHECK_FLAG(ITFlags, I2C_FLAG_TCR) != RESET) && \
|
else if ((I2C_CHECK_FLAG(ITFlags, I2C_FLAG_TCR) != RESET) && \
|
||||||
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TCI) != RESET))
|
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TCI) != RESET))
|
||||||
{
|
{
|
||||||
|
/* Disable Interrupt related to address step */
|
||||||
|
I2C_Disable_IRQ(hi2c, I2C_XFER_TX_IT);
|
||||||
|
|
||||||
/* Enable only Error interrupt */
|
/* Enable only Error interrupt */
|
||||||
I2C_Enable_IRQ(hi2c, I2C_XFER_ERROR_IT);
|
I2C_Enable_IRQ(hi2c, I2C_XFER_ERROR_IT);
|
||||||
|
|
||||||
@ -5413,7 +5590,15 @@ static HAL_StatusTypeDef I2C_Mem_ISR_DMA(struct __I2C_HandleTypeDef *hi2c, uint3
|
|||||||
/* Prepare the new XferSize to transfer */
|
/* Prepare the new XferSize to transfer */
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
/* Errata workaround 170323 */
|
||||||
|
if (I2C_GET_DIR(hi2c) == I2C_DIRECTION_RECEIVE)
|
||||||
|
{
|
||||||
|
hi2c->XferSize = 1U;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hi2c->XferSize = MAX_NBYTE_SIZE;
|
||||||
|
}
|
||||||
I2C_TransferConfig(hi2c, (uint16_t)hi2c->Devaddress, (uint8_t)hi2c->XferSize,
|
I2C_TransferConfig(hi2c, (uint16_t)hi2c->Devaddress, (uint8_t)hi2c->XferSize,
|
||||||
I2C_RELOAD_MODE, I2C_NO_STARTSTOP);
|
I2C_RELOAD_MODE, I2C_NO_STARTSTOP);
|
||||||
}
|
}
|
||||||
@ -5447,6 +5632,12 @@ static HAL_StatusTypeDef I2C_Mem_ISR_DMA(struct __I2C_HandleTypeDef *hi2c, uint3
|
|||||||
else if ((I2C_CHECK_FLAG(ITFlags, I2C_FLAG_TC) != RESET) && \
|
else if ((I2C_CHECK_FLAG(ITFlags, I2C_FLAG_TC) != RESET) && \
|
||||||
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TCI) != RESET))
|
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_TCI) != RESET))
|
||||||
{
|
{
|
||||||
|
/* Disable Interrupt related to address step */
|
||||||
|
I2C_Disable_IRQ(hi2c, I2C_XFER_TX_IT);
|
||||||
|
|
||||||
|
/* Enable only Error and NACK interrupt for data transfer */
|
||||||
|
I2C_Enable_IRQ(hi2c, I2C_XFER_ERROR_IT);
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_BUSY_RX)
|
if (hi2c->State == HAL_I2C_STATE_BUSY_RX)
|
||||||
{
|
{
|
||||||
direction = I2C_GENERATE_START_READ;
|
direction = I2C_GENERATE_START_READ;
|
||||||
@ -5454,7 +5645,15 @@ static HAL_StatusTypeDef I2C_Mem_ISR_DMA(struct __I2C_HandleTypeDef *hi2c, uint3
|
|||||||
|
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
/* Errata workaround 170323 */
|
||||||
|
if (I2C_GET_DIR(hi2c) == I2C_DIRECTION_RECEIVE)
|
||||||
|
{
|
||||||
|
hi2c->XferSize = 1U;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hi2c->XferSize = MAX_NBYTE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
/* Set NBYTES to write and reload if hi2c->XferCount > MAX_NBYTE_SIZE and generate RESTART */
|
||||||
I2C_TransferConfig(hi2c, (uint16_t)hi2c->Devaddress, (uint8_t)hi2c->XferSize,
|
I2C_TransferConfig(hi2c, (uint16_t)hi2c->Devaddress, (uint8_t)hi2c->XferSize,
|
||||||
@ -5524,9 +5723,8 @@ static HAL_StatusTypeDef I2C_Slave_ISR_DMA(struct __I2C_HandleTypeDef *hi2c, uin
|
|||||||
/* Call I2C Slave complete process */
|
/* Call I2C Slave complete process */
|
||||||
I2C_ITSlaveCplt(hi2c, ITFlags);
|
I2C_ITSlaveCplt(hi2c, ITFlags);
|
||||||
}
|
}
|
||||||
|
else if ((I2C_CHECK_FLAG(ITFlags, I2C_FLAG_AF) != RESET) && \
|
||||||
if ((I2C_CHECK_FLAG(ITFlags, I2C_FLAG_AF) != RESET) && \
|
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_NACKI) != RESET))
|
||||||
(I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_NACKI) != RESET))
|
|
||||||
{
|
{
|
||||||
/* Check that I2C transfer finished */
|
/* Check that I2C transfer finished */
|
||||||
/* if yes, normal use case, a NACK is sent by the MASTER when Transfer is finished */
|
/* if yes, normal use case, a NACK is sent by the MASTER when Transfer is finished */
|
||||||
@ -6125,6 +6323,7 @@ static void I2C_ITSlaveCplt(I2C_HandleTypeDef *hi2c, uint32_t ITFlags)
|
|||||||
{
|
{
|
||||||
uint32_t tmpcr1value = READ_REG(hi2c->Instance->CR1);
|
uint32_t tmpcr1value = READ_REG(hi2c->Instance->CR1);
|
||||||
uint32_t tmpITFlags = ITFlags;
|
uint32_t tmpITFlags = ITFlags;
|
||||||
|
uint32_t tmpoptions = hi2c->XferOptions;
|
||||||
HAL_I2C_StateTypeDef tmpstate = hi2c->State;
|
HAL_I2C_StateTypeDef tmpstate = hi2c->State;
|
||||||
|
|
||||||
/* Clear STOP Flag */
|
/* Clear STOP Flag */
|
||||||
@ -6141,6 +6340,11 @@ static void I2C_ITSlaveCplt(I2C_HandleTypeDef *hi2c, uint32_t ITFlags)
|
|||||||
I2C_Disable_IRQ(hi2c, I2C_XFER_LISTEN_IT | I2C_XFER_RX_IT);
|
I2C_Disable_IRQ(hi2c, I2C_XFER_LISTEN_IT | I2C_XFER_RX_IT);
|
||||||
hi2c->PreviousState = I2C_STATE_SLAVE_BUSY_RX;
|
hi2c->PreviousState = I2C_STATE_SLAVE_BUSY_RX;
|
||||||
}
|
}
|
||||||
|
else if (tmpstate == HAL_I2C_STATE_LISTEN)
|
||||||
|
{
|
||||||
|
I2C_Disable_IRQ(hi2c, I2C_XFER_LISTEN_IT | I2C_XFER_TX_IT | I2C_XFER_RX_IT);
|
||||||
|
hi2c->PreviousState = I2C_STATE_NONE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Do nothing */
|
/* Do nothing */
|
||||||
@ -6207,6 +6411,57 @@ static void I2C_ITSlaveCplt(I2C_HandleTypeDef *hi2c, uint32_t ITFlags)
|
|||||||
hi2c->ErrorCode |= HAL_I2C_ERROR_AF;
|
hi2c->ErrorCode |= HAL_I2C_ERROR_AF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_AF) != RESET) && \
|
||||||
|
(I2C_CHECK_IT_SOURCE(tmpcr1value, I2C_IT_NACKI) != RESET))
|
||||||
|
{
|
||||||
|
/* Check that I2C transfer finished */
|
||||||
|
/* if yes, normal use case, a NACK is sent by the MASTER when Transfer is finished */
|
||||||
|
/* Mean XferCount == 0*/
|
||||||
|
/* So clear Flag NACKF only */
|
||||||
|
if (hi2c->XferCount == 0U)
|
||||||
|
{
|
||||||
|
if ((hi2c->State == HAL_I2C_STATE_LISTEN) && (tmpoptions == I2C_FIRST_AND_LAST_FRAME))
|
||||||
|
/* Same action must be done for (tmpoptions == I2C_LAST_FRAME) which removed for
|
||||||
|
Warning[Pa134]: left and right operands are identical */
|
||||||
|
{
|
||||||
|
/* Call I2C Listen complete process */
|
||||||
|
I2C_ITListenCplt(hi2c, tmpITFlags);
|
||||||
|
}
|
||||||
|
else if ((hi2c->State == HAL_I2C_STATE_BUSY_TX_LISTEN) && (tmpoptions != I2C_NO_OPTION_FRAME))
|
||||||
|
{
|
||||||
|
/* Clear NACK Flag */
|
||||||
|
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_AF);
|
||||||
|
|
||||||
|
/* Flush TX register */
|
||||||
|
I2C_Flush_TXDR(hi2c);
|
||||||
|
|
||||||
|
/* Last Byte is Transmitted */
|
||||||
|
/* Call I2C Slave Sequential complete process */
|
||||||
|
I2C_ITSlaveSeqCplt(hi2c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Clear NACK Flag */
|
||||||
|
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_AF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* if no, error use case, a Non-Acknowledge of last Data is generated by the MASTER*/
|
||||||
|
/* Clear NACK Flag */
|
||||||
|
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_AF);
|
||||||
|
|
||||||
|
/* Set ErrorCode corresponding to a Non-Acknowledge */
|
||||||
|
hi2c->ErrorCode |= HAL_I2C_ERROR_AF;
|
||||||
|
|
||||||
|
if ((tmpoptions == I2C_FIRST_FRAME) || (tmpoptions == I2C_NEXT_FRAME))
|
||||||
|
{
|
||||||
|
/* Call the corresponding callback to inform upper layer of End of Transfer */
|
||||||
|
I2C_ITError(hi2c, hi2c->ErrorCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hi2c->Mode = HAL_I2C_MODE_NONE;
|
hi2c->Mode = HAL_I2C_MODE_NONE;
|
||||||
hi2c->XferISR = NULL;
|
hi2c->XferISR = NULL;
|
||||||
|
|
||||||
@ -6624,7 +6879,15 @@ static void I2C_DMAMasterReceiveCplt(DMA_HandleTypeDef *hdma)
|
|||||||
/* Set the XferSize to transfer */
|
/* Set the XferSize to transfer */
|
||||||
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
if (hi2c->XferCount > MAX_NBYTE_SIZE)
|
||||||
{
|
{
|
||||||
hi2c->XferSize = MAX_NBYTE_SIZE;
|
/* Errata workaround 170323 */
|
||||||
|
if (I2C_GET_DIR(hi2c) == I2C_DIRECTION_RECEIVE)
|
||||||
|
{
|
||||||
|
hi2c->XferSize = 1U;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hi2c->XferSize = MAX_NBYTE_SIZE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -6735,6 +6998,12 @@ static HAL_StatusTypeDef I2C_WaitOnFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uin
|
|||||||
{
|
{
|
||||||
while (__HAL_I2C_GET_FLAG(hi2c, Flag) == Status)
|
while (__HAL_I2C_GET_FLAG(hi2c, Flag) == Status)
|
||||||
{
|
{
|
||||||
|
/* Check if an error is detected */
|
||||||
|
if (I2C_IsErrorOccurred(hi2c, Timeout, Tickstart) != HAL_OK)
|
||||||
|
{
|
||||||
|
return HAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for the Timeout */
|
/* Check for the Timeout */
|
||||||
if (Timeout != HAL_MAX_DELAY)
|
if (Timeout != HAL_MAX_DELAY)
|
||||||
{
|
{
|
||||||
@ -6846,16 +7115,18 @@ static HAL_StatusTypeDef I2C_WaitOnSTOPFlagUntilTimeout(I2C_HandleTypeDef *hi2c,
|
|||||||
static HAL_StatusTypeDef I2C_WaitOnRXNEFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uint32_t Timeout,
|
static HAL_StatusTypeDef I2C_WaitOnRXNEFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uint32_t Timeout,
|
||||||
uint32_t Tickstart)
|
uint32_t Tickstart)
|
||||||
{
|
{
|
||||||
while (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_RXNE) == RESET)
|
HAL_StatusTypeDef status = HAL_OK;
|
||||||
|
|
||||||
|
while ((__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_RXNE) == RESET) && (status == HAL_OK))
|
||||||
{
|
{
|
||||||
/* Check if an error is detected */
|
/* Check if an error is detected */
|
||||||
if (I2C_IsErrorOccurred(hi2c, Timeout, Tickstart) != HAL_OK)
|
if (I2C_IsErrorOccurred(hi2c, Timeout, Tickstart) != HAL_OK)
|
||||||
{
|
{
|
||||||
return HAL_ERROR;
|
status = HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if a STOPF is detected */
|
/* Check if a STOPF is detected */
|
||||||
if (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_STOPF) == SET)
|
if ((__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_STOPF) == SET) && (status == HAL_OK))
|
||||||
{
|
{
|
||||||
/* Check if an RXNE is pending */
|
/* Check if an RXNE is pending */
|
||||||
/* Store Last receive data if any */
|
/* Store Last receive data if any */
|
||||||
@ -6863,19 +7134,14 @@ static HAL_StatusTypeDef I2C_WaitOnRXNEFlagUntilTimeout(I2C_HandleTypeDef *hi2c,
|
|||||||
{
|
{
|
||||||
/* Return HAL_OK */
|
/* Return HAL_OK */
|
||||||
/* The Reading of data from RXDR will be done in caller function */
|
/* The Reading of data from RXDR will be done in caller function */
|
||||||
return HAL_OK;
|
status = HAL_OK;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/* Check a no-acknowledge have been detected */
|
||||||
|
if (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_AF) == SET)
|
||||||
{
|
{
|
||||||
if (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_AF) == SET)
|
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_AF);
|
||||||
{
|
hi2c->ErrorCode = HAL_I2C_ERROR_AF;
|
||||||
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_AF);
|
|
||||||
hi2c->ErrorCode = HAL_I2C_ERROR_AF;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hi2c->ErrorCode = HAL_I2C_ERROR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear STOP Flag */
|
/* Clear STOP Flag */
|
||||||
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF);
|
__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF);
|
||||||
@ -6889,12 +7155,16 @@ static HAL_StatusTypeDef I2C_WaitOnRXNEFlagUntilTimeout(I2C_HandleTypeDef *hi2c,
|
|||||||
/* Process Unlocked */
|
/* Process Unlocked */
|
||||||
__HAL_UNLOCK(hi2c);
|
__HAL_UNLOCK(hi2c);
|
||||||
|
|
||||||
return HAL_ERROR;
|
status = HAL_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hi2c->ErrorCode = HAL_I2C_ERROR_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for the Timeout */
|
/* Check for the Timeout */
|
||||||
if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
|
if ((((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) && (status == HAL_OK))
|
||||||
{
|
{
|
||||||
if ((__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_RXNE) == RESET))
|
if ((__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_RXNE) == RESET))
|
||||||
{
|
{
|
||||||
@ -6904,11 +7174,11 @@ static HAL_StatusTypeDef I2C_WaitOnRXNEFlagUntilTimeout(I2C_HandleTypeDef *hi2c,
|
|||||||
/* Process Unlocked */
|
/* Process Unlocked */
|
||||||
__HAL_UNLOCK(hi2c);
|
__HAL_UNLOCK(hi2c);
|
||||||
|
|
||||||
return HAL_ERROR;
|
status = HAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HAL_OK;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -7103,13 +7373,13 @@ static void I2C_Enable_IRQ(I2C_HandleTypeDef *hi2c, uint16_t InterruptRequest)
|
|||||||
|
|
||||||
if ((InterruptRequest & I2C_XFER_TX_IT) == I2C_XFER_TX_IT)
|
if ((InterruptRequest & I2C_XFER_TX_IT) == I2C_XFER_TX_IT)
|
||||||
{
|
{
|
||||||
/* Enable ERR, TC, STOP, NACK and RXI interrupts */
|
/* Enable ERR, TC, STOP, NACK and TXI interrupts */
|
||||||
tmpisr |= I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI | I2C_IT_TXI;
|
tmpisr |= I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI | I2C_IT_TXI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((InterruptRequest & I2C_XFER_RX_IT) == I2C_XFER_RX_IT)
|
if ((InterruptRequest & I2C_XFER_RX_IT) == I2C_XFER_RX_IT)
|
||||||
{
|
{
|
||||||
/* Enable ERR, TC, STOP, NACK and TXI interrupts */
|
/* Enable ERR, TC, STOP, NACK and RXI interrupts */
|
||||||
tmpisr |= I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI | I2C_IT_RXI;
|
tmpisr |= I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI | I2C_IT_RXI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7136,13 +7406,13 @@ static void I2C_Enable_IRQ(I2C_HandleTypeDef *hi2c, uint16_t InterruptRequest)
|
|||||||
|
|
||||||
if ((InterruptRequest & I2C_XFER_TX_IT) == I2C_XFER_TX_IT)
|
if ((InterruptRequest & I2C_XFER_TX_IT) == I2C_XFER_TX_IT)
|
||||||
{
|
{
|
||||||
/* Enable ERR, TC, STOP, NACK and RXI interrupts */
|
/* Enable ERR, TC, STOP, NACK and TXI interrupts */
|
||||||
tmpisr |= I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI | I2C_IT_TXI;
|
tmpisr |= I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI | I2C_IT_TXI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((InterruptRequest & I2C_XFER_RX_IT) == I2C_XFER_RX_IT)
|
if ((InterruptRequest & I2C_XFER_RX_IT) == I2C_XFER_RX_IT)
|
||||||
{
|
{
|
||||||
/* Enable ERR, TC, STOP, NACK and TXI interrupts */
|
/* Enable ERR, TC, STOP, NACK and RXI interrupts */
|
||||||
tmpisr |= I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI | I2C_IT_RXI;
|
tmpisr |= I2C_IT_ERRI | I2C_IT_TCI | I2C_IT_STOPI | I2C_IT_NACKI | I2C_IT_RXI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7158,7 +7428,7 @@ static void I2C_Enable_IRQ(I2C_HandleTypeDef *hi2c, uint16_t InterruptRequest)
|
|||||||
tmpisr |= (I2C_IT_STOPI | I2C_IT_TCI);
|
tmpisr |= (I2C_IT_STOPI | I2C_IT_TCI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hi2c->XferISR != I2C_Mem_ISR_DMA) && (InterruptRequest == I2C_XFER_RELOAD_IT))
|
if (InterruptRequest == I2C_XFER_RELOAD_IT)
|
||||||
{
|
{
|
||||||
/* Enable TC interrupts */
|
/* Enable TC interrupts */
|
||||||
tmpisr |= I2C_IT_TCI;
|
tmpisr |= I2C_IT_TCI;
|
||||||
@ -1021,7 +1021,10 @@ void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_M
|
|||||||
assert_param(IS_RCC_MCO(RCC_MCOx));
|
assert_param(IS_RCC_MCO(RCC_MCOx));
|
||||||
assert_param(IS_RCC_MCODIV(RCC_MCODiv));
|
assert_param(IS_RCC_MCODIV(RCC_MCODiv));
|
||||||
assert_param(IS_RCC_MCO1SOURCE(RCC_MCOSource));
|
assert_param(IS_RCC_MCO1SOURCE(RCC_MCOSource));
|
||||||
|
|
||||||
|
/* Prevent unused argument(s) compilation warning */
|
||||||
|
UNUSED(RCC_MCOx);
|
||||||
|
|
||||||
/* Configure the MCO1 pin in alternate function mode */
|
/* Configure the MCO1 pin in alternate function mode */
|
||||||
gpio.Mode = GPIO_MODE_AF_PP;
|
gpio.Mode = GPIO_MODE_AF_PP;
|
||||||
gpio.Speed = GPIO_SPEED_FREQ_HIGH;
|
gpio.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
@ -3822,13 +3822,16 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Cha
|
|||||||
*/
|
*/
|
||||||
void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
|
void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
|
||||||
{
|
{
|
||||||
|
uint32_t itsource = htim->Instance->DIER;
|
||||||
|
uint32_t itflag = htim->Instance->SR;
|
||||||
|
|
||||||
/* Capture compare 1 event */
|
/* Capture compare 1 event */
|
||||||
if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC1) != RESET)
|
if ((itflag & (TIM_FLAG_CC1)) == (TIM_FLAG_CC1))
|
||||||
{
|
{
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC1) != RESET)
|
if ((itsource & (TIM_IT_CC1)) == (TIM_IT_CC1))
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_FLAG(htim, TIM_FLAG_CC1);
|
||||||
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
|
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
|
||||||
|
|
||||||
/* Input capture event */
|
/* Input capture event */
|
||||||
@ -3856,11 +3859,11 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Capture compare 2 event */
|
/* Capture compare 2 event */
|
||||||
if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC2) != RESET)
|
if ((itflag & (TIM_FLAG_CC2)) == (TIM_FLAG_CC2))
|
||||||
{
|
{
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC2) != RESET)
|
if ((itsource & (TIM_IT_CC2)) == (TIM_IT_CC2))
|
||||||
{
|
{
|
||||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC2);
|
__HAL_TIM_CLEAR_FLAG(htim, TIM_FLAG_CC2);
|
||||||
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
|
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
|
||||||
/* Input capture event */
|
/* Input capture event */
|
||||||
if ((htim->Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U)
|
if ((htim->Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U)
|
||||||
@ -3886,11 +3889,11 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Capture compare 3 event */
|
/* Capture compare 3 event */
|
||||||
if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC3) != RESET)
|
if ((itflag & (TIM_FLAG_CC3)) == (TIM_FLAG_CC3))
|
||||||
{
|
{
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC3) != RESET)
|
if ((itsource & (TIM_IT_CC3)) == (TIM_IT_CC3))
|
||||||
{
|
{
|
||||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC3);
|
__HAL_TIM_CLEAR_FLAG(htim, TIM_FLAG_CC3);
|
||||||
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
|
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
|
||||||
/* Input capture event */
|
/* Input capture event */
|
||||||
if ((htim->Instance->CCMR2 & TIM_CCMR2_CC3S) != 0x00U)
|
if ((htim->Instance->CCMR2 & TIM_CCMR2_CC3S) != 0x00U)
|
||||||
@ -3916,11 +3919,11 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Capture compare 4 event */
|
/* Capture compare 4 event */
|
||||||
if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC4) != RESET)
|
if ((itflag & (TIM_FLAG_CC4)) == (TIM_FLAG_CC4))
|
||||||
{
|
{
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC4) != RESET)
|
if ((itsource & (TIM_IT_CC4)) == (TIM_IT_CC4))
|
||||||
{
|
{
|
||||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC4);
|
__HAL_TIM_CLEAR_FLAG(htim, TIM_FLAG_CC4);
|
||||||
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
|
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
|
||||||
/* Input capture event */
|
/* Input capture event */
|
||||||
if ((htim->Instance->CCMR2 & TIM_CCMR2_CC4S) != 0x00U)
|
if ((htim->Instance->CCMR2 & TIM_CCMR2_CC4S) != 0x00U)
|
||||||
@ -3946,11 +3949,11 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TIM Update event */
|
/* TIM Update event */
|
||||||
if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_UPDATE) != RESET)
|
if ((itflag & (TIM_FLAG_UPDATE)) == (TIM_FLAG_UPDATE))
|
||||||
{
|
{
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_UPDATE) != RESET)
|
if ((itsource & (TIM_IT_UPDATE)) == (TIM_IT_UPDATE))
|
||||||
{
|
{
|
||||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_UPDATE);
|
__HAL_TIM_CLEAR_FLAG(htim, TIM_FLAG_UPDATE);
|
||||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||||
htim->PeriodElapsedCallback(htim);
|
htim->PeriodElapsedCallback(htim);
|
||||||
#else
|
#else
|
||||||
@ -3959,11 +3962,11 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TIM Break input event */
|
/* TIM Break input event */
|
||||||
if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_BREAK) != RESET)
|
if ((itflag & (TIM_FLAG_BREAK)) == (TIM_FLAG_BREAK))
|
||||||
{
|
{
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_BREAK) != RESET)
|
if ((itsource & (TIM_IT_BREAK)) == (TIM_IT_BREAK))
|
||||||
{
|
{
|
||||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_BREAK);
|
__HAL_TIM_CLEAR_FLAG(htim, TIM_FLAG_BREAK);
|
||||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||||
htim->BreakCallback(htim);
|
htim->BreakCallback(htim);
|
||||||
#else
|
#else
|
||||||
@ -3972,11 +3975,11 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TIM Trigger detection event */
|
/* TIM Trigger detection event */
|
||||||
if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_TRIGGER) != RESET)
|
if ((itflag & (TIM_FLAG_TRIGGER)) == (TIM_FLAG_TRIGGER))
|
||||||
{
|
{
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_TRIGGER) != RESET)
|
if ((itsource & (TIM_IT_TRIGGER)) == (TIM_IT_TRIGGER))
|
||||||
{
|
{
|
||||||
__HAL_TIM_CLEAR_IT(htim, TIM_IT_TRIGGER);
|
__HAL_TIM_CLEAR_FLAG(htim, TIM_FLAG_TRIGGER);
|
||||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||||
htim->TriggerCallback(htim);
|
htim->TriggerCallback(htim);
|
||||||
#else
|
#else
|
||||||
@ -3985,11 +3988,11 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TIM commutation event */
|
/* TIM commutation event */
|
||||||
if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_COM) != RESET)
|
if ((itflag & (TIM_FLAG_COM)) == (TIM_FLAG_COM))
|
||||||
{
|
{
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_COM) != RESET)
|
if ((itsource & (TIM_IT_COM)) == (TIM_IT_COM))
|
||||||
{
|
{
|
||||||
__HAL_TIM_CLEAR_IT(htim, TIM_FLAG_COM);
|
__HAL_TIM_CLEAR_FLAG(htim, TIM_FLAG_COM);
|
||||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||||
htim->CommutationCallback(htim);
|
htim->CommutationCallback(htim);
|
||||||
#else
|
#else
|
||||||
@ -4476,7 +4479,8 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_O
|
|||||||
* @retval HAL status
|
* @retval HAL status
|
||||||
*/
|
*/
|
||||||
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
||||||
uint32_t BurstRequestSrc, const uint32_t *BurstBuffer, uint32_t BurstLength)
|
uint32_t BurstRequestSrc, const uint32_t *BurstBuffer,
|
||||||
|
uint32_t BurstLength)
|
||||||
{
|
{
|
||||||
HAL_StatusTypeDef status;
|
HAL_StatusTypeDef status;
|
||||||
|
|
||||||
@ -6819,6 +6823,13 @@ void TIM_Base_SetConfig(TIM_TypeDef *TIMx, const TIM_Base_InitTypeDef *Structure
|
|||||||
/* Generate an update event to reload the Prescaler
|
/* Generate an update event to reload the Prescaler
|
||||||
and the repetition counter (only for advanced timer) value immediately */
|
and the repetition counter (only for advanced timer) value immediately */
|
||||||
TIMx->EGR = TIM_EGR_UG;
|
TIMx->EGR = TIM_EGR_UG;
|
||||||
|
|
||||||
|
/* Check if the update flag is set after the Update Generation, if so clear the UIF flag */
|
||||||
|
if (HAL_IS_BIT_SET(TIMx->SR, TIM_FLAG_UPDATE))
|
||||||
|
{
|
||||||
|
/* Clear the update flag */
|
||||||
|
CLEAR_BIT(TIMx->SR, TIM_FLAG_UPDATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6833,11 +6844,12 @@ static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, const TIM_OC_InitTypeDef *OC_Co
|
|||||||
uint32_t tmpccer;
|
uint32_t tmpccer;
|
||||||
uint32_t tmpcr2;
|
uint32_t tmpcr2;
|
||||||
|
|
||||||
|
/* Get the TIMx CCER register value */
|
||||||
|
tmpccer = TIMx->CCER;
|
||||||
|
|
||||||
/* Disable the Channel 1: Reset the CC1E Bit */
|
/* Disable the Channel 1: Reset the CC1E Bit */
|
||||||
TIMx->CCER &= ~TIM_CCER_CC1E;
|
TIMx->CCER &= ~TIM_CCER_CC1E;
|
||||||
|
|
||||||
/* Get the TIMx CCER register value */
|
|
||||||
tmpccer = TIMx->CCER;
|
|
||||||
/* Get the TIMx CR2 register value */
|
/* Get the TIMx CR2 register value */
|
||||||
tmpcr2 = TIMx->CR2;
|
tmpcr2 = TIMx->CR2;
|
||||||
|
|
||||||
@ -6908,11 +6920,12 @@ void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, const TIM_OC_InitTypeDef *OC_Config)
|
|||||||
uint32_t tmpccer;
|
uint32_t tmpccer;
|
||||||
uint32_t tmpcr2;
|
uint32_t tmpcr2;
|
||||||
|
|
||||||
|
/* Get the TIMx CCER register value */
|
||||||
|
tmpccer = TIMx->CCER;
|
||||||
|
|
||||||
/* Disable the Channel 2: Reset the CC2E Bit */
|
/* Disable the Channel 2: Reset the CC2E Bit */
|
||||||
TIMx->CCER &= ~TIM_CCER_CC2E;
|
TIMx->CCER &= ~TIM_CCER_CC2E;
|
||||||
|
|
||||||
/* Get the TIMx CCER register value */
|
|
||||||
tmpccer = TIMx->CCER;
|
|
||||||
/* Get the TIMx CR2 register value */
|
/* Get the TIMx CR2 register value */
|
||||||
tmpcr2 = TIMx->CR2;
|
tmpcr2 = TIMx->CR2;
|
||||||
|
|
||||||
@ -6941,7 +6954,6 @@ void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, const TIM_OC_InitTypeDef *OC_Config)
|
|||||||
tmpccer |= (OC_Config->OCNPolarity << 4U);
|
tmpccer |= (OC_Config->OCNPolarity << 4U);
|
||||||
/* Reset the Output N State */
|
/* Reset the Output N State */
|
||||||
tmpccer &= ~TIM_CCER_CC2NE;
|
tmpccer &= ~TIM_CCER_CC2NE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_TIM_BREAK_INSTANCE(TIMx))
|
if (IS_TIM_BREAK_INSTANCE(TIMx))
|
||||||
@ -6984,11 +6996,12 @@ static void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, const TIM_OC_InitTypeDef *OC_Co
|
|||||||
uint32_t tmpccer;
|
uint32_t tmpccer;
|
||||||
uint32_t tmpcr2;
|
uint32_t tmpcr2;
|
||||||
|
|
||||||
|
/* Get the TIMx CCER register value */
|
||||||
|
tmpccer = TIMx->CCER;
|
||||||
|
|
||||||
/* Disable the Channel 3: Reset the CC2E Bit */
|
/* Disable the Channel 3: Reset the CC2E Bit */
|
||||||
TIMx->CCER &= ~TIM_CCER_CC3E;
|
TIMx->CCER &= ~TIM_CCER_CC3E;
|
||||||
|
|
||||||
/* Get the TIMx CCER register value */
|
|
||||||
tmpccer = TIMx->CCER;
|
|
||||||
/* Get the TIMx CR2 register value */
|
/* Get the TIMx CR2 register value */
|
||||||
tmpcr2 = TIMx->CR2;
|
tmpcr2 = TIMx->CR2;
|
||||||
|
|
||||||
@ -7058,11 +7071,12 @@ static void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, const TIM_OC_InitTypeDef *OC_Co
|
|||||||
uint32_t tmpccer;
|
uint32_t tmpccer;
|
||||||
uint32_t tmpcr2;
|
uint32_t tmpcr2;
|
||||||
|
|
||||||
|
/* Get the TIMx CCER register value */
|
||||||
|
tmpccer = TIMx->CCER;
|
||||||
|
|
||||||
/* Disable the Channel 4: Reset the CC4E Bit */
|
/* Disable the Channel 4: Reset the CC4E Bit */
|
||||||
TIMx->CCER &= ~TIM_CCER_CC4E;
|
TIMx->CCER &= ~TIM_CCER_CC4E;
|
||||||
|
|
||||||
/* Get the TIMx CCER register value */
|
|
||||||
tmpccer = TIMx->CCER;
|
|
||||||
/* Get the TIMx CR2 register value */
|
/* Get the TIMx CR2 register value */
|
||||||
tmpcr2 = TIMx->CR2;
|
tmpcr2 = TIMx->CR2;
|
||||||
|
|
||||||
@ -7253,9 +7267,9 @@ void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_
|
|||||||
uint32_t tmpccer;
|
uint32_t tmpccer;
|
||||||
|
|
||||||
/* Disable the Channel 1: Reset the CC1E Bit */
|
/* Disable the Channel 1: Reset the CC1E Bit */
|
||||||
|
tmpccer = TIMx->CCER;
|
||||||
TIMx->CCER &= ~TIM_CCER_CC1E;
|
TIMx->CCER &= ~TIM_CCER_CC1E;
|
||||||
tmpccmr1 = TIMx->CCMR1;
|
tmpccmr1 = TIMx->CCMR1;
|
||||||
tmpccer = TIMx->CCER;
|
|
||||||
|
|
||||||
/* Select the Input */
|
/* Select the Input */
|
||||||
if (IS_TIM_CC2_INSTANCE(TIMx) != RESET)
|
if (IS_TIM_CC2_INSTANCE(TIMx) != RESET)
|
||||||
@ -7343,9 +7357,9 @@ static void TIM_TI2_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32
|
|||||||
uint32_t tmpccer;
|
uint32_t tmpccer;
|
||||||
|
|
||||||
/* Disable the Channel 2: Reset the CC2E Bit */
|
/* Disable the Channel 2: Reset the CC2E Bit */
|
||||||
|
tmpccer = TIMx->CCER;
|
||||||
TIMx->CCER &= ~TIM_CCER_CC2E;
|
TIMx->CCER &= ~TIM_CCER_CC2E;
|
||||||
tmpccmr1 = TIMx->CCMR1;
|
tmpccmr1 = TIMx->CCMR1;
|
||||||
tmpccer = TIMx->CCER;
|
|
||||||
|
|
||||||
/* Select the Input */
|
/* Select the Input */
|
||||||
tmpccmr1 &= ~TIM_CCMR1_CC2S;
|
tmpccmr1 &= ~TIM_CCMR1_CC2S;
|
||||||
@ -7382,9 +7396,9 @@ static void TIM_TI2_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity,
|
|||||||
uint32_t tmpccer;
|
uint32_t tmpccer;
|
||||||
|
|
||||||
/* Disable the Channel 2: Reset the CC2E Bit */
|
/* Disable the Channel 2: Reset the CC2E Bit */
|
||||||
|
tmpccer = TIMx->CCER;
|
||||||
TIMx->CCER &= ~TIM_CCER_CC2E;
|
TIMx->CCER &= ~TIM_CCER_CC2E;
|
||||||
tmpccmr1 = TIMx->CCMR1;
|
tmpccmr1 = TIMx->CCMR1;
|
||||||
tmpccer = TIMx->CCER;
|
|
||||||
|
|
||||||
/* Set the filter */
|
/* Set the filter */
|
||||||
tmpccmr1 &= ~TIM_CCMR1_IC2F;
|
tmpccmr1 &= ~TIM_CCMR1_IC2F;
|
||||||
@ -7426,9 +7440,9 @@ static void TIM_TI3_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32
|
|||||||
uint32_t tmpccer;
|
uint32_t tmpccer;
|
||||||
|
|
||||||
/* Disable the Channel 3: Reset the CC3E Bit */
|
/* Disable the Channel 3: Reset the CC3E Bit */
|
||||||
|
tmpccer = TIMx->CCER;
|
||||||
TIMx->CCER &= ~TIM_CCER_CC3E;
|
TIMx->CCER &= ~TIM_CCER_CC3E;
|
||||||
tmpccmr2 = TIMx->CCMR2;
|
tmpccmr2 = TIMx->CCMR2;
|
||||||
tmpccer = TIMx->CCER;
|
|
||||||
|
|
||||||
/* Select the Input */
|
/* Select the Input */
|
||||||
tmpccmr2 &= ~TIM_CCMR2_CC3S;
|
tmpccmr2 &= ~TIM_CCMR2_CC3S;
|
||||||
@ -7474,9 +7488,9 @@ static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32
|
|||||||
uint32_t tmpccer;
|
uint32_t tmpccer;
|
||||||
|
|
||||||
/* Disable the Channel 4: Reset the CC4E Bit */
|
/* Disable the Channel 4: Reset the CC4E Bit */
|
||||||
|
tmpccer = TIMx->CCER;
|
||||||
TIMx->CCER &= ~TIM_CCER_CC4E;
|
TIMx->CCER &= ~TIM_CCER_CC4E;
|
||||||
tmpccmr2 = TIMx->CCMR2;
|
tmpccmr2 = TIMx->CCMR2;
|
||||||
tmpccer = TIMx->CCER;
|
|
||||||
|
|
||||||
/* Select the Input */
|
/* Select the Input */
|
||||||
tmpccmr2 &= ~TIM_CCMR2_CC4S;
|
tmpccmr2 &= ~TIM_CCMR2_CC4S;
|
||||||
@ -836,7 +836,7 @@ HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channe
|
|||||||
|
|
||||||
/* Disable the TIM Break interrupt (only if no more channel is active) */
|
/* Disable the TIM Break interrupt (only if no more channel is active) */
|
||||||
tmpccer = htim->Instance->CCER;
|
tmpccer = htim->Instance->CCER;
|
||||||
if ((tmpccer & (TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE)) == (uint32_t)RESET)
|
if ((tmpccer & TIM_CCER_CCxNE_MASK) == (uint32_t)RESET)
|
||||||
{
|
{
|
||||||
__HAL_TIM_DISABLE_IT(htim, TIM_IT_BREAK);
|
__HAL_TIM_DISABLE_IT(htim, TIM_IT_BREAK);
|
||||||
}
|
}
|
||||||
@ -1082,17 +1082,6 @@ HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Chann
|
|||||||
(+) Stop the Complementary PWM and disable interrupts.
|
(+) Stop the Complementary PWM and disable interrupts.
|
||||||
(+) Start the Complementary PWM and enable DMA transfers.
|
(+) Start the Complementary PWM and enable DMA transfers.
|
||||||
(+) Stop the Complementary PWM and disable DMA transfers.
|
(+) Stop the Complementary PWM and disable DMA transfers.
|
||||||
(+) Start the Complementary Input Capture measurement.
|
|
||||||
(+) Stop the Complementary Input Capture.
|
|
||||||
(+) Start the Complementary Input Capture and enable interrupts.
|
|
||||||
(+) Stop the Complementary Input Capture and disable interrupts.
|
|
||||||
(+) Start the Complementary Input Capture and enable DMA transfers.
|
|
||||||
(+) Stop the Complementary Input Capture and disable DMA transfers.
|
|
||||||
(+) Start the Complementary One Pulse generation.
|
|
||||||
(+) Stop the Complementary One Pulse.
|
|
||||||
(+) Start the Complementary One Pulse and enable interrupts.
|
|
||||||
(+) Stop the Complementary One Pulse and disable interrupts.
|
|
||||||
|
|
||||||
@endverbatim
|
@endverbatim
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
@ -1318,7 +1307,7 @@ HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Chann
|
|||||||
|
|
||||||
/* Disable the TIM Break interrupt (only if no more channel is active) */
|
/* Disable the TIM Break interrupt (only if no more channel is active) */
|
||||||
tmpccer = htim->Instance->CCER;
|
tmpccer = htim->Instance->CCER;
|
||||||
if ((tmpccer & (TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE)) == (uint32_t)RESET)
|
if ((tmpccer & TIM_CCER_CCxNE_MASK) == (uint32_t)RESET)
|
||||||
{
|
{
|
||||||
__HAL_TIM_DISABLE_IT(htim, TIM_IT_BREAK);
|
__HAL_TIM_DISABLE_IT(htim, TIM_IT_BREAK);
|
||||||
}
|
}
|
||||||
@ -2113,7 +2102,7 @@ HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Hall commutation changed callback in non-blocking mode
|
* @brief Commutation callback in non-blocking mode
|
||||||
* @param htim TIM handle
|
* @param htim TIM handle
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
@ -2127,7 +2116,7 @@ __weak void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Hall commutation changed half complete callback in non-blocking mode
|
* @brief Commutation half complete callback in non-blocking mode
|
||||||
* @param htim TIM handle
|
* @param htim TIM handle
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
@ -2142,7 +2131,7 @@ __weak void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Hall Break detection callback in non-blocking mode
|
* @brief Break detection callback in non-blocking mode
|
||||||
* @param htim TIM handle
|
* @param htim TIM handle
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
@ -2293,15 +2282,6 @@ static void TIM_DMADelayPulseNCplt(DMA_HandleTypeDef *hdma)
|
|||||||
TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_3, HAL_TIM_CHANNEL_STATE_READY);
|
TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_3, HAL_TIM_CHANNEL_STATE_READY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
|
|
||||||
{
|
|
||||||
htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
|
|
||||||
|
|
||||||
if (hdma->Init.Mode == DMA_NORMAL)
|
|
||||||
{
|
|
||||||
TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_4, HAL_TIM_CHANNEL_STATE_READY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
@ -2370,13 +2350,13 @@ static void TIM_CCxNChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Cha
|
|||||||
{
|
{
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
tmp = TIM_CCER_CC1NE << (Channel & 0x1FU); /* 0x1FU = 31 bits max shift */
|
tmp = TIM_CCER_CC1NE << (Channel & 0xFU); /* 0xFU = 15 bits max shift */
|
||||||
|
|
||||||
/* Reset the CCxNE Bit */
|
/* Reset the CCxNE Bit */
|
||||||
TIMx->CCER &= ~tmp;
|
TIMx->CCER &= ~tmp;
|
||||||
|
|
||||||
/* Set or reset the CCxNE Bit */
|
/* Set or reset the CCxNE Bit */
|
||||||
TIMx->CCER |= (uint32_t)(ChannelNState << (Channel & 0x1FU)); /* 0x1FU = 31 bits max shift */
|
TIMx->CCER |= (uint32_t)(ChannelNState << (Channel & 0xFU)); /* 0xFU = 15 bits max shift */
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
@ -105,7 +105,7 @@
|
|||||||
|
|
||||||
[..]
|
[..]
|
||||||
Use function HAL_UART_UnRegisterCallback() to reset a callback to the default
|
Use function HAL_UART_UnRegisterCallback() to reset a callback to the default
|
||||||
weak (surcharged) function.
|
weak function.
|
||||||
HAL_UART_UnRegisterCallback() takes as parameters the HAL peripheral handle,
|
HAL_UART_UnRegisterCallback() takes as parameters the HAL peripheral handle,
|
||||||
and the Callback ID.
|
and the Callback ID.
|
||||||
This function allows to reset following callbacks:
|
This function allows to reset following callbacks:
|
||||||
@ -127,10 +127,10 @@
|
|||||||
|
|
||||||
[..]
|
[..]
|
||||||
By default, after the HAL_UART_Init() and when the state is HAL_UART_STATE_RESET
|
By default, after the HAL_UART_Init() and when the state is HAL_UART_STATE_RESET
|
||||||
all callbacks are set to the corresponding weak (surcharged) functions:
|
all callbacks are set to the corresponding weak functions:
|
||||||
examples HAL_UART_TxCpltCallback(), HAL_UART_RxHalfCpltCallback().
|
examples HAL_UART_TxCpltCallback(), HAL_UART_RxHalfCpltCallback().
|
||||||
Exception done for MspInit and MspDeInit functions that are respectively
|
Exception done for MspInit and MspDeInit functions that are respectively
|
||||||
reset to the legacy weak (surcharged) functions in the HAL_UART_Init()
|
reset to the legacy weak functions in the HAL_UART_Init()
|
||||||
and HAL_UART_DeInit() only when these callbacks are null (not registered beforehand).
|
and HAL_UART_DeInit() only when these callbacks are null (not registered beforehand).
|
||||||
If not, MspInit or MspDeInit are not null, the HAL_UART_Init() and HAL_UART_DeInit()
|
If not, MspInit or MspDeInit are not null, the HAL_UART_Init() and HAL_UART_DeInit()
|
||||||
keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
|
keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
|
||||||
@ -147,7 +147,7 @@
|
|||||||
[..]
|
[..]
|
||||||
When The compilation define USE_HAL_UART_REGISTER_CALLBACKS is set to 0 or
|
When The compilation define USE_HAL_UART_REGISTER_CALLBACKS is set to 0 or
|
||||||
not defined, the callback registration feature is not available
|
not defined, the callback registration feature is not available
|
||||||
and weak (surcharged) callbacks are used.
|
and weak callbacks are used.
|
||||||
|
|
||||||
|
|
||||||
@endverbatim
|
@endverbatim
|
||||||
@ -191,8 +191,8 @@
|
|||||||
/** @addtogroup UART_Private_Functions
|
/** @addtogroup UART_Private_Functions
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
static void UART_EndTxTransfer(UART_HandleTypeDef *huart);
|
|
||||||
static void UART_EndRxTransfer(UART_HandleTypeDef *huart);
|
static void UART_EndRxTransfer(UART_HandleTypeDef *huart);
|
||||||
|
static void UART_EndTxTransfer(UART_HandleTypeDef *huart);
|
||||||
static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma);
|
static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma);
|
||||||
static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma);
|
static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma);
|
||||||
static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
|
static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
|
||||||
@ -330,17 +330,19 @@ HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart)
|
|||||||
|
|
||||||
__HAL_UART_DISABLE(huart);
|
__HAL_UART_DISABLE(huart);
|
||||||
|
|
||||||
|
/* Perform advanced settings configuration */
|
||||||
|
/* For some items, configuration requires to be done prior TE and RE bits are set */
|
||||||
|
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
||||||
|
{
|
||||||
|
UART_AdvFeatureConfig(huart);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the UART Communication parameters */
|
/* Set the UART Communication parameters */
|
||||||
if (UART_SetConfig(huart) == HAL_ERROR)
|
if (UART_SetConfig(huart) == HAL_ERROR)
|
||||||
{
|
{
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
|
||||||
{
|
|
||||||
UART_AdvFeatureConfig(huart);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In asynchronous mode, the following bits must be kept cleared:
|
/* In asynchronous mode, the following bits must be kept cleared:
|
||||||
- LINEN (if LIN is supported) and CLKEN bits in the USART_CR2 register,
|
- LINEN (if LIN is supported) and CLKEN bits in the USART_CR2 register,
|
||||||
- SCEN (if Smartcard is supported), HDSEL and IREN (if IrDA is supported) bits in the USART_CR3 register.*/
|
- SCEN (if Smartcard is supported), HDSEL and IREN (if IrDA is supported) bits in the USART_CR3 register.*/
|
||||||
@ -411,17 +413,19 @@ HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart)
|
|||||||
|
|
||||||
__HAL_UART_DISABLE(huart);
|
__HAL_UART_DISABLE(huart);
|
||||||
|
|
||||||
|
/* Perform advanced settings configuration */
|
||||||
|
/* For some items, configuration requires to be done prior TE and RE bits are set */
|
||||||
|
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
||||||
|
{
|
||||||
|
UART_AdvFeatureConfig(huart);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the UART Communication parameters */
|
/* Set the UART Communication parameters */
|
||||||
if (UART_SetConfig(huart) == HAL_ERROR)
|
if (UART_SetConfig(huart) == HAL_ERROR)
|
||||||
{
|
{
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
|
||||||
{
|
|
||||||
UART_AdvFeatureConfig(huart);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In half-duplex mode, the following bits must be kept cleared:
|
/* In half-duplex mode, the following bits must be kept cleared:
|
||||||
- LINEN (if LIN is supported) and CLKEN bits in the USART_CR2 register,
|
- LINEN (if LIN is supported) and CLKEN bits in the USART_CR2 register,
|
||||||
- SCEN (if Smartcard is supported) and IREN (if IrDA is supported) bits in the USART_CR3 register.*/
|
- SCEN (if Smartcard is supported) and IREN (if IrDA is supported) bits in the USART_CR3 register.*/
|
||||||
@ -512,17 +516,19 @@ HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLe
|
|||||||
|
|
||||||
__HAL_UART_DISABLE(huart);
|
__HAL_UART_DISABLE(huart);
|
||||||
|
|
||||||
|
/* Perform advanced settings configuration */
|
||||||
|
/* For some items, configuration requires to be done prior TE and RE bits are set */
|
||||||
|
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
||||||
|
{
|
||||||
|
UART_AdvFeatureConfig(huart);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the UART Communication parameters */
|
/* Set the UART Communication parameters */
|
||||||
if (UART_SetConfig(huart) == HAL_ERROR)
|
if (UART_SetConfig(huart) == HAL_ERROR)
|
||||||
{
|
{
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
|
||||||
{
|
|
||||||
UART_AdvFeatureConfig(huart);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In LIN mode, the following bits must be kept cleared:
|
/* In LIN mode, the following bits must be kept cleared:
|
||||||
- LINEN and CLKEN bits in the USART_CR2 register,
|
- LINEN and CLKEN bits in the USART_CR2 register,
|
||||||
- SCEN(if Smartcard is supported) and IREN(if IrDA is supported) bits in the USART_CR3 register.*/
|
- SCEN(if Smartcard is supported) and IREN(if IrDA is supported) bits in the USART_CR3 register.*/
|
||||||
@ -609,17 +615,19 @@ HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Add
|
|||||||
|
|
||||||
__HAL_UART_DISABLE(huart);
|
__HAL_UART_DISABLE(huart);
|
||||||
|
|
||||||
|
/* Perform advanced settings configuration */
|
||||||
|
/* For some items, configuration requires to be done prior TE and RE bits are set */
|
||||||
|
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
||||||
|
{
|
||||||
|
UART_AdvFeatureConfig(huart);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the UART Communication parameters */
|
/* Set the UART Communication parameters */
|
||||||
if (UART_SetConfig(huart) == HAL_ERROR)
|
if (UART_SetConfig(huart) == HAL_ERROR)
|
||||||
{
|
{
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
|
||||||
{
|
|
||||||
UART_AdvFeatureConfig(huart);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In multiprocessor mode, the following bits must be kept cleared:
|
/* In multiprocessor mode, the following bits must be kept cleared:
|
||||||
- LINEN (if LIN is supported) and CLKEN bits in the USART_CR2 register,
|
- LINEN (if LIN is supported) and CLKEN bits in the USART_CR2 register,
|
||||||
- SCEN (if Smartcard is supported), HDSEL and IREN (if IrDA is supported) bits in the USART_CR3 register. */
|
- SCEN (if Smartcard is supported), HDSEL and IREN (if IrDA is supported) bits in the USART_CR3 register. */
|
||||||
@ -738,7 +746,7 @@ __weak void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
|
|||||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||||
/**
|
/**
|
||||||
* @brief Register a User UART Callback
|
* @brief Register a User UART Callback
|
||||||
* To be used instead of the weak predefined callback
|
* To be used to override the weak predefined callback
|
||||||
* @note The HAL_UART_RegisterCallback() may be called before HAL_UART_Init(), HAL_HalfDuplex_Init(),
|
* @note The HAL_UART_RegisterCallback() may be called before HAL_UART_Init(), HAL_HalfDuplex_Init(),
|
||||||
* HAL_LIN_Init(), HAL_MultiProcessor_Init() or HAL_RS485Ex_Init() in HAL_UART_STATE_RESET to register
|
* HAL_LIN_Init(), HAL_MultiProcessor_Init() or HAL_RS485Ex_Init() in HAL_UART_STATE_RESET to register
|
||||||
* callbacks for HAL_UART_MSPINIT_CB_ID and HAL_UART_MSPDEINIT_CB_ID
|
* callbacks for HAL_UART_MSPINIT_CB_ID and HAL_UART_MSPDEINIT_CB_ID
|
||||||
@ -994,10 +1002,7 @@ HAL_StatusTypeDef HAL_UART_RegisterRxEventCallback(UART_HandleTypeDef *huart, pU
|
|||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process locked */
|
if (huart->RxState == HAL_UART_STATE_READY)
|
||||||
__HAL_LOCK(huart);
|
|
||||||
|
|
||||||
if (huart->gState == HAL_UART_STATE_READY)
|
|
||||||
{
|
{
|
||||||
huart->RxEventCallback = pCallback;
|
huart->RxEventCallback = pCallback;
|
||||||
}
|
}
|
||||||
@ -1008,9 +1013,6 @@ HAL_StatusTypeDef HAL_UART_RegisterRxEventCallback(UART_HandleTypeDef *huart, pU
|
|||||||
status = HAL_ERROR;
|
status = HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release Lock */
|
|
||||||
__HAL_UNLOCK(huart);
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1024,10 +1026,7 @@ HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback(UART_HandleTypeDef *huart)
|
|||||||
{
|
{
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
HAL_StatusTypeDef status = HAL_OK;
|
||||||
|
|
||||||
/* Process locked */
|
if (huart->RxState == HAL_UART_STATE_READY)
|
||||||
__HAL_LOCK(huart);
|
|
||||||
|
|
||||||
if (huart->gState == HAL_UART_STATE_READY)
|
|
||||||
{
|
{
|
||||||
huart->RxEventCallback = HAL_UARTEx_RxEventCallback; /* Legacy weak UART Rx Event Callback */
|
huart->RxEventCallback = HAL_UARTEx_RxEventCallback; /* Legacy weak UART Rx Event Callback */
|
||||||
}
|
}
|
||||||
@ -1038,8 +1037,6 @@ HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback(UART_HandleTypeDef *huart)
|
|||||||
status = HAL_ERROR;
|
status = HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release Lock */
|
|
||||||
__HAL_UNLOCK(huart);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3180,6 +3177,13 @@ void UART_AdvFeatureConfig(UART_HandleTypeDef *huart)
|
|||||||
/* Check whether the set of advanced features to configure is properly set */
|
/* Check whether the set of advanced features to configure is properly set */
|
||||||
assert_param(IS_UART_ADVFEATURE_INIT(huart->AdvancedInit.AdvFeatureInit));
|
assert_param(IS_UART_ADVFEATURE_INIT(huart->AdvancedInit.AdvFeatureInit));
|
||||||
|
|
||||||
|
/* if required, configure RX/TX pins swap */
|
||||||
|
if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_SWAP_INIT))
|
||||||
|
{
|
||||||
|
assert_param(IS_UART_ADVFEATURE_SWAP(huart->AdvancedInit.Swap));
|
||||||
|
MODIFY_REG(huart->Instance->CR2, USART_CR2_SWAP, huart->AdvancedInit.Swap);
|
||||||
|
}
|
||||||
|
|
||||||
/* if required, configure TX pin active level inversion */
|
/* if required, configure TX pin active level inversion */
|
||||||
if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_TXINVERT_INIT))
|
if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_TXINVERT_INIT))
|
||||||
{
|
{
|
||||||
@ -3201,13 +3205,6 @@ void UART_AdvFeatureConfig(UART_HandleTypeDef *huart)
|
|||||||
MODIFY_REG(huart->Instance->CR2, USART_CR2_DATAINV, huart->AdvancedInit.DataInvert);
|
MODIFY_REG(huart->Instance->CR2, USART_CR2_DATAINV, huart->AdvancedInit.DataInvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if required, configure RX/TX pins swap */
|
|
||||||
if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_SWAP_INIT))
|
|
||||||
{
|
|
||||||
assert_param(IS_UART_ADVFEATURE_SWAP(huart->AdvancedInit.Swap));
|
|
||||||
MODIFY_REG(huart->Instance->CR2, USART_CR2_SWAP, huart->AdvancedInit.Swap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if required, configure RX overrun detection disabling */
|
/* if required, configure RX overrun detection disabling */
|
||||||
if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_RXOVERRUNDISABLE_INIT))
|
if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_RXOVERRUNDISABLE_INIT))
|
||||||
{
|
{
|
||||||
@ -3333,24 +3330,24 @@ HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_
|
|||||||
return HAL_TIMEOUT;
|
return HAL_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (READ_BIT(huart->Instance->CR1, USART_CR1_RE) != 0U)
|
if ((READ_BIT(huart->Instance->CR1, USART_CR1_RE) != 0U) && (Flag != UART_FLAG_TXE) && (Flag != UART_FLAG_TC))
|
||||||
{
|
{
|
||||||
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE) == SET)
|
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE) == SET)
|
||||||
{
|
{
|
||||||
/* Clear Overrun Error flag*/
|
/* Clear Overrun Error flag*/
|
||||||
__HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF);
|
__HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF);
|
||||||
|
|
||||||
/* Blocking error : transfer is aborted
|
/* Blocking error : transfer is aborted
|
||||||
Set the UART state ready to be able to start again the process,
|
Set the UART state ready to be able to start again the process,
|
||||||
Disable Rx Interrupts if ongoing */
|
Disable Rx Interrupts if ongoing */
|
||||||
UART_EndRxTransfer(huart);
|
UART_EndRxTransfer(huart);
|
||||||
|
|
||||||
huart->ErrorCode = HAL_UART_ERROR_ORE;
|
huart->ErrorCode = HAL_UART_ERROR_ORE;
|
||||||
|
|
||||||
/* Process Unlocked */
|
/* Process Unlocked */
|
||||||
__HAL_UNLOCK(huart);
|
__HAL_UNLOCK(huart);
|
||||||
|
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_RTOF) == SET)
|
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_RTOF) == SET)
|
||||||
{
|
{
|
||||||
@ -195,17 +195,19 @@ HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity,
|
|||||||
/* Disable the Peripheral */
|
/* Disable the Peripheral */
|
||||||
__HAL_UART_DISABLE(huart);
|
__HAL_UART_DISABLE(huart);
|
||||||
|
|
||||||
|
/* Perform advanced settings configuration */
|
||||||
|
/* For some items, configuration requires to be done prior TE and RE bits are set */
|
||||||
|
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
||||||
|
{
|
||||||
|
UART_AdvFeatureConfig(huart);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the UART Communication parameters */
|
/* Set the UART Communication parameters */
|
||||||
if (UART_SetConfig(huart) == HAL_ERROR)
|
if (UART_SetConfig(huart) == HAL_ERROR)
|
||||||
{
|
{
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
|
|
||||||
{
|
|
||||||
UART_AdvFeatureConfig(huart);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable the Driver Enable mode by setting the DEM bit in the CR3 register */
|
/* Enable the Driver Enable mode by setting the DEM bit in the CR3 register */
|
||||||
SET_BIT(huart->Instance->CR3, USART_CR3_DEM);
|
SET_BIT(huart->Instance->CR3, USART_CR3_DEM);
|
||||||
|
|
||||||
@ -634,7 +636,7 @@ HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle(UART_HandleTypeDef *huart, uint8_t *p
|
|||||||
*/
|
*/
|
||||||
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
|
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
|
||||||
{
|
{
|
||||||
HAL_StatusTypeDef status;
|
HAL_StatusTypeDef status = HAL_OK;
|
||||||
|
|
||||||
/* Check that a Rx process is not already ongoing */
|
/* Check that a Rx process is not already ongoing */
|
||||||
if (huart->RxState == HAL_UART_STATE_READY)
|
if (huart->RxState == HAL_UART_STATE_READY)
|
||||||
@ -659,24 +661,20 @@ HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t
|
|||||||
huart->ReceptionType = HAL_UART_RECEPTION_TOIDLE;
|
huart->ReceptionType = HAL_UART_RECEPTION_TOIDLE;
|
||||||
huart->RxEventType = HAL_UART_RXEVENT_TC;
|
huart->RxEventType = HAL_UART_RXEVENT_TC;
|
||||||
|
|
||||||
status = UART_Start_Receive_IT(huart, pData, Size);
|
(void)UART_Start_Receive_IT(huart, pData, Size);
|
||||||
|
|
||||||
/* Check Rx process has been successfully started */
|
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
||||||
if (status == HAL_OK)
|
|
||||||
{
|
{
|
||||||
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
__HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
|
||||||
{
|
ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
||||||
__HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
|
}
|
||||||
ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
else
|
||||||
}
|
{
|
||||||
else
|
/* In case of errors already pending when reception is started,
|
||||||
{
|
Interrupts may have already been raised and lead to reception abortion.
|
||||||
/* In case of errors already pending when reception is started,
|
(Overrun error for instance).
|
||||||
Interrupts may have already been raised and lead to reception abortion.
|
In such case Reception Type has been reset to HAL_UART_RECEPTION_STANDARD. */
|
||||||
(Overrun error for instance).
|
status = HAL_ERROR;
|
||||||
In such case Reception Type has been reset to HAL_UART_RECEPTION_STANDARD. */
|
|
||||||
status = HAL_ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
@ -788,7 +786,7 @@ HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_DMA(UART_HandleTypeDef *huart, uint8_
|
|||||||
* @param huart UART handle.
|
* @param huart UART handle.
|
||||||
* @retval Rx Event Type (return vale will be a value of @ref UART_RxEvent_Type_Values)
|
* @retval Rx Event Type (return vale will be a value of @ref UART_RxEvent_Type_Values)
|
||||||
*/
|
*/
|
||||||
HAL_UART_RxEventTypeTypeDef HAL_UARTEx_GetRxEventType(UART_HandleTypeDef *huart)
|
HAL_UART_RxEventTypeTypeDef HAL_UARTEx_GetRxEventType(const UART_HandleTypeDef *huart)
|
||||||
{
|
{
|
||||||
/* Return Rx Event type value, as stored in UART handle */
|
/* Return Rx Event type value, as stored in UART handle */
|
||||||
return (huart->RxEventType);
|
return (huart->RxEventType);
|
||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<Targets>
|
<Targets>
|
||||||
<Target>
|
<Target>
|
||||||
<TargetName>stm32f0_cherryusb</TargetName>
|
<TargetName>stm32f072_usb_mouse_keyboard</TargetName>
|
||||||
<ToolsetNumber>0x4</ToolsetNumber>
|
<ToolsetNumber>0x4</ToolsetNumber>
|
||||||
<ToolsetName>ARM-ADS</ToolsetName>
|
<ToolsetName>ARM-ADS</ToolsetName>
|
||||||
<pCCUsed>6160000::V6.16::ARMCLANG</pCCUsed>
|
<pCCUsed>6160000::V6.16::ARMCLANG</pCCUsed>
|
||||||
@ -48,8 +48,8 @@
|
|||||||
<NotGenerated>0</NotGenerated>
|
<NotGenerated>0</NotGenerated>
|
||||||
<InvalidFlash>1</InvalidFlash>
|
<InvalidFlash>1</InvalidFlash>
|
||||||
</TargetStatus>
|
</TargetStatus>
|
||||||
<OutputDirectory>stm32f0_cherryusb\</OutputDirectory>
|
<OutputDirectory>stm32f072_usb_mouse_keyboard\</OutputDirectory>
|
||||||
<OutputName>stm32f0_cherryusb</OutputName>
|
<OutputName>stm32f072_usb_mouse_keyboard</OutputName>
|
||||||
<CreateExecutable>1</CreateExecutable>
|
<CreateExecutable>1</CreateExecutable>
|
||||||
<CreateLib>0</CreateLib>
|
<CreateLib>0</CreateLib>
|
||||||
<CreateHexFile>1</CreateHexFile>
|
<CreateHexFile>1</CreateHexFile>
|
||||||
@ -134,11 +134,11 @@
|
|||||||
<RunIndependent>0</RunIndependent>
|
<RunIndependent>0</RunIndependent>
|
||||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||||
<Capability>1</Capability>
|
<Capability>1</Capability>
|
||||||
<DriverSelection>4096</DriverSelection>
|
<DriverSelection>4101</DriverSelection>
|
||||||
</Flash1>
|
</Flash1>
|
||||||
<bUseTDR>1</bUseTDR>
|
<bUseTDR>1</bUseTDR>
|
||||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
<Flash2>BIN\UL2V8M.DLL</Flash2>
|
||||||
<Flash3>"" ()</Flash3>
|
<Flash3></Flash3>
|
||||||
<Flash4></Flash4>
|
<Flash4></Flash4>
|
||||||
<pFcarmOut></pFcarmOut>
|
<pFcarmOut></pFcarmOut>
|
||||||
<pFcarmGrp></pFcarmGrp>
|
<pFcarmGrp></pFcarmGrp>
|
||||||
@ -339,7 +339,7 @@
|
|||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define>USE_HAL_DRIVER,STM32F072xB</Define>
|
<Define>USE_HAL_DRIVER,STM32F072xB</Define>
|
||||||
<Undefine></Undefine>
|
<Undefine></Undefine>
|
||||||
<IncludePath>../Core/Inc;../Drivers/STM32F0xx_HAL_Driver/Inc;../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F0xx/Include;../Drivers/CMSIS/Include;../3rdParty/CherryUSB/class/hid;../3rdParty/CherryUSB/common;../3rdParty/CherryUSB/core;../3rdParty/CherryUSB/port/fsdev</IncludePath>
|
<IncludePath>../Core/Inc;../Drivers/STM32F0xx_HAL_Driver/Inc;../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F0xx/Include;../Drivers/CMSIS/Include;..\Third_Party\CherryUSB\class\hid;..\Third_Party\CherryUSB\common;..\Third_Party\CherryUSB\core;..\Third_Party\CherryUSB\port\fsdev</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
</Cads>
|
</Cads>
|
||||||
<Aads>
|
<Aads>
|
||||||
@ -393,16 +393,6 @@
|
|||||||
<Group>
|
<Group>
|
||||||
<GroupName>Application/User/Core</GroupName>
|
<GroupName>Application/User/Core</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
<File>
|
|
||||||
<FileName>hid_keyboard_mouse.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\Core\Src\hid_keyboard_mouse.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<FileName>bsp_key.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\Core\Src\bsp_key.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
<File>
|
||||||
<FileName>main.c</FileName>
|
<FileName>main.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
@ -418,6 +408,16 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>../Core/Src/stm32f0xx_hal_msp.c</FilePath>
|
<FilePath>../Core/Src/stm32f0xx_hal_msp.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>bsp_key.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\Core\Src\bsp_key.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>hid_keyboard_mouse.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\Core\Src\hid_keyboard_mouse.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
@ -521,22 +521,27 @@
|
|||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>3rdParty/CherryUSB</GroupName>
|
<GroupName>Third_Party/CherryUSB</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
<File>
|
|
||||||
<FileName>usbd_core.c</FileName>
|
|
||||||
<FileType>1</FileType>
|
|
||||||
<FilePath>..\3rdParty\CherryUSB\core\usbd_core.c</FilePath>
|
|
||||||
</File>
|
|
||||||
<File>
|
<File>
|
||||||
<FileName>usbd_hid.c</FileName>
|
<FileName>usbd_hid.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\3rdParty\CherryUSB\class\hid\usbd_hid.c</FilePath>
|
<FilePath>..\Third_Party\CherryUSB\class\hid\usbd_hid.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>usbd_core.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\Third_Party\CherryUSB\core\usbd_core.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>usb_dc_fsdev.c</FileName>
|
<FileName>usb_dc_fsdev.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\3rdParty\CherryUSB\port\fsdev\usb_dc_fsdev.c</FilePath>
|
<FilePath>..\Third_Party\CherryUSB\port\fsdev\usb_dc_fsdev.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>usb_config.h</FileName>
|
||||||
|
<FileType>5</FileType>
|
||||||
|
<FilePath>..\Core\Inc\usb_config.h</FilePath>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
@ -553,7 +558,7 @@
|
|||||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device">
|
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device">
|
||||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
|
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
|
||||||
<targetInfos>
|
<targetInfos>
|
||||||
<targetInfo name="stm32f0_cherryusb"/>
|
<targetInfo name="stm32f072_usb_mouse_keyboard"/>
|
||||||
</targetInfos>
|
</targetInfos>
|
||||||
</component>
|
</component>
|
||||||
</components>
|
</components>
|
||||||
@ -563,7 +568,7 @@
|
|||||||
<LayerInfo>
|
<LayerInfo>
|
||||||
<Layers>
|
<Layers>
|
||||||
<Layer>
|
<Layer>
|
||||||
<LayName>stm32f0_cherryusb</LayName>
|
<LayName>stm32f072_usb_mouse_keyboard</LayName>
|
||||||
<LayPrjMark>1</LayPrjMark>
|
<LayPrjMark>1</LayPrjMark>
|
||||||
</Layer>
|
</Layer>
|
||||||
</Layers>
|
</Layers>
|
||||||
@ -17,7 +17,7 @@ In order to make it easier for users to learn USB basics, enumeration, driver lo
|
|||||||
- Class-drivers and porting-drivers are templating and simplification
|
- Class-drivers and porting-drivers are templating and simplification
|
||||||
- Clear API classification (slave: initialisation, registration api, command callback api, data sending and receiving api; host: initialisation, lookup api, data sending and receiving api)
|
- Clear API classification (slave: initialisation, registration api, command callback api, data sending and receiving api; host: initialisation, lookup api, data sending and receiving api)
|
||||||
|
|
||||||
### Easy to use USB
|
### Easy to use USB
|
||||||
|
|
||||||
In order to facilitate the use of the USB interface and to take into account the fact that users have learned about uart and dma, the following advantages have been designed for the data sending and receiving class of interface:
|
In order to facilitate the use of the USB interface and to take into account the fact that users have learned about uart and dma, the following advantages have been designed for the data sending and receiving class of interface:
|
||||||
|
|
||||||
@ -34,29 +34,16 @@ Taking into account USB performance issues and trying to achieve the theoretical
|
|||||||
- Unlimited length make it easier to interface with hardware DMA and take advantage of DMA
|
- Unlimited length make it easier to interface with hardware DMA and take advantage of DMA
|
||||||
- Subcontracting function is handled in interrupt
|
- Subcontracting function is handled in interrupt
|
||||||
|
|
||||||
## Directoy Structure
|
## Directory Structure
|
||||||
|
|
||||||
```
|
|
||||||
.
|
|
||||||
├── class
|
|
||||||
├── common
|
|
||||||
├── core
|
|
||||||
├── demo
|
|
||||||
├── docs
|
|
||||||
├── osal
|
|
||||||
├── packet capture
|
|
||||||
└── port
|
|
||||||
└── tools
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
| Directory | Description |
|
| Directory | Description |
|
||||||
|:-------------:|:---------------------------:|
|
|:-------------:|:---------------------------:|
|
||||||
|class | usb class driver |
|
|class | usb class driver |
|
||||||
|common | usb spec macros and utils |
|
|common | usb spec macros and utils |
|
||||||
|core | usb core implementation |
|
|core | usb core implementation |
|
||||||
|demo | different chips demo |
|
|demo | usb device and host demo |
|
||||||
|osal | os wrapper |
|
|osal | os wrapper |
|
||||||
|
|platform | class support for other os |
|
||||||
|docs | doc for guiding |
|
|docs | doc for guiding |
|
||||||
|port | usb dcd and hcd porting |
|
|port | usb dcd and hcd porting |
|
||||||
|tools | tool url |
|
|tools | tool url |
|
||||||
@ -78,15 +65,17 @@ CherryUSB Device Stack has the following functions:
|
|||||||
- Support Device Firmware Upgrade CLASS (DFU)
|
- Support Device Firmware Upgrade CLASS (DFU)
|
||||||
- Support USB MIDI CLASS (MIDI)
|
- Support USB MIDI CLASS (MIDI)
|
||||||
- Support Remote NDIS (RNDIS)
|
- Support Remote NDIS (RNDIS)
|
||||||
- Support WINUSB1.0、WINUSB2.0(with BOS)
|
- Support WINUSB1.0、WINUSB2.0、WEBUSB、BOS
|
||||||
- Support Vendor class
|
- Support Vendor class
|
||||||
|
- Support UF2
|
||||||
|
- Support Android Debug Bridge (Only support shell)
|
||||||
- Support multi device with the same USB IP
|
- Support multi device with the same USB IP
|
||||||
|
|
||||||
CherryUSB Device Stack resource usage (GCC 10.2 with -O2):
|
CherryUSB Device Stack resource usage (GCC 10.2 with -O2):
|
||||||
|
|
||||||
| file | FLASH (Byte) | No Cache RAM (Byte) | RAM (Byte) | Heap (Byte) |
|
| file | FLASH (Byte) | No Cache RAM (Byte) | RAM (Byte) | Heap (Byte) |
|
||||||
|:-------------:|:--------------:|:-------------------------:|:-------------:|:----------------:|
|
|:-------------:|:--------------:|:-------------------------:|:-------------:|:----------------:|
|
||||||
|usbd_core.c | 3516 | 256(default) + 320 | 0 | 0 |
|
|usbd_core.c | 3516 | 512(default) + 320 | 0 | 0 |
|
||||||
|usbd_cdc.c | 392 | 0 | 0 | 0 |
|
|usbd_cdc.c | 392 | 0 | 0 | 0 |
|
||||||
|usbd_msc.c | 2839 | 128 + 512(default) | 16 | 0 |
|
|usbd_msc.c | 2839 | 128 + 512(default) | 16 | 0 |
|
||||||
|usbd_hid.c | 364 | 0 | 0 | 0 |
|
|usbd_hid.c | 364 | 0 | 0 | 0 |
|
||||||
@ -100,6 +89,7 @@ The CherryUSB Host Stack has a standard enumeration implementation for devices m
|
|||||||
|
|
||||||
CherryUSB Host Stack has the following functions:
|
CherryUSB Host Stack has the following functions:
|
||||||
|
|
||||||
|
- Support low speed, full speed, high speed and super speed devices
|
||||||
- Automatic loading of supported Class drivers
|
- Automatic loading of supported Class drivers
|
||||||
- Support blocking transfers and asynchronous transfers
|
- Support blocking transfers and asynchronous transfers
|
||||||
- Support Composite Device
|
- Support Composite Device
|
||||||
@ -107,11 +97,11 @@ CherryUSB Host Stack has the following functions:
|
|||||||
- Support Communication Device Class (CDC_ACM, CDC_ECM)
|
- Support Communication Device Class (CDC_ACM, CDC_ECM)
|
||||||
- Support Human Interface Device (HID)
|
- Support Human Interface Device (HID)
|
||||||
- Support Mass Storage Class (MSC)
|
- Support Mass Storage Class (MSC)
|
||||||
- Support USB Video CLASS (commercial charge)
|
- Support USB Video CLASS (UVC1.0、UVC1.5)
|
||||||
- Support USB Audio CLASS (commercial charge)
|
- Support USB Audio CLASS (UAC1.0)
|
||||||
- Support Remote NDIS (RNDIS)
|
- Support Remote NDIS (RNDIS)
|
||||||
- Support USB Bluetooth class (support nimble and zephyr bluetooth stack, support **CLASS:0xE0** or vendor class like cdc acm)
|
- Support USB Bluetooth class (support nimble and zephyr bluetooth stack, support **CLASS:0xE0** or vendor class like cdc acm)
|
||||||
- Support Vendor class
|
- Support Vendor class (serial, net, wifi)
|
||||||
- Support USB modeswitch
|
- Support USB modeswitch
|
||||||
- Support multi host with the same USB IP
|
- Support multi host with the same USB IP
|
||||||
|
|
||||||
@ -121,14 +111,14 @@ CherryUSB Host Stack resource usage (GCC 10.2 with -O2):
|
|||||||
|
|
||||||
| file | FLASH (Byte) | No Cache RAM (Byte) | RAM (Byte) | Heap (Byte) |
|
| file | FLASH (Byte) | No Cache RAM (Byte) | RAM (Byte) | Heap (Byte) |
|
||||||
|:-------------:|:--------------:|:-------------------------------:|:---------------------------:|:------------:|
|
|:-------------:|:--------------:|:-------------------------------:|:---------------------------:|:------------:|
|
||||||
|usbh_core.c | ~7700 | 512 + 8 * (1+x) *n | 28 | 0 |
|
|usbh_core.c | ~7700 | 512 + 8 * (1+x) *n | 28 | raw_config_desc |
|
||||||
|usbh_hub.c | ~5600 | 32 + 4* (1+x) | 12 + sizeof(struct usbh_hub) * (1+x) | 0 |
|
|usbh_hub.c | ~5600 | 32 + 4* (1+x) | 12 + sizeof(struct usbh_hub) * (1+x) | 0 |
|
||||||
|usbh_cdc_acm.c | ~1200 | 7 | 4 + sizeof(struct usbh_cdc_acm) * x | 0 |
|
|usbh_cdc_acm.c | ~1200 | 7 | 4 + sizeof(struct usbh_cdc_acm) * x | 0 |
|
||||||
|usbh_msc.c | ~2500 | 32 | 4 + sizeof(struct usbh_msc) * x | 0 |
|
|usbh_msc.c | ~2500 | 32 | 4 + sizeof(struct usbh_msc) * x | 0 |
|
||||||
|usbh_hid.c | ~1000 | 128 | 4 + sizeof(struct usbh_hid) * x | 0 |
|
|usbh_hid.c | ~1000 | 128 | 4 + sizeof(struct usbh_hid) * x | 0 |
|
||||||
|usbh_video.c | ~3700 | 128 | 4 + sizeof(struct usbh_video) * x | 0 |
|
|usbh_video.c | ~3700 | 128 | 4 + sizeof(struct usbh_video) * x | 0 |
|
||||||
|usbh_audio.c | ~3100 | 128 | 4 + sizeof(struct usbh_audio) * x | 0 |
|
|usbh_audio.c | ~3100 | 128 | 4 + sizeof(struct usbh_audio) * x | 0 |
|
||||||
|usbh_rndis.c | ~3900 | 4096 + 2 * 2048 | sizeof(struct usbh_rndis) * 1 | 0 |
|
|usbh_rndis.c | ~3900 | 4096 + 2 * 2048(default)| sizeof(struct usbh_rndis) * 1 | 0 |
|
||||||
|usbh_cdc_ecm.c | ~2500 | 2 * 1514 | sizeof(struct usbh_cdc_ecm) * 1 | 0 |
|
|usbh_cdc_ecm.c | ~2500 | 2 * 1514 | sizeof(struct usbh_cdc_ecm) * 1 | 0 |
|
||||||
|usbh_bluetooth.c | ~2300 | 2 * 2048(default) | sizeof(struct usbh_bluetooth) * 1 | 0 |
|
|usbh_bluetooth.c | ~2300 | 2 * 2048(default) | sizeof(struct usbh_bluetooth) * 1 | 0 |
|
||||||
|
|
||||||
@ -161,10 +151,11 @@ Only standard and commercial USB IP are listed.
|
|||||||
| OHCI(intel) | none | OHCI | × |
|
| OHCI(intel) | none | OHCI | × |
|
||||||
| EHCI(intel) | none | EHCI | √ |
|
| EHCI(intel) | none | EHCI | √ |
|
||||||
| XHCI(intel) | none | XHCI | √ |
|
| XHCI(intel) | none | XHCI | √ |
|
||||||
| UHCI(intel) | none | UHCI | × |
|
| UHCI(intel) | none | UHCI | × |
|
||||||
| DWC2(synopsys) | DWC2 | DWC2 | √ |
|
| DWC2(synopsys) | DWC2 | DWC2 | √ |
|
||||||
| MUSB(mentor) | MUSB | MUSB | √ |
|
| MUSB(mentor) | MUSB | MUSB | √ |
|
||||||
| FOTG210(faraday)| FOTG210 | EHCI | √ |
|
| FOTG210(faraday)| FOTG210 | EHCI | √ |
|
||||||
|
| CHIPIDEA(synopsys)| CHIPIDEA | EHCI | √ |
|
||||||
| CDNS2(cadence) | CDNS2 | CDNS2 | √ |
|
| CDNS2(cadence) | CDNS2 | CDNS2 | √ |
|
||||||
| CDNS3(cadence) | CDNS3 | XHCI | × |
|
| CDNS3(cadence) | CDNS3 | XHCI | × |
|
||||||
| DWC3(synopsys) | DWC3 | XHCI | × |
|
| DWC3(synopsys) | DWC3 | XHCI | × |
|
||||||
@ -186,17 +177,31 @@ USB basic concepts and how the CherryUSB Device stack is implemented, see [Cherr
|
|||||||
| Manufacturer | CHIP or Series | USB IP| Repo Url | Support version | Support status |
|
| Manufacturer | CHIP or Series | USB IP| Repo Url | Support version | Support status |
|
||||||
|:--------------------:|:------------------:|:-----:|:--------:|:------------------:|:-------------:|
|
|:--------------------:|:------------------:|:-----:|:--------:|:------------------:|:-------------:|
|
||||||
|Bouffalolab | BL702/BL616/BL808 | bouffalolab/ehci|[bouffalo_sdk](https://github.com/CherryUSB/bouffalo_sdk)|<= latest | Long-term |
|
|Bouffalolab | BL702/BL616/BL808 | bouffalolab/ehci|[bouffalo_sdk](https://github.com/CherryUSB/bouffalo_sdk)|<= latest | Long-term |
|
||||||
|ST | STM32F1x | fsdev |[stm32_repo](https://github.com/CherryUSB/cherryusb_stm32)|<= latest | Long-term |
|
|ST | STM32F1x | fsdev |[stm32_repo](https://github.com/CherryUSB/cherryusb_stm32)|<= latest | Long-term |
|
||||||
|ST | STM32F4/STM32H7 | dwc2 |[stm32_repo](https://github.com/CherryUSB/cherryusb_stm32)|<= latest | Long-term |
|
|ST | STM32F4/STM32H7 | dwc2 |[stm32_repo](https://github.com/CherryUSB/cherryusb_stm32)|<= latest | Long-term |
|
||||||
|HPMicro | HPM6750 | hpm/ehci |[hpm_sdk](https://github.com/CherryUSB/hpm_sdk)|<= latest | Long-term |
|
|HPMicro | HPM6000/HPM5000 | hpm/ehci |[hpm_sdk](https://github.com/CherryUSB/hpm_sdk)|<= latest | Long-term |
|
||||||
|Essemi | ES32F36xx | musb |[es32f369_repo](https://github.com/CherryUSB/cherryusb_es32)|<= latest | Long-term |
|
|Essemi | ES32F36xx | musb |[es32f369_repo](https://github.com/CherryUSB/cherryusb_es32)|<= latest | Long-term |
|
||||||
|Phytium | e2000 | pusb2/xhci |[phytium_repo](https://gitee.com/phytium_embedded/phytium-free-rtos-sdk)|v0.10.2 | Long-term |
|
|Phytium | e2000 | pusb2/xhci |[phytium_repo](https://gitee.com/phytium_embedded/phytium-free-rtos-sdk)|>=1.4.0 | Long-term |
|
||||||
|artinchip | d12x/d13x/d21x | dwc2/ehci/ohci |[luban-lite](https://gitee.com/artinchip/luban-lite)|<= latest | Long-term |
|
|Artinchip | d12x/d13x/d21x | aic/ehci/ohci |[luban-lite](https://gitee.com/artinchip/luban-lite)|<= latest | Long-term |
|
||||||
|Espressif | esp32s2/esp32s3 | dwc2 |[esp32_repo](https://github.com/CherryUSB/cherryusb_esp32)|<= latest | the same with ST |
|
|Espressif | esp32s2/esp32s3/esp32p4 | dwc2 |[esp32_repo](https://github.com/CherryUSB/cherryusb_esp32)|<= latest | Long-term |
|
||||||
|AllwinnerTech | F1C100S/F1C200S | musb |[cherryusb_rtt_f1c100s](https://github.com/CherryUSB/cherryusb_rtt_f1c100s)|<= latest | the same with Essemi |
|
|NXP | mcx | chipidea/ehci |[nxp_mcx_repo](https://github.com/CherryUSB/cherryusb_mcx)|<= latest | Long-term |
|
||||||
|WCH | CH32V307/ch58x | ch32_usbfs/ch32_usbhs/ch58x |[wch_repo](https://github.com/CherryUSB/cherryusb_wch)|<= v0.10.2 | TBD |
|
|AllwinnerTech | F1C100S/F1C200S | musb |[cherryusb_rtt_f1c100s](https://github.com/CherryUSB/cherryusb_rtt_f1c100s)|<= latest | the same with musb |
|
||||||
|Nordicsemi | Nrf52840 | nrf5x |[nrf5x_repo](https://github.com/CherryUSB/cherryusb_nrf5x)|<= v0.10.2 | No more updated |
|
|Bekencorp | bk7256/bk7258 | musb |[bk_idk](https://github.com/CherryUSB/bk_idk)| v0.7.0 | the same with musb |
|
||||||
|Raspberry pi | rp2040 | rp2040 |[pico-examples](https://github.com/CherryUSB/pico-examples)|<= v0.10.2 | No more updated |
|
|Sophgo | cv18xx | dwc2 |[cvi_alios_open](https://github.com/CherryUSB/cvi_alios_open)| v0.7.0 | TBD |
|
||||||
|
|WCH | CH32V307/ch58x | ch32_usbfs/ch32_usbhs/ch58x |[wch_repo](https://github.com/CherryUSB/cherryusb_wch)|<= v0.10.2 | TBD |
|
||||||
|
|Raspberry pi | rp2040 | rp2040 |[pico-examples](https://github.com/CherryUSB/pico-examples)|<= v0.10.2 | No more updated |
|
||||||
|
|
||||||
|
## Package Support
|
||||||
|
|
||||||
|
CherryUSB package is available as follows:
|
||||||
|
|
||||||
|
- [RT-Thread](https://packages.rt-thread.org/detail.html?package=CherryUSB)
|
||||||
|
- [YOC](https://www.xrvm.cn/document?temp=usb-host-protocol-stack-device-driver-adaptation-instructions&slug=yocbook)
|
||||||
|
- [ESP-Registry](https://components.espressif.com/components/cherry-embedded/cherryusb)
|
||||||
|
|
||||||
|
## Commercial Support
|
||||||
|
|
||||||
|
Refer to https://cherryusb.readthedocs.io/zh-cn/latest/support/index.html.
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
|
||||||
@ -206,4 +211,4 @@ CherryUSB discord: https://discord.com/invite/wFfvrSAey8.
|
|||||||
|
|
||||||
Thanks to the following companies for their support (in no particular order).
|
Thanks to the following companies for their support (in no particular order).
|
||||||
|
|
||||||
<img src="docs/assets/bouffalolab.jpg" width="100" height="100"/> <img src="docs/assets/hpmicro.jpg" width="100" height="100" /> <img src="docs/assets/eastsoft.jpg" width="100" height="100" /> <img src="docs/assets/rtthread.jpg" width="100" height="100" /> <img src="docs/assets/sophgo.jpg" width="100" height="100" /> <img src="docs/assets/phytium.jpg" width="100" height="100" /> <img src="docs/assets/thead.jpg" width="100" height="100" /> <img src="docs/assets/nuvoton.jpg" width="100" height="100" /> <img src="docs/assets/artinchip.jpg" width="100" height="100" />
|
<img src="docs/assets/bouffalolab.jpg" width="100" height="80"/> <img src="docs/assets/hpmicro.jpg" width="100" height="80" /> <img src="docs/assets/eastsoft.jpg" width="100" height="80" /> <img src="docs/assets/rtthread.jpg" width="100" height="80" /> <img src="docs/assets/sophgo.jpg" width="100" height="80" /> <img src="docs/assets/phytium.jpg" width="100" height="80" /> <img src="docs/assets/thead.jpg" width="100" height="80" /> <img src="docs/assets/nuvoton.jpg" width="100" height="80" /> <img src="docs/assets/artinchip.jpg" width="100" height="80" /> <img src="docs/assets/bekencorp.jpg" width="100" height="80" /> <img src="docs/assets/nxp.png" width="100" height="80" /> <img src="docs/assets/espressif.png" width="100" height="80" />
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,89 +1,126 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, sakumisu
|
* Copyright (c) 2022, sakumisu
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#include "usbd_core.h"
|
#include "usbd_core.h"
|
||||||
#include "usbd_hid.h"
|
#include "usbd_hid.h"
|
||||||
|
|
||||||
static int hid_class_interface_request_handler(uint8_t busid, struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
static int hid_class_interface_request_handler(uint8_t busid, struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||||
{
|
{
|
||||||
USB_LOG_DBG("HID Class request: "
|
USB_LOG_DBG("HID Class request: "
|
||||||
"bRequest 0x%02x\r\n",
|
"bRequest 0x%02x\r\n",
|
||||||
setup->bRequest);
|
setup->bRequest);
|
||||||
|
|
||||||
uint8_t intf_num = LO_BYTE(setup->wIndex);
|
uint8_t intf_num = LO_BYTE(setup->wIndex);
|
||||||
|
|
||||||
switch (setup->bRequest) {
|
switch (setup->bRequest) {
|
||||||
case HID_REQUEST_GET_REPORT:
|
case HID_REQUEST_GET_REPORT:
|
||||||
/* report id ,report type */
|
/* report id ,report type */
|
||||||
usbd_hid_get_report(busid, intf_num, LO_BYTE(setup->wValue), HI_BYTE(setup->wValue), data, len);
|
usbd_hid_get_report(busid, intf_num, LO_BYTE(setup->wValue), HI_BYTE(setup->wValue), data, len);
|
||||||
break;
|
break;
|
||||||
case HID_REQUEST_GET_IDLE:
|
case HID_REQUEST_GET_IDLE:
|
||||||
(*data)[0] = usbd_hid_get_idle(busid, intf_num, LO_BYTE(setup->wValue));
|
(*data)[0] = usbd_hid_get_idle(busid, intf_num, LO_BYTE(setup->wValue));
|
||||||
*len = 1;
|
*len = 1;
|
||||||
break;
|
break;
|
||||||
case HID_REQUEST_GET_PROTOCOL:
|
case HID_REQUEST_GET_PROTOCOL:
|
||||||
(*data)[0] = usbd_hid_get_protocol(busid, intf_num);
|
(*data)[0] = usbd_hid_get_protocol(busid, intf_num);
|
||||||
*len = 1;
|
*len = 1;
|
||||||
break;
|
break;
|
||||||
case HID_REQUEST_SET_REPORT:
|
case HID_REQUEST_SET_REPORT:
|
||||||
/* report id ,report type, report, report len */
|
/* report id ,report type, report, report len */
|
||||||
usbd_hid_set_report(busid, intf_num, LO_BYTE(setup->wValue), HI_BYTE(setup->wValue), *data, *len);
|
usbd_hid_set_report(busid, intf_num, LO_BYTE(setup->wValue), HI_BYTE(setup->wValue), *data, *len);
|
||||||
break;
|
break;
|
||||||
case HID_REQUEST_SET_IDLE:
|
case HID_REQUEST_SET_IDLE:
|
||||||
/* report id, duration */
|
/* report id, duration */
|
||||||
usbd_hid_set_idle(busid, intf_num, LO_BYTE(setup->wValue), HI_BYTE(setup->wValue));
|
usbd_hid_set_idle(busid, intf_num, LO_BYTE(setup->wValue), HI_BYTE(setup->wValue));
|
||||||
break;
|
break;
|
||||||
case HID_REQUEST_SET_PROTOCOL:
|
case HID_REQUEST_SET_PROTOCOL:
|
||||||
/* protocol */
|
/* protocol */
|
||||||
usbd_hid_set_protocol(busid, intf_num, LO_BYTE(setup->wValue));
|
usbd_hid_set_protocol(busid, intf_num, LO_BYTE(setup->wValue));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
USB_LOG_WRN("Unhandled HID Class bRequest 0x%02x\r\n", setup->bRequest);
|
USB_LOG_WRN("Unhandled HID Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usbd_interface *usbd_hid_init_intf(uint8_t busid, struct usbd_interface *intf, const uint8_t *desc, uint32_t desc_len)
|
struct usbd_interface *usbd_hid_init_intf(uint8_t busid, struct usbd_interface *intf, const uint8_t *desc, uint32_t desc_len)
|
||||||
{
|
{
|
||||||
intf->class_interface_handler = hid_class_interface_request_handler;
|
(void)busid;
|
||||||
intf->class_endpoint_handler = NULL;
|
|
||||||
intf->vendor_handler = NULL;
|
intf->class_interface_handler = hid_class_interface_request_handler;
|
||||||
intf->notify_handler = NULL;
|
intf->class_endpoint_handler = NULL;
|
||||||
|
intf->vendor_handler = NULL;
|
||||||
intf->hid_report_descriptor = desc;
|
intf->notify_handler = NULL;
|
||||||
intf->hid_report_descriptor_len = desc_len;
|
|
||||||
return intf;
|
intf->hid_report_descriptor = desc;
|
||||||
}
|
intf->hid_report_descriptor_len = desc_len;
|
||||||
|
return intf;
|
||||||
__WEAK void usbd_hid_get_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t **data, uint32_t *len)
|
}
|
||||||
{
|
|
||||||
(*data[0]) = 0;
|
/*
|
||||||
*len = 1;
|
* Appendix G: HID Request Support Requirements
|
||||||
}
|
*
|
||||||
|
* The following table enumerates the requests that need to be supported by various types of HID class devices.
|
||||||
__WEAK uint8_t usbd_hid_get_idle(uint8_t busid, uint8_t intf, uint8_t report_id)
|
* Device type GetReport SetReport GetIdle SetIdle GetProtocol SetProtocol
|
||||||
{
|
* ------------------------------------------------------------------------------------------
|
||||||
return 0;
|
* Boot Mouse Required Optional Optional Optional Required Required
|
||||||
}
|
* Non-Boot Mouse Required Optional Optional Optional Optional Optional
|
||||||
|
* Boot Keyboard Required Optional Required Required Required Required
|
||||||
__WEAK uint8_t usbd_hid_get_protocol(uint8_t busid, uint8_t intf)
|
* Non-Boot Keybrd Required Optional Required Required Optional Optional
|
||||||
{
|
* Other Device Required Optional Optional Optional Optional Optional
|
||||||
return 0;
|
*/
|
||||||
}
|
|
||||||
|
__WEAK void usbd_hid_get_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t **data, uint32_t *len)
|
||||||
__WEAK void usbd_hid_set_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t *report, uint32_t report_len)
|
{
|
||||||
{
|
(void)busid;
|
||||||
}
|
(void)intf;
|
||||||
|
(void)report_id;
|
||||||
__WEAK void usbd_hid_set_idle(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t duration)
|
(void)report_type;
|
||||||
{
|
(*data[0]) = 0;
|
||||||
}
|
*len = 1;
|
||||||
|
}
|
||||||
__WEAK void usbd_hid_set_protocol(uint8_t busid, uint8_t intf, uint8_t protocol)
|
|
||||||
{
|
__WEAK uint8_t usbd_hid_get_idle(uint8_t busid, uint8_t intf, uint8_t report_id)
|
||||||
|
{
|
||||||
|
(void)busid;
|
||||||
|
(void)intf;
|
||||||
|
(void)report_id;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__WEAK uint8_t usbd_hid_get_protocol(uint8_t busid, uint8_t intf)
|
||||||
|
{
|
||||||
|
(void)busid;
|
||||||
|
(void)intf;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__WEAK void usbd_hid_set_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t *report, uint32_t report_len)
|
||||||
|
{
|
||||||
|
(void)busid;
|
||||||
|
(void)intf;
|
||||||
|
(void)report_id;
|
||||||
|
(void)report_type;
|
||||||
|
(void)report;
|
||||||
|
(void)report_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
__WEAK void usbd_hid_set_idle(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t duration)
|
||||||
|
{
|
||||||
|
(void)busid;
|
||||||
|
(void)intf;
|
||||||
|
(void)report_id;
|
||||||
|
(void)duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
__WEAK void usbd_hid_set_protocol(uint8_t busid, uint8_t intf, uint8_t protocol)
|
||||||
|
{
|
||||||
|
(void)busid;
|
||||||
|
(void)intf;
|
||||||
|
(void)protocol;
|
||||||
}
|
}
|
||||||
@ -1,34 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, sakumisu
|
* Copyright (c) 2022, sakumisu
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#ifndef USBD_HID_H
|
#ifndef USBD_HID_H
|
||||||
#define USBD_HID_H
|
#define USBD_HID_H
|
||||||
|
|
||||||
#include "usb_hid.h"
|
#include "usb_hid.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Init hid interface driver */
|
/* Init hid interface driver */
|
||||||
struct usbd_interface *usbd_hid_init_intf(uint8_t busid, struct usbd_interface *intf, const uint8_t *desc, uint32_t desc_len);
|
struct usbd_interface *usbd_hid_init_intf(uint8_t busid, struct usbd_interface *intf, const uint8_t *desc, uint32_t desc_len);
|
||||||
|
|
||||||
/* Register desc api */
|
/* Register desc api */
|
||||||
void usbd_hid_descriptor_register(uint8_t busid, uint8_t intf_num, const uint8_t *desc);
|
void usbd_hid_descriptor_register(uint8_t busid, uint8_t intf_num, const uint8_t *desc);
|
||||||
void usbd_hid_report_descriptor_register(uint8_t busid, uint8_t intf_num, const uint8_t *desc, uint32_t desc_len);
|
void usbd_hid_report_descriptor_register(uint8_t busid, uint8_t intf_num, const uint8_t *desc, uint32_t desc_len);
|
||||||
|
|
||||||
/* Setup request command callback api */
|
/* Setup request command callback api */
|
||||||
void usbd_hid_get_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t **data, uint32_t *len);
|
void usbd_hid_get_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t **data, uint32_t *len);
|
||||||
uint8_t usbd_hid_get_idle(uint8_t busid, uint8_t intf, uint8_t report_id);
|
uint8_t usbd_hid_get_idle(uint8_t busid, uint8_t intf, uint8_t report_id);
|
||||||
uint8_t usbd_hid_get_protocol(uint8_t busid, uint8_t intf);
|
uint8_t usbd_hid_get_protocol(uint8_t busid, uint8_t intf);
|
||||||
void usbd_hid_set_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t *report, uint32_t report_len);
|
void usbd_hid_set_report(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t report_type, uint8_t *report, uint32_t report_len);
|
||||||
void usbd_hid_set_idle(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t duration);
|
void usbd_hid_set_idle(uint8_t busid, uint8_t intf, uint8_t report_id, uint8_t duration);
|
||||||
void usbd_hid_set_protocol(uint8_t busid, uint8_t intf, uint8_t protocol);
|
void usbd_hid_set_protocol(uint8_t busid, uint8_t intf, uint8_t protocol);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* USBD_HID_H */
|
#endif /* USBD_HID_H */
|
||||||
@ -1,194 +1,194 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, sakumisu
|
* Copyright (c) 2022, sakumisu
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#ifndef USB_DC_H
|
#ifndef USB_DC_H
|
||||||
#define USB_DC_H
|
#define USB_DC_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief init device controller registers.
|
* @brief init device controller registers.
|
||||||
* @return On success will return 0, and others indicate fail.
|
* @return On success will return 0, and others indicate fail.
|
||||||
*/
|
*/
|
||||||
int usb_dc_init(uint8_t busid);
|
int usb_dc_init(uint8_t busid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief deinit device controller registers.
|
* @brief deinit device controller registers.
|
||||||
* @return On success will return 0, and others indicate fail.
|
* @return On success will return 0, and others indicate fail.
|
||||||
*/
|
*/
|
||||||
int usb_dc_deinit(uint8_t busid);
|
int usb_dc_deinit(uint8_t busid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set USB device address
|
* @brief Set USB device address
|
||||||
*
|
*
|
||||||
* @param[in] addr Device address
|
* @param[in] addr Device address
|
||||||
*
|
*
|
||||||
* @return On success will return 0, and others indicate fail.
|
* @return On success will return 0, and others indicate fail.
|
||||||
*/
|
*/
|
||||||
int usbd_set_address(uint8_t busid, const uint8_t addr);
|
int usbd_set_address(uint8_t busid, const uint8_t addr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get USB device speed
|
* @brief Get USB device speed
|
||||||
*
|
*
|
||||||
* @param[in] port port index
|
* @param[in] busid bus index
|
||||||
*
|
*
|
||||||
* @return port speed, USB_SPEED_LOW or USB_SPEED_FULL or USB_SPEED_HIGH
|
* @return port speed, USB_SPEED_LOW or USB_SPEED_FULL or USB_SPEED_HIGH
|
||||||
*/
|
*/
|
||||||
uint8_t usbd_get_port_speed(uint8_t busid, const uint8_t port);
|
uint8_t usbd_get_port_speed(uint8_t busid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief configure and enable endpoint.
|
* @brief configure and enable endpoint.
|
||||||
*
|
*
|
||||||
* @param [in] ep_cfg Endpoint config.
|
* @param [in] ep_cfg Endpoint config.
|
||||||
*
|
*
|
||||||
* @return On success will return 0, and others indicate fail.
|
* @return On success will return 0, and others indicate fail.
|
||||||
*/
|
*/
|
||||||
int usbd_ep_open(uint8_t busid, const struct usb_endpoint_descriptor *ep);
|
int usbd_ep_open(uint8_t busid, const struct usb_endpoint_descriptor *ep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disable the selected endpoint
|
* @brief Disable the selected endpoint
|
||||||
*
|
*
|
||||||
* @param[in] ep Endpoint address
|
* @param[in] ep Endpoint address
|
||||||
*
|
*
|
||||||
* @return On success will return 0, and others indicate fail.
|
* @return On success will return 0, and others indicate fail.
|
||||||
*/
|
*/
|
||||||
int usbd_ep_close(uint8_t busid, const uint8_t ep);
|
int usbd_ep_close(uint8_t busid, const uint8_t ep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set stall condition for the selected endpoint
|
* @brief Set stall condition for the selected endpoint
|
||||||
*
|
*
|
||||||
* @param[in] ep Endpoint address
|
* @param[in] ep Endpoint address
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return On success will return 0, and others indicate fail.
|
* @return On success will return 0, and others indicate fail.
|
||||||
*/
|
*/
|
||||||
int usbd_ep_set_stall(uint8_t busid, const uint8_t ep);
|
int usbd_ep_set_stall(uint8_t busid, const uint8_t ep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clear stall condition for the selected endpoint
|
* @brief Clear stall condition for the selected endpoint
|
||||||
*
|
*
|
||||||
* @param[in] ep Endpoint address corresponding to the one
|
* @param[in] ep Endpoint address corresponding to the one
|
||||||
* listed in the device configuration table
|
* listed in the device configuration table
|
||||||
*
|
*
|
||||||
* @return On success will return 0, and others indicate fail.
|
* @return On success will return 0, and others indicate fail.
|
||||||
*/
|
*/
|
||||||
int usbd_ep_clear_stall(uint8_t busid, const uint8_t ep);
|
int usbd_ep_clear_stall(uint8_t busid, const uint8_t ep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if the selected endpoint is stalled
|
* @brief Check if the selected endpoint is stalled
|
||||||
*
|
*
|
||||||
* @param[in] ep Endpoint address
|
* @param[in] ep Endpoint address
|
||||||
*
|
*
|
||||||
* @param[out] stalled Endpoint stall status
|
* @param[out] stalled Endpoint stall status
|
||||||
*
|
*
|
||||||
* @return On success will return 0, and others indicate fail.
|
* @return On success will return 0, and others indicate fail.
|
||||||
*/
|
*/
|
||||||
int usbd_ep_is_stalled(uint8_t busid, const uint8_t ep, uint8_t *stalled);
|
int usbd_ep_is_stalled(uint8_t busid, const uint8_t ep, uint8_t *stalled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Setup in ep transfer setting and start transfer.
|
* @brief Setup in ep transfer setting and start transfer.
|
||||||
*
|
*
|
||||||
* This function is asynchronous.
|
* This function is asynchronous.
|
||||||
* This function is similar to uart with tx dma.
|
* This function is similar to uart with tx dma.
|
||||||
*
|
*
|
||||||
* This function is called to write data to the specified endpoint. The
|
* This function is called to write data to the specified endpoint. The
|
||||||
* supplied usbd_endpoint_callback function will be called when data is transmitted
|
* supplied usbd_endpoint_callback function will be called when data is transmitted
|
||||||
* out.
|
* out.
|
||||||
*
|
*
|
||||||
* @param[in] ep Endpoint address corresponding to the one
|
* @param[in] ep Endpoint address corresponding to the one
|
||||||
* listed in the device configuration table
|
* listed in the device configuration table
|
||||||
* @param[in] data Pointer to data to write
|
* @param[in] data Pointer to data to write
|
||||||
* @param[in] data_len Length of the data requested to write. This may
|
* @param[in] data_len Length of the data requested to write. This may
|
||||||
* be zero for a zero length status packet.
|
* be zero for a zero length status packet.
|
||||||
* @return 0 on success, negative errno code on fail.
|
* @return 0 on success, negative errno code on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_ep_start_write(uint8_t busid, const uint8_t ep, const uint8_t *data, uint32_t data_len);
|
int usbd_ep_start_write(uint8_t busid, const uint8_t ep, const uint8_t *data, uint32_t data_len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Setup out ep transfer setting and start transfer.
|
* @brief Setup out ep transfer setting and start transfer.
|
||||||
*
|
*
|
||||||
* This function is asynchronous.
|
* This function is asynchronous.
|
||||||
* This function is similar to uart with rx dma.
|
* This function is similar to uart with rx dma.
|
||||||
*
|
*
|
||||||
* This function is called to read data to the specified endpoint. The
|
* This function is called to read data to the specified endpoint. The
|
||||||
* supplied usbd_endpoint_callback function will be called when data is received
|
* supplied usbd_endpoint_callback function will be called when data is received
|
||||||
* in.
|
* in.
|
||||||
*
|
*
|
||||||
* @param[in] ep Endpoint address corresponding to the one
|
* @param[in] ep Endpoint address corresponding to the one
|
||||||
* listed in the device configuration table
|
* listed in the device configuration table
|
||||||
* @param[in] data Pointer to data to read
|
* @param[in] data Pointer to data to read
|
||||||
* @param[in] data_len Max length of the data requested to read.
|
* @param[in] data_len Max length of the data requested to read.
|
||||||
*
|
*
|
||||||
* @return 0 on success, negative errno code on fail.
|
* @return 0 on success, negative errno code on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_ep_start_read(uint8_t busid, const uint8_t ep, uint8_t *data, uint32_t data_len);
|
int usbd_ep_start_read(uint8_t busid, const uint8_t ep, uint8_t *data, uint32_t data_len);
|
||||||
|
|
||||||
/* usb dcd irq callback */
|
/* usb dcd irq callback */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Usb connect irq callback.
|
* @brief Usb connect irq callback.
|
||||||
*/
|
*/
|
||||||
void usbd_event_connect_handler(uint8_t busid);
|
void usbd_event_connect_handler(uint8_t busid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Usb disconnect irq callback.
|
* @brief Usb disconnect irq callback.
|
||||||
*/
|
*/
|
||||||
void usbd_event_disconnect_handler(uint8_t busid);
|
void usbd_event_disconnect_handler(uint8_t busid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Usb resume irq callback.
|
* @brief Usb resume irq callback.
|
||||||
*/
|
*/
|
||||||
void usbd_event_resume_handler(uint8_t busid);
|
void usbd_event_resume_handler(uint8_t busid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Usb suspend irq callback.
|
* @brief Usb suspend irq callback.
|
||||||
*/
|
*/
|
||||||
void usbd_event_suspend_handler(uint8_t busid);
|
void usbd_event_suspend_handler(uint8_t busid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Usb reset irq callback.
|
* @brief Usb reset irq callback.
|
||||||
*/
|
*/
|
||||||
void usbd_event_reset_handler(uint8_t busid);
|
void usbd_event_reset_handler(uint8_t busid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Usb setup packet recv irq callback.
|
* @brief Usb setup packet recv irq callback.
|
||||||
* @param[in] psetup setup packet.
|
* @param[in] psetup setup packet.
|
||||||
*/
|
*/
|
||||||
void usbd_event_ep0_setup_complete_handler(uint8_t busid, uint8_t *psetup);
|
void usbd_event_ep0_setup_complete_handler(uint8_t busid, uint8_t *psetup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief In ep transfer complete irq callback.
|
* @brief In ep transfer complete irq callback.
|
||||||
* @param[in] ep Endpoint address corresponding to the one
|
* @param[in] ep Endpoint address corresponding to the one
|
||||||
* listed in the device configuration table
|
* listed in the device configuration table
|
||||||
* @param[in] nbytes How many nbytes have transferred.
|
* @param[in] nbytes How many nbytes have transferred.
|
||||||
*/
|
*/
|
||||||
void usbd_event_ep_in_complete_handler(uint8_t busid, uint8_t ep, uint32_t nbytes);
|
void usbd_event_ep_in_complete_handler(uint8_t busid, uint8_t ep, uint32_t nbytes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Out ep transfer complete irq callback.
|
* @brief Out ep transfer complete irq callback.
|
||||||
* @param[in] ep Endpoint address corresponding to the one
|
* @param[in] ep Endpoint address corresponding to the one
|
||||||
* listed in the device configuration table
|
* listed in the device configuration table
|
||||||
* @param[in] nbytes How many nbytes have transferred.
|
* @param[in] nbytes How many nbytes have transferred.
|
||||||
*/
|
*/
|
||||||
void usbd_event_ep_out_complete_handler(uint8_t busid, uint8_t ep, uint32_t nbytes);
|
void usbd_event_ep_out_complete_handler(uint8_t busid, uint8_t ep, uint32_t nbytes);
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_TEST_MODE
|
#ifdef CONFIG_USBDEV_TEST_MODE
|
||||||
/**
|
/**
|
||||||
* @brief Usb execute test mode
|
* @brief Usb execute test mode
|
||||||
* @param[in] busid device busid
|
* @param[in] busid device busid
|
||||||
* @param[in] test_mode usb test mode
|
* @param[in] test_mode usb test mode
|
||||||
*/
|
*/
|
||||||
void usbd_execute_test_mode(uint8_t busid, uint8_t test_mode);
|
void usbd_execute_test_mode(uint8_t busid, uint8_t test_mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* USB_DC_H */
|
#endif /* USB_DC_H */
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023, sakumisu
|
* Copyright (c) 2023, sakumisu
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#ifndef USB_ERRNO_H
|
#ifndef USB_ERRNO_H
|
||||||
#define USB_ERRNO_H
|
#define USB_ERRNO_H
|
||||||
|
|
||||||
#define USB_ERR_NOMEM 1
|
#define USB_ERR_NOMEM 1
|
||||||
#define USB_ERR_INVAL 2
|
#define USB_ERR_INVAL 2
|
||||||
#define USB_ERR_NODEV 3
|
#define USB_ERR_NODEV 3
|
||||||
#define USB_ERR_NOTCONN 4
|
#define USB_ERR_NOTCONN 4
|
||||||
#define USB_ERR_NOTSUPP 5
|
#define USB_ERR_NOTSUPP 5
|
||||||
#define USB_ERR_BUSY 6
|
#define USB_ERR_BUSY 6
|
||||||
#define USB_ERR_RANGE 7
|
#define USB_ERR_RANGE 7
|
||||||
#define USB_ERR_STALL 8
|
#define USB_ERR_STALL 8
|
||||||
#define USB_ERR_BABBLE 9
|
#define USB_ERR_BABBLE 9
|
||||||
#define USB_ERR_NAK 10
|
#define USB_ERR_NAK 10
|
||||||
#define USB_ERR_DT 11
|
#define USB_ERR_DT 11
|
||||||
#define USB_ERR_IO 12
|
#define USB_ERR_IO 12
|
||||||
#define USB_ERR_SHUTDOWN 13
|
#define USB_ERR_SHUTDOWN 13
|
||||||
#define USB_ERR_TIMEOUT 14
|
#define USB_ERR_TIMEOUT 14
|
||||||
|
|
||||||
#endif /* USB_ERRNO_H */
|
#endif /* USB_ERRNO_H */
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user