From da34d97efb21719b2b332f8c60b2750d11bcde1f Mon Sep 17 00:00:00 2001 From: Otto Mattik Date: Thu, 8 Jul 2021 18:10:55 +0200 Subject: git: update to v1.0 --- gpio.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 gpio.c (limited to 'gpio.c') diff --git a/gpio.c b/gpio.c new file mode 100644 index 0000000..700dced --- /dev/null +++ b/gpio.c @@ -0,0 +1,54 @@ +/************************************************************************/ +/* */ +/* File: gpio.c */ +/* Description: general purpose input/output driver. */ +/* Version: 1.0 */ +/* Author: Otto Mattik */ +/* */ +/* (C)Copyright Otto Mattik 2014-2021. */ +/* */ +/* This file is a part of 'armen' (a tiny operating system). */ +/* 'armen' is distributed under the CeCILL-V2.1 licence. For more */ +/* details about this licence, please visit the website cecill.info */ +/* */ +/************************************************************************/ + +#include +#include "armen.h" + +#ifdef __AVR_ARCH__ + #define AVR_GPIO_C + #include "avr/gpio.c" +#endif + +/* + * initialize a gpio pin + * + * input: + * gpio gpio pin + * mode input or output +*/ +void gpio_pin_mode( uint8_t gpio, uint8_t mode, ... ) +{ +#ifdef CHECK_PARAM + if( gpio < (GPIO_MAX_PORT << 3) ) +#endif + { + if( mode == GPIO_INPUT ) + gpio_pin_mode_input( gpio ); + else +#ifdef CHECK_PARAM + if( mode == GPIO_OUTPUT ) +#endif + { + va_list args; + uint8_t value; + + va_start( args, mode ); + value = (uint8_t)va_arg( args, int ); + gpio_pin_mode_output( gpio, value ); + va_end( args ); + } + } +} + -- cgit v1.2.1