#include"stm32f10x.h"

//mise en place des bits d'accès
#define ACCESS_BTN_BLUE (1 << 13)
#define ACCESS_LED_GREEN (1 << 5)
	
//configuration du pin de la led
//GPIOA->PIN PA.5 = 4*5 (où 4 = nb bit par pin)
#define DECALAGE_PA5 (5 * 4)

int main(void){

	//activation des clocks
	RCC->APB2ENR |= (0x01 << 2) | (0x01 << 3) | (0x01 << 4) ;
	
	//on nettoie la config actuelle de PA5 (on reset)
	GPIOA->CRL &=  ~(0xF << DECALAGE_PA5);
	
	//on met la conf, output push-pull c'est le nombre 2
	GPIOA->CRL |= 2 << DECALAGE_PA5;
	
	while(1){
		
		if(GPIOC->IDR & ACCESS_BTN_BLUE){
			//bouton non pressé, il faut éteindre la led
			GPIOA->ODR &= ~(ACCESS_LED_GREEN);
		}
		else {
			//bouton pressé, il faut allumer la led
			GPIOA->ODR |= ACCESS_LED_GREEN;
		}
		
	}

}