2 * Copyright (c) 2020-2022 Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * -----------------------------------------------------------------------------
20 * Project: USART Server
21 * Title: USART Server hardware specific driver implementation
23 * -----------------------------------------------------------------------------
26 #include "USART_Server_HW.h"
28 #include "stm32f4xx_hal.h"
30 #define DCD_CLK_ENABLE() __GPIOA_CLK_ENABLE()
31 #define DCD_PORT GPIOA
32 #define DCD_PIN GPIO_PIN_13
34 #define RI_CLK_ENABLE() __GPIOA_CLK_ENABLE()
36 #define RI_PIN GPIO_PIN_14
39 \fn void USART_Server_Pins_Initialize (void)
40 \brief Initialize, power up and configure GPIO pins used for
41 driving DCD and RI lines of the USART Client.
44 void USART_Server_Pins_Initialize (void) {
45 GPIO_InitTypeDef gpio_config;
49 gpio_config.Mode = GPIO_MODE_OUTPUT_PP;
50 gpio_config.Pull = GPIO_NOPULL;
51 gpio_config.Speed = GPIO_SPEED_LOW;
53 /* Configure GPIO pin: DCD as output */
54 gpio_config.Pin = DCD_PIN;
55 HAL_GPIO_Init(DCD_PORT, &gpio_config);
57 /* Configure GPIO pin: RI as output */
58 gpio_config.Pin = RI_PIN;
59 HAL_GPIO_Init(DCD_PORT, &gpio_config);
63 \fn void USART_Server_Pins_Uninitialize (void)
64 \brief Unconfigure, power down and uninitialize GPIO pins used for
65 driving DCD and RI lines of the USART Client.
68 void USART_Server_Pins_Uninitialize (void) {
69 HAL_GPIO_DeInit(DCD_PORT, DCD_PIN);
70 HAL_GPIO_DeInit(DCD_PORT, RI_PIN);
74 \fn void USART_Server_Pin_DCD_SetState (uint32_t state)
75 \brief Set state of GPIO pin used for driving DCD line of the USART Client.
76 \param[in] state State to be set
77 - 0: Drive pin to not active state
78 - != 0: Drive pin to active state
81 void USART_Server_Pin_DCD_SetState (uint32_t state) {
84 HAL_GPIO_WritePin(DCD_PORT, DCD_PIN, ((state != 0U) ? GPIO_PIN_RESET : GPIO_PIN_SET));
88 \fn void USART_Server_Pin_RI_SetState (uint32_t state)
89 \brief Set state of GPIO pin used for driving RI line of the USART Client.
90 \param[in] state State to be set
91 - 0: Drive pin to not active state
92 - != 0: Drive pin to active state
95 void USART_Server_Pin_RI_SetState (uint32_t state) {
98 HAL_GPIO_WritePin(RI_PORT, RI_PIN, ((state != 0U) ? GPIO_PIN_RESET : GPIO_PIN_SET));