fixed some remaining bugs

sipo
Ondřej Hruška 7 years ago
parent ab2dfe3a76
commit a5d9635cee
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 6
      platform/debug_uart.c
  2. 3
      platform/lock_jumper.c
  3. 80
      platform/platform.c
  4. 3
      platform/status_led.c
  5. 2
      utils/error.h

@ -13,10 +13,8 @@
void DebugUart_Init(void) void DebugUart_Init(void)
{ {
// Debug UART // Debug UART
bool ok = true; assert_param(E_SUCCESS == rsc_claim(&UNIT_SYSTEM, R_USART2));
ok &= rsc_claim(&UNIT_SYSTEM, R_USART2); assert_param(E_SUCCESS == rsc_claim(&UNIT_SYSTEM, R_PA2));
ok &= rsc_claim(&UNIT_SYSTEM, R_PA2);
assert_param(ok);
} }
/** Init the hardware peripheral - this is called early in the boot process */ /** Init the hardware peripheral - this is called early in the boot process */

@ -33,8 +33,7 @@ void LockJumper_Init(void)
Resource rsc = pin2resource(LOCK_JUMPER_PORT, LOCK_JUMPER_PIN, &suc); Resource rsc = pin2resource(LOCK_JUMPER_PORT, LOCK_JUMPER_PIN, &suc);
assert_param(suc); assert_param(suc);
suc &= rsc_claim(&UNIT_SYSTEM, rsc); assert_param(E_SUCCESS == rsc_claim(&UNIT_SYSTEM, rsc));
assert_param(suc);
// Resolve pin // Resolve pin
lock_periph = port2periph(LOCK_JUMPER_PORT, &suc); lock_periph = port2periph(LOCK_JUMPER_PORT, &suc);

@ -16,6 +16,8 @@
void plat_init_resources(void) void plat_init_resources(void)
{ {
uint32_t rv = 0;
__HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE();
@ -50,23 +52,19 @@ void plat_init_resources(void)
// Claim resources not available due to board layout or internal usage // Claim resources not available due to board layout or internal usage
{ {
bool ok = true;
// HAL timebase // HAL timebase
ok &= rsc_claim(&UNIT_SYSTEM, R_TIM1); rv |= rsc_claim(&UNIT_SYSTEM, R_TIM1);
// HSE crystal // HSE crystal
ok &= rsc_claim(&UNIT_SYSTEM, R_PD0); rv |= rsc_claim(&UNIT_SYSTEM, R_PD0);
ok &= rsc_claim(&UNIT_SYSTEM, R_PD1); rv |= rsc_claim(&UNIT_SYSTEM, R_PD1);
// SWD // SWD
ok &= rsc_claim(&UNIT_SYSTEM, R_PA13); rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
ok &= rsc_claim(&UNIT_SYSTEM, R_PA14); rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
// USB // USB
ok &= rsc_claim(&UNIT_SYSTEM, R_PA11); rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
ok &= rsc_claim(&UNIT_SYSTEM, R_PA12); rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);
// BOOT pin(s) // BOOT pin(s)
ok &= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1 rv |= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1
assert_param(ok);
} }
#elif defined(GEX_PLAT_F072_DISCOVERY) #elif defined(GEX_PLAT_F072_DISCOVERY)
// Platform STM32F073RBT // Platform STM32F073RBT
@ -105,23 +103,19 @@ void plat_init_resources(void)
// Claim resources not available due to board layout or internal usage // Claim resources not available due to board layout or internal usage
{ {
bool ok = true;
// HAL timebase // HAL timebase
ok &= rsc_claim(&UNIT_SYSTEM, R_TIM1); rv |= rsc_claim(&UNIT_SYSTEM, R_TIM1);
// HSE crystal // HSE crystal
ok &= rsc_claim(&UNIT_SYSTEM, R_PF0); rv |= rsc_claim(&UNIT_SYSTEM, R_PF0);
//ok &= rsc_claim(&UNIT_SYSTEM, R_PF1); // - not used in BYPASS mode //rv |= rsc_claim(&UNIT_SYSTEM, R_PF1); // - not used in BYPASS mode
// SWD // SWD
ok &= rsc_claim(&UNIT_SYSTEM, R_PA13); rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
ok &= rsc_claim(&UNIT_SYSTEM, R_PA14); rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
// USB // USB
ok &= rsc_claim(&UNIT_SYSTEM, R_PA11); rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
ok &= rsc_claim(&UNIT_SYSTEM, R_PA12); rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);
// BOOT pin(s) // BOOT pin(s)
ok &= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1 rv |= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1
assert_param(ok);
} }
#elif defined(GEX_PLAT_F303_DISCOVERY) #elif defined(GEX_PLAT_F303_DISCOVERY)
// Platform STM32F303VCT // Platform STM32F303VCT
@ -162,23 +156,19 @@ void plat_init_resources(void)
// Claim resources not available due to board layout or internal usage // Claim resources not available due to board layout or internal usage
{ {
bool ok = true;
// HAL timebase // HAL timebase
ok &= rsc_claim(&UNIT_SYSTEM, R_TIM1); rv |= rsc_claim(&UNIT_SYSTEM, R_TIM1);
// HSE crystal // HSE crystal
ok &= rsc_claim(&UNIT_SYSTEM, R_PF0); rv |= rsc_claim(&UNIT_SYSTEM, R_PF0);
//ok &= rsc_claim(&UNIT_SYSTEM, R_PF1); // - not used in BYPASS mode //rv |= rsc_claim(&UNIT_SYSTEM, R_PF1); // - not used in BYPASS mode
// SWD // SWD
ok &= rsc_claim(&UNIT_SYSTEM, R_PA13); rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
ok &= rsc_claim(&UNIT_SYSTEM, R_PA14); rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
// USB // USB
ok &= rsc_claim(&UNIT_SYSTEM, R_PA11); rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
ok &= rsc_claim(&UNIT_SYSTEM, R_PA12); rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);
// BOOT pin(s) // BOOT pin(s)
ok &= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1 rv |= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1
assert_param(ok);
} }
#elif defined(GEX_PLAT_F407_DISCOVERY) #elif defined(GEX_PLAT_F407_DISCOVERY)
// Platform STM32F407VGT // Platform STM32F407VGT
@ -218,26 +208,24 @@ void plat_init_resources(void)
// Claim resources not available due to board layout or internal usage // Claim resources not available due to board layout or internal usage
{ {
bool ok = true;
// HAL timebase // HAL timebase
ok &= rsc_claim(&UNIT_SYSTEM, R_TIM1); rv |= rsc_claim(&UNIT_SYSTEM, R_TIM1);
// HSE crystal // HSE crystal
// H0 and H1 // H0 and H1
// SWD // SWD
ok &= rsc_claim(&UNIT_SYSTEM, R_PA13); rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
ok &= rsc_claim(&UNIT_SYSTEM, R_PA14); rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
// USB // USB
ok &= rsc_claim(&UNIT_SYSTEM, R_PA11); rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
ok &= rsc_claim(&UNIT_SYSTEM, R_PA12); rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);
// BOOT pin(s) // BOOT pin(s)
ok &= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1 rv |= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1
assert_param(ok);
} }
#else #else
#error "BAD PLATFORM!" #error "BAD PLATFORM!"
#endif #endif
assert_param(rv == 0);
} }

@ -56,8 +56,7 @@ void Indicator_Init(void)
Resource rsc = pin2resource(STATUS_LED_PORT, STATUS_LED_PIN, &suc); Resource rsc = pin2resource(STATUS_LED_PORT, STATUS_LED_PIN, &suc);
assert_param(suc); assert_param(suc);
suc &= rsc_claim(&UNIT_SYSTEM, rsc); assert_param(E_SUCCESS == rsc_claim(&UNIT_SYSTEM, rsc));
assert_param(suc);
} }
/** Set indicator ON */ /** Set indicator ON */

@ -29,7 +29,7 @@
// fields: name, msg. If msg is NULL, name as string will be used instead. // fields: name, msg. If msg is NULL, name as string will be used instead.
#define X_ERROR_CODES \ #define X_ERROR_CODES \
/* Shared errors */ \ /* Shared errors */ \
X(SUCCESS, NULL) /* operation succeeded / unit loaded */ \ X(SUCCESS, NULL) /* operation succeeded / unit loaded. Must be 0 */ \
X(FAILURE, NULL) /* generic error */ \ X(FAILURE, NULL) /* generic error */ \
X(INTERNAL_ERROR, NULL) /* a bug */ \ X(INTERNAL_ERROR, NULL) /* a bug */ \
X(LOADING, NULL) /* unit is loading */ \ X(LOADING, NULL) /* unit is loading */ \

Loading…
Cancel
Save