void SystemInit(void)
{
    /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register.
       It can also be done in the application main() function. */

    /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required
       to enable the use of peripherals" found at Product Anomaly document for your device found at
       https://www.nordicsemi.com/. The side effect of executing these instructions in the devices
       that do not need it is that the new peripherals in the second generation devices (LPCOMP for
       example) will not be available. */
    if (is_manual_peripheral_setup_needed())
    {
        *(uint32_t volatile *)0x40000504 = 0xC007FFDF;
        *(uint32_t volatile *)0x40006C18 = 0x00008000;
    }

    /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG
       register is incorrect" found at Product Anomaly document four your device found at
       https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */
    if (is_disabled_in_debug_needed())
    {
        NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos;
    }

    NVIC_Relocate();
}
void SystemInit(void)
{
  /* FPU settings ------------------------------------------------------------*/
  #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
    SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */
  #endif
  /* Reset the RCC clock configuration to the default reset state ------------*/
  /* Set MSION bit */
  RCC->CR |= RCC_CR_MSION;

  /* Reset CFGR register */
  RCC->CFGR = 0x00000000;

  /* Reset HSEON, CSSON , HSION, and PLLON bits */
  RCC->CR &= (uint32_t)0xEAF6FFFF;

  /* Reset PLLCFGR register */
  RCC->PLLCFGR = 0x00001000;

  /* Reset HSEBYP bit */
  RCC->CR &= (uint32_t)0xFFFBFFFF;

  /* Disable all interrupts */
  RCC->CIER = 0x00000000;

  /* Relocate the vector table */
  NVIC_Relocate();
}
Example #3
0
/**
 * @brief	Main program
 * @param	None
 * @retval	None: no exit point
 */
int main(void)
{
	uint16_t u16Menu = 0;
	uint16_t uVal;

	NVIC_Relocate();

	/* Initialize SysTick - 1msec resolution */
	SysTick_Config(SystemCoreClock / 1000);

	/* Initialize main board peripherals */
	MBD_Init();
	printf("miniSTM32 mainboard initialized.\n");

	/* Initialize LCD support */
	LCD_Init();
	LCD_DisplayOn();
	printf("LCD initialized.\n");
	LCD_BacklightOn();
	printf("\n\nPress the button to start demo.\n\n");

	while (1) 
	{
		/* main menu controlled by pushbutton interrupt */
		if( uIRQFlag == MAIN_BTN_EXTI_LINE ) {

			/* clear button interrupt flag */
			uIRQFlag = 0;

			/* droid family fonts */

			if( u16Menu == MENU_FONT_TEST1 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));

			/* 2.4inch LCD has not enough space to draw long string */
			#if defined(LCD_QD024CPS25)

				LCD_SetFont(&DroidSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans 18 point");

				uVal += DroidSans_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans Bold 18 pt");

				uVal += DroidSans_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif 18 point");

				uVal += DroidSerif_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Bold 18 pt");

				uVal += DroidSerif_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Italic 18");

			#else

				LCD_SetFont(&DroidSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans 18 point");

				uVal += DroidSans_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans Bold 18 point");

				uVal += DroidSans_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif 18 point");

				uVal += DroidSerif_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Bold 18 point");

				uVal += DroidSerif_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Italic 18 point");

			#endif
			}

			/* liberation family fonts, federant font */

			else if( u16Menu == MENU_FONT_TEST2 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));

			/* 2.4inch LCD has not enough space to draw long string */
			#if defined(LCD_QD024CPS25)

				LCD_SetFont(&LiberationSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Liberation Sans 18 point");

				uVal += LiberationSans_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif 18 point");

				uVal += LiberationSerif_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif Italic 18");

				uVal += LiberationSerif_Italic_18.Height + LINE_SEP;
				LCD_SetFont(&Federant_18); 
				LCD_DisplayStringLine(START_X, uVal, "Federant 18 point");

			#else

				LCD_SetFont(&LiberationSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Liberation Sans 18 point");

				uVal += LiberationSans_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif 18 point");

				uVal += LiberationSerif_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif Italic 18 point");

				uVal += LiberationSerif_Italic_18.Height + LINE_SEP;
				LCD_SetFont(&Federant_18); 
				LCD_DisplayStringLine(START_X, uVal, "Federant 18 point");

			#endif
			}

			/* Ubuntu family fonts */

			else if( u16Menu == MENU_FONT_TEST3 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));
			
			/* 2.4inch LCD has not enough space to draw long string */
			#if defined(LCD_QD024CPS25)

				LCD_SetFont(&Ubuntu_18);
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu 18 point");

				uVal += Ubuntu_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Bold 18 point");

				uVal += Ubuntu_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Italic 18");

			#else

				LCD_SetFont(&Ubuntu_18);
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu 18 point");

				uVal += Ubuntu_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Bold 18 point");

				uVal += Ubuntu_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Italic 18 point");

			#endif
			}

			/* various size of droid sans */

			else if( u16Menu == MENU_FONT_TEST4 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));

				LCD_SetFont(&DroidSans_10);
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 10 point");

				uVal += DroidSans_10.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_12); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 12 point");

				uVal += DroidSans_12.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_14); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 14 point");

				uVal += DroidSans_14.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_16); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 16 point");

				uVal += DroidSans_16.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_18); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 18 point");

				uVal += DroidSans_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_20); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 20 point");

			}

			/* at the end of menu, restart all over */
			if( ++u16Menu == MENU_END )
			{
				printf("\n\nEnd of Demo: Press the button to restart... \n\n\n");
				u16Menu = 0;
			}

		}

		/* usual household routine goes here */
		{
		}
	}
}