Hanna
Sourcecode Batteriemanagementsystem
port_driver.h
gehe zur Dokumentation dieser Datei
1 
57 #ifndef PORT_DRIVER_H
58 #define PORT_DRIVER_H
59 
60 //#include "avr_compiler.h"
61 #include <stdint.h>
62 #include <stdbool.h>
63 #include <stdlib.h>
64 #include <avr/io.h>
65 #include <avr/interrupt.h>
66 #include <avr/pgmspace.h>
67 #include <util/delay.h>
68 
69 typedef uint8_t port_pin_t;
70 typedef uint8_t ioport_pin_t;
71 
72 
73 /* Definitions of macros. */
74 
77 #define IO_ISC_BOTHEDGES (0 << 0)
78 #define IO_ISC_RISING (1 << 0)
79 #define IO_ISC_FALLING (2 << 0)
80 #define IO_ISC_LEVEL (3 << 0)
81 #define IO_ISC_INPUT_DISABLE (7 << 0)
82 #define IO_ISC_DEFAULT (0 << 0)
83 
87 #define IO_OPC_TOTEM (0 << 3)
88 #define IO_OPC_BUSKEEPER (1 << 3)
89 #define IO_OPC_PULL_DOWN (2 << 3)
90 #define IO_OPC_PULL_UP (3 << 3)
91 #define IO_OPC_WIRED_OR (4 << 3)
92 #define IO_OPC_WIRED_AND (5 << 3)
93 #define IO_OPC_WIRED_OR_PULL_DOWN (6 << 3)
94 #define IO_OPC_WIRED_AND_PULL_UP (7 << 3)
95 #define IO_OPC_DEFAULT (0 << 3)
100 #define IO_CONF_INV_ENABLED (1 << 0)
101 #define IO_CONF_INV_DISABLE (0 << 0)
106 #define IO_CONF_SRL_ENABLED (1 << 0)
107 #define IO_CONF_SRL_DISABLED (0 << 0)
121 #define IO_SetDirection( _port, _directionMask) ( (_port)->DIR = _directionMask )
122 
123 
132 #define IO_ToggleDirection( _port, _toggleMask) ( (_port)->DIRTGL = _toggleMask )
133 
134 
144 #define IO_SetOutputValue( _port, _outValue) ( (_port)->OUT = _outValue )
145 
146 
156 #define IO_SetPins( _port, _setMask) ( (_port)->OUTSET = _setMask )
157 
158 
168 #define IO_ClearPins( _port, _clearMask) ( (_port)->OUTCLR = _clearMask )
169 
170 
179 #define IO_TogglePins( _port, _toggleMask ) ( (_port)->OUTTGL = _toggleMask )
180 
181 
190 #define IO_GetPortValue( _port ) ( (_port)->IN )
191 
192 
202 #define IO_GetInterruptFlags( _port, _bitMask ) ( (_port)->INTFLAGS & _bitMask )
203 
204 
213 #define IO_ClearInterruptFlags( _port, _bitMask ) ( (_port)->INTFLAGS = _bitMask )
214 
215 
216 
217 /* Prototyping of functions. Documentation is found in source file. */
218 
219 
220 void IO_SetPinHigh( PORT_t * port, uint8_t pinMask );
221 
222 void IO_SetPinLow( PORT_t * port, uint8_t pinMask );
223 
224 void IO_SetPinAsOutput( PORT_t * port, uint8_t pinMask );
225 void IO_SetPinAsOutput_InitHigh( PORT_t * port, uint8_t pinMask );
226 
227 void IO_SetPinAsInput( PORT_t * port, uint8_t pinMask );
228 
229 void IO_TogglePin( PORT_t * port, uint8_t pinMask );
230 
231 bool IO_GetPinLevel( PORT_t * port, uint8_t pinMask );
232 
233 
234 void IO_ConfigureInterrupt0( PORT_t * port, PORT_INT0LVL_t intLevel, uint8_t pinMask);
235 
236 void IO_ConfigureInterrupt1( PORT_t * port, PORT_INT1LVL_t intLevel, uint8_t pinMask);
237 
238 void IO_ConfigurePin( PORT_t * port, uint8_t pinMask, uint8_t slewRateEnable, uint8_t invertEnable,
239  PORT_OPC_t opc, PORT_ISC_t isc);
240 
241 void IO_MapVirtualPort0(PORTCFG_VP02MAP_t realPort);
242 void IO_MapVirtualPort1(PORTCFG_VP13MAP_t realPort);
243 void IO_MapVirtualPort2(PORTCFG_VP02MAP_t realPort);
244 void IO_MapVirtualPort3(PORTCFG_VP13MAP_t realPort);
245 
246 
247 #endif
void IO_MapVirtualPort2(PORTCFG_VP02MAP_t realPort)
Maps a real port to virtual port 2.
Definition: port_driver.c:249
void IO_ConfigureInterrupt0(PORT_t *port, PORT_INT0LVL_t intLevel, uint8_t pinMask)
Configures interrupt 0.
Definition: port_driver.c:189
void IO_SetPinAsInput(PORT_t *port, uint8_t pinMask)
This function configures a pin in an I/O port or virtual port as an input.
Definition: port_driver.c:159
void IO_SetPinLow(PORT_t *port, uint8_t pinMask)
This function clears a bit in the OUT register of an I/O port or virtual port.
Definition: port_driver.c:121
void IO_SetPinHigh(PORT_t *port, uint8_t pinMask)
This function sets a bit in the OUT register of an I/O port or virtual port.
Definition: port_driver.c:108
void IO_SetPinAsOutput_InitHigh(PORT_t *port, uint8_t pinMask)
This function configures a pin in an I/O port or virtual port as an output and sets the pin to high a...
Definition: port_driver.c:145
void IO_MapVirtualPort0(PORTCFG_VP02MAP_t realPort)
Maps a real port to virtual port 0.
Definition: port_driver.c:223
void IO_TogglePin(PORT_t *port, uint8_t pinMask)
Toggle the value of an IOPORT pin, which has previously been configured as an output.
Definition: port_driver.c:174
void IO_SetPinAsOutput(PORT_t *port, uint8_t pinMask)
This function configures a pin in an I/O port or virtual port as an output.
Definition: port_driver.c:133
void IO_ConfigureInterrupt1(PORT_t *port, PORT_INT1LVL_t intLevel, uint8_t pinMask)
Configures interrupt 1.
Definition: port_driver.c:207
void IO_MapVirtualPort1(PORTCFG_VP13MAP_t realPort)
Maps a real port to virtual port 1.
Definition: port_driver.c:236
void IO_ConfigurePin(PORT_t *port, uint8_t pinMask, uint8_t slewRateEnable, uint8_t invertEnable, PORT_OPC_t opc, PORT_ISC_t isc)
This function changes the configuration of a set of pins.
Definition: port_driver.c:77
void IO_MapVirtualPort3(PORTCFG_VP13MAP_t realPort)
Maps a real port to virtual port 3.
Definition: port_driver.c:262