ESP32 38Khz modulated output

Usage:
IOT - IR control

Background:
I am in the very first steps of consolidating my code from my proMini and ESP-01 to an ESP32(ESP8266) to control my various items.

Problem:
Difficulty locating source of (semi)consolidated information with examples; resulting in combing through header, cpp, and accompanying files.

Sure, I can download an ESP32 library and make it work. However, a few years ago, NickG outlined perfect explanations and examples leaving with a working understanding:

//create 38Khz PWM variable names
#define TIMER_RESET
#define TIMER_ENABLE_PWM    (TCCR2A |= _BV(COM2B1))
#define TIMER_DISABLE_PWM   (TCCR2A &= ~(_BV(COM2B1)))
#define TIMER_ENABLE_INTR   (TIMSK2 = _BV(OCIE2A))
#define TIMER_DISABLE_INTR  (TIMSK2 = 0)
#define TIMER_INTR_NAME     TIMER2_COMPA_vect

#ifdef F_CPU
#  define SYSCLOCK  F_CPU     // main Arduino clock
#else
# define SYSCLOCK  16000000  // main Arduino clock
#endif

// microseconds per clock interrupt tick
#define USECPERTICK    50

//finalize calculations for creation of 38Khz PWM
#define TIMER_CONFIG_KHZ(val) ({ \
  const uint8_t pwmval = SYSCLOCK / 2000 / (val); \
 TCCR2A               = _BV(WGM20); \
 TCCR2B               = _BV(WGM22) | _BV(CS20); \
 OCR2A                = pwmval; \
 OCR2B                = pwmval / 3; \
})

#define TIMER_COUNT_TOP  (SYSCLOCK * USECPERTICK / 1000000)

//-----------------
#if (TIMER_COUNT_TOP < 256)
#  define TIMER_CONFIG_NORMAL() ({ \
   TCCR2A = _BV(WGM21); \
   TCCR2B = _BV(CS20); \
   OCR2A  = TIMER_COUNT_TOP; \
   TCNT2  = 0; \
 })
#else
#  define TIMER_CONFIG_NORMAL() ({ \
   TCCR2A = _BV(WGM21); \
   TCCR2B = _BV(CS21); \
   OCR2A  = TIMER_COUNT_TOP / 8; \
   TCNT2  = 0; \
 })
#endif

#define TIMER_PWM_PIN  3

For obvious reasons, the above code did not build.

In case one is wondering, I do aspire to reinvent the wheel - I just want to know how it works as opposed to loading a ready-made library. If someone one could trim off the right angles of my square wheels, I can begin to roll forward - choppy as it may be.

Realizing the ESP32 is not an endorsed product, I probably should move the question to the other website; that said, I know which sandbox the real experts play in.

Thank you in advance.

The esp32 experts hang out on their forums, not here. This is where the arduino on AVR experts (and ide board manager expert) hang out. I dont think ive seen any posts on advanced use of esp32 on chip peripherals here (which this is)....

I would suggest though that, if you can find a library that does it, that you go ahead and use it - the ESP peripherals arent as straightforward as the AVR ones...

Thanks for the direction, DrA; searching for answers in the explicit forum: I’ll share the solution when found.