Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Amp AverageAnalogIn Envelope FilterController Sequence BaseMachineComon mbed-rtos mbed
Fork of SpiSequenceSender_Test by
main.cpp
- Committer:
- ryood
- Date:
- 2016-06-23
- Revision:
- 6:fc10eac60b91
- Parent:
- 5:4abac408b827
- Child:
- 7:ed01846ee0a5
File content as of revision 6:fc10eac60b91:
#include "mbed.h"
#include "rtos.h"
#define UART_TRACE (0)
#include "SpiSequenceSender.h"
#include "Envelope.h"
#define SEQUENCE_N (16)
#define SPI_RATE (8000000)
SPI spiMaster(SPI_MOSI, SPI_MISO, SPI_SCK);
Sequence sequence[SEQUENCE_N];
SpiSequenceSender sequenceSender(&spiMaster, D9, sequence, SEQUENCE_N, 5);
Envelope envelope(4095, 25, 20, 10, 2047);
class TestClass {
public:
void callbackFunction(int ticks)
{
printf("%d\r\n", ticks);
}
} testClass;
int main()
{
spiMaster.format(8, 0);
spiMaster.frequency(SPI_RATE);
// Test SequencerSender Run
//
sequenceSender.setBpm(120);
for (int i = 0; i < SEQUENCE_N; i++) {
Sequence& seq = sequenceSender.getSequences()[i];
seq.setPitch(i);
seq.setOctave(-1);
seq.tie = true;
}
sequence[3].setOctave(2);
sequence[7].setOctave(1);
sequence[11].setOctave(0);
sequence[15].setOctave(1);
sequenceSender.attach(&testClass, &TestClass::callbackFunction);
sequenceSender.run(0);
for (;;) {
sequenceSender.setPulseWidth(sequenceSender.getPulseWidth() + 4);
Thread::wait(500);
sequenceSender.setWaveShape(SpiSequenceSender::WAVESHAPE_SAW);
Thread::wait(500);
sequenceSender.setWaveShape(SpiSequenceSender::WAVESHAPE_SQUARE);
}
}
