Stepper-Motor-Control  v3.0.0
System on a Chip 2014 - Group 04
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
motorIRQhandler.c
Go to the documentation of this file.
1 /**
2  *****************************************************************************
3  * @file motorIRQhandler.c
4  * @author Michael Riedel
5  * @author Marc Kossmann
6  * @version v1.0.0
7  * @date 11.11.2014
8  * @brief IRQ-handler for motor stopped
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 by Riedel:
14  * - basic implementation
15  * - moved function-documentation to header-file
16  * @details v0.1.2 02.11.2014 Riedel
17  * - finalized ISR-functionality
18  * @details v1.0.0 11.11.2014 Riedel & Kossmann
19  * - Adapted code to new registerAccess.h (using ctrlRegBitClr/-Set)
20  * @details v1.0.1 18.11.2014 Riedel & Kossmann
21  * - added MOTOR_STOP_EVENT post to UserOutputTask
22  *****************************************************************************
23  */
24 
25 #include "../INC/motorIRQhandler.h"
26 
27 extern OS_FLAG_GRP *userInputTaskFlagsGrp;
28 
29 void motorIRQhandler(void *context) {
30  uint32_t ctrlReg = 0;
31  INT8U err;
32 
33  OSIntEnter();
34  ctrlReg = ctrlRegGet();
35 
36  if (ctrlReg & CTRL_REG_IE_MSK) {
37  // Clear request
39 
40  // Send the event
41  OSFlagPost(userInputTaskFlagsGrp, MOTOR_STOP_EVENT, OS_FLAG_SET, &err);
42  if (OS_NO_ERR != err) {
43  error("MOTOR_ISR_FLAG_ERR: %i\n", err);
44  }
45  OSFlagPost(userOutputTaskFlagsGrp, MOTOR_STOP_EVENT, OS_FLAG_SET, &err);
46  if (OS_NO_ERR != err) {
47  error("MOTOR_ISR_FLAG_ERR: %i\n", err);
48  }
49  } else
50  debug("IE not set!");
51 
52  OSIntExit();
53 }
#define CTRL_REG_IE_MSK
Interrupt-Enable Bit.
#define error(...)
Prints the Error-messages in the terminal.
#define MOTOR_STOP_EVENT
the interrupt is sent via VHDL-Component, when the motor reached its end-position ...
Definition: events.h:52
void motorIRQhandler(void *context)
IRQ-Handler for motor stopped.
#define CTRL_REG_IR_MSK
Interrupt-Request Bit.
#define debug(...)
Prints Debug-messages in the terminal.
OS_FLAG_GRP * userOutputTaskFlagsGrp
The flags group used in the user-output-task.
Definition: events.h:51
OS_FLAG_GRP * userInputTaskFlagsGrp
The flags group used in the user-input-task.
Definition: events.h:32
static __inline__ void ctrlRegBitClr(uint8_t bitsToClr)
Clears the CtrlReg bitwise.
static __inline__ uint8_t ctrlRegGet(void)
Returns the actual content of the control-register.