uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
serial_communication.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright 2015 Sebastian Neuser
8  *
9  * This file is part of the uMIDI firmware.
10  *
11  * The MIDI volume controller firmware is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * The uMIDI firmware is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with the uMIDI firmware. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef _SERIAL_COM_H
26 #define _SERIAL_COM_H
27 
28 
29 //---------------- includes ----------------//
30 #include <stdbool.h>
31 #include <stdint.h>
32 #include <avr/pgmspace.h>
33 
34 
35 //---------------- constants ----------------//
36 
39 #define CMD_BUFFER_SIZE 100
40 
43 #define CMD_HISTORY_SIZE 4
44 
46 #define ESCAPE_CHAR_CODE 27
47 
52 #define MAX_PAGE_NUM ((PROGMEM_SIZE - BOOT_SECTION_SIZE) / SPM_PAGESIZE / 2 - 1)
53 
55 #define RESET_TIMEOUT 2
56 
57 
58 //---------------- data types ----------------//
59 
62 typedef bool (*cmd_handler_t)(const char* cmd);
63 
73 {
74  PGM_P cmd_string;
75 
76  PGM_P help_string;
77 
87 };
92 
93 
94 //---------------- functions and procedures ----------------//
95 
104 void init_serial_communication(const struct serial_command commands[], uint8_t commands_size);
105 
111 void serial_communication_task(void);
112 
113 
114 //---------------- EOF ----------------//
115 #endif // _SERIAL_COM_H
116 
void init_serial_communication(const struct serial_command commands[], uint8_t commands_size)
Initializes the USB communication module.
bool(* cmd_handler_t)(const char *cmd)
Type for command handlers.
Definition: serial_communication.h:62
PGM_P cmd_string
The command as typed in the console.
Definition: serial_communication.h:74
void serial_communication_task(void)
Main task for USB communication.
Definition: serial_communication.c:477
PGM_P help_string
Definition: serial_communication.h:76
Command specification.
Definition: serial_communication.h:72
cmd_handler_t handler
Definition: serial_communication.h:86