User Tools

Site Tools


mcan

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
mcan [2018/08/03 11:40]
antichambre [How to use MIOS32_CAN.]
mcan [2018/08/03 12:53] (current)
antichambre [A basic example]
Line 256: Line 256:
 **But before any MIDI features we need the MIOS32 driver for that CAN controller...** **But before any MIDI features we need the MIOS32 driver for that CAN controller...**
 ---- ----
-===== MIOS32_CAN ​implementation ​=====+===== MIOS32_CAN =====
 ==== CAN controller as a generic peripheral in MIOS32. ==== ==== CAN controller as a generic peripheral in MIOS32. ====
 MIOS32_CAN feature is only compilable under STM32F4.\\ ​ MIOS32_CAN feature is only compilable under STM32F4.\\ ​
Line 395: Line 395:
 ---- ----
  
-===== MIOS32_CAN_MIDI ​implementation ​=====+===== MIOS32_CAN_MIDI =====
 ==== Package and Packet ==== ==== Package and Packet ====
 Like the others MIDI peripherals,​ we need a bridge between our new CAN features(mios32_can.c/​h) and the MIDI process[[http://​www.midibox.org/​mios32/​manual/​group___m_i_o_s32___m_i_d_i.html|(mios32_midi.c/​h)]]\\ Like the others MIDI peripherals,​ we need a bridge between our new CAN features(mios32_can.c/​h) and the MIDI process[[http://​www.midibox.org/​mios32/​manual/​group___m_i_o_s32___m_i_d_i.html|(mios32_midi.c/​h)]]\\
Line 458: Line 458:
 ---- ----
  
-==== Basic Mode ====+===== MCAN Basic Mode =====
 This is the default mode, the funny one, just interconnect some Cores in parallel with J18 and they are able to communicate in MIDI. Easy.\\ This is the default mode, the funny one, just interconnect some Cores in parallel with J18 and they are able to communicate in MIDI. Easy.\\
 In this mode: In this mode:
Line 471: Line 471:
 \\ \\
 \\ \\
-=== Standard Packet in Basic Mode ===+==== Standard Packet in Basic Mode ====
 Even if the MCAN make the MIDI packet for you, let me show you some of them:\\ Even if the MCAN make the MIDI packet for you, let me show you some of them:\\
 The IDE bit in frame is always 0, cause we only use the Standard Id Packet, the Type and the Cable must be placed in the Id.\\ The IDE bit in frame is always 0, cause we only use the Standard Id Packet, the Type and the Cable must be placed in the Id.\\
Line 481: Line 481:
 The Sysex messages are an exception for the DLC, we makes packets of 8 bytes(max) with it, and we mark the packets as Starts, Continues or Ends in the Type field, using the code 0x4, 0x6 and 0x7.\\ The Sysex messages are an exception for the DLC, we makes packets of 8 bytes(max) with it, and we mark the packets as Starts, Continues or Ends in the Type field, using the code 0x4, 0x6 and 0x7.\\
  
-**Real-time messages**+==== Real-time ​packet ​messages ​example ====
 <code c [mios32_midi_pcktype_num_bytes]>​ <code c [mios32_midi_pcktype_num_bytes]>​
   1, // 5: Single-byte system common message   1, // 5: Single-byte system common message
Line 494: Line 494:
 <wrap lo center> an 0xf8 MIDI Clock over the port MCAN2.</​wrap>​\\ <wrap lo center> an 0xf8 MIDI Clock over the port MCAN2.</​wrap>​\\
  
-**Voice messages**+==== Voice packet ​messages ​examples ====
 <code c [mios32_midi_pcktype_num_bytes]>​ <code c [mios32_midi_pcktype_num_bytes]>​
   3, // 8: Note Off   3, // 8: Note Off
Line 517: Line 517:
 <wrap lo center> Program: 33, on MCAN3/​Channel 13.</​wrap>​\\ <wrap lo center> Program: 33, on MCAN3/​Channel 13.</​wrap>​\\
  
-**SysEx messages**+==== SysEx packets message example ====
 <code c [mios32_midi_pcktype_num_bytes]>​ <code c [mios32_midi_pcktype_num_bytes]>​
   3, // 4: SysEx starts   3, // 4: SysEx starts
Line 547: Line 547:
  
 ---- ----
-==== Basic Mode, declare and use ====+===== Basic Mode, declare and use =====
 Just add this lines in your mios32_config.h(your app).\\ Just add this lines in your mios32_config.h(your app).\\
 <code c [mios32_config.h]>​ <code c [mios32_config.h]>​
Line 562: Line 562:
 #define MIOS32_CAN_MIDI_NUM_PORTS 16 #define MIOS32_CAN_MIDI_NUM_PORTS 16
 </​code>​ </​code>​
-<wrap lo>Done! MCAN is ready!</​wrap>​ +<wrap lo>Done! MCAN is ready!</​wrap>​\\ 
-==== Enhanced Mode ====+ 
 +==== A basic example ==== 
 +For this example we will use 2 Cores to get an 8 MIDI ports link between 2 different computers.\\ 
 +\\ 
 +<WRAP group> 
 +<WRAP half column>​ 
 +{{:​antichambre:​mcan_example1.png?​400 |}} 
 +</​WRAP>​ 
 + 
 +<WRAP half column>​ 
 + 
 +</​WRAP>​ 
 +</​WRAP>​ 
 +\\ 
 + 
 +\\ 
 +The USB limits the link to 8 MIDI ports. Don't forget to declare it too.\\ 
 +<code c [mios32_config.h]>​ 
 +/* the use of CAN Controller must be precised.  
 + */ 
 +#define MIOS32_USE_CAN 
 + 
 +/* CAN1 is MCAN must be precised.  
 + */ 
 +#define MIOS32_USE_CAN_MIDI 
 + 
 +/* Number MCAN MIDI Ports, default and max is 16  
 + */ 
 +#define MIOS32_CAN_MIDI_NUM_PORTS 8 
 + 
 +// enable 8 USB MIDI ports 
 +#define MIOS32_USB_MIDI_NUM_PORTS 8 
 +</​code>​ 
 +\\ 
 +Go in your App code and add this lines in your APP_MIDI_NotifyPackage:​\\ 
 +<code c [app.c]>​ 
 +/////////////////////////////////////////////////////////////////////////////​ 
 +// This hook is called when a MIDI package has been received 
 +/////////////////////////////////////////////////////////////////////////////​ 
 +void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package) 
 +
 +  if((port & 0xf0) == MCAN0){ 
 +    // receive the voice messages from MCANx and forward it to the USBx 
 +    MIOS32_MIDI_SendPackage(USB0 + (port & 0x0f), midi_package);​ 
 +     
 +  }else if((port & 0xf0) == USB0){ 
 +    // filter for voice messages from USBx 
 +    if(midi_package.type >= 0x8 && midi_package.type <= 0xe){ 
 +      // forward the voice messages to MCANx 
 +      MIOS32_MIDI_SendPackage(MCAN0 + (port & 0x0f), midi_package);​ 
 +    } 
 +  } 
 +
 +</​code>​\\ 
 +\\ 
 +**Done! Your App with the MCAN(Basic) is ready to upload and is the same for both Cores. 8-) ** 
 +\\ 
 +\\ 
 +\\ 
 + 
 +---- 
 + 
 +===== MCAN Enhanced Mode =====
 <WRAP center round todo 60%> <WRAP center round todo 60%>
  
mcan.1533296453.txt.gz · Last modified: 2018/08/03 11:40 by antichambre