diff options
| author | Otto Mattik <otto@mattik.org> | 2021-07-08 18:10:55 +0200 |
|---|---|---|
| committer | Otto Mattik <otto@mattik.org> | 2021-07-08 18:10:55 +0200 |
| commit | da34d97efb21719b2b332f8c60b2750d11bcde1f (patch) | |
| tree | 2de9fe89f6d79b8ebfcde64c5e86204e904aedf2 /gpio.c | |
| download | armen-master.tar.gz armen-master.zip | |
Diffstat (limited to 'gpio.c')
| -rw-r--r-- | gpio.c | 54 |
1 files changed, 54 insertions, 0 deletions
@@ -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 <stdarg.h> +#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 ); + } + } +} + |
