~ruther/stm32h747i-disco-usb-image-viewer

ref: a42a0f99932c4a7afdd569cac97a46d0bbc15c07 stm32h747i-disco-usb-image-viewer/include/registers.h -rw-r--r-- 3.2 KiB
a42a0f99 — Rutherther tests: add device descriptor test 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <stdint.h>

#ifndef REGISTERS_H
#define REGISTERS_H

/**
 * @brief Writes data on the given position in register.
 * @param[in,out] reg The address to change.
 * @param[in] data The data to write on pos.
 * @param[in] pos The position to start writing to. First @see data param is shifted by this.
 * @param[in] mask The mask to and the data with, ie. if you want only two bits, set to 0x3.
 */
extern inline void reg_write_bits_pos(volatile uint32_t *reg, uint32_t data, uint8_t pos, uint32_t mask);

/**
 * @brief Writes data into the register.
 * @param[in,out] reg The address to change.
 * @param[in] data The data to write to the whole register.
 * @param[in] mask The mask to and the data with, ie. if you want only two bits, set to 0x3.
 */
extern inline void reg_write_bits(volatile uint32_t *reg, uint32_t data, uint32_t mask);

/**
 * @brief Write ones on the given position in register.
 * @param[in,out] reg The address to change.
 * @param[in] pos The position to start writing to. First @see mask param is shifted by this.
 * @param[in] mask The mask of bits to write ones to, ie. if you want only two bits, set to 0x3.
 */
extern inline void reg_set_bits_pos(volatile uint32_t *reg, uint8_t pos, uint32_t mask);

/**
 * @brief Write ones into register.
 * @param[in,out] reg The address to change.
 * @param[in] mask The mask of bits to write ones to.
 */
extern inline void reg_set_bits(volatile uint32_t *reg, uint32_t mask);

/**
 * @brief Toggle bits in the register, starting from @see pos.
 * @details Toggles bits where one is written to the mask, but shifted by @see pos.
 * @param[in,out] reg Address of the register to toggle bits in.
 * @param[in] pos The position to shift the @see mask by.
 * @param[in] mask The mask saying what bits to toggle (1), from the @see pos.
 */
extern inline void reg_toggle_bits_pos(volatile uint32_t *reg, uint8_t pos, uint32_t mask);

/**
 * @brief Toggle bits in the register.
 * @details Toggles bits where one is written to the mask.
 * @param[in,out] reg Address of the register to toggle bits in.
 * @param[in] mask The mask saying what bits to toggle (1).
 */
extern inline void reg_toggle_bits(volatile uint32_t *reg, uint32_t mask);

/**
 * @brief Writes zeros on the given position in register.
 * @param[in,out] reg The address to change.
 * @param[in] pos The position to start writing to. First the mask is shifted by this.
 * @param[in] mask The mask of bits to write ones to, ie. if you want only two bits, set to 0x3.
 */
extern inline void reg_clear_bits_pos(volatile uint32_t *reg, uint8_t pos, uint32_t mask);

/**
 * @brief Write zeros on into register.
 * @param[in,out] reg The address to change.
 * @param[in] mask The mask of bits to write ones to.
 */
extern inline void reg_clear_bits(volatile uint32_t *reg, uint32_t mask);

/**
 * @brief Get bits from the register on the given position.
 * @details The obtained value starts from @see pos, and is anded with @see mask.
 * @param[in,out] reg The register address to read
 * @param[in] pos The position to shift data by.
 * @param[in] mask The mask to apply on the resulting data
 * @return The read data.
 */
extern inline uint32_t reg_read_bits_pos(volatile uint32_t *reg, uint8_t pos, uint32_t mask);

#endif // REGISTERS_H
Do not follow this link