#include <stdint.h>
#define RCC_Base 0x40021000
#define GPIOD_Base 0x50000C00
uint32_t *RCC_Enable_Reg = (uint32_t*) (RCC_Base+0x34); //POinter to AHB1 Enable Register
uint32_t *GPIOD_Mode_Reg = (uint32_t*) (GPIOD_Base+0x00); //Pointer to Mode Register of Port 0
uint32_t *GPIOD_OutReg = (uint32_t*) (GPIOD_Base+0x14); //Pointer to Output Dtaa Register of Port 0
uint32_t *GPIOD_InReg = (uint32_t*) (GPIOD_Base+0x10); //Pointer to Input data register if Port D
void setup()
{
// put your setup code here, to run once:
*RCC_Enable_Reg |= (1<<3); //Enable clock to Port D
*GPIOD_Mode_Reg |= (1<<0); // Bit 0 is configured as HIGH to make GPIOD0 as output pin
*GPIOD_Mode_Reg &= ~(1<<1); //Bit 1 is configures as LOW to make GPIOD2 AS OUTPUT PIN
*GPIOD_Mode_Reg &= ~(1<<4); // Bit 4 is configured as LOW to make GPIOD2 as output pin
*GPIOD_Mode_Reg &= ~(1<<5); //Bit 5 is configures as LOW to make GPIOD2 as output pin
}
void loop()
{
if((*GPIOD_InReg & (1<<2))){
// put your main code here, to run repeatedly:
*GPIOD_OutReg ^= (1<<0);
}
delay(1000); // this speeds up the simulation
}