ACS Firmware Documentation
Attitude Control System Capstone 2018 for OreSat
Data Structures | Macros | Typedefs | Enumerations | Functions
acs.h File Reference
#include "ch.h"
#include "hal.h"
#include "bldc.h"
#include "magnetorquer.h"
#include "chprintf.h"
#include "oresat.h"
Include dependency graph for acs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  can_buffer
 can_buffer structure holds the send and recv buffers that are registered with the CAN bus More...
 
struct  ACS
 ACS structure for maintaining the ACS state. More...
 
struct  acs_transition
 structure for manipulating state transistions and trap functions More...
 

Macros

#define WA_ACS_THD_SIZE   (1<<7)
 
#define CAN_NODE   0x3F
 
#define CAN_BUF_SIZE   8
 
#define DEBUG_SERIAL   SD2
 
#define DEBUG_CHP   ((BaseSequentialStream *) &DEBUG_SERIAL)
 
#define EXIT_SUCCESS   0
 
#define EXIT_FAILURE   1
 

Typedefs

typedef struct acs_transition acs_trap
 

Enumerations

enum  can_msg { MSG_TYPE =0, ARG_BYTE, ARG_BYTE1, ARG_BYTE2 }
 can_msg enumeraton More...
 
enum  can_recv { ERROR_CODE = 0, ACS_STATE, LAST_EVENT, LAST_TRAP }
 enumeration for the recv buffer More...
 
enum  can_msg_type { NOP =0, CHG_STATE, CALL_TRAP }
 enumeration for CAN message types More...
 
enum  acs_state {
  ST_ANY =-1, ST_OFF, ST_INIT, ST_RDY,
  ST_RW, ST_MTQR
}
 enumeration for ACS states More...
 
enum  acs_event {
  EV_ANY =-1, EV_OFF, EV_INIT, EV_RDY,
  EV_RW, EV_MTQR, EV_RW_START, EV_RW_STOP,
  EV_RW_STRETCH, EV_RW_CONTROL, EV_RW_SKIP, EV_RW_SCALE,
  EV_MTQR_START, EV_MTQR_STOP, EV_MTQR_DC, EV_MTQR_DIR,
  EV_END
}
 enumeration for all the possible events More...
 

Functions

int acsInit (ACS *acs)
 general ACS initialization More...
 
 THD_WORKING_AREA (wa_acsThread, WA_ACS_THD_SIZE)
 
 THD_FUNCTION (acsThread, acs)
 

Macro Definition Documentation

◆ CAN_BUF_SIZE

#define CAN_BUF_SIZE   8

◆ CAN_NODE

#define CAN_NODE   0x3F

◆ DEBUG_CHP

#define DEBUG_CHP   ((BaseSequentialStream *) &DEBUG_SERIAL)

◆ DEBUG_SERIAL

#define DEBUG_SERIAL   SD2

◆ EXIT_FAILURE

#define EXIT_FAILURE   1

◆ EXIT_SUCCESS

#define EXIT_SUCCESS   0

◆ WA_ACS_THD_SIZE

#define WA_ACS_THD_SIZE   (1<<7)
Todo:
: Thread sizes cause continual problems for managing memory if the threads are too small it breaks, if the thread working areas are too large then you run out of memory. One solution is to move to a mcu with more memory.

Typedef Documentation

◆ acs_trap

typedef struct acs_transition acs_trap

Enumeration Type Documentation

◆ acs_event

enum acs_event

enumeration for all the possible events

Todo:
: This is going to change in v2.0 to more accurately reflect how the ACS will operate

hexidecimal values are passed to the ACS via the bus.

Enumerator
EV_ANY 

-1

EV_OFF 

0

EV_INIT 

1

EV_RDY 

2

EV_RW 

3

EV_MTQR 

4

EV_RW_START 

5

EV_RW_STOP 

6

EV_RW_STRETCH 

7

EV_RW_CONTROL 

8

EV_RW_SKIP 

9

EV_RW_SCALE 

a

EV_MTQR_START 

b

EV_MTQR_STOP 

c

EV_MTQR_DC 

d

EV_MTQR_DIR 

e

EV_END 

this must be the last event

113  {
114  EV_ANY=-1,
115  EV_OFF,
116  EV_INIT,
117  EV_RDY,
118  EV_RW,
119  EV_MTQR,
120  EV_RW_START,
121  EV_RW_STOP,
122  EV_RW_STRETCH,
123  EV_RW_CONTROL,
124  EV_RW_SKIP,
125  EV_RW_SCALE,
126  EV_MTQR_START,
127  EV_MTQR_STOP,
128  EV_MTQR_DC,
129  EV_MTQR_DIR,
130  EV_END
131 }acs_event;
5
Definition: acs.h:120
2
Definition: acs.h:117
e
Definition: acs.h:129
b
Definition: acs.h:126
acs_event
enumeration for all the possible events
Definition: acs.h:113
d
Definition: acs.h:128
9
Definition: acs.h:124
7
Definition: acs.h:122
4
Definition: acs.h:119
3
Definition: acs.h:118
0
Definition: acs.h:115
this must be the last event
Definition: acs.h:130
c
Definition: acs.h:127
1
Definition: acs.h:116
8
Definition: acs.h:123
6
Definition: acs.h:121
a
Definition: acs.h:125
-1
Definition: acs.h:114

◆ acs_state

enum acs_state

enumeration for ACS states

Todo:
: This is going to change in v2.0 to more accurately reflect how the ACS will operate
Enumerator
ST_ANY 
ST_OFF 
ST_INIT 
ST_RDY 
ST_RW 
ST_MTQR 
95  {
96  ST_ANY=-1,
97  ST_OFF,
98  ST_INIT,
99  ST_RDY,
100  ST_RW,
101  ST_MTQR
102 }acs_state;
Definition: acs.h:101
Definition: acs.h:100
Definition: acs.h:98
Definition: acs.h:99
Definition: acs.h:96
acs_state
enumeration for ACS states
Definition: acs.h:95
Definition: acs.h:97

◆ can_msg

enum can_msg

can_msg enumeraton

Todo:
: This is going to change in v2.0 once a protocol is decided for communication with the ACS

Byte Name Use 0 MSG_TYPE CHG_STATE is the only current implementation 1 ARG_BYTE used for passing arguments 2 ARG_BYTE1 used for passing arguments 3 ARG_BYTE2 used for passing arguments 4 unimplemented 5 unimplemented 6 unimplemented 7 unimplemented

Enumerator
MSG_TYPE 
ARG_BYTE 
ARG_BYTE1 
ARG_BYTE2 
44  {
45  MSG_TYPE=0,
46  ARG_BYTE,
47  ARG_BYTE1,
48  ARG_BYTE2
49 }can_msg;
Definition: acs.h:47
Definition: acs.h:46
Definition: acs.h:45
Definition: acs.h:48
can_msg
can_msg enumeraton
Definition: acs.h:44

◆ can_msg_type

enumeration for CAN message types

Todo:
: This is going to change in v2.0 once a protocol is decided for communication with the ACS
Enumerator
NOP 
CHG_STATE 
CALL_TRAP 
82  {
83  NOP=0,
84  CHG_STATE,
85  CALL_TRAP,
can_msg_type
enumeration for CAN message types
Definition: acs.h:82
Definition: acs.h:84
Definition: acs.h:85
Definition: acs.h:83

◆ can_recv

enum can_recv

enumeration for the recv buffer

Todo:
: This is going to change in v2.0 once a protocol is decided for communication with the ACS

Byte Name Use 0 unimplemented 1 STATE current state 2 LAST_EVENT last event received 3 unimplemented 4 unimplemented 5 unimplemented 6 unimplemented 7 unimplemented

Enumerator
ERROR_CODE 
ACS_STATE 
LAST_EVENT 
LAST_TRAP 
68  {
69  ERROR_CODE = 0,
70  ACS_STATE,
71  LAST_EVENT,
72  LAST_TRAP,
73 }can_recv;
Definition: acs.h:72
Definition: acs.h:69
Definition: acs.h:71
Definition: acs.h:70
can_recv
enumeration for the recv buffer
Definition: acs.h:68

Function Documentation

◆ acsInit()

int acsInit ( ACS acs)

general ACS initialization

412  {
413  (void)acs;
414  mtqrInit(&acs->mtqr);
415  return EXIT_SUCCESS;
416 }
void mtqrInit(MTQR *mtqr)
Magnetorquer initialization function.
Definition: magnetorquer.c:9
#define EXIT_SUCCESS
Definition: acs.h:24
MTQR mtqr
Definition: acs.h:153

◆ THD_FUNCTION()

THD_FUNCTION ( acsThread  ,
acs   
)
423  {
424  chRegSetThreadName("acsThread");
425  chEvtRegister(&rpdo_event,&el,0);
426 
428 }
static int acs_statemachine(ACS *acs)
the ACS state machine
Definition: acs.c:372
ACS acs
Definition: main.c:25
event_listener_t el
Definition: acs.c:3

◆ THD_WORKING_AREA()

THD_WORKING_AREA ( wa_acsThread  ,
WA_ACS_THD_SIZE   
)