Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "main_base.h"
- int f = 0;
- void mryganie_diody(unsigned int);
- int main(void) {
- RCC->AHB1ENR |= RCC_AHB1Periph_GPIOG;
- GPIOG->MODER |= GPIO_Mode_OUT << (14*2);// 1 - output
- GPIOG->OTYPER|= GPIO_OType_PP << 14;//0 - push-pull (def.)
- GPIOG->PUPDR |= GPIO_PuPd_NOPULL << (14*2);//0 - (default)
- GPIOG->MODER |= GPIO_Mode_OUT << (13*2);// 1 - output
- GPIOG->OTYPER|= GPIO_OType_PP << 13;//0 - push-pull (def.)
- GPIOG->PUPDR |= GPIO_PuPd_NOPULL << (13*2);//0 - (default)
- RCC->AHB1ENR |= RCC_AHB1Periph_GPIOA;
- GPIOA->MODER |= GPIO_Mode_IN; // 0 - input (default)
- GPIOA->PUPDR |= GPIO_PuPd_NOPULL ; // 0 - (default)
- GPIOG->BSRR = 0x4000;
- while (1) {
- while((GPIOA->IDR&1) ){
- f=0;
- mryganie_diody(f);
- for(int g = 0;g<2000000;g++){}
- f=1;
- while(!(GPIOA->IDR&1) ){}
- mryganie_diody(f);
- for(int K = 0;K<2000000;K++){}
- }
- }
- // GPIOG->BSRR = GPIO_Pin_14<<16; //0x40000000
- //GPIOG->BSRR = GPIO_Pin_13; //0x4000
- }
- --------------------------------------------------------------------------------------------------------------
- .syntax unified
- .set PRESCALER_MAX,50
- .set PERIPH_BASE,0x40000000
- .set AHB1PERIPH_OFFSET, 0x00020000
- .set GPIOG_BASE,PERIPH_BASE+AHB1PERIPH_OFFSET+0x1800
- .set BSRR_OFFSET,0x18
- .global mryganie_diody
- .section .text
- mryganie_diody:
- ldr r3,=GPIOG_BASE+BSRR_OFFSET
- mov r1,#0x20000000
- mov r4,#0x40000000
- mov r2,#0x2000
- lsl r2,r2,r0
- str r4,[r3]
- str r1,[r3]
- str r2,[r3]
- mov pc,lr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement