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.
main.cpp@1:bfc4fc3bd803, 2021-04-09 (annotated)
- Committer:
- antonmadto
- Date:
- Fri Apr 09 08:45:28 2021 +0000
- Revision:
- 1:bfc4fc3bd803
- Parent:
- 0:d47d291acdf4
STM32F303 AD7606
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
antonmadto | 0:d47d291acdf4 | 1 | #include "mbed.h" |
antonmadto | 1:bfc4fc3bd803 | 2 | #include "USBSerial.h" |
antonmadto | 0:d47d291acdf4 | 3 | #include "ad7606.h" |
antonmadto | 0:d47d291acdf4 | 4 | |
antonmadto | 1:bfc4fc3bd803 | 5 | |
antonmadto | 1:bfc4fc3bd803 | 6 | #define MISO PB_4 |
antonmadto | 1:bfc4fc3bd803 | 7 | #define SCLK PB_3 |
antonmadto | 1:bfc4fc3bd803 | 8 | #define CS PA_8 |
antonmadto | 1:bfc4fc3bd803 | 9 | #define CONVST PB_1 |
antonmadto | 1:bfc4fc3bd803 | 10 | #define BUSY PB_6 |
antonmadto | 1:bfc4fc3bd803 | 11 | #define RESET PB_7 |
antonmadto | 1:bfc4fc3bd803 | 12 | |
antonmadto | 0:d47d291acdf4 | 13 | |
antonmadto | 0:d47d291acdf4 | 14 | |
antonmadto | 1:bfc4fc3bd803 | 15 | // Create a BufferedSerial object with a default baud rate. |
antonmadto | 1:bfc4fc3bd803 | 16 | static BufferedSerial pc(USBTX, USBRX); |
antonmadto | 0:d47d291acdf4 | 17 | AD7606 ad7606(MISO, SCLK, CS, CONVST, BUSY, RESET, 10500000); |
antonmadto | 0:d47d291acdf4 | 18 | double aValues[8] = {0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F}; |
antonmadto | 1:bfc4fc3bd803 | 19 | int16_t rawValues[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
antonmadto | 0:d47d291acdf4 | 20 | Ticker tick1; |
antonmadto | 0:d47d291acdf4 | 21 | |
antonmadto | 0:d47d291acdf4 | 22 | volatile bool timerInterrupt = false; |
antonmadto | 0:d47d291acdf4 | 23 | |
antonmadto | 0:d47d291acdf4 | 24 | void timInterrupt_ISR() { |
antonmadto | 0:d47d291acdf4 | 25 | timerInterrupt = true; |
antonmadto | 0:d47d291acdf4 | 26 | |
antonmadto | 0:d47d291acdf4 | 27 | } |
antonmadto | 0:d47d291acdf4 | 28 | |
antonmadto | 0:d47d291acdf4 | 29 | int main() { |
antonmadto | 0:d47d291acdf4 | 30 | |
antonmadto | 1:bfc4fc3bd803 | 31 | pc.set_baud(115200); |
antonmadto | 1:bfc4fc3bd803 | 32 | printf("Hello, World!\r\n"); |
antonmadto | 0:d47d291acdf4 | 33 | ad7606.setDR(10.0f); |
antonmadto | 1:bfc4fc3bd803 | 34 | // tick1.attach(timInterrupt_ISR, 0.1F); |
antonmadto | 0:d47d291acdf4 | 35 | |
antonmadto | 0:d47d291acdf4 | 36 | while(1) { |
antonmadto | 1:bfc4fc3bd803 | 37 | // if (timerInterrupt) { |
antonmadto | 1:bfc4fc3bd803 | 38 | ad7606.readRAW(rawValues); |
antonmadto | 1:bfc4fc3bd803 | 39 | // printf("%d, %d, %d, %d, %d, %d, %d, %d\r\n", rawValues[0], rawValues[1], rawValues[2], rawValues[3], rawValues[4], rawValues[5], rawValues[6], rawValues[7]); |
antonmadto | 1:bfc4fc3bd803 | 40 | printf("%d\r\n", rawValues[0]); |
antonmadto | 1:bfc4fc3bd803 | 41 | // ad7606.readAnalog(aValues); |
antonmadto | 1:bfc4fc3bd803 | 42 | // printf("%d \r\n", rawValues[0], aValues[0]); |
antonmadto | 1:bfc4fc3bd803 | 43 | wait_us(10000); |
antonmadto | 1:bfc4fc3bd803 | 44 | // pc.write(aValues[0], 2); |
antonmadto | 1:bfc4fc3bd803 | 45 | // timerInterrupt = false; |
antonmadto | 1:bfc4fc3bd803 | 46 | // } |
antonmadto | 0:d47d291acdf4 | 47 | } |
antonmadto | 0:d47d291acdf4 | 48 | } |