blob: 700dced641aca453504ff8e369b967342ca3406f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 );
}
}
}
|