Port naming, turn on both LEDs on startup

This commit is contained in:
Rihards Skuja 2018-01-09 20:17:50 +02:00
parent 4a4d6e19de
commit a48b71620f
No known key found for this signature in database
GPG Key ID: 53FA13A3F7F8571B
5 changed files with 21 additions and 16 deletions

View File

@ -1,9 +1,10 @@
#ifndef LED_H
#define LED_H
#define LED_DDR DDRD
#define LED_1_BIT PD3
#define LED_2_BIT PD4
#define LED_DDR DDRD
#define LED_PORT PORTD
#define LED_GREEN_BIT PD3
#define LED_BLUE_BIT PD4
void init_leds(void);

View File

@ -1,11 +1,11 @@
#ifndef SERVOS_H
#define SERVOS_H
#define SERVO_DDR DDRD
#define SERVO_L_REG OCR0B
#define SERVO_R_REG OCR0A
#define SERVO_L_BIT PD5
#define SERVO_R_BIT PD6
#define SERVO_DDR DDRD
#define SERVO_L_REG OCR0B
#define SERVO_R_REG OCR0A
#define SERVO_L_BIT PD5
#define SERVO_R_BIT PD6
#define SERVO_MIN 930 // (us). Go backwards
#define SERVO_MAX 1930 // (us). Go forwards

View File

@ -4,6 +4,6 @@
void init_leds(void)
{
SET(LED_DDR, LED_1_BIT);
SET(LED_DDR, LED_2_BIT);
SET(LED_DDR, LED_GREEN_BIT);
SET(LED_DDR, LED_BLUE_BIT);
}

View File

@ -39,6 +39,10 @@ int main(void)
init_servos();
init_sonar();
// Use green LED as power LED
SET(LED_PORT, LED_GREEN_BIT);
SET(LED_PORT, LED_BLUE_BIT); // Temporary for debug
run_servos();
read_temp();

View File

@ -22,12 +22,6 @@ void trigger_sonar(void)
_delay_us(1);
}
ISR(TIMER1_OVF_vect)
{
++overflow_counter;
TCNT1 = 0;
}
int32_t read_sonar(void)
{
int dist_in_cm = 0;
@ -58,3 +52,9 @@ int32_t read_sonar(void)
return dist_in_cm;
}
ISR(TIMER1_OVF_vect)
{
++overflow_counter;
TCNT1 = 0;
}