RTEMS 7.0-rc1
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_stm32u5_STM32U5_HAL_H
29#define LIBBSP_ARM_stm32u5_STM32U5_HAL_H
30
31#include <stm32u5xx_hal.h>
32
33#include <rtems/termiostypes.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39typedef enum {
40 STM32U5_MODULE_INVALID,
41 STM32U5_MODULE_GPIOA,
42 STM32U5_MODULE_GPIOB,
43 STM32U5_MODULE_GPIOC,
44 STM32U5_MODULE_GPIOD,
45 STM32U5_MODULE_GPIOE,
46 STM32U5_MODULE_GPIOF,
47 STM32U5_MODULE_GPIOG,
48 STM32U5_MODULE_GPIOH,
49 STM32U5_MODULE_GPIOI,
50 STM32U5_MODULE_GPIOJ,
51 STM32U5_MODULE_USART1,
52 STM32U5_MODULE_USART2,
53 STM32U5_MODULE_USART3,
54 STM32U5_MODULE_UART4,
55 STM32U5_MODULE_UART5,
56 STM32U5_MODULE_USART6,
57 STM32U5_MODULE_RNG,
58 STM32U5_MODULE_SDMMC1,
59 STM32U5_MODULE_SDMMC2,
60} stm32u5_module_index;
61
62stm32u5_module_index stm32u5_get_module_index(const void *regs);
63
64void stm32u5_clk_enable(stm32u5_module_index index);
65
66void stm32u5_clk_disable(stm32u5_module_index index);
67
68typedef struct {
69 GPIO_TypeDef *regs;
70 GPIO_InitTypeDef config;
72
73void stm32u5_gpio_init(const stm32u5_gpio_config *config);
74
75typedef struct {
78 uint8_t device_index;
80
81typedef struct {
82 UART_HandleTypeDef uart;
83 bool transmitting;
85 const stm32u5_uart_config *config;
87
88static inline stm32u5_uart_context *stm32u5_uart_get_context(
90)
91{
92 return RTEMS_CONTAINER_OF(base, stm32u5_uart_context, device);
93}
94
95void stm32u5_uart_polled_write(rtems_termios_device_context *base, char c);
96
97int stm32u5_uart_polled_read(rtems_termios_device_context *base);
98
99extern stm32u5_uart_context stm32u5_usart1_instance;
100
101extern const stm32u5_uart_config stm32u5_usart1_config;
102
103extern stm32u5_uart_context stm32u5_usart2_instance;
104
105extern const stm32u5_uart_config stm32u5_usart2_config;
106
107extern stm32u5_uart_context stm32u5_usart3_instance;
108
109extern const stm32u5_uart_config stm32u5_usart3_config;
110
111extern stm32u5_uart_context stm32u5_uart4_instance;
112
113extern const stm32u5_uart_config stm32u5_uart4_config;
114
115extern stm32u5_uart_context stm32u5_uart5_instance;
116
117extern const stm32u5_uart_config stm32u5_uart5_config;
118
119extern stm32u5_uart_context stm32u5_usart6_instance;
120
121extern const stm32u5_uart_config stm32u5_usart6_config;
122
123extern stm32u5_uart_context stm32u5_uart7_instance;
124
125extern const stm32u5_uart_config stm32u5_uart7_config;
126
127extern stm32u5_uart_context stm32u5_uart8_instance;
128
129extern const stm32u5_uart_config stm32u5_uart8_config;
130
131extern stm32u5_uart_context stm32u5_uart9_instance;
132
133extern const stm32u5_uart_config stm32u5_uart9_config;
134
135extern stm32u5_uart_context stm32u5_usart10_instance;
136
137extern const stm32u5_uart_config stm32u5_usart10_config;
138
139extern const uint32_t stm32u5_config_pwr_regulator_voltagescaling;
140
141extern const RCC_OscInitTypeDef stm32u5_config_oscillator;
142
143extern const RCC_ClkInitTypeDef stm32u5_config_clocks;
144
145extern const uint32_t stm32u5_config_flash_latency;
146
147extern const RCC_PeriphCLKInitTypeDef stm32u5_config_peripheral_clocks;
148
149extern RTC_HandleTypeDef hrtc;
150
151extern RTC_TimeTypeDef sTime;
152
153extern RTC_DateTypeDef sDate;
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif /* LIBBSP_ARM_stm32u5_STM32U5_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
General Purpose I/O.
Definition: stm32u5g9xx.h:747
Termios device context.
Definition: termiosdevice.h:68
Definition: hal.h:68
Definition: hal.h:75
Definition: hal.h:81