EE445M RTOS
Taken at the University of Texas Spring 2015
lswitch Class Reference

#include <switchpp.hpp>

Inheritance diagram for lswitch:
Inheritance graph
Collaboration diagram for lswitch:
Collaboration graph

Public Member Functions

 lswitch ()
 
 lswitch (memory_address_t lswitch_base, memory_address_t lswitch_pin, semaphore *sem, timer_t timer_id, subtimer_t timer_subtimer, uint32_t switch_interrupt, uint32_t interrupt_mask=GPIO_BOTH_EDGES, bool start=false)
 
virtual void start (void)
 
virtual void stop (void)
 
virtual uint32_t ack (void)
 
void debounce (void)
 
uint32_t end_debounce (void)
 
uint32_t sample (void)
 
- Public Member Functions inherited from interruptable
 interruptable ()
 

Public Attributes

uint32_t debounced_data
 

Private Attributes

memory_address_t base
 
memory_address_t pin
 
semaphoresem
 
timer tim
 

Detailed Description

Definition at line 16 of file switchpp.hpp.

Constructor & Destructor Documentation

lswitch::lswitch ( )

Initialize lswitch.

Definition at line 15 of file switchpp.cpp.

References NULL, and sem.

15  {
16 
17  this->sem = NULL;
18 }
#define NULL
Definition: switchpp.cpp:13
semaphore * sem
Definition: switchpp.hpp:20
lswitch::lswitch ( memory_address_t  lswitch_base,
memory_address_t  lswitch_pin,
semaphore sem,
timer_t  timer_id,
subtimer_t  timer_subtimer,
uint32_t  switch_interrupt,
uint32_t  interrupt_mask = GPIO_BOTH_EDGES,
bool  start = false 
)

Definition at line 20 of file switchpp.cpp.

References base, ctlsys::enable_periph(), pin, sem, start(), tim, and ctlsys::timer_timeout_from_subtimer().

22  {
23 
24  base = lswitch_base;
25  pin = lswitch_pin;
26 
28  GPIOPinTypeGPIOInput(base, pin);
29  GPIODirModeSet(base, pin, GPIO_DIR_MODE_IN);
30 
31  if ((base == GPIO_PORTF_BASE) && (pin & GPIO_PIN_0)) {
32  HWREG(base + GPIO_O_LOCK) = GPIO_LOCK_KEY;
33  HWREG(base + GPIO_O_CR) = 0x01;
34  HWREG(base + GPIO_O_LOCK) = 0;
35 
36  GPIOPadConfigSet(base, pin, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
37  }
38 
39  /* other solution: timer scoreboard */
40  this->tim = timer(timer_id, timer_subtimer, TIMER_CFG_ONE_SHOT, SysCtlClockGet() / 50,
41  ctlsys::timer_timeout_from_subtimer(timer_subtimer));
42 
43  GPIOIntTypeSet(base, pin, switch_interrupt);
44  IntEnable(interrupt_mask);
45 
46  this->sem = sem;
47  *(this->sem) = semaphore();
48 
49  if (start) {
50  this->start();
51  }
52 }
memory_address_t pin
Definition: switchpp.hpp:19
semaphore * sem
Definition: switchpp.hpp:20
static uint32_t timer_timeout_from_subtimer(uint32_t subtimer)
Definition: ctlsysctl.hpp:47
virtual void start(void)
Definition: switchpp.cpp:54
timer tim
Definition: switchpp.hpp:21
static void enable_periph(uint32_t sys_periph)
Definition: ctlsysctl.hpp:24
memory_address_t base
Definition: switchpp.hpp:18

Here is the call graph for this function:

Member Function Documentation

uint32_t lswitch::ack ( void  )
virtual

Implements interruptable.

Definition at line 83 of file switchpp.cpp.

References base, and pin.

Referenced by GPIOPortE_Handler().

83  {
84 
85  GPIOIntClear(base, pin);
86 }
memory_address_t pin
Definition: switchpp.hpp:19
memory_address_t base
Definition: switchpp.hpp:18

Here is the caller graph for this function:

void lswitch::debounce ( void  )

Call this in the isr of the switch

Definition at line 65 of file switchpp.cpp.

References timer::start(), and tim.

Referenced by GPIOPortE_Handler().

65  {
66 
67  tim.start();
68 }
virtual void start()
Definition: timerpp.cpp:62
timer tim
Definition: switchpp.hpp:21

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t lswitch::end_debounce ( void  )

Call this in the isr of the switch's timer

Definition at line 74 of file switchpp.cpp.

References timer::ack(), NULL, semaphore::post(), sample(), sem, and tim.

Referenced by Timer1A_Handler().

74  {
75 
76  tim.ack();
77  if(NULL != sem) {
78  sem->post();
79  }
80  return sample();
81 }
void post(void)
Definition: semaphorepp.cpp:45
#define NULL
Definition: switchpp.cpp:13
semaphore * sem
Definition: switchpp.hpp:20
virtual uint32_t ack()
Definition: timerpp.cpp:74
uint32_t sample(void)
Definition: switchpp.cpp:88
timer tim
Definition: switchpp.hpp:21

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t lswitch::sample ( void  )

Return current value of the limit lswitch

Definition at line 88 of file switchpp.cpp.

References base, debounced_data, and pin.

Referenced by end_debounce().

88  {
89 
90  return debounced_data = GPIOPinRead(base, pin);
91 }
memory_address_t pin
Definition: switchpp.hpp:19
uint32_t debounced_data
Definition: switchpp.hpp:40
memory_address_t base
Definition: switchpp.hpp:18

Here is the caller graph for this function:

void lswitch::start ( void  )
virtual

Implements interruptable.

Definition at line 54 of file switchpp.cpp.

References base, and pin.

Referenced by lswitch().

54  {
55 
56  GPIOIntEnable(base, pin);
57 }
memory_address_t pin
Definition: switchpp.hpp:19
memory_address_t base
Definition: switchpp.hpp:18

Here is the caller graph for this function:

void lswitch::stop ( void  )
virtual

Implements interruptable.

Definition at line 59 of file switchpp.cpp.

References base, and pin.

59  {
60 
61  GPIOIntDisable(base, pin);
62 }
memory_address_t pin
Definition: switchpp.hpp:19
memory_address_t base
Definition: switchpp.hpp:18

Member Data Documentation

memory_address_t lswitch::base
private

Definition at line 18 of file switchpp.hpp.

Referenced by ack(), lswitch(), sample(), start(), and stop().

uint32_t lswitch::debounced_data

Definition at line 40 of file switchpp.hpp.

Referenced by sample(), and switch_responder().

memory_address_t lswitch::pin
private

Definition at line 19 of file switchpp.hpp.

Referenced by ack(), lswitch(), sample(), start(), and stop().

semaphore* lswitch::sem
private

Definition at line 20 of file switchpp.hpp.

Referenced by end_debounce(), and lswitch().

timer lswitch::tim
private

Definition at line 21 of file switchpp.hpp.

Referenced by debounce(), end_debounce(), and lswitch().


The documentation for this class was generated from the following files: