Style fixes
This commit is contained in:
parent
10dfdb5a1b
commit
e3312dd394
@ -42,6 +42,7 @@ Don't forget to `make clean` after each checkout!
|
||||
|
||||
# License
|
||||
|
||||
```Text
|
||||
Copyright (C) 2016 Arti Zirk <arti.zirk@gmail.com>
|
||||
|
||||
This file is part of I237 Door Access program.
|
||||
@ -58,4 +59,4 @@ Don't forget to `make clean` after each checkout!
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with I237 Door Access. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
```
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../lib/matejx_avr_lib/mfrc522.h"
|
||||
#include "rfid.h"
|
||||
|
||||
|
||||
typedef struct cli_cmd {
|
||||
PGM_P cmd;
|
||||
PGM_P help;
|
||||
@ -178,6 +179,7 @@ void cli_rfid_remove(const char *const *argv)
|
||||
rfid_remove_card_by_user(argv[1]);
|
||||
}
|
||||
|
||||
|
||||
void cli_rfid_list(const char *const *argv)
|
||||
{
|
||||
(void) argv;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define NUM_ELEMS(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define UART_STATUS_MASK 0x00FF
|
||||
|
||||
|
||||
void cli_print(const char * str);
|
||||
char cli_get_char(void);
|
||||
void cli_print_help(const char *const *argv);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <avr/pgmspace.h>
|
||||
#include "hmi_msg.h"
|
||||
|
||||
|
||||
static const char m1[] PROGMEM = "January";
|
||||
static const char m2[] PROGMEM = "February";
|
||||
static const char m3[] PROGMEM = "March";
|
||||
@ -43,5 +44,4 @@ const char remove_cmd[] PROGMEM = REMOVE_CMD;
|
||||
const char remove_help[] PROGMEM = REMOVE_HELP;
|
||||
const char list_cmd[] PROGMEM = LIST_CMD;
|
||||
const char list_help[] PROGMEM = LIST_HELP;
|
||||
|
||||
const char access_denied_msg[] PROGMEM = ACCESS_DENIED_MSG;
|
||||
|
@ -18,14 +18,20 @@
|
||||
#ifndef _HMI_MSG_H_
|
||||
#define _HMI_MSG_H_
|
||||
|
||||
|
||||
#define PROG_VERSION "Version: %S built on: %S %S"
|
||||
#define LIBC_VERSION "avr-libc version: %S avr-gcc version: %S"
|
||||
#define STUD_NAME "Arti Zirk"
|
||||
#define GET_MONTH_MSG "Enter Month name first letter >"
|
||||
#define UPTIME_MSG "Uptime: %lu s"
|
||||
|
||||
#define CLI_HELP_MSG "Implemented commands:"
|
||||
#define CLI_NO_CMD "Command not implemented.\n Use <help> to get help."
|
||||
#define CLI_ARGS_MSG "To few or to many arguments for this command\nUse <help>"
|
||||
|
||||
#define HELP_CMD "help"
|
||||
#define HELP_HELP "Get help"
|
||||
|
||||
#define VER_CMD "version"
|
||||
#define VER_HELP "Print FW version"
|
||||
|
||||
@ -35,10 +41,6 @@
|
||||
#define MONTH_CMD "month"
|
||||
#define MONTH_HELP "Find matching month from lookup list. Usage: month <string>"
|
||||
|
||||
#define CLI_HELP_MSG "Implemented commands:"
|
||||
#define CLI_NO_CMD "Command not implemented.\n Use <help> to get help."
|
||||
#define CLI_ARGS_MSG "To few or to many arguments for this command\nUse <help>"
|
||||
|
||||
#define READ_CMD "read"
|
||||
#define READ_HELP "Read and print out card info that is currently in proximity of the reader"
|
||||
|
||||
@ -65,6 +67,7 @@
|
||||
#define CARD_UID_MSG "Card UID: "
|
||||
#define CARD_NOT_SELECTED "Unable to select card.\n"
|
||||
|
||||
|
||||
extern PGM_P const months[];
|
||||
|
||||
extern const char help_cmd[];
|
||||
@ -85,4 +88,5 @@ extern const char list_cmd[];
|
||||
extern const char list_help[];
|
||||
extern const char access_denied_msg[];
|
||||
|
||||
|
||||
#endif /* _HMI_MSG_H_ */
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "rfid.h"
|
||||
|
||||
|
||||
// uart0 and uart3 will run at this speed
|
||||
#define BAUDRATE 9600
|
||||
|
||||
// For configuring arduino mega pin 25
|
||||
@ -60,6 +61,7 @@ static inline void init_system_clock(void)
|
||||
TIMSK5 |= _BV(OCIE5A); // Output Compare A Match Interrupt Enable
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t time(void)
|
||||
{
|
||||
uint32_t cur_time;
|
||||
@ -106,6 +108,7 @@ static inline void init_hw (void)
|
||||
sei();
|
||||
}
|
||||
|
||||
|
||||
static inline void start_ui (void)
|
||||
{
|
||||
print_version(stderr);
|
||||
@ -116,6 +119,7 @@ static inline void start_ui (void)
|
||||
lcd_puts_P(PSTR(STUD_NAME));
|
||||
}
|
||||
|
||||
|
||||
static inline void start_cli(void)
|
||||
{
|
||||
// Call init with ptr to microrl instance and print callback
|
||||
@ -124,6 +128,7 @@ static inline void start_cli(void)
|
||||
microrl_set_execute_callback (prl, cli_execute);
|
||||
}
|
||||
|
||||
|
||||
static inline void heartbeat (void)
|
||||
{
|
||||
static uint32_t time_prev;
|
||||
@ -136,6 +141,7 @@ static inline void heartbeat (void)
|
||||
LED_TOGGLE;
|
||||
}
|
||||
|
||||
|
||||
static inline void handle_door()
|
||||
{
|
||||
Uid uid;
|
||||
@ -169,6 +175,8 @@ static inline void handle_door()
|
||||
}
|
||||
|
||||
if ((message_start + 5) < time_cur) {
|
||||
// clean the screen once again in 10 secconds so that cli command
|
||||
// `month` could show found months for some time
|
||||
message_start = time_cur + 5;
|
||||
lcd_goto(0x40);
|
||||
for (int8_t i = 16; i > -1; i--) {
|
||||
@ -181,6 +189,7 @@ static inline void handle_door()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
init_hw();
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <avr/pgmspace.h>
|
||||
#include "print_helper.h"
|
||||
|
||||
|
||||
int print_ascii_tbl (FILE *stream)
|
||||
{
|
||||
for (char c = ' '; c <= '~'; c++) {
|
||||
|
@ -23,8 +23,10 @@
|
||||
#include "rfid.h"
|
||||
#include "hmi_msg.h"
|
||||
|
||||
|
||||
card_t *head = NULL;
|
||||
|
||||
|
||||
void rfid_print_card(const card_t *card)
|
||||
{
|
||||
for (uint8_t i = 0; i < card->uid_size; i++) {
|
||||
@ -33,6 +35,7 @@ void rfid_print_card(const card_t *card)
|
||||
printf(": %s", card->user);
|
||||
}
|
||||
|
||||
|
||||
card_t* rfid_find_card(const card_t *card)
|
||||
{
|
||||
if (head != NULL) {
|
||||
@ -51,6 +54,7 @@ card_t* rfid_find_card(const card_t *card)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void rfid_add_card(const card_t *card)
|
||||
{
|
||||
card_t *found_card = rfid_find_card(card);
|
||||
@ -92,6 +96,7 @@ void rfid_add_card(const card_t *card)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void rfid_list_cards(void)
|
||||
{
|
||||
if (head == NULL) {
|
||||
@ -109,6 +114,7 @@ void rfid_list_cards(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void rfid_remove_card_by_user(const char *user)
|
||||
{
|
||||
card_t *curr;
|
||||
|
@ -19,8 +19,10 @@
|
||||
#include <stdio.h>
|
||||
#include "../lib/andygock_avr-uart/uart.h"
|
||||
|
||||
|
||||
#define UART_STATUS_MASK 0x00FF
|
||||
|
||||
|
||||
int uart0_putc_wrap(char c, FILE *stream)
|
||||
{
|
||||
(void) stream;
|
||||
@ -33,6 +35,7 @@ int uart0_putc_wrap(char c, FILE *stream)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uart0_getc_wrap(FILE *stream)
|
||||
{
|
||||
(void) stream;
|
||||
@ -43,6 +46,7 @@ int uart0_getc_wrap(FILE *stream)
|
||||
return uart0_getc() & UART_STATUS_MASK;
|
||||
}
|
||||
|
||||
|
||||
int uart3_putc_wrap(char c, FILE *stream)
|
||||
{
|
||||
(void) stream;
|
||||
|
Loading…
Reference in New Issue
Block a user