| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| #include <assert.h> |
| #include "hal/hal_gpio.h" |
| #include "mcu/cmsis_nvic.h" |
| |
| /** |
| * gpio init in |
| * |
| * Initializes the specified pin as an input |
| * |
| * @param pin Pin number to set as input |
| * @param pull pull type |
| * |
| * @return int 0: no error; -1 otherwise. |
| */ |
| int |
| hal_gpio_init_in(int pin, hal_gpio_pull_t pull) |
| { |
| return 0; |
| } |
| |
| /** |
| * gpio init out |
| * |
| * Initialize the specified pin as an output, setting the pin to the specified |
| * value. |
| * |
| * @param pin Pin number to set as output |
| * @param val Value to set pin |
| * |
| * @return int 0: no error; -1 otherwise. |
| */ |
| int |
| hal_gpio_init_out(int pin, int val) |
| { |
| return 0; |
| } |
| |
| /** |
| * gpio write |
| * |
| * Write a value (either high or low) to the specified pin. |
| * |
| * @param pin Pin to set |
| * @param val Value to set pin (0:low 1:high) |
| */ |
| void |
| hal_gpio_write(int pin, int val) |
| { |
| return; |
| } |
| |
| /** |
| * gpio read |
| * |
| * Reads the specified pin. |
| * |
| * @param pin Pin number to read |
| * |
| * @return int 0: low, 1: high |
| */ |
| int |
| hal_gpio_read(int pin) |
| { |
| return 0; |
| } |
| |
| /** |
| * gpio toggle |
| * |
| * Toggles the specified pin |
| * |
| * @param pin Pin number to toggle |
| * |
| * @return current pin state int 0: low, 1: high |
| */ |
| int |
| hal_gpio_toggle(int pin) |
| { |
| int pin_state = (hal_gpio_read(pin) == 0); |
| hal_gpio_write(pin, pin_state); |
| return pin_state; |
| } |
| |
| /** |
| * gpio irq init |
| * |
| * Initialize an external interrupt on a gpio pin |
| * |
| * @param pin Pin number to enable gpio. |
| * @param handler Interrupt handler |
| * @param arg Argument to pass to interrupt handler |
| * @param trig Trigger mode of interrupt |
| * @param pull Push/pull mode of input. |
| * |
| * @return int |
| */ |
| int |
| hal_gpio_irq_init(int pin, hal_gpio_irq_handler_t handler, void *arg, |
| hal_gpio_irq_trig_t trig, hal_gpio_pull_t pull) |
| { |
| return 0; |
| } |
| |
| /** |
| * gpio irq release |
| * |
| * No longer interrupt when something occurs on the pin. NOTE: this function |
| * does not change the GPIO push/pull setting. |
| * It also does not disable the NVIC interrupt enable setting for the irq. |
| * |
| * @param pin |
| */ |
| void |
| hal_gpio_irq_release(int pin) |
| { |
| return; |
| } |
| |
| /** |
| * gpio irq enable |
| * |
| * Enable the irq on the specified pin |
| * |
| * @param pin |
| */ |
| void |
| hal_gpio_irq_enable(int pin) |
| { |
| return; |
| } |
| |
| /** |
| * gpio irq disable |
| * |
| * |
| * @param pin |
| */ |
| void |
| hal_gpio_irq_disable(int pin) |
| { |
| return; |
| } |