Skip to content

Commit

Permalink
init channels 2 and 3 on timer
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjairo committed Jan 3, 2012
1 parent d9044c1 commit a8dcac1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
15 changes: 3 additions & 12 deletions esc-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ void esc_init()
{
// Setup timer1 for PWM
timer1.setMode(TIMER_CH1, TIMER_PWM);
timer1.setMode(TIMER_CH2, TIMER_PWM);
timer1.setMode(TIMER_CH3, TIMER_PWM);
timer1.setPrescaleFactor(21);

// Set throttle to minimum
Expand Down Expand Up @@ -76,8 +78,6 @@ void esc_manual_control(void) {
SerialUSB.println("Any other key zeroes command and exits");
SerialUSB.println();

disable_usarts();

uint8 input;
float rate1 = 0;
while (1) {
Expand All @@ -93,7 +93,7 @@ void esc_manual_control(void) {
}
else if(input == 'z')
{
rate1 = 0;
rate1 = 0.00;

}else{
break;
Expand All @@ -114,14 +114,5 @@ void esc_manual_control(void) {
set_rotor_throttle(2, 0.0);
set_rotor_throttle(3, 0.0);



// for (uint32 i = 0; i < BOARD_NR_PWM_PINS; i++) {
// if (boardUsesPin(i))
// continue;
// pinMode(boardPWMPins[i], OUTPUT);
// }
// init_all_timers(1);
enable_usarts();
}

1 change: 0 additions & 1 deletion esc-control.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

void esc_init();
void esc_manual_control(void);
void set_servo_angle(float angle);
void set_rotor_throttle(int rotor, float rate);

7 changes: 3 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
// -- setup() and loop() ------------------------------------------------------

void setup() {
disable_usarts();

// Set up the LED to blink
pinMode(BOARD_LED_PIN, OUTPUT);
// Set up ESC pins
pinMode(ROTOR1_PIN, PWM);
pinMode(ROTOR2_PIN, PWM);
pinMode(ROTOR3_PIN, PWM);
// Yaw servo pin
// Yaw servo pin (8)
pinMode(YAW_SERVO_PIN, PWM);
// Set up PPM pin
pinMode(PPM_PIN, INPUT_PULLUP);
Expand All @@ -39,8 +38,8 @@ void setup() {
init_ppm_timer_and_dma();
ppm_decode_go();

// init imu rx
Serial3.begin(28800);
// imu interface init
imu_interface_init();

// initialize usb
SerialUSB.begin();
Expand Down
10 changes: 5 additions & 5 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
*
*/

#define COPTER_DEBUG
//#define COPTER_DEBUG

/* Timer 1, Ch 1 */
#define ROTOR1_PIN 27
/* Timer 1, Ch 2 */
#define ROTOR2_PIN 26
/* Timer 1, Ch 3 */
#define ROTOR3_PIN 25
/* Mounted on rotor 3 */
#define YAW_SERVO_PIN 24
/* Timer 2, Channel 4 pin */
#define YAW_SERVO_PIN 8

/* Timer 4, Ch 1 */
#define PPM_PIN 16

/* 3_RX */
#define IMU_RX_PIN 0
/* 3_RX (pin 0 on Maple Mini) */
#define IMU_RX_PIN BOARD_USART3_RX_PIN


/* min: 1ms in tick counts */
Expand Down

0 comments on commit a8dcac1

Please sign in to comment.