KizarmProbe.
 Vše Třídy Soubory Funkce Proměnné Výčty Hodnoty výčtu Definice maker Skupiny Stránky
gpio.h
Zobrazit dokumentaci tohoto souboru.
1 #ifndef GPIO_H
2 #define GPIO_H
3 
4 #include "LPC11Uxx.h"
5 
6 typedef enum {
7  GPIO_Mode_IN = 0x00,
8  GPIO_Mode_OUT = 0x01,
10 
20 class GpioClass {
21  public:
26  GpioClass (const uint32_t no, const GPIODir_TypeDef type = GPIO_Mode_OUT) :
27  pos(1UL << no) {
28  // Povol hodiny
29  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
30  // A nastav pin.
31  setDir (type);
32  };
34  const void set (const bool b) const {
35  if (b) LPC_GPIO->SET[0] = pos;
36  else LPC_GPIO->CLR[0] = pos;
37  };
39  const void set (void) const {
40  LPC_GPIO->SET[0] = pos;
41  };
43  const void clr (void) const {
44  LPC_GPIO->CLR[0] = pos;
45  };
47  const void change (void) const {
48  LPC_GPIO->NOT[0] = pos;
49  };
51  const bool get (void) const {
52  if (LPC_GPIO->PIN[0] & pos) return true;
53  else return false;
54  };
55  void setDir (GPIODir_TypeDef p) {
56  if (p) LPC_GPIO->DIR[0] |= pos;
57  else LPC_GPIO->DIR[0] &= ~pos;
58  }
59  private:
61  const uint32_t pos;
62 
63 };
64 
65 
66 
67 #endif // GPIO_H
GpioClass(const uint32_t no, const GPIODir_TypeDef type=GPIO_Mode_OUT)
Definition: gpio.h:26
__IO uint32_t SYSAHBCLKCTRL
Definition: LPC11Uxx.h:490
Definition: gpio.h:8
const void clr(void) const
Nastav pin na log. L.
Definition: gpio.h:43
Obecný GPIO pin.
Definition: gpio.h:20
const void set(const bool b) const
Nastav pin.
Definition: gpio.h:34
GPIODir_TypeDef
Definition: gpio.h:6
const void set(void) const
Nastav pin na log. H.
Definition: gpio.h:39
Definition: gpio.h:7
const void change(void) const
Změň hodnotu pinu.
Definition: gpio.h:47
CMSIS Cortex-M0 Core Peripheral Access Layer Header File for default LPC11Uxx Device Series...