IN / OUT in C für das mySTM32 Board Light

//---------------------------------------------------------------------------
// Title     : simple IN OUT Solution, ARM C application in SiSy
//---------------------------------------------------------------------------
// Function  : ...
// Wiring    : ...
//---------------------------------------------------------------------------
// Hardware  : ...
// Clock     : ... MHz
// Language  : ARM C
// Date      : ...
// Version   : ...
// Author    : ...
//---------------------------------------------------------------------------
#include <stddef.h>
#include <stdlib.h>
#include "hardware.h"

void initApplication()
{
    // config 10ms SystemTimer
    SysTick_Config(SystemCoreClock/100);
    // user initializations here
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB,ENABLE);
    GPIO_InitTypeDef led;
    led.GPIO_Mode  = GPIO_Mode_OUT;
 	led.GPIO_OType = GPIO_OType_PP;
 	led.GPIO_Pin   = GPIO_Pin_0;
 	led.GPIO_PuPd  = GPIO_PuPd_NOPULL;
 	led.GPIO_Speed = GPIO_Speed_2MHz;
 	GPIO_Init(GPIOB,&led);  

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);
    GPIO_InitTypeDef button;
    button.GPIO_Mode  = GPIO_Mode_IN;
 	button.GPIO_Pin   = GPIO_Pin_0;
 	button.GPIO_PuPd  = GPIO_PuPd_UP;
 	GPIO_Init(GPIOA,&button);  


}
int main(void)
{
    SystemInit();
    initApplication();
    do{
        if (GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0)==0)
        	GPIO_SetBits(GPIOB,GPIO_Pin_0);
        else
        	GPIO_ResetBits(GPIOB,GPIO_Pin_0);
       
    } while (true);
    return 0;
}
extern "C" void SysTick_Handler(void)
{
    // Application SysTick default 10ms
}
//------------------------------------------------------------------------------

Version mit der STM32 HAL Library

Version mit der STM32 LL Library

Weiter mit