-
Notifications
You must be signed in to change notification settings - Fork 13
/
io.h
63 lines (56 loc) · 1.84 KB
/
io.h
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
55
56
57
58
59
60
61
62
63
/* This file is part of ukbdc.
*
* ukbdc is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ukbdc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ukbdc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*! \defgroup IO
* \brief Easy AVR port pins control
*
* This module creates a layer of abstraction for microcontroller pins.
*
* Every pin is represented by a 1-byte unsigned number. Numbers up to 127
* represent *internal* pins, which means pins belonging to microcontroller's
* ports. Numbers higher than that represent *external* pins. The external
* pins can be anything and the implementation of the writing, reading and
* configuring functions can be provided by the user.
*
* @{
*/
#pragma once
#include "platforms.h"
#ifdef PLATFORM_alpha
#include "hc595.h"
#endif
#include <avr/io.h>
#include <stdbool.h>
/*! A macro for pin's output mode */
#define OUTPUT true
/*! A macro for pin's input mode */
#define INPUT false
/*! Reads the state of pin
* \param pin pin number
* \return binary state of the pin
*/
bool IO_get(uint8_t pin);
/*! Sets the state of pin
* \param pin pin number
* \oaran val the value to set
*/
void IO_set(uint8_t pin, bool val);
/*! Sets the mode of a pin
* \param pin pin number
* \param dir the mode of the pin (\ref INPUT or \ref OUTPUT)
*/
void IO_config(uint8_t pin, bool dir);
/*! @} */