49 #include "../INC/userInputTask.h"
63 uint32_t oldStepsReg = 0;
67 uint32_t stepsReg = 0;
71 .activeUseCase =
STOP };
75 .stepsReg = 0, .systemState = systemState };
78 uint32_t switchesReg = 0;
81 printf_term(
"Stepper Motor - System on a Chip 2014\n");
94 #ifdef INTERRUPT_ENABLE
109 OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME, 10, &err);
110 if (OS_NO_ERR == err) {
143 }
else if (OS_TIMEOUT != err) {
144 error(
"INPUT_TASK_FLAG_ERR: %i\n", err);
166 if (OS_NO_ERR != err) {
167 error(
"INPUT_TASK_FLAG_ERR: %i\n", err);
173 if (OS_NO_ERR != err) {
174 error(
"INPUT_TASK_FLAG_ERR: %i\n", err);
185 }
else if ((modeBits & MODE_STOP_CON_RUN_MSK) ==
MODE_CON_RUN) {
198 if (newInput | ((ctrlReg & CTRL_REG_RS_MSK) & (oldStepsReg != stepsReg))) {
200 outputTaskDataLocal.
ctrlReg = ctrlReg;
201 outputTaskDataLocal.
speedReg = speedReg;
202 oldStepsReg = stepsReg;
203 outputTaskDataLocal.
stepsReg = stepsReg;
206 if (OS_NO_ERR != err) {
207 error(
"INPUT_TASK_GLOB_VAR_ERR: %i\n", err);
210 if (OS_NO_ERR != err) {
211 error(
"INPUT_TASK_FLAG_ERR: %i\n", err);
240 OSTimeDlyHMSM(0, 0, 1, 0);
242 OSTimeDlyHMSM(0, 0, 1, 0);
244 OSTimeDlyHMSM(0, 0, 1, 0);
246 OSTimeDlyHMSM(0, 0, 1, 0);
248 OSTimeDlyHMSM(0, 0, 1, 0);
254 OSTimeDlyHMSM(0, 0, 1, 0);
256 OSTimeDlyHMSM(0, 0, 1, 0);
264 OSTimeDlyHMSM(0, 0, 1, 0);
271 OSTimeDlyHMSM(0, 0, 1, 0);
278 OSTimeDlyHMSM(0, 0, 1, 0);
289 for (i = 0; i < 7; i++) {
291 OSTimeDlyHMSM(0, 0, 0, 500);
293 OSTimeDlyHMSM(0, 0, 0, 500);
295 OSTimeDlyHMSM(0, 0, 0, 500);
#define CTRL_REG_LR_MSK
Left (0) or Right (1)-Bit.
void printf_term(const char *,...)
Writes formated string to terminal.
Struct to store state of system and use case information.
#define MODE_CH_OF_ST_2
Bits must be 0b1110
#define CTRL_REG_IE_MSK
Interrupt-Enable Bit.
#define MODE_CH_OF_ST_1_2
Bits must be 0b0110
void fflush_lcd()
Writes buffed data to lcd.
static __inline__ void PIO_HEX1_Set(uint32_t segmentValues)
Function to set segments on hex1 display.
#define error(...)
Prints the Error-messages in the terminal.
#define CTRL_REG_MODE_MSK
Mode-combination according to ctrlRegSet()-function.
#define PIO_SW_DEBUG_MSK
Debug mask for PIO-Switches.
uint8_t ctrlReg
copy control register
Motor turning one rotation.
#define PIO_SW_MODE_MSK
Mode mask for PIO-Switches.
#define MODE_STOP_CON_RUN_MSK
Bit 0 & 1 only.
static __inline__ void PIO_HEX2_Set(uint32_t segmentValues)
Function to set segments on hex2 display.
#define MOTOR_STOP_EVENT
the interrupt is sent via VHDL-Component, when the motor reached its end-position ...
#define MODE_CH_OF_ST_1
Bits must be 0b1010
state_t operationalStatus
operational status
static __inline__ void ctrlRegBitSet(uint8_t bitsToSet)
Sets the CtrlReg bitwise.
#define DEBUG_OFF_EVENT
deactivates the debug-mode via sw_9
void clear_lcd(void)
Clears display.
everything is full functional
uint8_t speedReg
copy of speed register
static __inline__ void speedRegSet(uint8_t newSpeed)
Sets the speed, how fast the Stepper-Motor-Control turns the motor.
#define DATE
global date definition
#define CTRL_REG_IR_MSK
Interrupt-Request Bit.
systemState_t systemState
stores state of system
uint8_t outputTaskDataTx(outputTaskData_t data)
Sends data to ipc channel.
Motor turning 1/2 rotation.
static __inline__ void PIO_HEX3_Set(uint32_t segmentValues)
Function to set segments on hex3 display.
static __inline__ void PIO_LED9_Set(uint32_t ledValue)
Function to set led9 for heartbeat.
#define SW_UPDATE_EVENT
signalizes that switches changed
Motor is continously running.
Motor turning 1/4 rotation.
#define KEY3_PLUS_EVENT
increases the steps to turn via key_3
static __inline__ uint32_t PIO_SW_GetValues(void)
Function to read content of switches data register.
#define MODE_CH_OF_ST_1_4
Bits must be 0b0010
void init_lcd(void)
Initializes lcd output.
#define MODE_CON_RUN
Use "MODE_STOP_CON_RUN_MSK"; Must be 0b01
#define DEBUG_ON_EVENT
activates the debug-mode via sw_9
#define CTRL_REG_RS_MSK
Run (1) or Stop (0)-Bit.
#define GLOB_VAR_UPDATE
signals that data changed
static __inline__ uint32_t stepsRegGet(void)
Returns the actual content of the steps-register.
void printf_lcd(const char *,...)
Writes formated string to lcd.
static __inline__ uint8_t speedRegGet(void)
Returns the actual content of the speed-register.
#define VERSION
global version definition
#define PIO_SW_LR_MSK
Left/Right mask for PIO-Switches.
void setPos_lcd(int32_t row, int32_t col)
Sets the cursor position on display.
uint32_t stepsReg
copy of steps register
#define KEY0_RS_EVENT
runs or stops the motor via key_0
#define KEY2_MINUS_EVENT
decreases the steps to turn via key_2
static __inline__ void ctrlRegBitClr(uint8_t bitsToClr)
Clears the CtrlReg bitwise.
Motor turning two rotation.
useCases_t activeUseCase
active use case
static __inline__ uint8_t ctrlRegGet(void)
Returns the actual content of the control-register.
static __inline__ void PIO_HEX0_Set(uint32_t segmentValues)
Function to set segments on hex0 display.
Datatype of global variable for transmitting information from InputTask to OutputTask.
#define MODE_STOP
MODE_STOP_CON_RUN_MSK; Must be 0b00