// (C) 2026 Philip Endecott.
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENCE.txt or copy at https://www.boost.org/LICENSE_1_0.txt

#ifndef lipstick_gpio_hh
#define lipstick_gpio_hh


inline void setup_gpio()
{
  // Make everything outputs.
  // Note this doesn't interfere with the pins that are configured to not
  // be GPIOs, e.g. ADC inputs.
  *IO0DIR = 0xffffffff;  // 1 = output; default 0.
  *IO1DIR = 0xffffffff;  // 1 = output; default 0.
  *IO0PIN = 0;           // Initialise low.
  *IO1PIN = 0;           // Initialise low.
}

inline void gpio0_set_bit(int bit)
{
  *IO0SET = 1<<bit;
}

inline void gpio0_clear_bit(int bit)
{
  *IO0CLR = 1<<bit;
}

inline void gpio1_set_bit(int bit)
{
  *IO1SET = 1<<bit;
}

inline void gpio1_clear_bit(int bit)
{
  *IO1CLR = 1<<bit;
}


#endif
