uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
Data Structures | Macros | Typedefs | Functions
serial_communication.h File Reference

Serial communication module. More...

#include <stdbool.h>
#include <stdint.h>
#include <avr/pgmspace.h>
Include dependency graph for serial_communication.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  serial_command
 Command specification. More...
 

Macros

#define CMD_BUFFER_SIZE   100
 Size of the command buffer of the shell. More...
 
#define CMD_HISTORY_SIZE   4
 Number of recent commands in the history. More...
 
#define ESCAPE_CHAR_CODE   27
 ASCII escape character. More...
 
#define MAX_PAGE_NUM   ((PROGMEM_SIZE - BOOT_SECTION_SIZE) / SPM_PAGESIZE / 2 - 1)
 Maximum program size in number of pages. More...
 
#define RESET_TIMEOUT   2
 Device reset timout in [s]. More...
 

Typedefs

typedef bool(* cmd_handler_t) (const char *cmd)
 Type for command handlers. More...
 

Functions

void init_serial_communication (const struct serial_command commands[], uint8_t commands_size)
 Initializes the USB communication module. More...
 
void serial_communication_task (void)
 Main task for USB communication. More...
 

Detailed Description

Serial communication module.

This module contains a firmware update procedure and a command interpreter that can be extended by custom commands.

Macro Definition Documentation

◆ CMD_BUFFER_SIZE

#define CMD_BUFFER_SIZE   100

Size of the command buffer of the shell.

Must be int the range of uint8_t.

◆ CMD_HISTORY_SIZE

#define CMD_HISTORY_SIZE   4

Number of recent commands in the history.

Must be int the range of uint8_t.

◆ ESCAPE_CHAR_CODE

#define ESCAPE_CHAR_CODE   27

ASCII escape character.

◆ MAX_PAGE_NUM

#define MAX_PAGE_NUM   ((PROGMEM_SIZE - BOOT_SECTION_SIZE) / SPM_PAGESIZE / 2 - 1)

Maximum program size in number of pages.

  • usable program space 136 KiB - 8 KiB boot section
    • one self-programming page is 256 B
    • the last page is in use by the bootloader and can therefore not be used

◆ RESET_TIMEOUT

#define RESET_TIMEOUT   2

Device reset timout in [s].

Typedef Documentation

◆ cmd_handler_t

typedef bool(* cmd_handler_t) (const char *cmd)

Type for command handlers.

See also
serial_command

Function Documentation

◆ init_serial_communication()

void init_serial_communication ( const struct serial_command  commands[],
uint8_t  commands_size 
)

Initializes the USB communication module.

Registers the specified commands.

Parameters
commandsan array of command specifications
commands_sizethe number of command specifications in commands
See also
serial_command
serial_communication_task

◆ serial_communication_task()

void serial_communication_task ( void  )

Main task for USB communication.

This task must be run as a slow or medium speed task in order to enable USB communication and firmware updates. It processes commands arriving on the bus and takes required actions by calling registered handler functions.

See also
init_serial_communication