lutunovoleg

Untitled

Feb 18th, 2026
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include "riscv_csr_encoding.h"
  2. #include "scr1_csr_encoding.h"
  3. #include "mcu32_memory_map.h"
  4. #include <power_manager.h>
  5. #include <gpio.h>
  6.  
  7. #define L0 9u
  8. #define L1 10u
  9. #define BTN 15u
  10. #define MS(d) for(volatile int _=0;_<d;_++)
  11.  
  12. void main(){
  13. PM->CLK_APB_P_SET=0x1E000; PM->CLK_APB_M_SET=0xF000; PM->CLK_AHB_SET|=0x400;
  14. GPIO_1->DIR_IN=1u<<BTN; GPIO_0->DIR_OUT=(1u<<L0)|(1u<<L1);
  15. uint8_t s=0; GPIO_0->OUT=1u<<L0;
  16. for(;;){
  17. if(!(GPIO_1->STATE&(1u<<BTN))){
  18. MS(30000);
  19. if(!(GPIO_1->STATE&(1u<<BTN))){
  20. GPIO_0->OUT=1u<<(s?L0:L1); s^=1;
  21. while(!(GPIO_1->STATE&(1u<<BTN))) MS(100);
  22. }
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment