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

ref: d0823eecd4dee0c7e2f3ee08534b89477526b6ad stm32h747i-disco-usb-image-viewer/src/registers.c -rw-r--r-- 593 bytes
d0823eec — Rutherther feat: add registers, pin, exti, usb_device skeleton 6 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
#include <stdint.h>

void reg_set_bits_pos(volatile uint32_t *reg, uint32_t data, uint8_t pos, uint8_t mask) {
  *reg &= ~(mask << pos);
  *reg |= (data & mask) << pos;
}

void reg_set_bits(volatile uint32_t *reg, uint32_t data, uint8_t mask) {
  *reg &= ~(mask);
  *reg |= (data & mask);
}

void reg_toggle_bits_pos(volatile uint32_t *reg, uint8_t pos, uint8_t mask) {
  *reg ^= (mask << pos);
}

void reg_toggle_bits(volatile uint32_t *reg, uint8_t mask) {
  *reg ^= mask;
}

uint32_t reg_read_bits_pos(volatile uint32_t *reg, uint8_t pos, uint8_t mask) {
  return ((*reg) >> pos) & mask;
}
Do not follow this link