Merge pull request #4 from rhssk/high_low_macros
Introduce macros for setting pin to low or high
This commit is contained in:
commit
be9cedee7d
@ -1,6 +1,9 @@
|
|||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
|
#define SET_HIGH(PORT, PIN) (PORT) |= (1 << (PIN))
|
||||||
|
#define SET_LOW(PORT, PIN) (PORT) &= ~(1 << (PIN))
|
||||||
|
|
||||||
void initIO(void);
|
void initIO(void);
|
||||||
void blinkLed(void);
|
void blinkLed(void);
|
||||||
void readTemp(void);
|
void readTemp(void);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
void initIO()
|
void initIO()
|
||||||
{
|
{
|
||||||
/* Servos */
|
/* Servos */
|
||||||
DDRB |= (1 << SERVO_L);
|
SET_HIGH(DDRB, SERVO_L);
|
||||||
/* Phase Correct PWM, 9-bit; Inverting mode */
|
/* Phase Correct PWM, 9-bit; Inverting mode */
|
||||||
TCCR1A |= 1 << WGM11 | 1 << COM1A1 | 1 << COM1A0;
|
TCCR1A |= 1 << WGM11 | 1 << COM1A1 | 1 << COM1A0;
|
||||||
/* "Clear Timer on Compare match" mode; Prescaler = 1 */
|
/* "Clear Timer on Compare match" mode; Prescaler = 1 */
|
||||||
@ -20,7 +20,7 @@ void initIO()
|
|||||||
ICR1 = 19999; // F_CPU / 50Hz - 1
|
ICR1 = 19999; // F_CPU / 50Hz - 1
|
||||||
|
|
||||||
/* LED */
|
/* LED */
|
||||||
DDRD |= (1 << LED_1);
|
SET_HIGH(DDRD, LED_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void readTemp()
|
void readTemp()
|
||||||
@ -31,9 +31,9 @@ void readTemp()
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
d = ds18b20_gettemp();
|
d = ds18b20_gettemp();
|
||||||
if (d >= 21)
|
if (d >= 21)
|
||||||
PORTD |= (1 << LED_1);
|
SET_HIGH(PORTD, LED_1);
|
||||||
else
|
else
|
||||||
PORTD &= ~(1 << LED_1);
|
SET_LOW(PORTD, LED_1);
|
||||||
|
|
||||||
_delay_ms(500);
|
_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user