Subversion Repositories svn.mios

Rev

Blame | Last modification | View Log | RSS feed

HEADER 3 MIOS C Example

<H3>Controlling 128 LEDs via MIDI</H3>

<P CLASS=INFO>We want to set/clear LEDs, which are connected to one or more DOUTX4 modules, with Note Events over MIDI Channel #1</P>

<P CLASS=INFO>Copy the SDCC skeleton into a new directory, open the main.c file and enhance the hooks like described below. Thereafter type "make" in the command shell, and upload the new project.hex file to the core.</P>

<P CLASS=INFO>Within the Init() function, you have to specify, how many shift registers are connected to the core:</P>

<TT><PRE>
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the 
// application
/////////////////////////////////////////////////////////////////////////////
void Init(void) __wparam
{
  // set shift register update frequency
  MIOS_SRIO_UpdateFrqSet(1); // ms

  // Up to 4 DOUTX4 modules (=16 shift registers = 128 digital outputs) can be connected
  // set the maximum number here - it doesn't really hurt!
  MIOS_SRIO_NumberSet(16);
}
</PRE></TT>

<P CLASS=INFO>
<TT><PRE>
/////////////////////////////////////////////////////////////////////////////
//  This function is called by MIOS when a complete MIDI event has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedEvnt(
  unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
  // a note event provides 128 different note values (0..127)
  // in this simple example, each note sets an individual pin
  // for DOUT pin numbers, see also this documentation:
  // http://www.ucapps.de/mios/mios_pin_list.txt

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!
    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)
    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off
      MIOS_DOUT_PinSet(pin, 0);

    } else {

      // Note On
      MIOS_DOUT_PinSet(pin, 1);

    }
  }
}
</PRE></TT>

<P CLASS=INFO>A list of available MIOS function can be found <A HREF="cmios_fun.html">here</A>.</P>

FOOTER