xyControl  0.1
Quadrotor Flight Controller on AVR Basis
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
Files | Functions | Variables
Motor Controller Driver

Controlling four BL-Ctrl V1.2 Brushless controllers. More...

Files

file  motor.h
 BL-Ctrl V1.2 Controller API Header.
 
file  motor.c
 BL-Ctrl V1.2 Controller API Implementation.
 

Functions

void motorInit (void)
 Initializes the motor control library. More...
 
void motorSet (uint8_t id, uint8_t speed)
 Set the speed of one or all motors. More...
 
void motorTask (void)
 Send the values stored in motorSpeed to the Controllers. More...
 

Variables

uint8_t motorSpeed [MOTORCOUNT]
 Speed for the four motors. More...
 
uint8_t motorSpeed [MOTORCOUNT]
 Speed for the four motors. More...
 

Detailed Description

Controlling four BL-Ctrl V1.2 Brushless controllers.

Function Documentation

void motorInit ( void  )

Initializes the motor control library.

Really only sets motorSpeed to zero.

Examples:
hardwareTest.c, and uartFlight.c.

Definition at line 58 of file motor.c.

References MOTORCOUNT, and motorSpeed.

58  {
59  for (uint8_t i = 0; i < MOTORCOUNT; i++) {
60  motorSpeed[i] = 0;
61  }
62 }
void motorSet ( uint8_t  id,
uint8_t  speed 
)

Set the speed of one or all motors.

Parameters
idMotor ID (0 to 3, 4 = all)
speedNew Speed

Definition at line 64 of file motor.c.

References MOTORCOUNT, and motorSpeed.

Referenced by setMotorSpeeds().

64  {
65  if (id < MOTORCOUNT) {
66  motorSpeed[id] = speed;
67  } else {
68  for (id = 0; id < MOTORCOUNT; id++) {
69  motorSpeed[id] = speed;
70  }
71  }
72 }
void motorTask ( void  )

Send the values stored in motorSpeed to the Controllers.

I2C already has to be initialized!

Examples:
uartFlight.c.

Definition at line 50 of file motor.c.

References MOTOR_BASEADDRESS, MOTORCOUNT, motorSpeed, TWI_WRITE, twiStart(), twiStop(), and twiWrite().

50  {
51  for (uint8_t i = 0; i < MOTORCOUNT; i++) {
52  twiStart(MOTOR_BASEADDRESS + (i << 1) + TWI_WRITE);
53  twiWrite(motorSpeed[i]);
54  twiStop();
55  }
56 }

Variable Documentation

uint8_t motorSpeed[MOTORCOUNT]

Speed for the four motors.

Examples:
uartFlight.c.

Definition at line 48 of file motor.c.

Referenced by motorInit(), motorSet(), and motorTask().

uint8_t motorSpeed[MOTORCOUNT]

Speed for the four motors.

Definition at line 48 of file motor.c.

Referenced by motorInit(), motorSet(), and motorTask().