Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "main_base.h"
- int x = 120, y = 160, dx = 1, dy = 1;
- unsigned int pomiar;
- void move_square_asm();
- unsigned short int RGB16Pack(unsigned char,unsigned char,unsigned char);
- void move_square_C()
- {
- x=pomiar;
- //y+=dy;
- //if (x <= 1 || x >= 240 - 34)
- // pomiar = -pomiar;
- //if (y <= 1 || y >= 320 - 34)
- //dy = -dy;
- }
- int main(void) {
- HAL_Init();
- SystemClock_Config();
- BSP_SDRAM_Init();
- LCD_Config();
- RCC->APB2ENR|=RCC_APB2ENR_TIM1EN;
- GPIOA->AFR[1]|= 1 << (0*4); // 1 - Tim2_CH1 //funkcja alternatywna wejsc (AFR), bo port moze byc i/o/adc/enkoder/inne alternatywne
- GPIOA->AFR[1]|= 1 << (1*4); // 1 - Tim2_CH2
- GPIOA->MODER |= GPIO_Mode_AF << (8*2);
- GPIOA->MODER |= GPIO_Mode_AF << (9*2); //bylo gpiob
- GPIOA->PUPDR |= GPIO_PuPd_UP << (8*2);
- GPIOA->PUPDR |= GPIO_PuPd_UP << (9*2); //bylo gpiob
- TIM1->PSC=0; // Brak preskalera
- TIM1->CNT=16; // Pocz¹tkowy stan licznika
- TIM1->SMCR=1; // Wybór trybu pracy enkodera
- TIM1->CCMR1=0x3232; /* CCxS bits = 01 - Ustawia kana³y
- CH1 i CH2 do pracy wejœciowej (CAPTURE) ICxF bits = 3 -
- ustawia rozmiar okna filtru wejœciowego */ //jeszcze go skonfigurowac?
- TIM1->ARR=32; // Rejestr prze³adowania stanu licznika
- TIM1->CR1=1; // Odblokowuje licznik
- //pomiar=TIM1->CNT;
- while (1)
- {
- pomiar=TIM1->CNT;
- Clear_And_Reload_Screen();
- #ifdef ASM_EXMPL
- move_square_asm();
- #else
- move_square_C();
- #endif
- for (int yy = 0; yy < 32; yy++)
- {
- unsigned short int *pixel = (unsigned short int*) (LCD_BUF + x + (y + yy) * 240);
- for (int xx = 0; xx < 32; xx++)
- {
- #ifdef ASM_EXMPL
- *pixel++ = RGB16Pack(y >> 4, (xx + (((240 - x)) * (32 - yy) / 240)+x * yy / 240), 31 - (x >> 4));
- #else
- *pixel++ = ((31 - ((x >> 4) & 0x1f)) << 11) | (((xx + (((240 - x)) * (32 - yy) / 240) + x * yy / 240) & 0x3f) << 5) | (((y >> 4) & 0x1f) << 0);
- #endif
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement