Skip to content

Commit b8dc15f

Browse files
ahmed-haouestom-van
authored andcommitted
flash/stm32h7x: use BIT macro whenever possible
Use the BIT() macro in place of bare shifts Change-Id: Iad66e12354fc3c76c718a793eb6689258d497b00 Signed-off-by: HAOUES Ahmed <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/9012 Tested-by: jenkins Reviewed-by: Tomas Vanek <[email protected]>
1 parent fe3c626 commit b8dc15f

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

src/flash/nor/stm32h7x.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "imp.h"
1111
#include <helper/binarybuffer.h>
12+
#include <helper/bits.h>
1213
#include <target/algorithm.h>
1314
#include <target/cortex_m.h>
1415

@@ -55,45 +56,45 @@ static const uint32_t stm32h7_flash_regs[STM32_FLASH_REG_INDEX_NUM] = {
5556
};
5657

5758
/* FLASH_CR register bits */
58-
#define FLASH_LOCK (1 << 0)
59-
#define FLASH_PG (1 << 1)
60-
#define FLASH_SER (1 << 2)
61-
#define FLASH_BER (1 << 3)
59+
#define FLASH_LOCK BIT(0)
60+
#define FLASH_PG BIT(1)
61+
#define FLASH_SER BIT(2)
62+
#define FLASH_BER BIT(3)
6263
#define FLASH_PSIZE_8 (0 << 4)
6364
#define FLASH_PSIZE_16 (1 << 4)
6465
#define FLASH_PSIZE_32 (2 << 4)
6566
#define FLASH_PSIZE_64 (3 << 4)
66-
#define FLASH_FW (1 << 6)
67-
#define FLASH_START (1 << 7)
67+
#define FLASH_FW BIT(6)
68+
#define FLASH_START BIT(7)
6869

6970
/* FLASH_SR register bits */
70-
#define FLASH_BSY (1 << 0) /* Operation in progress */
71-
#define FLASH_QW (1 << 2) /* Operation queue in progress */
72-
#define FLASH_WRPERR (1 << 17) /* Write protection error */
73-
#define FLASH_PGSERR (1 << 18) /* Programming sequence error */
74-
#define FLASH_STRBERR (1 << 19) /* Strobe error */
75-
#define FLASH_INCERR (1 << 21) /* Inconsistency error */
76-
#define FLASH_OPERR (1 << 22) /* Operation error */
77-
#define FLASH_RDPERR (1 << 23) /* Read Protection error */
78-
#define FLASH_RDSERR (1 << 24) /* Secure Protection error */
79-
#define FLASH_SNECCERR (1 << 25) /* Single ECC error */
80-
#define FLASH_DBECCERR (1 << 26) /* Double ECC error */
71+
#define FLASH_BSY BIT(0) /* Operation in progress */
72+
#define FLASH_QW BIT(2) /* Operation queue in progress */
73+
#define FLASH_WRPERR BIT(17) /* Write protection error */
74+
#define FLASH_PGSERR BIT(18) /* Programming sequence error */
75+
#define FLASH_STRBERR BIT(19) /* Strobe error */
76+
#define FLASH_INCERR BIT(21) /* Inconsistency error */
77+
#define FLASH_OPERR BIT(22) /* Operation error */
78+
#define FLASH_RDPERR BIT(23) /* Read Protection error */
79+
#define FLASH_RDSERR BIT(24) /* Secure Protection error */
80+
#define FLASH_SNECCERR BIT(25) /* Single ECC error */
81+
#define FLASH_DBECCERR BIT(26) /* Double ECC error */
8182

8283
#define FLASH_ERROR (FLASH_WRPERR | FLASH_PGSERR | FLASH_STRBERR | FLASH_INCERR | FLASH_OPERR | \
8384
FLASH_RDPERR | FLASH_RDSERR | FLASH_SNECCERR | FLASH_DBECCERR)
8485

8586
/* FLASH_OPTCR register bits */
86-
#define OPT_LOCK (1 << 0)
87-
#define OPT_START (1 << 1)
87+
#define OPT_LOCK BIT(0)
88+
#define OPT_START BIT(1)
8889

8990
/* FLASH_OPTSR register bits */
90-
#define OPT_BSY (1 << 0)
91+
#define OPT_BSY BIT(0)
9192
#define OPT_RDP_POS 8
9293
#define OPT_RDP_MASK (0xff << OPT_RDP_POS)
93-
#define OPT_OPTCHANGEERR (1 << 30)
94+
#define OPT_OPTCHANGEERR BIT(30)
9495

9596
/* FLASH_OPTCCR register bits */
96-
#define OPT_CLR_OPTCHANGEERR (1 << 30)
97+
#define OPT_CLR_OPTCHANGEERR BIT(30)
9798

9899
/* register unlock keys */
99100
#define KEY1 0x45670123

0 commit comments

Comments
 (0)