|
9 | 9 |
|
10 | 10 | #include "imp.h" |
11 | 11 | #include <helper/binarybuffer.h> |
| 12 | +#include <helper/bits.h> |
12 | 13 | #include <target/algorithm.h> |
13 | 14 | #include <target/cortex_m.h> |
14 | 15 |
|
@@ -55,45 +56,45 @@ static const uint32_t stm32h7_flash_regs[STM32_FLASH_REG_INDEX_NUM] = { |
55 | 56 | }; |
56 | 57 |
|
57 | 58 | /* 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) |
62 | 63 | #define FLASH_PSIZE_8 (0 << 4) |
63 | 64 | #define FLASH_PSIZE_16 (1 << 4) |
64 | 65 | #define FLASH_PSIZE_32 (2 << 4) |
65 | 66 | #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) |
68 | 69 |
|
69 | 70 | /* 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 */ |
81 | 82 |
|
82 | 83 | #define FLASH_ERROR (FLASH_WRPERR | FLASH_PGSERR | FLASH_STRBERR | FLASH_INCERR | FLASH_OPERR | \ |
83 | 84 | FLASH_RDPERR | FLASH_RDSERR | FLASH_SNECCERR | FLASH_DBECCERR) |
84 | 85 |
|
85 | 86 | /* 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) |
88 | 89 |
|
89 | 90 | /* FLASH_OPTSR register bits */ |
90 | | -#define OPT_BSY (1 << 0) |
| 91 | +#define OPT_BSY BIT(0) |
91 | 92 | #define OPT_RDP_POS 8 |
92 | 93 | #define OPT_RDP_MASK (0xff << OPT_RDP_POS) |
93 | | -#define OPT_OPTCHANGEERR (1 << 30) |
| 94 | +#define OPT_OPTCHANGEERR BIT(30) |
94 | 95 |
|
95 | 96 | /* FLASH_OPTCCR register bits */ |
96 | | -#define OPT_CLR_OPTCHANGEERR (1 << 30) |
| 97 | +#define OPT_CLR_OPTCHANGEERR BIT(30) |
97 | 98 |
|
98 | 99 | /* register unlock keys */ |
99 | 100 | #define KEY1 0x45670123 |
|
0 commit comments