GPIO Wrapper Class

Easy C++ Architecture
Solve this problem

Implement a simple C++ GPIO wrapper class that abstracts reading and writing a memory-mapped register. The class must provide `set()`, `clear()`, and `read()` methods.

Constraints

  • Do not use STL.
  • Assume GPIO register is mapped at `volatile uint32_t* base`.
  • Only bit 0 controls the GPIO pin.
  • `set()` must set bit 0.
  • `clear()` must clear bit 0.
  • `read()` must return 0 or 1.
Starter codeC++
1class GPIO {2private:3    volatile uint32_t* base;4public:5    GPIO(volatile uint32_t* addr);6    void set();7    void clear();8    int read();9};