mcan
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mcan [2018/08/03 11:40] – [Basic Mode, declare and use] antichambre | mcan [2018/08/03 12:53] (current) – [A basic example] antichambre | ||
|---|---|---|---|
| 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 | + | ===== 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 297: | Line 297: | ||
| There a few options you can override here... | There a few options you can override here... | ||
| <code c [mios32_config.h]> | <code c [mios32_config.h]> | ||
| - | /* the use of MCAN must be precised. | + | /* the use of CAN Controller |
| */ | */ | ||
| #define MIOS32_USE_CAN | #define MIOS32_USE_CAN | ||
| Line 395: | Line 395: | ||
| ---- | ---- | ||
| - | ===== MIOS32_CAN_MIDI | + | ===== MIOS32_CAN_MIDI ===== |
| ==== Package and Packet ==== | ==== Package and Packet ==== | ||
| Like the others MIDI peripherals, | Like the others MIDI peripherals, | ||
| 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 |
| <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 lo center> an 0xf8 MIDI Clock over the port MCAN2.</ | ||
| - | **Voice messages** | + | ==== Voice packet |
| <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/ | <wrap lo center> Program: 33, on MCAN3/ | ||
| - | **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 | ||
| </ | </ | ||
| - | <wrap lo>Done! MCAN is ready!</ | + | <wrap lo>Done! MCAN is ready!</ |
| - | ==== 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> | ||
| + | {{: | ||
| + | </ | ||
| + | |||
| + | <WRAP half column> | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | \\ | ||
| + | |||
| + | \\ | ||
| + | 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 | ||
| + | </ | ||
| + | \\ | ||
| + | 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); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | \\ | ||
| + | **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.1533296431.txt.gz · Last modified: 2018/08/03 11:40 by antichambre
