Skip to content

Commit

Permalink
init network after minidexed starts
Browse files Browse the repository at this point in the history
  • Loading branch information
omersiar committed Nov 6, 2024
1 parent 893b9f6 commit 2046d81
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 73 deletions.
9 changes: 8 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ else
export TOOLCHAIN_PREFIX="arm-none-eabi-"
fi

SDHOST=$([ "${RPI}" == 3 ] && echo "" || echo "")

# Define system options
OPTIONS="-o USE_PWM_AUDIO_ON_ZERO -o SAVE_VFP_REGS_ON_IRQ -o REALTIME -o USE_SDHOST -o SCREEN_DMA_BURST_LENGTH=1"
OPTIONS="-o USE_PWM_AUDIO_ON_ZERO -o SAVE_VFP_REGS_ON_IRQ -o REALTIME -o SCREEN_DMA_BURST_LENGTH=1"
if [ "${RPI}" -gt "1" ]; then
OPTIONS="${OPTIONS} -o ARM_ALLOW_MULTI_CORE"
fi

# For wireless access
if [ "${RPI}" == "3" ]; then
OPTIONS="${OPTIONS} -o USE_SDHOST"
fi

# USB Vendor and Device ID for use with USB Gadget Mode
source USBID.sh
if [ "${USB_VID}" ] ; then
Expand Down
1 change: 1 addition & 0 deletions src/circle_stdlib_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class CStdlibAppStdio: public CStdlibAppScreen
CEMMCDevice mEMMC;
FATFS mFileSystem;
CConsole mConsole;
CScheduler mScheduler;
};

/**
Expand Down
38 changes: 37 additions & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ void CConfig::Load (void)

// Network
m_bNetworkEnabled = m_Properties.GetNumber ("NetworkEnabled", 0) != 0;
m_NetworkType = m_Properties.GetString ("NetworkType", "");
m_bNetworkDHCP = m_Properties.GetNumber ("NetworkDHCP", 0) != 0;
m_NetworkType = m_Properties.GetString ("NetworkType", "wifi");
m_NetworkHostname = m_Properties.GetString ("NetworkHostname", "minidexed");
m_INetworkIPAddress = m_Properties.GetIPAddress("NetworkIPAddress") != 0;
m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0;
m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0;
m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0;
}

bool CConfig::GetUSBGadgetMode (void) const
Expand Down Expand Up @@ -514,7 +520,37 @@ bool CConfig::GetNetworkEnabled (void) const
return m_bNetworkEnabled;
}

bool CConfig::GetNetworkDHCP (void) const
{
return m_bNetworkDHCP;
}

const char *CConfig::GetNetworkType (void) const
{
return m_NetworkType.c_str();
}

const char *CConfig::GetNetworkHostname (void) const
{
return m_NetworkHostname.c_str();
}

CIPAddress CConfig::GetNetworkIPAddress (void) const
{
return m_INetworkIPAddress;
}

CIPAddress CConfig::GetNetworkSubnetMask (void) const
{
return m_INetworkSubnetMask;
}

CIPAddress CConfig::GetNetworkDefaultGateway (void) const
{
return m_INetworkDefaultGateway;
}

CIPAddress CConfig::GetNetworkDNSServer (void) const
{
return m_INetworkDNSServer;
}
13 changes: 13 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#ifndef _config_h
#define _config_h

#include <circle/net/ipaddress.h>
#include <fatfs/ff.h>
#include <Properties/propertiesfatfsfile.h>
#include <circle/sysconfig.h>
Expand Down Expand Up @@ -171,6 +172,12 @@ class CConfig // Configuration for MiniDexed
// Network
bool GetNetworkEnabled (void) const;
const char *GetNetworkType (void) const;
bool GetNetworkDHCP (void) const;
const char *GetNetworkHostname (void) const;
CIPAddress GetNetworkIPAddress (void) const;
CIPAddress GetNetworkSubnetMask (void) const;
CIPAddress GetNetworkDefaultGateway (void) const;
CIPAddress GetNetworkDNSServer (void) const;

private:
CPropertiesFatFsFile m_Properties;
Expand Down Expand Up @@ -259,7 +266,13 @@ class CConfig // Configuration for MiniDexed

// Network
bool m_bNetworkEnabled;
bool m_bNetworkDHCP;
std::string m_NetworkType;
std::string m_NetworkHostname;
CIPAddress m_INetworkIPAddress;
CIPAddress m_INetworkSubnetMask;
CIPAddress m_INetworkDefaultGateway;
CIPAddress m_INetworkDNSServer;
};

#endif
9 changes: 5 additions & 4 deletions src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ CKernel *CKernel::s_pThis = 0;

CKernel::CKernel (void)
:
//CStdlibAppStdio ("minidexed"),
CStdlibAppNetwork ("minidexed", CSTDLIBAPP_DEFAULT_PARTITION,
0, 0, 0, 0, NET_DEVICE_TYPE),
CStdlibAppStdio ("minidexed"),
//CStdlibAppNetwork ("minidexed", CSTDLIBAPP_DEFAULT_PARTITION,
// 0, 0, 0, 0, NET_DEVICE_TYPE),
m_Config (&mFileSystem),
m_GPIOManager (&mInterrupt),
m_I2CMaster (CMachineInfo::Get ()->GetDevice (DeviceI2CMaster), TRUE),
//m_Scheduler(),
m_pDexed (0)
{
s_pThis = this;
Expand All @@ -52,7 +53,7 @@ CKernel::~CKernel(void)

bool CKernel::Initialize (void)
{
if (!CStdlibAppNetwork::Initialize ())
if (!CStdlibAppStdio::Initialize ())
{
return FALSE;
}
Expand Down
4 changes: 3 additions & 1 deletion src/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <circle/gpiomanager.h>
#include <circle/i2cmaster.h>
#include <circle/usb/usbcontroller.h>
#include <circle/sched/scheduler.h>
#include "config.h"
#include "minidexed.h"

Expand All @@ -35,7 +36,7 @@ enum TShutdownMode
ShutdownReboot
};

class CKernel : public CStdlibAppNetwork
class CKernel : public CStdlibAppStdio
{
public:
CKernel (void);
Expand All @@ -54,6 +55,7 @@ class CKernel : public CStdlibAppNetwork
CCPUThrottle m_CPUThrottle;
CGPIOManager m_GPIOManager;
CI2CMaster m_I2CMaster;
//CScheduler m_Scheduler;
CMiniDexed *m_pDexed;
CUSBController *m_pUSB;

Expand Down
12 changes: 0 additions & 12 deletions src/mididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
}

m_MIDISpinLock.Acquire ();
printf ("MIDI-DEBUG: SPINLOCK ACQUIRED\n");

u8 ucStatus = pMessage[0];
u8 ucChannel = ucStatus & 0x0F;
Expand Down Expand Up @@ -205,7 +204,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
{
if ((ucChannel == nPerfCh) || (nPerfCh == OmniMode))
{
//printf("Performance Select Channel %d\n", nPerfCh);
m_pSynthesizer->ProgramChangePerformance (pMessage[1]);
}
}
Expand All @@ -214,10 +212,8 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
}

// Process MIDI for each Tone Generator
printf ("MIDI-DEBUG: EACH TONEGENERATOR LOOP\n");
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
{
printf ("%u TONE GENERATOR", nTG);
if (ucStatus == MIDI_SYSTEM_EXCLUSIVE_BEGIN)
{
// MIDI SYSEX per MIDI channel
Expand All @@ -230,15 +226,12 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
}
else
{
printf ("NOT AN SYSEX");

if ( m_ChannelMap[nTG] == ucChannel
|| m_ChannelMap[nTG] == OmniMode)
{
switch (ucType)
{
case MIDI_NOTE_ON:
printf ("MIDI-DEBUG: CASE MIDI NOTE ON\n");
if (nLength < 3)
{
break;
Expand All @@ -248,15 +241,12 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
{
if (pMessage[2] <= 127)
{
printf ("MIDI-DEBUG: KEYDOWN EVENT\n");
m_pSynthesizer->keydown (pMessage[1],
pMessage[2], nTG);
}
}
else
{
printf ("MIDI-DEBUG: KEYUP EVENT\n");
//printf ("MIDI-RTP: %02X\n", m_pSynthesizer);
m_pSynthesizer->keyup (pMessage[1], nTG);
}
break;
Expand All @@ -266,7 +256,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
{
break;
}
printf ("MIDI-DEBUG: MIDI NOTE OFF\n");
m_pSynthesizer->keyup (pMessage[1], nTG);
break;

Expand Down Expand Up @@ -388,7 +377,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
}
}
m_MIDISpinLock.Release ();
printf ("MIDI-DEBUG: SPINLOCK RELEASED\n");
}

void CMIDIDevice::AddDevice (const char *pDeviceName)
Expand Down
Loading

0 comments on commit 2046d81

Please sign in to comment.