Ryo Od
/
Nucleo_rtos_SPISlave_Test
SPI Slave Test.
Diff: main.cpp
- Revision:
- 5:ca0be3b8b8a6
- Parent:
- 4:0051fa8b5475
--- a/main.cpp Fri Oct 07 09:03:07 2016 +0000 +++ b/main.cpp Fri Oct 07 09:57:56 2016 +0000 @@ -19,6 +19,23 @@ // SPI2 SPISlave SpiS(PB_15, PB_14, PB_13, PB_12); // mosi, miso, sclk, ssel +enum SequencerCmd { + CMD_RCV_PLAYING_STEP = 0x01, + CMD_RUN = 0x11, + CMD_BPM = 0x12, + CMD_ACCENT_LEVEL = 0x13, + CMD_WAVE_SHAPE = 0x21, + CMD_PULSE_WIDTH = 0x22, + CMD_CUTOFF = 0x31, + CMD_RESONANCE = 0x32, + CMD_LEVEL = 0x41, + CMD_DURATION = 0x42, + CMD_DECAY = 0x43, + CMD_SUSTAIN = 0x44, + CMD_NOTE = 0x51, + CMD_PITCH = 0x52, +}; + unsigned int step = 0; void stepUp(void const* arg) @@ -49,14 +66,23 @@ // RtosTimer RtosTimer stepTimer(stepUp, osTimerPeriodic, (void *)0); - stepTimer.start(125); + //stepTimer.start(125); - SpiS.reply(0); while(1) { if(SpiS.receive()) { SpiS.reply(step % 16); - int v = SpiS.read(); // Read byte from master + uint16_t v = SpiS.read(); Leds.write(v); + + if (v >> 8 == CMD_RUN) { + printf("CMD_RUN\r\n"); + if ((v & 0xff) == 1) { + stepTimer.start(125); + } else { + stepTimer.stop(); + } + } + printf("%04x\r\n", v); } }