Skip to content

Commit

Permalink
Bring x64/ARM build compatibility patches into main (monome#328)
Browse files Browse the repository at this point in the history
* Squash VCV compatibility history into PR branch (#6)

* Reapply TT/VCV Rack modifications to 3.2.0 branch

* Fix const RDATA for gcc 10

* Switch to libavr32 fork

* Move TT libavr32 back to upstream/main

* First pass at separating scene serialization from USB

* Remove unnecessary scene_num arg from serialization functions

* Separate header for serializer typedefs

* Init scene cal data to fix div by zero in test suite

* Add serialization tests

* Add fragment deserialization test

* Update presets 5-7 for post-2.0 II ops

* tidy up function names

* move nvram datatypes to header

* build with avr32-gcc

* Run clang-format

* Update CHANGELOG.md and whats_new.md
  • Loading branch information
Dewb committed Aug 29, 2023
1 parent 72193af commit 2779adb
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- **NEW**: new ops: `CV.CAL` and `CV.CAL.RESET` to calibrate CV outputs
- **FIX**: N.CS scales 7 & 8 were incorrectly swapped; make them consistent with N.S and docs
- **FIX**: libavr32 update: support CDC grid size detection (e.g. zero), increase HID message buffer
- **NEW**: apply VCV Rack compatibility patches, so branches off main can be used in both hardware and software

## v4.0.0

Expand Down
1 change: 1 addition & 0 deletions docs/whats_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- **NEW**: new ops: `CV.CAL` and `CV.CAL.RESET` to calibrate CV outputs
- **FIX**: N.CS scales 7 & 8 were incorrectly swapped; make them consistent with N.S and docs
- **FIX**: libavr32 update: support CDC grid size detection (e.g. zero), increase HID message buffer
- **NEW**: apply VCV Rack compatibility patches, so branches off main can be used in both hardware and software

## v4.0.0

Expand Down
27 changes: 4 additions & 23 deletions module/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,14 @@
#include "teletype.h"

#define FIRSTRUN_KEY 0x22
#define BUTTON_STATE_SIZE (GRID_BUTTON_COUNT >> 3)

typedef struct {
uint8_t button_states[BUTTON_STATE_SIZE];
uint8_t fader_states[GRID_FADER_COUNT];
} grid_data_t;
static grid_data_t grid_data;

// NVRAM data structure located in the flash array.
typedef const struct {
scene_script_t scripts[EDITABLE_SCRIPT_COUNT];
scene_pattern_t patterns[PATTERN_COUNT];
grid_data_t grid_data;
char text[SCENE_TEXT_LINES][SCENE_TEXT_CHARS];
} nvram_scene_t;

typedef const struct {
nvram_scene_t scenes[SCENE_SLOTS];
uint8_t last_scene;
tele_mode_t last_mode;
uint8_t fresh;
cal_data_t cal;
device_config_t device_config;
} nvram_data_t;


#if defined(__AVR32__)
static __attribute__((__section__(".flash_nvram"))) nvram_data_t f;
#else
nvram_data_t f;
#endif

static void pack_grid(scene_state_t *scene);
static void unpack_grid(scene_state_t *scene);
Expand Down
23 changes: 23 additions & 0 deletions module/flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@
#include "teletype.h"

#define SCENE_SLOTS 32
#define BUTTON_STATE_SIZE (GRID_BUTTON_COUNT >> 3)

typedef struct {
uint8_t button_states[BUTTON_STATE_SIZE];
uint8_t fader_states[GRID_FADER_COUNT];
} grid_data_t;

// NVRAM data structure located in the flash array.
typedef struct {
scene_script_t scripts[EDITABLE_SCRIPT_COUNT]; // Exclude TEMP script
scene_pattern_t patterns[PATTERN_COUNT];
grid_data_t grid_data;
char text[SCENE_TEXT_LINES][SCENE_TEXT_CHARS];
} nvram_scene_t;

typedef struct {
nvram_scene_t scenes[SCENE_SLOTS];
uint8_t last_scene;
tele_mode_t last_mode;
uint8_t fresh;
cal_data_t cal;
device_config_t device_config;
} nvram_data_t;

u8 is_flash_fresh(void);
void flash_prepare(void);
Expand Down
13 changes: 9 additions & 4 deletions module/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ static void handler_AppCustom(int32_t data);
static void empty_event_handlers(void);
void assign_main_event_handlers(void);
static void assign_msc_event_handlers(void);
static void check_events(void);
void check_events(void);

// key handling
static void process_keypress(uint8_t key, uint8_t mod_key, bool is_held_key,
bool is_release);
void process_keypress(uint8_t key, uint8_t mod_key, bool is_held_key,
bool is_release);
static bool process_global_keys(uint8_t key, uint8_t mod_key, bool is_held_key);

// start/stop monome polling/refresh timers
Expand All @@ -189,6 +189,8 @@ static void render_init(void);
static void exit_screensaver(void);
static void update_device_config(u8 refresh);

void initialize_module(void);


////////////////////////////////////////////////////////////////////////////////
// timer callbacks
Expand Down Expand Up @@ -1184,7 +1186,7 @@ void reset_midi_counter() {
////////////////////////////////////////////////////////////////////////////////
// main

int main(void) {
void initialize_module(void) {
sysclk_init();

init_dbg_rs232(FMCK_HZ);
Expand Down Expand Up @@ -1300,7 +1302,10 @@ int main(void) {

run_script(&scene_state, INIT_SCRIPT);
scene_state.initializing = false;
}

int main(void) {
initialize_module();
#ifdef TELETYPE_PROFILE
uint32_t count = 0;
#endif
Expand Down

0 comments on commit 2779adb

Please sign in to comment.