1 |
786 |
skrzyp |
#ifndef CYGONCE_HAL_VAR_IO_GPIO_H
|
2 |
|
|
#define CYGONCE_HAL_VAR_IO_GPIO_H
|
3 |
|
|
//===========================================================================
|
4 |
|
|
//
|
5 |
|
|
// var_io_gpio.h
|
6 |
|
|
//
|
7 |
|
|
// Kinetis GPIO
|
8 |
|
|
//
|
9 |
|
|
//===========================================================================
|
10 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 2011 Free Software Foundation, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//===========================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): Tomas Frydrych <tomas@sleepfive.com>
|
45 |
|
|
// Date: 2011-11-14
|
46 |
|
|
// Purpose: Kinetis variant specific registers
|
47 |
|
|
// Description:
|
48 |
|
|
// Usage: #include <cyg/hal/var_io.h> // var_io.h includes this file
|
49 |
|
|
//
|
50 |
|
|
//####DESCRIPTIONEND####
|
51 |
|
|
//
|
52 |
|
|
//===========================================================================
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
//---------------------------------------------------------------------------
|
56 |
|
|
// GPIO
|
57 |
|
|
typedef volatile struct cyghwr_hal_kinetis_gpio_s {
|
58 |
|
|
cyg_uint32 pdor;
|
59 |
|
|
cyg_uint32 psor;
|
60 |
|
|
cyg_uint32 pcor;
|
61 |
|
|
cyg_uint32 ptor;
|
62 |
|
|
cyg_uint32 pdir;
|
63 |
|
|
cyg_uint32 pddr;
|
64 |
|
|
} cyghwr_hal_kinetis_gpio_t;
|
65 |
|
|
|
66 |
|
|
// PTA-PTE base pointers
|
67 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_PORTA_P ((cyghwr_hal_kinetis_gpio_t*)0x400FF000u)
|
68 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_PORTB_P ((cyghwr_hal_kinetis_gpio_t*)0x400FF040u)
|
69 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_PORTC_P ((cyghwr_hal_kinetis_gpio_t*)0x400FF080u)
|
70 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_PORTD_P ((cyghwr_hal_kinetis_gpio_t*)0x400FF0C0u)
|
71 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_PORTE_P ((cyghwr_hal_kinetis_gpio_t*)0x400FF100u)
|
72 |
|
|
|
73 |
|
|
// GPIO register on a given port (register name is lower case)
|
74 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO(__port, __reg) \
|
75 |
|
|
(CYGHWR_HAL_KINETIS_GPIO_PORT##__port##_P)->__reg
|
76 |
|
|
|
77 |
|
|
// Get values for entire port
|
78 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_GET(__port) \
|
79 |
|
|
CYGHWR_HAL_KINETIS_GPIO(__port, pdir)
|
80 |
|
|
|
81 |
|
|
// Output values for entire port
|
82 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_PUT(__port, __val) \
|
83 |
|
|
CYGHWR_HAL_KINETIS_GPIO(__port, pdor) = __val
|
84 |
|
|
|
85 |
|
|
// Set values for entire port based on bitmask
|
86 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_SET(__port, __val) \
|
87 |
|
|
CYGHWR_HAL_KINETIS_GPIO(__port, psor) = __val
|
88 |
|
|
|
89 |
|
|
// Clear values for entire port based on bitmask
|
90 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_CLEAR(__port, __val) \
|
91 |
|
|
CYGHWR_HAL_KINETIS_GPIO(__port, pcor) = __val
|
92 |
|
|
|
93 |
|
|
// Toggle values for entire port based on bitmask
|
94 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_TOGGLE(__port, __val) \
|
95 |
|
|
CYGHWR_HAL_KINETIS_GPIO(__port, ptor) = __val
|
96 |
|
|
|
97 |
|
|
// Get value for a single pin on given port
|
98 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_GET_PIN(__port, __pin) \
|
99 |
|
|
(BIT_(__pin) & CYGHWR_HAL_KINETIS_GPIO_GET(__port))
|
100 |
|
|
|
101 |
|
|
// Set a single pin on a given register
|
102 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_SET_PIN(__port, __pin) \
|
103 |
|
|
CYGHWR_HAL_KINETIS_GPIO_SET(__port, BIT_(__pin))
|
104 |
|
|
|
105 |
|
|
// Clear a single pin on a given register
|
106 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_CLEAR_PIN(__port, __pin) \
|
107 |
|
|
CYGHWR_HAL_KINETIS_GPIO_CLEAR(__port, BIT_(__pin))
|
108 |
|
|
|
109 |
|
|
// Toggle a single pin on a given register
|
110 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_TOGGLE_PIN(__port, __pin) \
|
111 |
|
|
CYGHWR_HAL_KINETIS_GPIO_TOGGLE(__port, BIT_(__pin))
|
112 |
|
|
|
113 |
|
|
// Set pin data direction
|
114 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_PIN_DDR_OUT(__port, __pin) \
|
115 |
|
|
CYGHWR_HAL_KINETIS_GPIO(__port, pddr) |= BIT_(__pin)
|
116 |
|
|
|
117 |
|
|
#define CYGHWR_HAL_KINETIS_GPIO_PIN_DDR_IN(__port, __pin) \
|
118 |
|
|
CYGHWR_HAL_KINETIS_GPIO(__port, pddr) &= ~BIT_(__pin)
|
119 |
|
|
|
120 |
|
|
//-----------------------------------------------------------------------------
|
121 |
|
|
// end of var_io_gpio.h
|
122 |
|
|
#endif // CYGONCE_HAL_VAR_IO_GPIO_H
|