Exemple #1
0
int main (void)  {                /* execution starts here                    */

#if 0
  	IOPIN=0x1;

	ram_test1();
#endif





  busyLoop(BUSY_LOOP_TIMES);
#if 0
  printf ("Hello World\n");       /* the 'printf' function call               */
#else
  output_str("Hello World\n");
#endif
  while (1) {                          /* An embedded program does not stop and       */
#if 1  	
  	IOPIN=0x1;
  	busyLoop(BUSY_LOOP_TIMES);
	IOPIN=0x0;
  	busyLoop(BUSY_LOOP_TIMES);
      /* ... */                       /* never returns. We use an endless loop.      */
#endif	  
  }                                    /* Replace the dots (...) with your own code.  */

}
int init_led(void)
{
    //init_led();
    GPIO_InitTypeDef GPIO_InitStructure;
    
    #if 0
    /* Enable GPIO C clock. */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
    #endif

    /* GPIOD Periph clock enable */
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

  /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

      


#if 0
       
    /* Set the LED pin state such that the LED is off.  The LED is connected
     * between power and the microcontroller pin, which makes it turn on when
     * the pin is low.
     */
    GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_SET);

    /* Configure the LED pin as push-pull output. */
    GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_12;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOC, &GPIO_InitStructure);


    while(1) {
       GPIOC->BRR = 0x00001000;
       busyLoop(500000);
       GPIOC->BSRR = 0x00001000;
       busyLoop(500000);
    }
#endif
  GPIO_ResetBits(GPIOD, GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);
}