Style fixes

This commit is contained in:
Arti Zirk 2016-12-18 23:05:43 +02:00
parent 10dfdb5a1b
commit e3312dd394
9 changed files with 46 additions and 18 deletions

View File

@ -42,6 +42,7 @@ Don't forget to `make clean` after each checkout!
# License # License
```Text
Copyright (C) 2016 Arti Zirk <arti.zirk@gmail.com> Copyright (C) 2016 Arti Zirk <arti.zirk@gmail.com>
This file is part of I237 Door Access program. 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 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/>. along with I237 Door Access. If not, see <http://www.gnu.org/licenses/>.
```

View File

@ -27,6 +27,7 @@
#include "../lib/matejx_avr_lib/mfrc522.h" #include "../lib/matejx_avr_lib/mfrc522.h"
#include "rfid.h" #include "rfid.h"
typedef struct cli_cmd { typedef struct cli_cmd {
PGM_P cmd; PGM_P cmd;
PGM_P help; PGM_P help;
@ -178,6 +179,7 @@ void cli_rfid_remove(const char *const *argv)
rfid_remove_card_by_user(argv[1]); rfid_remove_card_by_user(argv[1]);
} }
void cli_rfid_list(const char *const *argv) void cli_rfid_list(const char *const *argv)
{ {
(void) argv; (void) argv;

View File

@ -21,6 +21,7 @@
#define NUM_ELEMS(x) (sizeof(x) / sizeof((x)[0])) #define NUM_ELEMS(x) (sizeof(x) / sizeof((x)[0]))
#define UART_STATUS_MASK 0x00FF #define UART_STATUS_MASK 0x00FF
void cli_print(const char * str); void cli_print(const char * str);
char cli_get_char(void); char cli_get_char(void);
void cli_print_help(const char *const *argv); void cli_print_help(const char *const *argv);

View File

@ -18,6 +18,7 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "hmi_msg.h" #include "hmi_msg.h"
static const char m1[] PROGMEM = "January"; static const char m1[] PROGMEM = "January";
static const char m2[] PROGMEM = "February"; static const char m2[] PROGMEM = "February";
static const char m3[] PROGMEM = "March"; 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 remove_help[] PROGMEM = REMOVE_HELP;
const char list_cmd[] PROGMEM = LIST_CMD; const char list_cmd[] PROGMEM = LIST_CMD;
const char list_help[] PROGMEM = LIST_HELP; const char list_help[] PROGMEM = LIST_HELP;
const char access_denied_msg[] PROGMEM = ACCESS_DENIED_MSG; const char access_denied_msg[] PROGMEM = ACCESS_DENIED_MSG;

View File

@ -18,14 +18,20 @@
#ifndef _HMI_MSG_H_ #ifndef _HMI_MSG_H_
#define _HMI_MSG_H_ #define _HMI_MSG_H_
#define PROG_VERSION "Version: %S built on: %S %S" #define PROG_VERSION "Version: %S built on: %S %S"
#define LIBC_VERSION "avr-libc version: %S avr-gcc version: %S" #define LIBC_VERSION "avr-libc version: %S avr-gcc version: %S"
#define STUD_NAME "Arti Zirk" #define STUD_NAME "Arti Zirk"
#define GET_MONTH_MSG "Enter Month name first letter >" #define GET_MONTH_MSG "Enter Month name first letter >"
#define UPTIME_MSG "Uptime: %lu s" #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_CMD "help"
#define HELP_HELP "Get help" #define HELP_HELP "Get help"
#define VER_CMD "version" #define VER_CMD "version"
#define VER_HELP "Print FW version" #define VER_HELP "Print FW version"
@ -35,10 +41,6 @@
#define MONTH_CMD "month" #define MONTH_CMD "month"
#define MONTH_HELP "Find matching month from lookup list. Usage: month <string>" #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_CMD "read"
#define READ_HELP "Read and print out card info that is currently in proximity of the reader" #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_UID_MSG "Card UID: "
#define CARD_NOT_SELECTED "Unable to select card.\n" #define CARD_NOT_SELECTED "Unable to select card.\n"
extern PGM_P const months[]; extern PGM_P const months[];
extern const char help_cmd[]; extern const char help_cmd[];
@ -85,4 +88,5 @@ extern const char list_cmd[];
extern const char list_help[]; extern const char list_help[];
extern const char access_denied_msg[]; extern const char access_denied_msg[];
#endif /* _HMI_MSG_H_ */ #endif /* _HMI_MSG_H_ */

View File

@ -33,6 +33,7 @@
#include "rfid.h" #include "rfid.h"
// uart0 and uart3 will run at this speed
#define BAUDRATE 9600 #define BAUDRATE 9600
// For configuring arduino mega pin 25 // 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 TIMSK5 |= _BV(OCIE5A); // Output Compare A Match Interrupt Enable
} }
static inline uint32_t time(void) static inline uint32_t time(void)
{ {
uint32_t cur_time; uint32_t cur_time;
@ -106,6 +108,7 @@ static inline void init_hw (void)
sei(); sei();
} }
static inline void start_ui (void) static inline void start_ui (void)
{ {
print_version(stderr); print_version(stderr);
@ -116,6 +119,7 @@ static inline void start_ui (void)
lcd_puts_P(PSTR(STUD_NAME)); lcd_puts_P(PSTR(STUD_NAME));
} }
static inline void start_cli(void) static inline void start_cli(void)
{ {
// Call init with ptr to microrl instance and print callback // 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); microrl_set_execute_callback (prl, cli_execute);
} }
static inline void heartbeat (void) static inline void heartbeat (void)
{ {
static uint32_t time_prev; static uint32_t time_prev;
@ -136,6 +141,7 @@ static inline void heartbeat (void)
LED_TOGGLE; LED_TOGGLE;
} }
static inline void handle_door() static inline void handle_door()
{ {
Uid uid; Uid uid;
@ -169,6 +175,8 @@ static inline void handle_door()
} }
if ((message_start + 5) < time_cur) { 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; message_start = time_cur + 5;
lcd_goto(0x40); lcd_goto(0x40);
for (int8_t i = 16; i > -1; i--) { for (int8_t i = 16; i > -1; i--) {
@ -181,6 +189,7 @@ static inline void handle_door()
} }
} }
int main (void) int main (void)
{ {
init_hw(); init_hw();

View File

@ -19,6 +19,7 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "print_helper.h" #include "print_helper.h"
int print_ascii_tbl (FILE *stream) int print_ascii_tbl (FILE *stream)
{ {
for (char c = ' '; c <= '~'; c++) { for (char c = ' '; c <= '~'; c++) {

View File

@ -23,8 +23,10 @@
#include "rfid.h" #include "rfid.h"
#include "hmi_msg.h" #include "hmi_msg.h"
card_t *head = NULL; card_t *head = NULL;
void rfid_print_card(const card_t *card) void rfid_print_card(const card_t *card)
{ {
for (uint8_t i = 0; i < card->uid_size; i++) { 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); printf(": %s", card->user);
} }
card_t* rfid_find_card(const card_t *card) card_t* rfid_find_card(const card_t *card)
{ {
if (head != NULL) { if (head != NULL) {
@ -51,6 +54,7 @@ card_t* rfid_find_card(const card_t *card)
return NULL; return NULL;
} }
void rfid_add_card(const card_t *card) void rfid_add_card(const card_t *card)
{ {
card_t *found_card = rfid_find_card(card); card_t *found_card = rfid_find_card(card);
@ -92,6 +96,7 @@ void rfid_add_card(const card_t *card)
return; return;
} }
void rfid_list_cards(void) void rfid_list_cards(void)
{ {
if (head == NULL) { if (head == NULL) {
@ -109,6 +114,7 @@ void rfid_list_cards(void)
} }
} }
void rfid_remove_card_by_user(const char *user) void rfid_remove_card_by_user(const char *user)
{ {
card_t *curr; card_t *curr;

View File

@ -19,8 +19,10 @@
#include <stdio.h> #include <stdio.h>
#include "../lib/andygock_avr-uart/uart.h" #include "../lib/andygock_avr-uart/uart.h"
#define UART_STATUS_MASK 0x00FF #define UART_STATUS_MASK 0x00FF
int uart0_putc_wrap(char c, FILE *stream) int uart0_putc_wrap(char c, FILE *stream)
{ {
(void) stream; (void) stream;
@ -33,6 +35,7 @@ int uart0_putc_wrap(char c, FILE *stream)
return 0; return 0;
} }
int uart0_getc_wrap(FILE *stream) int uart0_getc_wrap(FILE *stream)
{ {
(void) stream; (void) stream;
@ -43,6 +46,7 @@ int uart0_getc_wrap(FILE *stream)
return uart0_getc() & UART_STATUS_MASK; return uart0_getc() & UART_STATUS_MASK;
} }
int uart3_putc_wrap(char c, FILE *stream) int uart3_putc_wrap(char c, FILE *stream)
{ {
(void) stream; (void) stream;