Initialization and Configuration functions.
More...
Initialization and Configuration functions.
==============================================================================
##### Initialization and Configuration functions #####
==============================================================================
[..]
This subsection provides a set of functions allowing to initialize the USARTx
in asynchronous IRDA mode.
(+) For the asynchronous mode only these parameters can be configured:
(++) Baud Rate
(++) Word Length
(++) Parity: If the parity is enabled, then the MSB bit of the data written
in the data register is transmitted but is changed by the parity bit.
(++) Power mode
(++) Prescaler setting
(++) Receiver/transmitter modes
[..]
The HAL_IRDA_Init() API follows the USART asynchronous configuration procedures
(details for the procedures are available in reference manual).Depending on the frame length defined by the M1 and M0 bits (7-bit, 8-bit or 9-bit), the possible IRDA frame formats are listed in the following table.
Table 1. IRDA frame format. +--------------------------------------------------------------------—+ | M1 bit | M0 bit | PCE bit | IRDA frame | |------—|------—|--------—|------------------------------------—| | 0 | 0 | 0 | | SB | 8 bit data | STB | | |------—|------—|--------—|------------------------------------—| | 0 | 0 | 1 | | SB | 7 bit data | PB | STB | | |------—|------—|--------—|------------------------------------—| | 0 | 1 | 0 | | SB | 9 bit data | STB | | |------—|------—|--------—|------------------------------------—| | 0 | 1 | 1 | | SB | 8 bit data | PB | STB | | |------—|------—|--------—|------------------------------------—| | 1 | 0 | 0 | | SB | 7 bit data | STB | | |------—|------—|--------—|------------------------------------—| | 1 | 0 | 1 | | SB | 6 bit data | PB | STB | | +--------------------------------------------------------------------—+
◆ HAL_IRDA_DeInit()
DeInitialize the IRDA peripheral.
- Parameters
-
| hirda | Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. |
- Return values
-
Definition at line 401 of file stm32l4xx_hal_irda.c.
412 hirda->gState = HAL_IRDA_STATE_BUSY;
415 #if USE_HAL_IRDA_REGISTER_CALLBACKS == 1 416 if (hirda->MspDeInitCallback == NULL)
421 hirda->MspDeInitCallback(hirda);
426 __HAL_IRDA_DISABLE(hirda);
428 hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
429 hirda->gState = HAL_IRDA_STATE_RESET;
430 hirda->RxState = HAL_IRDA_STATE_RESET;
void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda)
DeInitialize the IRDA MSP.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
◆ HAL_IRDA_Init()
Initialize the IRDA mode according to the specified parameters in the IRDA_InitTypeDef and initialize the associated handle.
- Parameters
-
| hirda | Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. |
- Return values
-
Definition at line 336 of file stm32l4xx_hal_irda.c.
347 if (hirda->gState == HAL_IRDA_STATE_RESET)
352 #if USE_HAL_IRDA_REGISTER_CALLBACKS == 1 355 if (hirda->MspInitCallback == NULL)
361 hirda->MspInitCallback(hirda);
368 hirda->gState = HAL_IRDA_STATE_BUSY;
371 __HAL_IRDA_DISABLE(hirda);
382 CLEAR_BIT(hirda->Instance->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP));
383 CLEAR_BIT(hirda->Instance->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
386 hirda->Instance->CR3 |= USART_CR3_IREN;
389 __HAL_IRDA_ENABLE(hirda);
static HAL_StatusTypeDef IRDA_SetConfig(IRDA_HandleTypeDef *hirda)
Configure the IRDA peripheral.
void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda)
Initialize the IRDA MSP.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
void IRDA_InitCallbacksToDefault(IRDA_HandleTypeDef *hirda)
Initialize the callbacks to their default values.
static HAL_StatusTypeDef IRDA_CheckIdleState(IRDA_HandleTypeDef *hirda)
Check the IRDA Idle State.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
◆ HAL_IRDA_MspDeInit()
DeInitialize the IRDA MSP.
- Parameters
-
| hirda | Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. |
- Return values
-
Definition at line 460 of file stm32l4xx_hal_irda.c.
◆ HAL_IRDA_MspInit()
Initialize the IRDA MSP.
- Parameters
-
| hirda | Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. |
- Return values
-
Definition at line 444 of file stm32l4xx_hal_irda.c.
◆ HAL_IRDA_RegisterCallback()
Register a User IRDA Callback To be used instead of the weak predefined callback.
- Parameters
-
| hirda | irda handle |
| CallbackID | ID of the callback to be registered This parameter can be one of the following values:
|
| pCallback | pointer to the Callback function |
- Return values
-
Definition at line 490 of file stm32l4xx_hal_irda.c.
493 HAL_StatusTypeDef status =
HAL_OK;
495 if (pCallback == NULL)
498 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
505 if (hirda->gState == HAL_IRDA_STATE_READY)
510 hirda->TxHalfCpltCallback = pCallback;
514 hirda->TxCpltCallback = pCallback;
518 hirda->RxHalfCpltCallback = pCallback;
522 hirda->RxCpltCallback = pCallback;
526 hirda->ErrorCallback = pCallback;
530 hirda->AbortCpltCallback = pCallback;
534 hirda->AbortTransmitCpltCallback = pCallback;
538 hirda->AbortReceiveCpltCallback = pCallback;
542 hirda->MspInitCallback = pCallback;
546 hirda->MspDeInitCallback = pCallback;
551 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
558 else if (hirda->gState == HAL_IRDA_STATE_RESET)
563 hirda->MspInitCallback = pCallback;
567 hirda->MspDeInitCallback = pCallback;
572 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
582 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
◆ HAL_IRDA_UnRegisterCallback()
Unregister an IRDA callback IRDA callback is redirected to the weak predefined callback.
- Parameters
-
| hirda | irda handle |
| CallbackID | ID of the callback to be unregistered This parameter can be one of the following values:
|
- Return values
-
Definition at line 612 of file stm32l4xx_hal_irda.c.
614 HAL_StatusTypeDef status =
HAL_OK;
619 if (HAL_IRDA_STATE_READY == hirda->gState)
665 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
672 else if (HAL_IRDA_STATE_RESET == hirda->gState)
686 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
696 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda)
IRDA Abort Receive Complete callback.
void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda)
Initialize the IRDA MSP.
void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda)
Rx Half Transfer complete callback.
void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda)
IRDA error callback.
void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda)
DeInitialize the IRDA MSP.
void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda)
Tx Transfer completed callback.
void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda)
Tx Half Transfer completed callback.
void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda)
IRDA Abort Complete callback.
void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda)
Rx Transfer completed callback.
void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda)
IRDA Abort Complete callback.