STM32F30xx Standard Peripheral Library
/* ------------ RCC registers bit address in the alias region -----
------ */
#define RCC_OFFSET (RCC_BASE - PERIPH_BASE)
...
/* --- CR Register ---*/
/* Alias word address of PLLON bit */
#define CR_OFFSET (RCC_OFFSET + 0x00)
#define PLLON_BitNumber 0x18
#define CR_PLLON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) +
(PLLON_BitNumber * 4))
To code a function which enables/disables the PLL, the usual method is the following:
...
void RCC_PLLCmd(FunctionalState NewState)
{
if (NewState != DISABLE)
{ /* Enable PLL */
RCC->CR |= RCC_CR_PLLON;
}
else
{ /* Disable PLL */
RCC->CR &= ~RCC_CR_PLLON;
}
}
Using bit-band access this function will be coded as follows:
void RCC_PLLCmd(FunctionalState NewState)
{
*(__IO uint32_t *) CR_PLLON_BB = (uint32_t)NewState;
}
1.1.5 Run-time checking
The library implements run-time failure detection by checking the input values of all library
functions. The run-time checking is achieved by using an assert_param macro. This
macro is used in all the library functions which have an input parameter. It allows checking
that the input value lies within the parameter allowed values.
To enable the run-time checking, use the assert_param macro, and leave the define
USE_FULL_ASSERT uncommented in stm32f30x_conf.h file.
Example:PWR_ClearFlag function
stm32f30x_pwr.c:
void PWR_ClearFlag(uint32_t PWR_FLAG)
{
/* Check the parameters */
assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG));
PWR->CR |= PWR_FLAG << 2;
}
stm32f30x_pwr.h:
/* PWR Flag */
#define PWR_FLAG_WU ((uint32_t)0x00000001)
#define PWR_FLAG_SB ((uint32_t)0x00000002)
#define PWR_FLAG_PVDO ((uint32_t)0x00000004)
#define PWR_FLAG_VREFINTRDY ((uint32_t)0x00000008)