0% found this document useful (0 votes)
17 views2 pages

Structhello

Structure

Uploaded by

iamezel0205
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Structhello

Structure

Uploaded by

iamezel0205
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <stdint.

h> //required for uint32_t datatype

#define PERIPHERAL_BASE (0x40000000UL)


#define APB2_OFFSET 0x00010000UL)
#define APB2_BASE (PERIPHERAL_BASE +
APB2_OFFSET)

#define GPIOA_OFFSET (0x00000800UL)


#define GPIOA_BASE (APB2_BASE +
GPIOA_OFFSET)

#define RCC_OFFSET (0x00021000UL)


#define RCC_BASE (PERIPHERAL_BASE +
RCC_OFFSET)

#define PIN5 /*Your code here*/

#define IOPORT_A (1UL<<2)

#define __IO volatile //__IO is same as volatile .It is as per


MISRA C standard.

typedef struct
{
__IO uint32_t CRL;
__IO uint32_t UNUSED_REGS[2]; //__IO uint32_t CRH; //__IO uint32_t
IDR;
__IO uint32_t ODR;
/* __IO uint32_t BSRR;
__IO uint32_t BRR;
__IO uint32_t LCKR;*/
} GPIO_TypeDef;

typedef struct
{
/*__IO uint32_t CR;
__IO uint32_t CFGR;
__IO uint32_t CIR;
__IO uint32_t APB2RSTR;
__IO uint32_t APB1RSTR;
__IO uint32_t AHBENR;*/
__IO uint32_t UNUSED_REGS[6];
__IO uint32_t APB2ENR;
/* __IO uint32_t APB1ENR;
__IO uint32_t BDCR;
__IO uint32_t CSR;*/
} RCC_TypeDef;

#define RCC ((RCC_TypeDef*)RCC_BASE) //RCC_BASE typecasted to


RCC_Typedef type pointer
#define GPIOA ((GPIO_TypeDef*)GPIOA_BASE) //GPIOA_BASE typecasted
to GPIO_Typedef type pointer

int main (void) {

/*Your code here*/


while(1){

/*Your Code here*/

You might also like