<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wait_for_edge(channel, trigger, timeout=-1):
 """ This function is designed to block execution of your program until an edge is detected. :param channel: the channel based on the numbering system you have specified (:py:attr:`GPIO.BOARD`, :py:attr:`GPIO.BCM` or :py:attr:`GPIO.SUNXI`). :param trigger: The event to detect, one of: :py:attr:`GPIO.RISING`, :py:attr:`GPIO.FALLING` or :py:attr:`GPIO.BOTH`. :param timeout: (optional) TODO In other words, the polling example above that waits for a button press could be rewritten as: .. code:: python GPIO.wait_for_edge(channel, GPIO.RISING) Note that you can detect edges of type :py:attr:`GPIO.RISING`, :py:attr`GPIO.FALLING` or :py:attr:`GPIO.BOTH`. The advantage of doing it this way is that it uses a negligible amount of CPU, so there is plenty left for other tasks. If you only want to wait for a certain length of time, you can use the timeout parameter: .. code:: python # wait for up to 5 seconds for a rising edge (timeout is in milliseconds) channel = GPIO.wait_for_edge(channel, GPIO_RISING, timeout=5000) if channel is None: print('Timeout occurred') else: print('Edge detected on channel', channel) """

    _check_configured(channel, direction=IN)
    pin = get_gpio_pin(_mode, channel)
    if event.blocking_wait_for_edge(pin, trigger, timeout) is not None:
        return channel