NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
gpio.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef GPIO_GPIO_H_
20 #define GPIO_GPIO_H_
21 
22 #include <stdint.h>
23 
24 namespace gpio {
25 
26 // These functions do nothing if we are not on ARM. Technically I could give
27 // the operators direct access to variables for the IO line, but I'm using
28 // functions instead so that in the event this is x86_64, nothing happens
29 // here.
30 class IOManager {
31  volatile uint32_t* gpio4_;
32  volatile uint32_t* iomux_;
33 
34  public:
35  // Constants that are specific to iMX6 DL, which is what was used on Prototype 3 LLP
36  // This is the 32bit address for device mux for output pin GPIO19
37  static constexpr uint32_t kIOMUXC_SW_MUX_CTL_PAD_GPIO19 = static_cast<uint32_t>(0x20e0220);
38  // GPIO19 PIN corresponds to signal GPIO04_IO05
39  static constexpr uint32_t kGPIO4_DR = static_cast<uint32_t>(0x20A8000);
40  static constexpr uint32_t kGPIO4_GDIR = static_cast<uint32_t>(0x20A8004);
41  static constexpr uint32_t kGPIO4_PSR = static_cast<uint32_t>(0x20A8008);
42  static constexpr uint32_t kPageSize = 4096u;
43  static constexpr uint32_t kPageLMask = kPageSize - 1;
44  static constexpr uint32_t kPageHMask = ~(kPageSize - 1);
45 
46  // To find more of these magical constants, please read i.MX 6Solo/6DualLite
47  // Applications Processor Reference Manual.
48  //
49  // Again, this is specific to Prototype 3's LLP
50 
51  IOManager();
52 
53  void InitializeGPIO19();
54  void ToggleGPIO19();
55 };
56 
57 } // end namespace gpio
58 
59 #endif // GPIO_GPIO_H_
gpio::IOManager::kPageHMask
static constexpr uint32_t kPageHMask
Definition: gpio.h:44
gpio::IOManager
Definition: gpio.h:30
gpio::IOManager::kPageLMask
static constexpr uint32_t kPageLMask
Definition: gpio.h:43
gpio::IOManager::ToggleGPIO19
void ToggleGPIO19()
Definition: gpio.cc:80
gpio::IOManager::kGPIO4_PSR
static constexpr uint32_t kGPIO4_PSR
Definition: gpio.h:41
gpio::IOManager::kGPIO4_DR
static constexpr uint32_t kGPIO4_DR
Definition: gpio.h:39
gpio
Definition: GPIO.h:28
gpio::IOManager::kIOMUXC_SW_MUX_CTL_PAD_GPIO19
static constexpr uint32_t kIOMUXC_SW_MUX_CTL_PAD_GPIO19
Definition: gpio.h:37
gpio::IOManager::InitializeGPIO19
void InitializeGPIO19()
Definition: gpio.cc:79
gpio::IOManager::kPageSize
static constexpr uint32_t kPageSize
Definition: gpio.h:42
gpio::IOManager::kGPIO4_GDIR
static constexpr uint32_t kGPIO4_GDIR
Definition: gpio.h:40
gpio::IOManager::IOManager
IOManager()
Definition: gpio.cc:78