![](/media/cache/profiles/P1050323.jpg.50x50_q85.jpg)
KIK01 Release
Dependencies: mcp3008 mbed mbed-rtos AverageMCP3008 VoltageMonitor
Diff: main.cpp
- Revision:
- 18:1bf4abf6895b
- Parent:
- 17:a5d9908bd456
- Child:
- 19:d9e4c66cb49b
--- a/main.cpp Fri Sep 15 23:33:27 2017 +0000 +++ b/main.cpp Fri Sep 15 23:58:44 2017 +0000 @@ -22,26 +22,27 @@ #define MCP3008_SPI_SPEED (1000000) #define AD8402_SPI_SPEED (4000000) -#define ENVELOPE_UPDATE_RATE (1000) // Hz +#define ENVELOPE_UPDATE_RATE (10000) // Hz AnalogOut Dac1(A2); -/* +// AD8402 SPI SPI SpiM1(SPI_MOSI, SPI_MISO, SPI_SCK); -*/ +DigitalOut AD8402Cs(D10); +// MCP3008 SPI SPI SpiM3(D4, D5, D3); MCP3008 Adc0(&SpiM3, D6); MCP3008 Adc1(&SpiM3, D7); +// Sync +DigitalOut SyncPin(D2); + // Check pins DigitalOut Dout0(D8); DigitalOut Dout1(D9); DigitalOut Dout2(D14); -// Sync -DigitalOut SyncPin(D2); - class EnvelopeAR { public: @@ -239,14 +240,11 @@ void AD8402Write(uint8_t address, uint8_t value) { - wait_us(10); - /* - SpiCs = 0; - SpiM.write(address); - SpiM.write(value); - SpiCs = 1; + AD8402Cs = 0; + SpiM1.write(address); + SpiM1.write(value); + AD8402Cs = 1; wait_us(1); - */ } void DcoSetFrequency() @@ -260,8 +258,6 @@ float r = 1.0f / (2.0f * PI_F * frequency * c); uint8_t v = 256.0f * (r - 50.0f) / 10000.0f; - //printf("%d\r\n", v); - AD8402Write(0, v); AD8402Write(1, v);