Classes | Defines | Typedefs | Functions | Variables

brushless.c File Reference

#include <types.h>
#include <cpu_def.h>
#include <mcu_regs.h>
#include <system_def.h>
#include <string.h>
#include <boot_fn.h>
#include <pxmc.h>
#include <pxmcbsp.h>
#include <ctype.h>
#include <stdlib.h>
#include <utils.h>
#include <periph/sci_rs232.h>
#include <periph/sci_channels.h>
#include <stdio.h>
#include <stdbool.h>
#include <cmd_proc.h>
#include "cmd_pxmc.h"
#include <candriver.h>
#include <canOpenDriver.h>
#include <can_ids.h>
Include dependency graph for brushless.c:

Classes

struct  dbg_prt_des
struct  odometryData_t

Defines

#define INLINE
#define MAX(a, b)   ((a)>(b)?(a):(b))
#define _PXMC_MAX_OUT_   0x6f
#define CMD_ARR_STACK_SIZE   4
#define DBGPF_AXES   0x00ff
#define DBGPF_PER_TIME   0x0100
#define DBGPF_PER_POS   0x0800
#define DBGPF_CMD_PROC   0x1000
#define ODOMETRY_TABLE_SIZE   10
#define ODOMETRY_PERIOD   43
#define ODOMETRY_TIMEOUT   (3*ODOMETRY_PERIOD)
#define PERIOD   1000
Motor control (h8eurobot)

#define LED_LIVE   0
 D1: Blinks once per second when software is alive.
#define LED_CAN_REC   1
 D2: Blinks when a CAN message is received:

  • 50ms for motion message
  • 5ms for other message (corr_trig).

#define LED_ERROR   2
 D3: Light = Unhandled exception, Slow blink (4s) = motor error.
#define LED_RESET   3
 D4: Blinks for 1 s after reset.

Typedefs

typedef struct dbg_prt_des dbg_prt_des_t

Functions

int cmd_do_quit (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_canst (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_setflags (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_haltest (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
 Rotates motor slowly four turns forward and than two turns backward (in a feedforward manner).
int cmd_do_setindex (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_setvang (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_setshift (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_showene (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_nopxmc (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_mypwm (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_help_wd (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
void run_dbg_prt (cmd_io_t *cmd_io)
int cmd_do_switches (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
int cmd_do_pthalign (cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
void unhandled_exception (void)
void print_mcs_err (pxmc_state_t *mcs, char *name)
void led_can_rec (unsigned duration_msec)
void _print (char *ptr)
int main ()

Variables

bool odometry_triggered = false
unsigned char trig_seq
unsigned dbg_prt_flg = 0
const dbg_prt_des_t dbg_prt_des []
int runtime_display = 0
int slowgo = 0
cmd_des_t const ** cmd_list = cmd_list_default
cmd_des_t const cmd_des_help
cmd_des_t const cmd_des_showene
cmd_des_t const cmd_des_mypwm
cmd_des_t const cmd_des_nopxmc
cmd_des_t const cmd_des_disp
cmd_des_t const cmd_des_slowgo
cmd_des_t const cmd_des_setindex
cmd_des_t const cmd_des_setvang
cmd_des_t const cmd_des_halindex
cmd_des_t const cmd_des_pthalign
cmd_des_t const cmd_des_setshift
cmd_des_t const cmd_des_quit
cmd_des_t const cmd_des_canst
cmd_des_t const cmd_des_dprint
cmd_des_t const cmd_des_setflags
cmd_io_t cmd_io_rs232_line
cmd_des_t const * cmd_list_default []
short idxRecive = 0
short idxStore = 0
struct odometryData_t oddata [ODOMETRY_TABLE_SIZE]

Define Documentation

#define _PXMC_MAX_OUT_   0x6f
#define CMD_ARR_STACK_SIZE   4
#define DBGPF_AXES   0x00ff
#define DBGPF_CMD_PROC   0x1000
#define DBGPF_PER_POS   0x0800
#define DBGPF_PER_TIME   0x0100
#define INLINE
#define MAX (   a,
  b 
)    ((a)>(b)?(a):(b))
#define ODOMETRY_PERIOD   43
#define ODOMETRY_TABLE_SIZE   10
#define ODOMETRY_TIMEOUT   (3*ODOMETRY_PERIOD)
#define PERIOD   1000

Typedef Documentation

typedef struct dbg_prt_des dbg_prt_des_t

Function Documentation

void _print ( char *  ptr  ) 
int cmd_do_canst ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)
int cmd_do_haltest ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Rotates motor slowly four turns forward and than two turns backward (in a feedforward manner).

During movement it displays values read from HAL sensors and tries to detect correct index mark position.

Here is the call graph for this function:

int cmd_do_help_wd ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Here is the call graph for this function:

int cmd_do_mypwm ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)
int cmd_do_nopxmc ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Here is the call graph for this function:

int cmd_do_pthalign ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Here is the call graph for this function:

int cmd_do_quit ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)
int cmd_do_setflags ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Here is the call graph for this function:

int cmd_do_setindex ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Here is the call graph for this function:

int cmd_do_setshift ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Here is the call graph for this function:

int cmd_do_setvang ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Here is the call graph for this function:

int cmd_do_showene ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Here is the call graph for this function:

int cmd_do_switches ( cmd_io_t *  cmd_io,
const struct cmd_des *  des,
char *  param[] 
)

Here is the call graph for this function:

void led_can_rec ( unsigned  duration_msec  ) 
int main ( void   ) 

Here is the call graph for this function:

void print_mcs_err ( pxmc_state_t *  mcs,
char *  name 
)
void run_dbg_prt ( cmd_io_t *  cmd_io  ) 

Here is the caller graph for this function:

void unhandled_exception ( void   ) 

Variable Documentation

cmd_des_t const cmd_des_canst
Initial value:
{0, 0,"CANST","Print CAN controller status",
                              cmd_do_canst}
cmd_des_t const cmd_des_disp
Initial value:
{0, CDESM_OPCHR|CDESM_RW,"DISP","switch on/off runtime display of variables",
                              cmd_do_rw_int, {(char*)&runtime_display}}
cmd_des_t const cmd_des_dprint
Initial value:
{0, 0,"dprint","enable debug messages to print, use + - to add remove, list types ?",
                        cmd_do_switches,
                        {(char*)&dbg_prt_flg,(char*)dbg_prt_des}}
cmd_des_t const cmd_des_halindex
Initial value:
{0, 0,"HALTEST?","show hal state with respect to ptindex",
                                  cmd_do_haltest}
cmd_des_t const cmd_des_help
Initial value:
{0, 0,"HELP","prints help for commands",
                              cmd_do_help_wd,{(char*)&cmd_list}}
cmd_des_t const cmd_des_mypwm
Initial value:
{0, 0,"x#","test",
                               cmd_do_mypwm}
cmd_des_t const cmd_des_nopxmc
Initial value:
{0, 0,"NOPXMC?","switch of pxmc controller and output",
                                cmd_do_nopxmc}
cmd_des_t const cmd_des_pthalign
Initial value:
{0, CDESM_OPCHR|CDESM_RW,"PTHALIGN?","run alignement of phase according to HAL",
                                  cmd_do_pthalign}
cmd_des_t const cmd_des_quit
Initial value:
{0, 0,"QUIT","exit",
                              cmd_do_quit}
cmd_des_t const cmd_des_setflags
Initial value:
{0, 0,"setflags","set some flags",
                                  cmd_do_setflags}
cmd_des_t const cmd_des_setindex
Initial value:
{0, 0,"SETINDEX?","changes pxms_ptindx",
                                  cmd_do_setindex}
cmd_des_t const cmd_des_setshift
Initial value:
{0, 0,"SETSHIFT?","changes pxms_ptshift",
                                  cmd_do_setshift}
cmd_des_t const cmd_des_setvang
Initial value:
{0, 0,"SETVANG?","changes pxms_ptvang",
                                 cmd_do_setvang}
cmd_des_t const cmd_des_showene
Initial value:
{0, 0,"SHOWENE?","shows ene and couple others parameters",
                                 cmd_do_showene}
cmd_des_t const cmd_des_slowgo
Initial value:
{0, CDESM_OPCHR|CDESM_RW,"SLOWGO","program controlled movement",
                                cmd_do_rw_int, {(char*)&slowgo}}
cmd_des_t const** cmd_list = cmd_list_default
cmd_des_t const* cmd_list_default[]
Initial value:
{
  {~0,"all"},
  {1,"A"},{2,"B"},
  {DBGPF_PER_TIME,"time"},
  {DBGPF_PER_POS, "pos"},
  {DBGPF_CMD_PROC,"cmd"},
  {0,NULL}
}
unsigned dbg_prt_flg = 0
short idxRecive = 0
short idxStore = 0
struct odometryData_t oddata[ODOMETRY_TABLE_SIZE]
bool odometry_triggered = false
int runtime_display = 0
int slowgo = 0
unsigned char trig_seq