Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sys ex control #287

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
85a663a
Update build.yml
BenZonneveld Jun 7, 2022
44d9c7e
Update build.yml
BenZonneveld Jun 7, 2022
a1c9ec0
Sysex patches
BenZonneveld Jun 8, 2022
b13c1f2
Patches to support TG settings using sysex.
BenZonneveld Jun 9, 2022
bbd3db3
Sysex implemented
BenZonneveld Jun 9, 2022
d62cbb7
More sysex implementations
BenZonneveld Jun 9, 2022
31c52b3
More midi
BenZonneveld Jun 10, 2022
6d189f8
More sysex
BenZonneveld Jun 13, 2022
d8316fd
Small sysex changes
BenZonneveld Jun 14, 2022
65ebb88
Forgot to add these files
BenZonneveld Jun 19, 2022
959b123
Added extra files
BenZonneveld Jun 20, 2022
d944ec4
This should fix the builds
BenZonneveld Jun 20, 2022
5ed8b18
Update build.yml
BenZonneveld Jun 20, 2022
d10c784
Update build.yml
BenZonneveld Jun 20, 2022
fd345d8
Restore build.yml
probonopd Jun 20, 2022
6351fdc
Restore build.sh
probonopd Jun 20, 2022
cb0f524
Moving Sysex check to mididevice.cpp
BenZonneveld Jul 5, 2022
92d5f4c
This should fix the build issues
BenZonneveld Jul 5, 2022
b87fd74
Merge branch 'SysExControl' of https://github.com/BenZonneveld/MiniDe…
BenZonneveld Jul 5, 2022
637bcec
Update rebuild.sh
BenZonneveld Jul 5, 2022
1902c47
Update rebuild.sh
BenZonneveld Jul 5, 2022
cf03de9
Upstream Dexed
BenZonneveld Jul 5, 2022
613d721
Fixing build
BenZonneveld Jul 5, 2022
5ee4469
Refactored the sysex check
BenZonneveld Jul 5, 2022
3e9ae9b
Refactored the sysex check
BenZonneveld Jul 5, 2022
01ef041
Build Fix and Working Sysex
BenZonneveld Jul 5, 2022
05f1e43
The check was not correct, fixed
BenZonneveld Jul 6, 2022
7c60100
Merge branch 'main' into SysExControl
probonopd Jul 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ jobs:
set -ex
wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
bash ./upload.sh ./MiniDexed*.zip

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ sdcard
*.zip
*.img

# Visual Studio artefacts
.vs

# Editor related files
*.swp
*.swo
*.swo
2 changes: 1 addition & 1 deletion Synth_Dexed
Submodule Synth_Dexed updated from 8c677c to 28ef0d
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ else
export TOOLCHAIN_PREFIX="arm-none-eabi-"
fi


# Define system options
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

# Build circle-stdlib library
# Apply NL to NL+CR on output fix
cp serial.h circle-stdlib/libs/circle/include/circle/serial.h
cd circle-stdlib/
make mrproper || true
./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000
Expand Down
2 changes: 1 addition & 1 deletion circle-stdlib
Submodule circle-stdlib updated 2 files
+4 −0 CHANGELOG.md
+1 −1 libs/circle
42 changes: 42 additions & 0 deletions rebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export RPI=3

export CLEAN="true"
export BUILDCIRCLE="true"
export PATH=$(readlink -f ./gcc-*/bin/):$PATH

# Build dependencies and MiniDexed
./build.sh
cp ./src/kernel*.img ./kernels/
if [[ $? -ne 0 ]] ; then
exit
fi
# Get Raspberry Pi boot files
cd ./circle-stdlib/libs/circle/boot
make
if [ "${RPI}" -gt 2 ]
then
make armstub64
fi
cd -

# Make zip that contains Raspberry Pi 4 boot files. The contents can be copied to a FAT32 formatted partition on a microSD card
#cd sdcard
#../getsysex.sh
#cd ..
cp -r ./circle-stdlib/libs/circle/boot/* sdcard
if [[ $? -ne 0 ]] ; then
exit
fi
rm -rf sdcard/config*.txt sdcard/README sdcard/Makefile sdcard/armstub sdcard/COPYING.linux
cp ./src/config.txt ./src/*img sdcard/
if [[ $? -ne 0 ]] ; then
exit
fi
echo "usbspeed=full" > sdcard/cmdline.txt
cd sdcard
cp ../kernels/* . || true
if [[ $? -ne 0 ]] ; then
exit
fi
zip -r ../MiniDexed_$(date +%Y-%m-%d).zip *
cd -
186 changes: 186 additions & 0 deletions serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
//
/// \file serial.h
//
// Circle - A C++ bare metal environment for Raspberry Pi
// Copyright (C) 2014-2021 R. Stange <rsta2@o2online.de>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _circle_serial_h
#define _circle_serial_h

#include <circle/device.h>
#include <circle/interrupt.h>
#include <circle/gpiopin.h>
#include <circle/spinlock.h>
#include <circle/sysconfig.h>
#include <circle/types.h>

/// \class CSerialDevice
/// \brief Driver for PL011 UART
///
/// \details GPIO pin mapping (chip numbers)
/// nDevice | TXD | RXD | Support
/// :-----: | :----: | :----: | :------
/// 0 | GPIO14 | GPIO15 | All boards
/// ^ | GPIO32 | GPIO33 | Compute Modules
/// ^ | GPIO36 | GPIO37 | Compute Modules
/// 1 | | | None (AUX)
/// 2 | GPIO0 | GPIO1 | Raspberry Pi 4 only
/// 3 | GPIO4 | GPIO5 | Raspberry Pi 4 only
/// 4 | GPIO8 | GPIO9 | Raspberry Pi 4 only
/// 5 | GPIO12 | GPIO13 | Raspberry Pi 4 only
/// GPIO32/33 and GPIO36/37 can be selected with system option SERIAL_GPIO_SELECT.\n
/// GPIO0/1 are normally reserved for ID EEPROM.\n
/// Handshake lines CTS and RTS are not supported.

#if RASPPI < 4
#define SERIAL_DEVICES 1
#else
#define SERIAL_DEVICES 6
#endif

#define SERIAL_BUF_SIZE 2048 // must be a power of 2
#define SERIAL_BUF_MASK (SERIAL_BUF_SIZE-1)

// serial options
#define SERIAL_OPTION_ONLCR 0 ///< Translate NL to NL+CR on output (default)

// returned from Read/Write as negative value
#define SERIAL_ERROR_BREAK 1
#define SERIAL_ERROR_OVERRUN 2
#define SERIAL_ERROR_FRAMING 3
#define SERIAL_ERROR_PARITY 4

class CSerialDevice : public CDevice
{
public:
enum TParity
{
ParityNone,
ParityOdd,
ParityEven,
ParityUnknown
};

public:
#ifndef USE_RPI_STUB_AT
/// \param pInterruptSystem Pointer to interrupt system object (or 0 for polling driver)
/// \param bUseFIQ Use FIQ instead of IRQ
/// \param nDevice Device number (see: GPIO pin mapping)
CSerialDevice (CInterruptSystem *pInterruptSystem = 0, boolean bUseFIQ = FALSE,
unsigned nDevice = 0);

~CSerialDevice (void);
#endif

/// \param nBaudrate Baud rate in bits per second
/// \param nDataBits Number of data bits (5..8, default 8)
/// \param nStopBits Number of stop bits (1..2, default 1)
/// \param Parity Parity setting (ParityNone (default), ParityOdd or ParityEven)
/// \return Operation successful?
#ifndef USE_RPI_STUB_AT
boolean Initialize (unsigned nBaudrate = 115200,
unsigned nDataBits = 8, unsigned nStopBits = 1,
TParity Parity = ParityNone);
#else
boolean Initialize (unsigned nBaudrate = 115200);
#endif

/// \param pBuffer Pointer to data to be sent
/// \param nCount Number of bytes to be sent
/// \return Number of bytes successfully sent (< 0 on error)
int Write (const void *pBuffer, size_t nCount);

#ifndef USE_RPI_STUB_AT
/// \param pBuffer Pointer to buffer for received data
/// \param nCount Maximum number of bytes to be received
/// \return Number of bytes received (0 no data available, < 0 on error)
int Read (void *pBuffer, size_t nCount);

/// \return Serial options mask (see serial options)
unsigned GetOptions (void) const;
/// \param nOptions Serial options mask (see serial options)
void SetOptions (unsigned nOptions);

typedef void TMagicReceivedHandler (void);
/// \param pMagic String for which is searched in the received data\n
/// (must remain valid after return from this method)
/// \param pHandler Handler which is called, when the magic string is found
/// \note Does only work with interrupt driver.
void RegisterMagicReceivedHandler (const char *pMagic, TMagicReceivedHandler *pHandler);

protected:
/// \return Number of bytes buffer space available for Write()
/// \note Does only work with interrupt driver.
unsigned AvailableForWrite (void);

/// \return Number of bytes already received available for Read()
/// \note Does only work with interrupt driver.
unsigned AvailableForRead (void);

/// \return Next received byte which will be returned by Read() (-1 if no data available)
/// \note Does only work with interrupt driver.
int Peek (void);

/// \brief Waits until all written bytes have been sent out
void Flush (void);

private:
boolean Write (u8 uchChar);

void InterruptHandler (void);
static void InterruptStub (void *pParam);

private:
CInterruptSystem *m_pInterruptSystem;
boolean m_bUseFIQ;
unsigned m_nDevice;
uintptr m_nBaseAddress;
boolean m_bValid;

#if SERIAL_GPIO_SELECT == 14
CGPIOPin m_GPIO32;
CGPIOPin m_GPIO33;
#endif
CGPIOPin m_TxDPin;
CGPIOPin m_RxDPin;

u8 m_RxBuffer[SERIAL_BUF_SIZE];
volatile unsigned m_nRxInPtr;
volatile unsigned m_nRxOutPtr;
volatile int m_nRxStatus;

u8 m_TxBuffer[SERIAL_BUF_SIZE];
volatile unsigned m_nTxInPtr;
volatile unsigned m_nTxOutPtr;

unsigned m_nOptions;

const char *m_pMagic;
const char *m_pMagicPtr;
TMagicReceivedHandler *m_pMagicReceivedHandler;

CSpinLock m_SpinLock;
CSpinLock m_LineSpinLock;

static unsigned s_nInterruptUseCount;
static CInterruptSystem *s_pInterruptSystem;
static boolean s_bUseFIQ;
static volatile u32 s_nInterruptDeviceMask;
static CSerialDevice *s_pThis[SERIAL_DEVICES];
#endif
};

#endif
Loading