MIOS32_DONT_SERVICE_SRIO_SCAN & Shiftregistors

i have a small 25keys keyboard here (alesis proton x25), i managed to get the keys velocity sensitive to working, the connector is 1:1 to the DIO-Matrix —lucky me!

 

but i run into the problem that the code uses:

#define MIOS32\_DONT\_SERVICE\_SRIO\_SCAN 1

which disables my normal Shiftregisters for Encoder I cant use the J10 or J5 for it, because they have to less pins, and they are already used for other stuff anyway…

 

How can i use the Shiftregistors?  … i have 4 DIN and 4 DOUT Registor in addition to the MB-DIO-Matrix

 

I read that in for example the MB-KB code:

///////////////////////////////////////////////////////////////////////////// // This hook is called after the shift register chain has been scanned ///////////////////////////////////////////////////////////////////////////// void APP\_SRIO\_ServiceFinish(void) { // -\> keyboard handler KEYBOARD\_SRIO\_ServiceFinish(); // standard SRIO scan has been disabled in programming\_models/traditional/main.c via MIOS32\_DONT\_SERVICE\_SRIO\_SCAN in mios32\_config.h // start the scan here - and retrigger it whenever it's finished APP\_SRIO\_ServicePrepare(); MIOS32\_SRIO\_ScanStart(APP\_SRIO\_ServiceFinish); }

i dont know what that mean? should it still working then?

 

 i found out, that i still can activate LEDs, and i get the DIN-States, however i dont get any ENC Values

 

The Hardware itself is functional since i debugged it with tutorials/015_enc_absolute

 

i am pretty sure that something in here, break the enc routin e:

void APP\_SRIO\_ServicePrepare(void){ // select next column, wrap at 16 if( ++selected\_row \>= MATRIX\_NUM\_ROWS ) { selected\_row = 0; // increment timestamp for velocity delay measurements ++timestamp; } // selection pattern (active selection is 0, all other outputs 1) u16 selection\_mask = ~(1 \<\< (u16)selected\_row); // transfer to DOUTs #if MATRIX\_DOUT\_SR1 MIOS32\_DOUT\_SRSet(MATRIX\_DOUT\_SR1-1, (selection\_mask \>\> 0) & 0xff); #endif #if MATRIX\_DOUT\_SR2 MIOS32\_DOUT\_SRSet(MATRIX\_DOUT\_SR2-1, (selection\_mask \>\> 8) & 0xff); #endif} } void APP\_SRIO\_ServiceFinish(void) { // check DINs #if MATRIX\_DIN\_SR // the DIN scan was done with previous row selection, not the current one: int prev\_row = selected\_row ? (selected\_row - 1) : (MATRIX\_NUM\_ROWS - 1); u8 sr = MATRIX\_DIN\_SR; MIOS32\_DIN\_SRChangedGetAndClear(sr-1, 0xff); // ensure that change won't be propagated to normal DIN handler u8 sr\_value = MIOS32\_DIN\_SRGet(sr-1); // determine pin changes u8 changed = sr\_value ^ din\_value[prev\_row]; if( changed ) { // add them to existing notifications din\_value\_changed[prev\_row] |= changed; // store new value din\_value[prev\_row] = sr\_value; // store timestamp for changed pin on 1-\>0 transition u8 sr\_pin; u8 mask = 0x01; for(sr\_pin=0; sr\_pin\<8; ++sr\_pin, mask \<\<= 1) { if( (changed & mask) && !(sr\_value & mask) ) { din\_activated\_timestamp[prev\_row\*8 + sr\_pin] = timestamp; } } } #endif // standard SRIO scan has been disabled in programming\_models/traditional/main.c via MIOS32\_DONT\_SERVICE\_SRIO\_SCAN in mios32\_config.h // start the scan here - and retrigger it whenever it's finished APP\_SRIO\_ServicePrepare(); MIOS32\_SRIO\_ScanStart(APP\_SRIO\_ServiceFinish); }

 

or could J19 (SPI2) reused, for a second “J8/J9” like SR “Chain”? (has this already some one done, which app?)

J16 cant be used because of:

Quote

J16 is normaly connected to a SD Card

Quote

J19 doesn’t support DMA transfers, so that [MIOS32_SPI_TransferBlock()](http://www.midibox.org/mios32/manual/group m_i_o_s32 s_p_i.html#gabcdae72100df8b893ee4684ad6763afb) will consume CPU time (but the callback handling does work).

so maybe not…

&&

Quote

MIOS32_spi.c says:

//! J19 provides SPI + two RCLK lines at 5V.
//! It’s some kind of general purpose SPI, and used to communicate with
//! various MBHP modules, such as MBHP_AOUT* and MBHP_AINSER*

 

 

 

…By the way this is the Keyboard Layout…:

 

and thats the midibox stuff… its getting pretty full in there :wink:

 

For scanning encoders just call MIOS32_ENC_UpdateStates before APP_SRIO_Prepare()

See also MBNG application, search for MIOS32_ENC_UpdateStates: https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/src/app.c

Best Regards, Thorsten.

THX that solved it!