RTEMS 6.1-rc2
Loading...
Searching...
No Matches
hal.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * Copyright (C) 2020 embedded brains GmbH & Co. KG
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef LIBBSP_ARM_STM32H7_STM32H7_HAL_H
29#define LIBBSP_ARM_STM32H7_STM32H7_HAL_H
30
31#include <stm32h7xx_hal.h>
32
33#include <rtems/termiostypes.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39typedef enum {
40 STM32H7_MODULE_INVALID,
41 STM32H7_MODULE_GPIOA,
42 STM32H7_MODULE_GPIOB,
43 STM32H7_MODULE_GPIOC,
44 STM32H7_MODULE_GPIOD,
45 STM32H7_MODULE_GPIOE,
46 STM32H7_MODULE_GPIOF,
47 STM32H7_MODULE_GPIOG,
48 STM32H7_MODULE_GPIOH,
49 STM32H7_MODULE_GPIOI,
50 STM32H7_MODULE_GPIOJ,
51 STM32H7_MODULE_GPIOK,
52 STM32H7_MODULE_USART1,
53 STM32H7_MODULE_USART2,
54 STM32H7_MODULE_USART3,
55 STM32H7_MODULE_UART4,
56 STM32H7_MODULE_UART5,
57 STM32H7_MODULE_USART6,
58 STM32H7_MODULE_UART7,
59 STM32H7_MODULE_UART8,
60 STM32H7_MODULE_UART9,
61 STM32H7_MODULE_USART10,
62 STM32H7_MODULE_RNG,
63 STM32H7_MODULE_ETH1MAC,
64 STM32H7_MODULE_ETH1TX,
65 STM32H7_MODULE_ETH1RX,
66 STM32H7_MODULE_USB1_OTG,
67 STM32H7_MODULE_USB1_OTG_ULPI,
68 STM32H7_MODULE_USB2_OTG,
69 STM32H7_MODULE_USB2_OTG_ULPI,
70 STM32H7_MODULE_SDMMC1,
71 STM32H7_MODULE_SDMMC2,
72} stm32h7_module_index;
73
74stm32h7_module_index stm32h7_get_module_index(const void *regs);
75
76void stm32h7_clk_enable(stm32h7_module_index index);
77
78void stm32h7_clk_disable(stm32h7_module_index index);
79
80void stm32h7_clk_low_power_enable(stm32h7_module_index index);
81
82void stm32h7_clk_low_power_disable(stm32h7_module_index index);
83
84typedef struct {
85 GPIO_TypeDef *regs;
88
89void stm32h7_gpio_init(const stm32h7_gpio_config *config);
90
91typedef struct {
94 uint8_t device_index;
96
97typedef struct {
99 bool transmitting;
103
104static inline stm32h7_uart_context *stm32h7_uart_get_context(
106)
107{
108 return RTEMS_CONTAINER_OF(base, stm32h7_uart_context, device);
109}
110
111void stm32h7_uart_polled_write(rtems_termios_device_context *base, char c);
112
113int stm32h7_uart_polled_read(rtems_termios_device_context *base);
114
115extern stm32h7_uart_context stm32h7_usart1_instance;
116
117extern const stm32h7_uart_config stm32h7_usart1_config;
118
119extern stm32h7_uart_context stm32h7_usart2_instance;
120
121extern const stm32h7_uart_config stm32h7_usart2_config;
122
123extern stm32h7_uart_context stm32h7_usart3_instance;
124
125extern const stm32h7_uart_config stm32h7_usart3_config;
126
127extern stm32h7_uart_context stm32h7_uart4_instance;
128
129extern const stm32h7_uart_config stm32h7_uart4_config;
130
131extern stm32h7_uart_context stm32h7_uart5_instance;
132
133extern const stm32h7_uart_config stm32h7_uart5_config;
134
135extern stm32h7_uart_context stm32h7_usart6_instance;
136
137extern const stm32h7_uart_config stm32h7_usart6_config;
138
139extern stm32h7_uart_context stm32h7_uart7_instance;
140
141extern const stm32h7_uart_config stm32h7_uart7_config;
142
143extern stm32h7_uart_context stm32h7_uart8_instance;
144
145extern const stm32h7_uart_config stm32h7_uart8_config;
146
147extern stm32h7_uart_context stm32h7_uart9_instance;
148
149extern const stm32h7_uart_config stm32h7_uart9_config;
150
151extern stm32h7_uart_context stm32h7_usart10_instance;
152
153extern const stm32h7_uart_config stm32h7_usart10_config;
154
155extern const uint32_t stm32h7_config_pwr_regulator_voltagescaling;
156
157extern const RCC_OscInitTypeDef stm32h7_config_oscillator;
158
159extern const RCC_ClkInitTypeDef stm32h7_config_clocks;
160
161extern const uint32_t stm32h7_config_flash_latency;
162
163extern const RCC_PeriphCLKInitTypeDef stm32h7_config_peripheral_clocks;
164
165#ifdef __cplusplus
166}
167#endif
168
169#endif /* LIBBSP_ARM_STM32H7_STM32H7_HAL_H */
#define RTEMS_CONTAINER_OF(_m, _type, _member_name)
Gets the container of a member.
Definition: basedefs.h:306
ISR_Vector_number rtems_vector_number
This integer type represents interrupt vector numbers.
Definition: intr.h:102
This file contains all the functions prototypes for the HAL module driver.
GPIO Init structure definition.
Definition: stm32h7xx_hal_gpio.h:48
General Purpose I/O.
Definition: stm32h723xx.h:1066
RCC System, AHB and APB busses clock configuration structure definition.
Definition: stm32h7xx_hal_rcc.h:124
RCC Internal/External Oscillator (HSE, HSI, CSI, LSE and LSI) configuration structure definition.
Definition: stm32h7xx_hal_rcc.h:86
RCC extended clocks structure definition.
Definition: stm32h7xx_hal_rcc_ex.h:142
UART handle Structure definition.
Definition: stm32h7xx_hal_uart.h:224
Definition: deflate.c:114
Termios device context.
Definition: termiosdevice.h:68
Definition: hal.h:84
Definition: hal.h:91
Definition: hal.h:97