uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
|
Program storage module implementation. More...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <avr/eeprom.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include "gpio.h"
#include "program.h"
Functions | |
void | copy_current_bank_to (uint8_t target_bank) |
Copies all programs in the current bank to another bank. More... | |
void | copy_current_program_to (uint8_t target_program) |
Copies the current program to the specified position in memory. More... | |
char * | export_bank (const uint8_t bank) |
Exports a program bank. More... | |
void | enter_program (uint8_t number) |
Loads and executes the specified program. More... | |
bool | import_bank (const uint8_t bank, const char *data) |
Imports and stores a program bank given as a hex-string. More... | |
void | init_program_module (uint32_t program_initializer_value, void(*const execute_program_callback)(uint32_t program_data)) |
Initializes the program storage module. More... | |
uint32_t | read_program_data (uint8_t number) |
Reads a program data word from the specified position in memory. More... | |
void | update_current_program (uint32_t program_data) |
Updates and stores the current program. More... | |
void | wipe_current_bank (void) |
Reinitializes all programs in the current bank. More... | |
void | wipe_current_program (void) |
Reinitializes the currently loaded program. More... | |
void | write_program (uint8_t number, uint32_t data) |
Stores a given program data word in the specified position in memory. More... | |
Variables | |
static uint32_t program_data_storage [120] | EEMEM |
EEPROM program storage. More... | |
static uint32_t | program_initializer |
Initialization value for empty programs. More... | |
static struct program | current_program |
Current program. More... | |
static void(* | execute_program )(uint32_t) |
Callback for program execution. More... | |
Program storage module implementation.
void copy_current_bank_to | ( | uint8_t | target_bank | ) |
Copies all programs in the current bank to another bank.
Irreversibly overwrites all programs in the target bank.
target_bank | Target bank number [0..11]. |
void copy_current_program_to | ( | uint8_t | target_program | ) |
Copies the current program to the specified position in memory.
Irreversibly overwrites the target program.
target_program | Target program number [0..119]. |
void enter_program | ( | uint8_t | number | ) |
Loads and executes the specified program.
Reads the new program data from EEPROM, updates the internal state and calls the registered callback function, which executes the program. If the specified program number is the same as the stored current program number, this function does nothing.
number | Program number [0..119]. |
char* export_bank | ( | const uint8_t | number | ) |
Exports a program bank.
Reads the data from EEPROM and converts it to a string of hexadecimal digits.
number | the number of the program bank to export |
bool import_bank | ( | const uint8_t | number, |
const char * | data | ||
) |
Imports and stores a program bank given as a hex-string.
Overwrites stored program data!
number | the number of the program bank to import [0..11] |
data | the program bank to store as a string of hexadecimal digits |
true
if sanity checks passed void init_program_module | ( | uint32_t | program_initializer, |
void(*)(uint32_t program_data) | execute_program_callback | ||
) |
Initializes the program storage module.
Stores the specified program data initialization word, used in the wipe functions and registers the provided callback function, which is executed whenever the current program data word is updated either by wiping the program or loading a new one.
program_initializer | On wiping, programs are initialized with this value. |
execute_program_callback | Callback for program execution. This procedure is called with the program configuration data that was read from memory as the parameter program_data . |
uint32_t read_program_data | ( | uint8_t | number | ) |
Reads a program data word from the specified position in memory.
number | Program number [0..119]. |
void update_current_program | ( | uint32_t | program_data | ) |
Updates and stores the current program.
program_data | the new configuration |
void wipe_current_bank | ( | void | ) |
Reinitializes all programs in the current bank.
void wipe_current_program | ( | void | ) |
Reinitializes the currently loaded program.
Updates the internal program data word with the initializer, stores it and executes the initialized program.
void write_program | ( | uint8_t | number, |
uint32_t | data | ||
) |
Stores a given program data word in the specified position in memory.
number | Program number [0..119]. |
data | Program data as 32-bit dword. |
|
static |
Current program.
|
static |
EEPROM program storage.
|
static |
Callback for program execution.
|
static |
Initialization value for empty programs.