KIK01 Release
Dependencies: mcp3008 mbed mbed-rtos AverageMCP3008 VoltageMonitor
Diff: main.cpp
- Revision:
- 21:a527f51381d6
- Parent:
- 20:70a05941db8c
- Child:
- 22:a3bb7594f9bb
--- a/main.cpp Sat Sep 16 00:10:18 2017 +0000 +++ b/main.cpp Sat Sep 16 00:26:56 2017 +0000 @@ -21,8 +21,8 @@ #define PI_F (3.1415926f) #define MCP3008_SPI_SPEED (1000000) -#define AD8402_SPI_SPEED (4000000) -#define ENVELOPE_UPDATE_RATE (10000) // Hz +#define AD8402_SPI_SPEED (10000000) +#define ENVELOPE_UPDATE_RATE (20000) // Hz #define AD8402_RMAX (10000.0f) #define AD8402_RMIN (50.0f) @@ -30,7 +30,7 @@ AnalogOut Dac1(A2); // AD8402 SPI -SPI SpiM1(SPI_MOSI, SPI_MISO, SPI_SCK); +SPI SpiMAD8402(SPI_MOSI, SPI_MISO, SPI_SCK); DigitalOut AD8402Cs(D10); // MCP3008 SPI @@ -178,19 +178,23 @@ void AD8402Write(uint8_t address, uint8_t value) { +#if (PIN_CHECK) + Dout1 = 1; +#endif + AD8402Cs = 0; - SpiM1.write(address); - SpiM1.write(value); + SpiMAD8402.write(address); + SpiMAD8402.write(value); AD8402Cs = 1; wait_us(1); + +#if (PIN_CHECK) + Dout1 = 0; +#endif } void DcoSetFrequency() { -#if (PIN_CHECK) - Dout1 = 1; -#endif - frequency = envelopeFrequency.getAmplitude(ticks); const float c = 0.00000047; @@ -199,13 +203,10 @@ if (r > AD8402_RMAX) r = AD8402_RMAX; uint8_t v = 256.0f * (r - AD8402_RMIN) / AD8402_RMAX; - + AD8402Write(0, v); AD8402Write(1, v); -#if (PIN_CHECK) - Dout1 = 0; -#endif } void update() @@ -278,10 +279,8 @@ { printf("%s %s\r\n", TITLE_STR1, TITLE_STR2); - /* - SpiM1.format(0, 0); - SpiM1.frequency(2000000); - */ + SpiMAD8402.format(8, 0); + SpiMAD8402.frequency(AD8402_SPI_SPEED); SpiM3.format(8, 0); SpiM3.frequency(MCP3008_SPI_SPEED);