Stepper-Motor-Control  v3.0.0
System on a Chip 2014 - Group 04
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
keysIRQhandler.c
Go to the documentation of this file.
1 /**
2  *****************************************************************************
3  * @file keysIRQhandler.c
4  * @author Michael Riedel
5  * @author Marc Kossmann
6  * @version v1.0.0
7  * @date 11.11.2014
8  * @brief IRQ-handler for keys
9  *****************************************************************************
10  * @par History:
11  * @details v0.1.0 21.10.2014 Riedel & Kossmann
12  * - first draft for milestone 1b
13  * @details v0.1.1 27.10.2014 Riedel
14  * - basic implementation
15  * - moved function-documentation to header-file
16  * @details v0.1.2 29.10.2014 Kossmann
17  * - modified clearing requests and evaluating pressed keys
18  * @details v0.1.3 30.10.2014 Riedel
19  * - added Debug and Error-Handling
20  * @details v1.0.0 30.10.2014 Kossmann
21  * - fixed bug in Debug and Error-Handling
22  *****************************************************************************
23  */
24 
25 #include "../INC/keysIRQhandler.h"
26 
27 extern OS_FLAG_GRP *userInputTaskFlagsGrp;
28 
29 void keysIRQhandler(void *context) {
30  uint32_t edgesCaptured = 0;
31  INT8U err;
32 
33  OSIntEnter();
34  edgesCaptured = PIO_KEY_GetEdgeCpt();
35 
36  // Send corresponding Event and clear bit in edgecapture reg
37  if (edgesCaptured & PIO_KEY_RS_IR0_MSK) {
38  OSFlagPost(userInputTaskFlagsGrp, KEY0_RS_EVENT, OS_FLAG_SET, &err);
39  if (OS_NO_ERR != err) {
40  error("KEY_ISR_FLAG_ERR: %i\n", err);
41  }
42  }
43  if (edgesCaptured & PIO_KEY_MINUS_IR2_MSK) {
44  OSFlagPost(userInputTaskFlagsGrp, KEY2_MINUS_EVENT, OS_FLAG_SET, &err);
45  if (OS_NO_ERR != err) {
46  error("KEY_ISR_FLAG_ERR: %i\n", err);
47  }
48  }
49  if (edgesCaptured & PIO_KEY_PLUS_IR3_MSK) {
50  OSFlagPost(userInputTaskFlagsGrp, KEY3_PLUS_EVENT, OS_FLAG_SET, &err);
51  if (OS_NO_ERR != err) {
52  error("KEY_ISR_FLAG_ERR: %i\n", err);
53  }
54  }
55  PIO_KEY_ClearEdgeCptBits(edgesCaptured);
56  OSIntExit();
57 }
#define PIO_KEY_MINUS_IR2_MSK
Increase steps mask for PIO-Key.
#define PIO_KEY_PLUS_IR3_MSK
Decreses steps mask for PIO-Key.
#define PIO_KEY_RS_IR0_MSK
Run/Stop mask for PIO-Key.
#define error(...)
Prints the Error-messages in the terminal.
static __inline__ void PIO_KEY_ClearEdgeCptBits(uint32_t clearbits)
Function to clear bits of keys edgecapture register.
#define KEY3_PLUS_EVENT
increases the steps to turn via key_3
Definition: events.h:35
static __inline__ uint32_t PIO_KEY_GetEdgeCpt(void)
Function to read content of keys edgecapture register.
#define KEY0_RS_EVENT
runs or stops the motor via key_0
Definition: events.h:33
#define KEY2_MINUS_EVENT
decreases the steps to turn via key_2
Definition: events.h:34
void keysIRQhandler(void *context)
IRQ-Handler for key-input.
OS_FLAG_GRP * userInputTaskFlagsGrp
The flags group used in the user-input-task.
Definition: events.h:32