Skip to content

Commit ed79933

Browse files
committed
bluepillplus: Cache SCB_CPUID in chip detection
1 parent 5f6e142 commit ed79933

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/platforms/bluepillplus/platform.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ static void platform_detect_variant(void)
140140
{
141141
/* Detect platform chip */
142142
const uint32_t device_id = DBGMCU_IDCODE & DBGMCU_IDCODE_DEV_ID_MASK;
143-
const uint32_t cpu_id = SCB_CPUID & SCB_CPUID_PARTNO;
143+
const uint32_t scb_cpuid = SCB_CPUID;
144+
const uint16_t cpu_id = scb_cpuid & SCB_CPUID_PARTNO;
144145
const uint64_t romtable_pidr = coresight_romtable_pidr();
145146
const uint32_t romtable_cidr = coresight_romtable_cidr_check();
146147
/* STM32F103CB: 0x410 (Medium density) is readable as 0x000 (errata) without debugger. So default to 72 MHz. */
@@ -151,15 +152,15 @@ static void platform_detect_variant(void)
151152
* then change USBDPSC[1:0] the CK_USBD prescaler
152153
* and finally enable PLL.
153154
*/
154-
if ((device_id == 0x410 || device_id == 0x000) && cpu_id == 0xc230 && SCB_CPUID == 0x411fc231U) {
155+
if ((device_id == 0x410 || device_id == 0x000) && cpu_id == 0xc230 && scb_cpuid == 0x411fc231U) {
155156
/* STM32F103CB: 0x410 (Medium density), 0x411fc231 (Cortex-M3 r1p1) */
156157
if (romtable_cidr == 0xb105100dU && romtable_pidr == 0xa0410) {
157158
/* STM32F103: Manufacturer 020 Partno 410 (PIDR = 0x00000a0410) */
158159
clock = &rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ];
159160
}
160161
}
161162

162-
if (device_id == 0x410 && cpu_id == 0xc230 && SCB_CPUID == 0x412fc231U) {
163+
if (device_id == 0x410 && cpu_id == 0xc230 && scb_cpuid == 0x412fc231U) {
163164
/* APM32F103CB: 0x410 (Medium Density), 0x412fc231 (Cortex-M3 r2p1) */
164165
if (romtable_cidr == 0xb105100dU && romtable_pidr == 0x04000bb4c3ULL) {
165166
/* APM32F103: Manufacturer 43b Partno 4c3 (PIDR = 0x04000bb4c3) */
@@ -170,7 +171,7 @@ static void platform_detect_variant(void)
170171
}
171172
}
172173

173-
if (device_id == 0x410 && cpu_id == 0xc230 && SCB_CPUID == 0x412fc231U) {
174+
if (device_id == 0x410 && cpu_id == 0xc230 && scb_cpuid == 0x412fc231U) {
174175
/* GD32F103CB: 0x410 (Medium Density), 0x412fc231 (Cortex-M3 r2p1) */
175176
if (romtable_cidr == 0xb105100dU && romtable_pidr == 0x07000d1f64ULL) {
176177
/* GD32F103: Manufacturer 751 Partno f64 (PIDR = 0x07000d1f64) */
@@ -181,7 +182,7 @@ static void platform_detect_variant(void)
181182
}
182183
}
183184

184-
if (device_id == 0x414 && cpu_id == 0xc240 && SCB_CPUID == 0x410fc241) {
185+
if (device_id == 0x414 && cpu_id == 0xc240 && scb_cpuid == 0x410fc241) {
185186
/* GD32F303CC: High density, 0x410fc241 (Cortex-M4F r0p1) */
186187
if (romtable_cidr == 0xb105100dU && romtable_pidr == 0x07000d1050ULL) {
187188
/* GD32F303: Manufacturer 751 Partno 050 (PIDR = 0x07000d1050) */

0 commit comments

Comments
 (0)