Subversion Repositories svn.mios32

Compare Revisions

Ignore whitespace Rev 2530 → Rev 2531

/trunk/apps/sequencers/midibox_seq_v4_lite/core/seq_file_hw.c
26,7 → 26,6
#include <string.h>
#include <aout.h>
#include <blm_cheapo.h>
#include <blm_x.h>
#include <seq_cv.h>
 
#include "file.h"
34,6 → 33,7
#include "seq_file_hw.h"
 
#include "seq_hwcfg.h"
#include "seq_blm8x8.h"
 
#include "seq_ui.h"
#include "seq_midi_port.h"
724,26 → 724,32
DEBUG_MSG("[SEQ_FILE_HW] BLM8X8_%s: %d", parameter, value);
#endif
 
int blm = 0; // TODO: multiple BLMs
 
if( strcasecmp(parameter, "ENABLED") == 0 ) {
seq_hwcfg_blm8x8.enabled = value;
} else if( strcasecmp(parameter, "DOUT_CATHODES_SR") == 0 ) {
blm_x_config_t config = BLM_X_ConfigGet();
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.rowsel_dout_sr = value;
BLM_X_ConfigSet(config);
SEQ_BLM8X8_ConfigSet(blm, config);
} else if( strcasecmp(parameter, "DOUT_CATHODES_INV_MASK") == 0 ) {
blm_x_config_t config = BLM_X_ConfigGet();
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.rowsel_inv_mask = value;
BLM_X_ConfigSet(config);
SEQ_BLM8X8_ConfigSet(blm, config);
} else if( strcasecmp(parameter, "DOUT_ANODES_INV_MASK") == 0 ) {
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.col_inv_mask = value;
SEQ_BLM8X8_ConfigSet(blm, config);
} else if( strcasecmp(parameter, "DOUT_LED_SR") == 0 ) {
blm_x_config_t config = BLM_X_ConfigGet();
config.led_first_dout_sr = value;
BLM_X_ConfigSet(config);
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.led_dout_sr = value;
SEQ_BLM8X8_ConfigSet(blm, config);
} else if( strcasecmp(parameter, "DOUT_GP_MAPPING") == 0 ) {
seq_hwcfg_blm8x8.dout_gp_mapping = value;
} else if( strcasecmp(parameter, "DIN_SR") == 0 ) {
blm_x_config_t config = BLM_X_ConfigGet();
config.btn_first_din_sr = value;
BLM_X_ConfigSet(config);
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.button_din_sr = value;
SEQ_BLM8X8_ConfigSet(blm, config);
} else {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_HW] ERROR: unknown BLM8X8_* name '%s'!", parameter);
1008,11 → 1014,17
MIOS32_SRIO_DebounceSet(delay);
BLM_CHEAPO_DebounceSet(delay);
 
// BLM_X based DINs
blm_x_config_t config = BLM_X_ConfigGet();
config.debounce_delay = delay;
BLM_X_ConfigSet(config);
// SEQ_BLM8X8 based DINs
{
int blm;
 
for(blm=0; blm<SEQ_BLM8X8_NUM; ++blm) {
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.debounce_delay = delay;
SEQ_BLM8X8_ConfigSet(blm, config);
}
}
 
} else if( strcasecmp(parameter, "AOUT_INTERFACE_TYPE") == 0 ) {
// only for compatibility reasons - AOUT interface is stored in MBSEQ_GC.V4L now!
// can be removed once most users switched to beta28 and later!
/trunk/apps/sequencers/midibox_seq_v4_lite/core/seq_ui.c
23,10 → 23,10
#include <seq_midi_out.h>
#include <seq_bpm.h>
#include <blm_cheapo.h>
#include <blm_x.h>
 
#include "tasks.h"
#include "seq_led.h"
#include "seq_blm8x8.h"
#include "seq_ui.h"
#include "seq_ui_pages.h"
#include "seq_hwcfg.h"
/trunk/apps/sequencers/midibox_seq_v4_lite/core/seq_hwcfg.c
20,7 → 20,7
 
#include <mios32.h>
 
#include <blm_x.h>
#include <seq_blm8x8.h>
#include "seq_hwcfg.h"
 
 
220,13 → 220,13
seq_hwcfg_cv_gate_sr[i] = 0;
 
// MBSEQV4L: pre-configure SRIO based frontpanel
blm_x_config_t config = BLM_X_ConfigGet();
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(0);
config.rowsel_dout_sr = 1;
config.rowsel_inv_mask = 0x00;
config.led_first_dout_sr = 2;
config.btn_first_din_sr = 1;
config.led_dout_sr = 2;
config.button_din_sr = 1;
config.debounce_delay = 20; // mS
BLM_X_ConfigSet(config);
SEQ_BLM8X8_ConfigSet(0, config);
 
return 0; // no error
}
/trunk/apps/sequencers/midibox_seq_v4_lite/Makefile
26,6 → 26,7
core/seq_ui_pages.c \
core/seq_ui_util.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_led.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_blm8x8.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_tpd.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_cv.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_midi_port.c \
122,9 → 123,6
# BLM_CHEAPO driver
include $(MIOS32_PATH)/modules/blm_cheapo/blm_cheapo.mk
 
# BLM_X
include $(MIOS32_PATH)/modules/blm_x/blm_x.mk
 
# BLM_SCALAR_MASTER
include $(MIOS32_PATH)/modules/blm_scalar_master/blm_scalar_master.mk
 
/trunk/apps/sequencers/midibox_seq_v4/core/app.c
27,7 → 27,6
#else
#include <blm_cheapo.h>
#endif
#include <blm_x.h>
#include <blm_scalar_master.h>
#include <ws2812.h>
 
41,6 → 40,7
 
#include "seq_core.h"
#include "seq_led.h"
#include "seq_blm8x8.h"
#include "seq_tpd.h"
#include "seq_ui.h"
#include "seq_pattern.h"
119,7 → 119,7
#else
BLM_CHEAPO_Init(0);
#endif
BLM_X_Init();
SEQ_BLM8X8_Init(0);
 
WS2812_Init(0);
 
260,7 → 260,7
 
if( seq_hwcfg_blm8x8.enabled ) {
// prepare DOUT registers of 8x8 BLM to drive the row
BLM_X_PrepareRow();
SEQ_BLM8X8_PrepareRow();
}
 
// TK: using MIOS32_DOUT_SRSet/PinSet instead of SEQ_LED_SRSet/PinSet to ensure compatibility with MBSEQV4L
359,7 → 359,7
 
if( seq_hwcfg_blm8x8.enabled ) {
// call the BL_X_GetRow function after scan is finished to capture the read DIN values
BLM_X_GetRow();
SEQ_BLM8X8_GetRow();
}
}
 
415,14 → 415,14
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called when a BLM_X button has been toggled
// This hook is called when a SEQ_BLM8X8 button has been toggled
// (see also SEQ_TASK_Period1mS)
// pin_value is 1 when button released, and 0 when button pressed
/////////////////////////////////////////////////////////////////////////////
void APP_BLM_X_NotifyToggle(u32 pin, u32 pin_value)
void APP_SEQ_BLM8X8_NotifyToggle(u8 blm, u32 pin, u32 pin_value)
{
if( app_din_testmode ) {
DEBUG_MSG("[DIN_TESTMODE] BLM8x8 Pin M%d D%d %s\n", (pin>>3)+1, pin&7, pin_value ? "depressed" : "pressed");
DEBUG_MSG("[DIN_TESTMODE] BLM8x8%c Pin M%d D%d %s\n", 'A'+blm, (pin>>3)+1, pin&7, pin_value ? "depressed" : "pressed");
}
 
#ifndef MBSEQV4L
504,8 → 504,8
#endif
 
if( seq_hwcfg_blm8x8.enabled ) {
// check for BLM_X pin changes, call button handler of sequencer on each toggled pin
BLM_X_BtnHandler(APP_BLM_X_NotifyToggle);
// check for SEQ_BLM8X8 pin changes, call button handler of sequencer on each toggled pin
SEQ_BLM8X8_ButtonHandler(APP_SEQ_BLM8X8_NotifyToggle);
}
#endif
}
/trunk/apps/sequencers/midibox_seq_v4/core/seq_hwcfg.c
20,7 → 20,7
 
#include <mios32.h>
 
#include <blm_x.h>
#include <seq_blm8x8.h>
#include "seq_hwcfg.h"
 
 
540,10 → 540,16
for(i=0; i<SEQ_HWCFG_NUM_SR_CV_GATES; ++i)
seq_hwcfg_cv_gate_sr[i] = 0;
 
// initial debounce delay for BLM_X
blm_x_config_t config = BLM_X_ConfigGet();
config.debounce_delay = 20; // mS
BLM_X_ConfigSet(config);
// initial debounce delay for BLM8x8
{
int blm;
 
for(blm=0; blm<SEQ_BLM8X8_NUM; ++blm) {
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.debounce_delay = 20; // mS
SEQ_BLM8X8_ConfigSet(blm, config);
}
}
 
return 0; // no error
}
/trunk/apps/sequencers/midibox_seq_v4/core/seq_ui.c
18,7 → 18,6
#include <mios32.h>
#include <string.h>
#include <blm.h>
#include <blm_x.h>
#include <seq_midi_out.h>
#include <seq_bpm.h>
#include <blm_scalar_master.h>
31,6 → 30,7
#include "seq_hwcfg.h"
#include "seq_lcd.h"
#include "seq_led.h"
#include "seq_blm8x8.h"
#include "seq_midply.h"
#include "seq_mixer.h"
#include "seq_live.h"
3197,9 → 3197,9
gp_mask <<= 1;
 
u8 mapped_sr = blm_x_sr_map[sr];
BLM_X_LED_rows[mapped_sr][0] = (BLM_X_LED_rows[mapped_sr][0] & 0x0f) | pattern;
seq_blm8x8_led_row[0][mapped_sr] = (seq_blm8x8_led_row[0][mapped_sr] & 0x0f) | pattern;
}
} else if( seq_hwcfg_blm8x8.dout_gp_mapping == 2 ) {
} else if( seq_hwcfg_blm8x8.dout_gp_mapping == 3 ) {
// for Antilog frontpanel
 
// BLM_X DOUT -> GP LED mapping
3229,7 → 3229,7
if( modified_gp_leds & (1 << 3) ) value |= (1 << 7);
if( pos_marker_mask & (1 << 3) ) value |= (1 << 6);
 
BLM_X_LED_rows[1][0] = value;
seq_blm8x8_led_row[0][1] = value;
}
 
// GP row, second quarter
3248,10 → 3248,48
if( modified_gp_leds & (1 << 7) ) value |= (1 << 7);
if( pos_marker_mask & (1 << 7) ) value |= (1 << 6);
 
BLM_X_LED_rows[5][0] = value;
seq_blm8x8_led_row[0][5] = value;
}
 
// GP row, third quarter
{
u8 value = 0;
 
if( modified_gp_leds & (1 << 8) ) value |= (1 << 0);
if( pos_marker_mask & (1 << 8) ) value |= (1 << 1);
 
if( modified_gp_leds & (1 << 9) ) value |= (1 << 3);
if( pos_marker_mask & (1 << 9) ) value |= (1 << 2);
 
if( modified_gp_leds & (1 << 10) ) value |= (1 << 5);
if( pos_marker_mask & (1 << 10) ) value |= (1 << 4);
 
if( modified_gp_leds & (1 << 11) ) value |= (1 << 7);
if( pos_marker_mask & (1 << 11) ) value |= (1 << 6);
 
seq_blm8x8_led_row[1][1] = value;
}
 
// GP row, fourth quarter
{
u8 value = 0;
 
if( modified_gp_leds & (1 << 12) ) value |= (1 << 0);
if( pos_marker_mask & (1 << 12) ) value |= (1 << 1);
 
if( modified_gp_leds & (1 << 13) ) value |= (1 << 3);
if( pos_marker_mask & (1 << 13) ) value |= (1 << 2);
 
if( modified_gp_leds & (1 << 14) ) value |= (1 << 5);
if( pos_marker_mask & (1 << 14) ) value |= (1 << 4);
 
if( modified_gp_leds & (1 << 15) ) value |= (1 << 7);
if( pos_marker_mask & (1 << 15) ) value |= (1 << 6);
 
seq_blm8x8_led_row[1][5] = value;
}
 
 
// BLM_X DOUT -> Select LED mapping
// like above, just next SR
 
3271,7 → 3309,7
if( ui_select_leds_green & (1 << 3) ) value |= (1 << 7);
if( ui_select_leds_red & (1 << 3) ) value |= (1 << 6);
 
BLM_X_LED_rows[2][0] = value;
seq_blm8x8_led_row[0][2] = value;
}
 
// Select row, second quarter
3290,8 → 3328,46
if( ui_select_leds_green & (1 << 7) ) value |= (1 << 7);
if( ui_select_leds_red & (1 << 7) ) value |= (1 << 6);
 
BLM_X_LED_rows[6][0] = value;
seq_blm8x8_led_row[0][6] = value;
}
 
// Select row, third quarter
{
u8 value = 0;
 
if( ui_select_leds_green & (1 << 8) ) value |= (1 << 0);
if( ui_select_leds_red & (1 << 8) ) value |= (1 << 1);
 
if( ui_select_leds_green & (1 << 9) ) value |= (1 << 3);
if( ui_select_leds_red & (1 << 9) ) value |= (1 << 2);
 
if( ui_select_leds_green & (1 << 10) ) value |= (1 << 5);
if( ui_select_leds_red & (1 << 10) ) value |= (1 << 4);
 
if( ui_select_leds_green & (1 << 11) ) value |= (1 << 7);
if( ui_select_leds_red & (1 << 11) ) value |= (1 << 6);
 
seq_blm8x8_led_row[1][2] = value;
}
 
// Select row, fourth quarter
{
u8 value = 0;
 
if( ui_select_leds_green & (1 << 12) ) value |= (1 << 0);
if( ui_select_leds_red & (1 << 12) ) value |= (1 << 1);
 
if( ui_select_leds_green & (1 << 13) ) value |= (1 << 3);
if( ui_select_leds_red & (1 << 13) ) value |= (1 << 2);
 
if( ui_select_leds_green & (1 << 14) ) value |= (1 << 5);
if( ui_select_leds_red & (1 << 14) ) value |= (1 << 4);
 
if( ui_select_leds_green & (1 << 15) ) value |= (1 << 7);
if( ui_select_leds_red & (1 << 15) ) value |= (1 << 6);
 
seq_blm8x8_led_row[1][6] = value;
}
}
}
 
/trunk/apps/sequencers/midibox_seq_v4/core/seq_blm8x8.c
New file
0,0 → 1,346
// $Id$
/*
* Button/LED Matrix Handler
*
* ==========================================================================
*
* Copyright (C) 2017 Thorsten Klose (tk@midibox.org)
* Licensed for personal non-commercial use only.
* All other rights reserved.
*
* ==========================================================================
*/
 
/////////////////////////////////////////////////////////////////////////////
// Include files
/////////////////////////////////////////////////////////////////////////////
 
#include <mios32.h>
 
#include "seq_blm8x8.h"
 
 
/////////////////////////////////////////////////////////////////////////////
// Global variables
/////////////////////////////////////////////////////////////////////////////
 
u8 seq_blm8x8_led_row[SEQ_BLM8X8_NUM][8];
 
 
/////////////////////////////////////////////////////////////////////////////
// Local variables
/////////////////////////////////////////////////////////////////////////////
 
static u8 seq_blm8x8_button_row[SEQ_BLM8X8_NUM][8];
static u8 seq_blm8x8_button_row_changed[SEQ_BLM8X8_NUM][8];
 
static u8 seq_blm8x8_current_row;
static u8 seq_blm8x8_debounce_ctr;
 
static seq_blm8x8_config_t seq_blm8x8_config[SEQ_BLM8X8_NUM];
 
/////////////////////////////////////////////////////////////////////////////
// Initialisation
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_BLM8X8_Init(u32 mode)
{
int blm;
 
seq_blm8x8_config_t *config = (seq_blm8x8_config_t *)&seq_blm8x8_config[0];
for(blm=0; blm<SEQ_BLM8X8_NUM; ++blm, ++config) {
int i;
 
for(i=0; i<8; ++i) {
seq_blm8x8_led_row[blm][i] = 0x00;
seq_blm8x8_button_row[blm][i] = 0xff;
seq_blm8x8_button_row_changed[blm][i] = 0x00;
}
 
config->rowsel_dout_sr = 0;
config->led_dout_sr = 0;
config->button_din_sr = 0;
config->rowsel_inv_mask = 0x00;
config->col_inv_mask = 0x00;
config->debounce_delay = 0;
}
 
seq_blm8x8_current_row = 0;
seq_blm8x8_debounce_ctr = 0;
 
return 0;
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This function prepares the DOUT register to drive a row
// It should be called from the APP_SRIO_ServicePrepare
// IN: -
// OUT: returns -1 on errors
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_BLM8X8_PrepareRow(void)
{
// increment current row, wrap at 8
if( ++seq_blm8x8_current_row >= 8 )
seq_blm8x8_current_row = 0;
 
u8 rowsel_value = ~(1 << seq_blm8x8_current_row);
 
int blm;
seq_blm8x8_config_t *config = (seq_blm8x8_config_t *)&seq_blm8x8_config[0];
for(blm=0; blm<SEQ_BLM8X8_NUM; ++blm, ++config) {
// cathode
if( config->rowsel_dout_sr ) {
MIOS32_DOUT_SRSet(config->rowsel_dout_sr - 1, rowsel_value ^ config->rowsel_inv_mask);
}
 
// anode
if( config->led_dout_sr ) {
MIOS32_DOUT_SRSet(config->led_dout_sr - 1, seq_blm8x8_led_row[blm][seq_blm8x8_current_row] ^ config->col_inv_mask);
}
}
 
return 0;
}
 
/////////////////////////////////////////////////////////////////////////////
// This function gets the DIN values of the selected row
// It should be called from the APP_SRIO_ServiceFinish hook
// IN: -
// OUT: returns -1 on errors
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_BLM8X8_GetRow(void)
{
u8 scanned_row = seq_blm8x8_current_row ? (seq_blm8x8_current_row - 1) : (8 - 1);
 
int blm;
seq_blm8x8_config_t *config = (seq_blm8x8_config_t *)&seq_blm8x8_config[0];
 
for(blm=0; blm<SEQ_BLM8X8_NUM; ++blm, ++config) {
 
if( config->button_din_sr ) {
u8 sr = config->button_din_sr - 1;
 
// ensure that change won't be propagated to normal DIN handler
MIOS32_DIN_SRChangedGetAndClear(sr, 0xff);
 
// cheap debounce handling. ignore any changes if debounce_ctr > 0
if( !seq_blm8x8_debounce_ctr ) {
u8 sr_value = MIOS32_DIN_SRGet(sr);
 
// *** set change notification and new value. should not be interrupted ***
MIOS32_IRQ_Disable();
 
// if a second change happens before the last change was notified (clear
// changed flags), the change flag will be unset (two changes -> original value)
if( seq_blm8x8_button_row_changed[blm][scanned_row] ^= (sr_value ^ seq_blm8x8_button_row[blm][scanned_row]) ) {
seq_blm8x8_debounce_ctr = config->debounce_delay; // restart debounce delay
}
 
// copy new values to seq_led_matrix_button_rows
seq_blm8x8_button_row[blm][scanned_row] = sr_value;
MIOS32_IRQ_Enable();
// *** end atomic block ***
} else {
--seq_blm8x8_debounce_ctr; // decrement debounce control
}
}
}
 
return 0;
}
 
/////////////////////////////////////////////////////////////////////////////
// This function should be called from a task to check for button changes
// periodically. Events (change from 0->1 or from 1->0) will be notified
// via the given callback function <notify_hook> with following parameters:
// <notifcation-hook>(u32 btn, u32 value)
// IN: -
// OUT: returns -1 on errors
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_BLM8X8_ButtonHandler(void *_notify_hook)
{
void (*notify_hook)(u8 blm, u32 pin, u32 value) = _notify_hook;
 
// no hook?
if( _notify_hook == NULL )
return -2;
 
int blm;
for(blm=0; blm<SEQ_BLM8X8_NUM; ++blm) {
int row;
 
u8 *button_row = (u8 *)&seq_blm8x8_button_row[blm][0];
u8 *button_row_changed = (u8 *)&seq_blm8x8_button_row_changed[blm][0];
 
for(row=0; row<8; ++row, ++button_row, ++button_row_changed) {
// *** fetch changed / values, reset changed. should not be interrupted ***
MIOS32_IRQ_Disable();
u8 changed = *button_row_changed;
u8 values = *button_row;
*button_row_changed = 0;
MIOS32_IRQ_Enable();
// *** end atomic block ***
 
// check if any changes in this row
if( !changed )
continue;
 
// ..walk pins and notify changes
int pin;
u8 pin_mask = 0x01;
for(pin=0; pin < 8; ++pin, pin_mask <<= 1) {
if( changed & pin_mask )
notify_hook(blm, row*8 + pin, (values & pin_mask) ? 1 : 0);
}
}
}
 
return 0;
}
 
 
/////////////////////////////////////////////////////////////////////////////
// returns a button's state
// IN: button number
// OUT: button value (0 or 1), returns < 0 if button not available
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_BLM8X8_ButtonGet(u8 blm, u32 button)
{
if( blm >= SEQ_BLM8X8_NUM )
return -1;
 
if( button >= 64 )
return -2;
 
return (seq_blm8x8_button_row[blm][button/8] & (1 << (button % 8))) ? 1 : 0;
}
 
/////////////////////////////////////////////////////////////////////////////
// returns the buttons serial-register value for a row / SR
// IN: button row in <row>, row-SR in <sr>
// OUT: serial register value (0 if register not available)
/////////////////////////////////////////////////////////////////////////////
u8 SEQ_BLM8X8_ButtonSRGet(u8 blm, u8 row)
{
if( blm >= SEQ_BLM8X8_NUM )
return -1;
 
if( row >= 8 )
return -2;
 
return seq_blm8x8_button_row[blm][row];
}
 
 
/////////////////////////////////////////////////////////////////////////////
// sets a LED's value
// IN: LED number in <led>, LED value in <value>
// OUT: returns < 0 if LED not available
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_BLM8X8_LEDSet(u8 blm, u8 led, u8 value)
{
if( blm >= SEQ_BLM8X8_NUM )
return -1;
 
if( led >= 64 )
return -2;
 
if( value ) {
seq_blm8x8_led_row[blm][led/8] |= (1 << (led % 8));
} else {
seq_blm8x8_led_row[blm][led/8] &= ~(1 << (led % 8));
}
 
return 0; // no error
}
 
/////////////////////////////////////////////////////////////////////////////
// returns the status of a LED
// IN: LED number in <led>
// OUT: returns LED state value or < 0 if pin not available
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_BLM8X8_LEDGet(u8 blm, u8 led)
{
if( blm >= SEQ_BLM8X8_NUM )
return -1;
 
if( led >= 64 )
return -2;
 
return (seq_blm8x8_led_row[blm][led/8] & (1 << (led % 8))) ? 1 : 0;
}
 
/////////////////////////////////////////////////////////////////////////////
// returns the LED serial-register value for a row / SR
// IN: LED row in <row>, row-SR in <sr>
// OUT: serial register value (0 if register not available)
/////////////////////////////////////////////////////////////////////////////
u8 SEQ_BLM8X8_LEDSRGet(u8 blm, u8 row)
{
if( blm >= SEQ_BLM8X8_NUM )
return -1;
 
if( row >= 8 )
return -2;
 
return seq_blm8x8_led_row[blm][row];
}
 
 
/////////////////////////////////////////////////////////////////////////////
// sets the LED serial-register value for a row / sr
// IN: LED row in <row>, row-SR in <sr>
// OUT: < 0 on error (SR not available), 0 on success
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_BLM8X8_LEDSRSet(u8 blm, u8 row, u8 sr_value)
{
if( blm >= SEQ_BLM8X8_NUM )
return -1;
 
if( row >= 8 )
return -2;
 
seq_blm8x8_led_row[blm][row] = sr_value;
 
return 0; // no error
}
 
/////////////////////////////////////////////////////////////////////////////
// sets the seq_blm8x8 soft configurations
// IN: config, struct with members:
// .rowsel_dout_sr
// .led_dout_sr
// .button_din_sr
// .rowsel_inv_mask
// .col_inv_mask
// .debounce_delay
// OUT: returns < 0 on error, 0 on success
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_BLM8X8_ConfigSet(u8 blm, seq_blm8x8_config_t config)
{
if( blm >= SEQ_BLM8X8_NUM )
return -1;
 
seq_blm8x8_config[blm] = config;
 
return 0; // no error
}
 
/////////////////////////////////////////////////////////////////////////////
// gets the seq_blm8x8 soft configurations
// IN: -
// OUT: struct with members:
// .rowsel_dout_sr
// .led_dout_sr
// .button_din_sr
// .rowsel_inv_mask
// .col_inv_mask
// .debounce_delay
/////////////////////////////////////////////////////////////////////////////
seq_blm8x8_config_t SEQ_BLM8X8_ConfigGet(u8 blm)
{
if( blm >= SEQ_BLM8X8_NUM )
blm = 0;
 
return seq_blm8x8_config[blm];
}
Property changes:
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: midibox_seq_v4/core/seq_blm8x8.h
===================================================================
--- midibox_seq_v4/core/seq_blm8x8.h (revision 0)
+++ midibox_seq_v4/core/seq_blm8x8.h (revision 2531)
@@ -0,0 +1,71 @@
+// $Id$
+/*
+ * Header file for SEQ Button/LED Matrix handler
+ *
+ * ==========================================================================
+ *
+ * Copyright (C) 2017 Thorsten Klose (tk@midibox.org)
+ * Licensed for personal non-commercial use only.
+ * All other rights reserved.
+ *
+ * ==========================================================================
+ */
+
+#ifndef _SEQ_BLM8X8_H
+#define _SEQ_BLM8X8_H
+
+/////////////////////////////////////////////////////////////////////////////
+// Global definitions
+/////////////////////////////////////////////////////////////////////////////
+
+// number of 8x8 matrices
+#ifndef SEQ_BLM8X8_NUM
+#define SEQ_BLM8X8_NUM 3
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Global Types
+/////////////////////////////////////////////////////////////////////////////
+
+typedef struct {
+ u8 rowsel_dout_sr;
+ u8 led_dout_sr;
+ u8 button_din_sr;
+ u8 rowsel_inv_mask;
+ u8 col_inv_mask;
+ u8 debounce_delay;
+} seq_blm8x8_config_t;
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+extern s32 SEQ_BLM8X8_Init(u32 mode);
+
+extern s32 SEQ_BLM8X8_PrepareRow(void);
+extern s32 SEQ_BLM8X8_GetRow(void);
+extern s32 SEQ_BLM8X8_ButtonHandler(void *notify_hook);
+
+extern s32 SEQ_BLM8X8_ButtonGet(u8 blm, u32 button);
+extern u8 SEQ_BLM8X8_ButtonSRGet(u8 blm, u8 row);
+
+extern s32 SEQ_BLM8X8_LEDSet(u8 blm, u8 led, u8 value);
+extern s32 SEQ_BLM8X8_LEDSRSet(u8 blm, u8 row, u8 sr_value);
+
+extern s32 SEQ_BLM8X8_LEDGet(u8 blm, u8 led);
+extern u8 SEQ_BLM8X8_LEDSRGet(u8 blm, u8 row);
+
+extern s32 SEQ_BLM8X8_ConfigSet(u8 blm, seq_blm8x8_config_t config);
+extern seq_blm8x8_config_t SEQ_BLM8X8_ConfigGet(u8 blm);
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Export global variables
+/////////////////////////////////////////////////////////////////////////////
+
+u8 seq_blm8x8_led_row[SEQ_BLM8X8_NUM][8];
+
+
+#endif /* _SEQ_BLM8X8_H */
/midibox_seq_v4/core/seq_blm8x8.h
Property changes:
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: midibox_seq_v4/core/seq_led.c
===================================================================
--- midibox_seq_v4/core/seq_led.c (revision 2530)
+++ midibox_seq_v4/core/seq_led.c (revision 2531)
@@ -17,9 +17,8 @@
#include <mios32.h>
-#include <blm_x.h>
-
#include "seq_led.h"
+#include "seq_blm8x8.h"
#include "seq_hwcfg.h"
#include "seq_file_hw.h"
@@ -72,7 +71,7 @@
}
}
- return BLM_X_LEDSet(pin-184, 0, value);
+ return SEQ_BLM8X8_LEDSet(0, pin-184, value);
}
return -1; // pin not available
@@ -111,7 +110,7 @@
value = mios32_dout_reverse_tab[value];
}
- return BLM_X_LEDSRSet(sr-23, 0, value);
+ return SEQ_BLM8X8_LEDSRSet(0, sr-23, value);
}
return -1; // SR not available
@@ -135,7 +134,7 @@
#endif
if( sr >= 23 && sr < 31 ) {
- u8 value = BLM_X_LEDSRGet(sr-23, 0);
+ u8 value = SEQ_BLM8X8_LEDSRGet(0, sr-23);
if( seq_hwcfg_blm8x8.dout_gp_mapping == 2 && sr >= 27 ) {
// MBSEQ V4L SRIO Board
/trunk/apps/sequencers/midibox_seq_v4/core/seq_file_hw.c
27,7 → 27,6
#include <aout.h>
#include <seq_cv.h>
#include <blm.h>
#include <blm_x.h>
 
#include "file.h"
#include "seq_file.h"
35,6 → 34,8
 
#include "seq_hwcfg.h"
 
#include "seq_blm8x8.h"
 
#include "seq_ui.h"
#include "seq_ui_pages.h"
#include "seq_midi_port.h"
1058,30 → 1059,32
DEBUG_MSG("[SEQ_FILE_HW] BLM8X8_%s: %d", parameter, value);
#endif
 
int blm = 0; // TODO: multiple BLMs
 
if( strcasecmp(parameter, "ENABLED") == 0 ) {
seq_hwcfg_blm8x8.enabled = value;
} else if( strcasecmp(parameter, "DOUT_CATHODES_SR") == 0 ) {
blm_x_config_t config = BLM_X_ConfigGet();
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.rowsel_dout_sr = value;
BLM_X_ConfigSet(config);
SEQ_BLM8X8_ConfigSet(blm, config);
} else if( strcasecmp(parameter, "DOUT_CATHODES_INV_MASK") == 0 ) {
blm_x_config_t config = BLM_X_ConfigGet();
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.rowsel_inv_mask = value;
BLM_X_ConfigSet(config);
SEQ_BLM8X8_ConfigSet(blm, config);
} else if( strcasecmp(parameter, "DOUT_ANODES_INV_MASK") == 0 ) {
blm_x_config_t config = BLM_X_ConfigGet();
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.col_inv_mask = value;
BLM_X_ConfigSet(config);
SEQ_BLM8X8_ConfigSet(blm, config);
} else if( strcasecmp(parameter, "DOUT_LED_SR") == 0 ) {
blm_x_config_t config = BLM_X_ConfigGet();
config.led_first_dout_sr = value;
BLM_X_ConfigSet(config);
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.led_dout_sr = value;
SEQ_BLM8X8_ConfigSet(blm, config);
} else if( strcasecmp(parameter, "DOUT_GP_MAPPING") == 0 ) {
seq_hwcfg_blm8x8.dout_gp_mapping = value;
} else if( strcasecmp(parameter, "DIN_SR") == 0 ) {
blm_x_config_t config = BLM_X_ConfigGet();
config.btn_first_din_sr = value;
BLM_X_ConfigSet(config);
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.button_din_sr = value;
SEQ_BLM8X8_ConfigSet(blm, config);
} else {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_HW] ERROR: unknown BLM8X8_* name '%s'!", parameter);
1346,11 → 1349,17
// common DINs
MIOS32_SRIO_DebounceSet(delay);
 
// BLM_X based DINs
blm_x_config_t config = BLM_X_ConfigGet();
config.debounce_delay = delay;
BLM_X_ConfigSet(config);
// SEQ_BLM8X8 based DINs
{
int blm;
 
for(blm=0; blm<SEQ_BLM8X8_NUM; ++blm) {
seq_blm8x8_config_t config = SEQ_BLM8X8_ConfigGet(blm);
config.debounce_delay = delay;
SEQ_BLM8X8_ConfigSet(blm, config);
}
}
 
} else if( strcasecmp(parameter, "AOUT_INTERFACE_TYPE") == 0 ) {
// only for compatibility reasons - AOUT interface is stored in MBSEQ_GC.V4 now!
// can be removed once most users switched to beta28 and later!
/trunk/apps/sequencers/midibox_seq_v4/Makefile
114,6 → 114,7
core/seq_terminal.c \
core/seq_statistics.c \
core/seq_led.c \
core/seq_blm8x8.c \
core/seq_tpd.c
 
# (following source stubs not relevant for Cortex M3 derivatives)
155,9 → 156,6
# BLM
include $(MIOS32_PATH)/modules/blm/blm.mk
 
# BLM_X
include $(MIOS32_PATH)/modules/blm_x/blm_x.mk
 
# BLM_SCALAR_MASTER
include $(MIOS32_PATH)/modules/blm_scalar_master/blm_scalar_master.mk
 
/trunk/apps/sequencers/midibox_seq_v4/hwcfg/wilba_tpd/MBSEQ_HW.V4
248,8 → 248,9
BLM8X8_DOUT_LED_SR 2
 
# 0: no mapping of 8x8 LEDs
# 1: enable GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: enable GP LED -> matrix mapping for Antilog PCB
# 1: select GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: select LED mapping for MBSEQ V4L SRIO board
# 3: select GP LED -> matrix mapping for Antilog PCB
BLM8X8_DOUT_GP_MAPPING 1
 
# 8x8 matrix for misc. button functions
/trunk/apps/sequencers/midibox_seq_v4/hwcfg/standard_v4/MBSEQ_HW.V4
247,8 → 247,9
BLM8X8_DOUT_LED_SR 2
 
# 0: no mapping of 8x8 LEDs
# 1: enable GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: enable GP LED -> matrix mapping for Antilog PCB
# 1: select GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: select LED mapping for MBSEQ V4L SRIO board
# 3: select GP LED -> matrix mapping for Antilog PCB
BLM8X8_DOUT_GP_MAPPING 1
 
# 8x8 matrix for misc. button functions
/trunk/apps/sequencers/midibox_seq_v4/hwcfg/antilog/MBSEQ_HW.V4
247,9 → 247,10
BLM8X8_DOUT_LED_SR 2
 
# 0: no mapping of 8x8 LEDs
# 1: enable GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: enable GP LED -> matrix mapping for Antilog PCB
BLM8X8_DOUT_GP_MAPPING 2
# 1: select GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: select LED mapping for MBSEQ V4L SRIO board
# 3: select GP LED -> matrix mapping for Antilog PCB
BLM8X8_DOUT_GP_MAPPING 3
 
# 8x8 matrix for misc. button functions
BLM8X8_DIN_SR 2
/trunk/apps/sequencers/midibox_seq_v4/hwcfg/tk/MBSEQ_HW.V4
247,8 → 247,9
BLM8X8_DOUT_LED_SR 2
 
# 0: no mapping of 8x8 LEDs
# 1: enable GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: enable GP LED -> matrix mapping for Antilog PCB
# 1: select GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: select LED mapping for MBSEQ V4L SRIO board
# 3: select GP LED -> matrix mapping for Antilog PCB
BLM8X8_DOUT_GP_MAPPING 1
 
# 8x8 matrix for misc. button functions
/trunk/apps/sequencers/midibox_seq_v4/hwcfg/wilba/MBSEQ_HW.V4
247,8 → 247,9
BLM8X8_DOUT_LED_SR 2
 
# 0: no mapping of 8x8 LEDs
# 1: enable GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: enable GP LED -> matrix mapping for Antilog PCB
# 1: select GP LED -> 8x8 matrix mapping for Wilba's MB-SEQ PCB
# 2: select LED mapping for MBSEQ V4L SRIO board
# 3: select GP LED -> matrix mapping for Antilog PCB
BLM8X8_DOUT_GP_MAPPING 1
 
# 8x8 matrix for misc. button functions