mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-30 13:41:50 +01:00
avr: use a own header to define constants
We will soon share them with python Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
parent
b5154faecd
commit
6725555af6
@ -18,6 +18,8 @@
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
#include "protocol.h"
|
||||
|
||||
#define RED 0x1
|
||||
#define GREEN 0x2
|
||||
#define YELLOW 0x4
|
||||
@ -107,17 +109,17 @@ static void update_state(unsigned char new_state, enum state_source source)
|
||||
case RED:
|
||||
set_bolzen(true);
|
||||
set_schnapper(false);
|
||||
ret = 'r';
|
||||
ret = AVR_STATE_SWITCH_RED;
|
||||
break;
|
||||
case YELLOW:
|
||||
set_bolzen(false);
|
||||
set_schnapper(false);
|
||||
ret = 'y';
|
||||
ret = AVR_STATE_SWITCH_YELLOW;
|
||||
break;
|
||||
case GREEN:
|
||||
set_bolzen(false);
|
||||
set_schnapper(true);
|
||||
ret = 'g';
|
||||
ret = AVR_STATE_SWITCH_GREEN;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -126,7 +128,7 @@ static void update_state(unsigned char new_state, enum state_source source)
|
||||
uart_putc(toupper(ret));
|
||||
break;
|
||||
case EMERGENCY:
|
||||
uart_putc('E');
|
||||
uart_putc(AVR_EMERGENCY);
|
||||
break;
|
||||
case TIMEOUT:
|
||||
uart_putc(ret);
|
||||
@ -142,13 +144,13 @@ ISR(USART_RX_vect)
|
||||
unsigned char c = UDR;
|
||||
|
||||
switch (c) {
|
||||
case 'r':
|
||||
case AVR_STATE_SWITCH_RED:
|
||||
update_state(RED, COMM);
|
||||
break;
|
||||
case 'y':
|
||||
case AVR_STATE_SWITCH_YELLOW:
|
||||
update_state(YELLOW, COMM);
|
||||
break;
|
||||
case 'g':
|
||||
case AVR_STATE_SWITCH_GREEN:
|
||||
update_state(GREEN, COMM);
|
||||
break;
|
||||
}
|
||||
|
16
avr-code/protocol.h
Normal file
16
avr-code/protocol.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* doorlock-avr, AVR code of Binary Kitchen's doorlock
|
||||
*
|
||||
* Copyright (c) Binary Kitchen, 2019
|
||||
*
|
||||
* Authors:
|
||||
* Ralf Ramsauer <ralf@binary-kitchen.de>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2. See
|
||||
* the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#define AVR_STATE_SWITCH_RED 'r'
|
||||
#define AVR_STATE_SWITCH_YELLOW 'y'
|
||||
#define AVR_STATE_SWITCH_GREEN 'g'
|
||||
#define AVR_EMERGENCY 'E'
|
Loading…
Reference in New Issue
Block a user