Skip to content

Commit

Permalink
added basic architecture ideas #49
Browse files Browse the repository at this point in the history
  • Loading branch information
SergNikitin committed May 15, 2014
1 parent fc469cd commit c1e37a5
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
6 changes: 6 additions & 0 deletions firmware/SatStepperBegin/control_modules/commutation_angle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "state.h"
#include "commutation_angle.h"

void computeCommutationAngle() {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void computeCommutationAngle();
23 changes: 23 additions & 0 deletions firmware/SatStepperBegin/control_modules/modules_list.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "modules_list.h"
#include "commutation_angle.h"

typedef void (* moduleExecuter)(void);
moduleExecuter controlModules[MODULE_LIST_END];
unsigned modulesStatus[MODULE_LIST_END] = {MODULE_DISABLED};

controlModules[COMMUT_ANGLE_MODULE] = &computeCommutationAngle;

void setModuleStatus(unsigned moduleId, unsigned status) {
// TODO: add static assert moduleId < MODULE_ENABLED
// and status == MODULE_ENABLED || status == MODULE_DISABLED

modulesStatus[moduleId] = status;
}

void runEnabledModules() {
for (unsigned moduleId = 0; moduleId < MODULE_LIST_END; ++moduleId) {
if (modulesStatus[moduleId] == MODULE_ENABLED) {
(*controlModules[moduleId])();
}
}
}
12 changes: 12 additions & 0 deletions firmware/SatStepperBegin/control_modules/modules_list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
enum {
COMMUT_ANGLE_MODULE = 0,
MODULE_LIST_END = 1
};

enum {
MODULE_DISABLED = 0,
MODULE_ENABLED = 1
};

void setModuleStatus(unsigned moduleId, unsigned status);
void runEnabledModules();
10 changes: 8 additions & 2 deletions firmware/SatStepperBegin/sensors/encoder/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include "state.h"
#define ENCODER_RANGE 25000

#include "control_modules/modules_list.h"


interrupt void encoderInputAIntHandler(void) {
#ifdef DEBUG
ASSERT(
Expand All @@ -42,6 +45,8 @@ interrupt void encoderInputAIntHandler(void) {
);
#endif // DEBUG
ACKNOWLEDGE_ONE_MORE_INTERRUPT_FROM_GROUP(PIEACK_GROUP1);

// runEnabledModules();
}

interrupt void encoderInputBIntHandler(void) {
Expand Down Expand Up @@ -70,6 +75,8 @@ interrupt void encoderInputBIntHandler(void) {
);
#endif // DEBUG
ACKNOWLEDGE_ONE_MORE_INTERRUPT_FROM_GROUP(PIEACK_GROUP1);

// runEnabledModules();
}

interrupt void encoderInputCIntHandler(void) {
Expand All @@ -90,8 +97,7 @@ interrupt void encoderInputCIntHandler(void) {
}
}

// Acknowledge interrupt to recieve more interrupts from PIE group 12
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
ACKNOWLEDGE_ONE_MORE_INTERRUPT_FROM_GROUP(PIEACK_GROUP12);
}

void encoderInit() {
Expand Down

0 comments on commit c1e37a5

Please sign in to comment.