YMZ294 Player. modified from "Yamaguchi's YMZ294 Library" for LPC1114.

Dependencies:   mbed

Committer:
kohacraft
Date:
Wed Dec 09 01:38:08 2015 +0000
Revision:
0:7a56bf0441ea
YMZ294 Player. modified from "Yamaguchi's YMZ294 Library" for LPC1114

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kohacraft 0:7a56bf0441ea 1 #ifndef MBED_YMZ294_H
kohacraft 0:7a56bf0441ea 2 #define MBED_YMZ294_H
kohacraft 0:7a56bf0441ea 3
kohacraft 0:7a56bf0441ea 4 #include "mbed.h"
kohacraft 0:7a56bf0441ea 5
kohacraft 0:7a56bf0441ea 6 enum Ch {CHANNEL_A = 0, CHANNEL_B, CHANNEL_C};
kohacraft 0:7a56bf0441ea 7
kohacraft 0:7a56bf0441ea 8 enum Mixer {NONE = 0x3F,
kohacraft 0:7a56bf0441ea 9 TONE_A = ~(1 << 0), TONE_B = ~(1 << 1), TONE_C = ~(1 << 2),
kohacraft 0:7a56bf0441ea 10 NOISE_A = ~(1 << 3), NOISE_B = ~(1 << 4), NOISE_C = ~(1 << 5)
kohacraft 0:7a56bf0441ea 11 };
kohacraft 0:7a56bf0441ea 12
kohacraft 0:7a56bf0441ea 13 class YMZ294 {
kohacraft 0:7a56bf0441ea 14 public:
kohacraft 0:7a56bf0441ea 15 YMZ294(PinName dataPin0, PinName dataPin1, PinName dataPin2, PinName dataPin3,
kohacraft 0:7a56bf0441ea 16 PinName dataPin4, PinName dataPin5, PinName dataPin6, PinName dataPin7,
kohacraft 0:7a56bf0441ea 17 PinName csPin, PinName wrPin, PinName a0Pin);
kohacraft 0:7a56bf0441ea 18 void setTone(Ch channel, float freq);
kohacraft 0:7a56bf0441ea 19 void setVolume(Ch channel, int volume);
kohacraft 0:7a56bf0441ea 20 void setNoise(int freq);
kohacraft 0:7a56bf0441ea 21 void setEnvelope(int freq, int shape);
kohacraft 0:7a56bf0441ea 22 void setMixer(Mixer m0, Mixer m1 = NONE, Mixer m2 = NONE, Mixer m3 = NONE, Mixer m4 = NONE, Mixer m5 = NONE);
kohacraft 0:7a56bf0441ea 23 private:
kohacraft 0:7a56bf0441ea 24 void write(char data, bool dataWrite = false);
kohacraft 0:7a56bf0441ea 25 void writeData(char address, int data, int nBytes = 1);
kohacraft 0:7a56bf0441ea 26
kohacraft 0:7a56bf0441ea 27 BusOut dataPins;
kohacraft 0:7a56bf0441ea 28 DigitalOut csPin;
kohacraft 0:7a56bf0441ea 29 DigitalOut wrPin;
kohacraft 0:7a56bf0441ea 30 DigitalOut a0Pin;
kohacraft 0:7a56bf0441ea 31 char volumes[3];
kohacraft 0:7a56bf0441ea 32 float freqs[3];
kohacraft 0:7a56bf0441ea 33 float noiseFreq;
kohacraft 0:7a56bf0441ea 34 };
kohacraft 0:7a56bf0441ea 35 #endif