RuiViana

ESP32_tst_P_Manipulation

Sep 10th, 2020
846
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //  ESP32   Technical Reference Manual  Version 4.2
  2. //
  3. //  5.3.3 Simple GPIO Output
  4. //
  5. //  The GPIO Matrix can also be used for simple GPIO output –
  6. //    setting a bit in the GPIO_OUT_DATA register will
  7. //  write to the corresponding GPIO pad.
  8. //  To configure a pad as simple GPIO output, the GPIO Matrix GPIO_FUNCx_OUT_SEL
  9. //    register is configured with a special peripheral index value (0x100).
  10. //---------------------------------------------------------------------------------
  11. void setup()
  12. {
  13.   // pinMode(2, OUTPUT);
  14.   // pinMode(13,OUTPUT);
  15.   REG_WRITE(GPIO_ENABLE_REG, BIT2);                 //Define GPIO2 as output
  16.   REG_WRITE(GPIO_FUNC2_OUT_SEL_CFG_REG, 0x100);     //Special peripheral index value (0x100)
  17.   //REG_WRITE(GPIO_ENABLE_REG, BIT13);                //Define GPIO13 as output
  18.   //REG_WRITE(GPIO_FUNC13_OUT_SEL_CFG_REG, 0x100);    //Special peripheral index value (0x100)
  19. }
  20. //---------------------------------------------------------------------------------
  21. void loop()
  22. {
  23.   REG_WRITE(GPIO_OUT_W1TS_REG, BIT2);                    //GPIO2 HIGH (set)
  24.   REG_WRITE(GPIO_OUT_W1TS_REG, BIT13);                   //GPIO13 HIGH (set)
  25.   delay(50);
  26.   REG_WRITE(GPIO_OUT_W1TC_REG, BIT2);                    //GPIO2 LOW (clear)
  27.   REG_WRITE(GPIO_OUT_W1TS_REG, BIT13);                   //GPIO13 LOW (clear)
  28.   delay(50);
  29. }
RAW Paste Data