/** * @brief Configures the System clock frequency, HCLK, PCLK2 and PCLK1 * prescalers. * @param None * @retval None */ void SetSysClock(void) { /* The System clock configuration functions defined below assume that: - For Low, Medium and High density devices an external 8MHz crystal is used to drive the System clock. - For Connectivity line devices an external 25MHz crystal is used to drive the System clock. If you are using different crystal you have to adapt those functions accordingly.*/ #if defined SYSCLK_HSE SetSysClockToHSE(); #elif defined SYSCLK_FREQ_24MHz SetSysClockTo24(); #elif defined SYSCLK_FREQ_36MHz SetSysClockTo36(); #elif defined SYSCLK_FREQ_48MHz SetSysClockTo48(); #elif defined SYSCLK_FREQ_56MHz SetSysClockTo56(); #elif defined SYSCLK_FREQ_72MHz SetSysClockTo72(); #endif /* If none of the define above is enabled, the HSI is used as System clock source (default after reset) */ }
int main(void) { SetSysClockTo56(); // ROS nodehandle initialization and topic registration nh.initNode(); // Initialize debug LED GPIO_InitTypeDef GPIO_Config; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); GPIO_Config.GPIO_Pin = GPIO_Pin_5; GPIO_Config.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Config.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_Config); GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_RESET); // Start ROS spin task, responsible for handling callbacks and communications if (spinInitTask(&nh)) { // Turn on LED on error GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_SET); while (1); } // Register and init publish task if (publishInitTask(&nh)) { // Turn on LED on error GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_SET); while (1); } // Register and init subscribe task if (subscribeInitTask(&nh)) { // Turn on LED on error GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_SET); while (1); } // Enter scheduler and loop forever vTaskStartScheduler(); // In case the scheduler returns for some reason,. while (1) { // Turn on LED on error GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_SET); } }
/** * @brief Configures the System clock frequency, HCLK, PCLK2 and PCLK1 * prescalers. * @param None. * @arg None. * @note : None. * @retval value: None. */ static void SetSysClock(void) { #ifdef SYSCLK_FREQ_HSE SetSysClockToHSE(); #elif defined SYSCLK_FREQ_20MHz SetSysClockTo20(); #elif defined SYSCLK_FREQ_36MHz SetSysClockTo36(); #elif defined SYSCLK_FREQ_48MHz SetSysClockTo48(); #elif defined SYSCLK_FREQ_56MHz SetSysClockTo56(); #elif defined SYSCLK_FREQ_72MHz SetSysClockTo72(); #endif /*!< If none of the define above is enabled, the HSI is used as System clock source (default after reset) */ }
int main(void) { SetSysClockTo56(); // ROS nodehandle initialization and topic registration nh.initNode(); nh.advertise(chatter); // Initialize LED GPIO_InitTypeDef GPIO_Config; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); GPIO_Config.GPIO_Pin = GPIO_Pin_5; GPIO_Config.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Config.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_Config); GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_RESET); while (1) { // Toggle LED if (GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_5)) GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_RESET); else GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_SET); // Publish message to be transmitted. str_msg.data = hello; chatter.publish(&str_msg); // Handle all communications and callbacks. nh.spinOnce(); // Delay for a bit. nh.getHardware()->delay(100); } }