<commit_before>/* motor.c
 * 
 * Module contains everything needed to operate an H-bridge.
 *
 * MAE3780 Mechatronics Final Project 2013
 * Cornell University
 * <NAME>, <NAME>, <NAME>
 */

//Include standard headers
#include <avr/io.h>			// For general I/O
#include <avr/interrupt.h>	// For interrupts
#include <stdint.h>			// For data types

//Include Local Headers
#include "motor.h"			// Header for this file

//Definitions
#define DEAD_TIME 1			// Define PWM dead time

/* Connection details
 * Pin		Side	Direction	
 * --------------------------
 * OCR0A	Left	Forward
 * OCR0B	Left	Reverse
 * OCR2A	Right	Forward
 * OCR2B	Right	Reverse
 */

//Define variables
static uint8_t rightSpeed[]={0,42,87,127,167,213,255};
static uint8_t leftSpeed[]={0,42,87,127,167,213,255};

void motor_init(void){
// Function to initialize PWM

	// Set OCR0A when high, reset when low
	TCCR0A |= (1<<COM0A1)|(1<<COM0A0);
	TCCR2A |= (1<<COM2A1)|(1<<COM2A0);
	// Reset OCR0B when high, set when low
	TCCR0A |= (1<<COM0B1);
	TCCR2A |= (1<<COM2B1);
	/* This is set up such that OCRnB should always be lower
	 * than OCRnA to allow time for the transistors to switch
	 */

	//Set Initial Speed
	motor_setSpeed(0, 0);
	motor_setSpeed(1, 0);

	// Set prescalar to 8
	TCCR0B |= (1<<CS01);
	TCCR2B |= (1<<CS21);
	
	// Set Waveform Generation Mode to Phase-correct PWM
	TCCR0A |= (1<<WGM00);
	TCCR2A |= (1<<WGM20);

	// Set motor pins to outputs
	PORTD |= (1<<3)|(1<<5)|(1<<6);
	PORTB |= (1<<3);
}<commit_msg>Fixed bug in initializing pins<commit_after>/* motor.c
 * 
 * Module contains everything needed to operate an H-bridge.
 *
 * MAE3780 Mechatronics Final Project 2013
 * Cornell University
 * <NAME>, <NAME>, <NAME>
 */

//Include standard headers
#include <avr/io.h>			// For general I/O
#include <avr/interrupt.h>	// For interrupts
#include <stdint.h>			// For data types

//Include Local Headers
#include "motor.h"			// Header for this file

//Definitions
#define DEAD_TIME 1			// Define PWM dead time

/* Connection details
 * Pin		Side	Direction	
 * --------------------------
 * OCR0A	Left	Forward
 * OCR0B	Left	Reverse
 * OCR2A	Right	Forward
 * OCR2B	Right	Reverse
 */

//Define variables
static uint8_t rightSpeed[]={0,42,87,127,167,213,255};
static uint8_t leftSpeed[]={0,42,87,127,167,213,255};

void motor_init(void){
// Function to initialize PWM
	
	// Set OCR0A when high, reset when low
	TCCR0A |= (1<<COM0A1)|(1<<COM0A0);
	TCCR2A |= (1<<COM2A1)|(1<<COM2A0);
	// Reset OCR0B when high, set when low
	TCCR0A |= (1<<COM0B1);
	TCCR2A |= (1<<COM2B1);
	/* This is set up such that OCRnB should always be lower
	 * than OCRnA to allow time for the transistors to switch
	 */

	//Set Initial Speed
	motor_setSpeed(0, 0);
	motor_setSpeed(1, 0);

	// Set prescalar to 8
	TCCR0B |= (1<<CS01);
	TCCR2B |= (1<<CS21);
	
	// Set Waveform Generation Mode to Phase-correct PWM
	TCCR0A |= (1<<WGM00);
	TCCR2A |= (1<<WGM20);

	// Set motor pins to outputs
	DDRD |= (1<<3)|(1<<5)|(1<<6);
	DDRB |= (1<<3);
}
{'fraction_non_alphanumeric': 0.16498993963782696, 'fraction_numerical': 0.06841046277665996, 'mean_word_length': 3.373900293255132, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1926571', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1146, 'n_words': 330}