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.
Dependencies: fastADC
src/main.cpp@8:233e02b9e498, 2019-12-08 (annotated)
- Committer:
- candre97
- Date:
- Sun Dec 08 06:50:16 2019 +0000
- Revision:
- 8:233e02b9e498
- Parent:
- 7:ae902c4b8b52
- Child:
- 9:7bc1efc28246
this one works;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| candre97 | 1:a6835f6c84eb | 1 | /* mbed Microcontroller Library |
| candre97 | 1:a6835f6c84eb | 2 | * Copyright (c) 2018 ARM Limited |
| candre97 | 1:a6835f6c84eb | 3 | * SPDX-License-Identifier: Apache-2.0 |
| candre97 | 1:a6835f6c84eb | 4 | */ |
| candre97 | 1:a6835f6c84eb | 5 | #include <stdio.h> |
| guoxsharon | 0:973a5bbb2a17 | 6 | |
| candre97 | 1:a6835f6c84eb | 7 | // Application helper |
| guoxsharon | 0:973a5bbb2a17 | 8 | #include "mbed.h" |
| candre97 | 1:a6835f6c84eb | 9 | #include <AnalogIn.h> |
| candre97 | 1:a6835f6c84eb | 10 | #include <DigitalOut.h> |
| candre97 | 6:011a31abf42a | 11 | #include "fastADC.h" |
| guoxsharon | 0:973a5bbb2a17 | 12 | |
| candre97 | 8:233e02b9e498 | 13 | |
| candre97 | 1:a6835f6c84eb | 14 | // PIN DEFINITIONS |
| candre97 | 1:a6835f6c84eb | 15 | DigitalOut vcc(GPIO0); |
| candre97 | 1:a6835f6c84eb | 16 | AnalogIn mic(PB_0); |
| candre97 | 1:a6835f6c84eb | 17 | |
| candre97 | 8:233e02b9e498 | 18 | // To sleep, 'wait' should be replaced by 'ThisThread::sleep_for' (C++) or 'thread_sleep_for' (C). If you wish to wait (without sleeping), call 'wait_us'. 'wait_us' is safe to call from ISR context. [since mbed-os-5.14] [-Wdeprecated-declarations] in "main.cpp", Line: 59, Col: 9 |
| guoxsharon | 0:973a5bbb2a17 | 19 | |
| candre97 | 1:a6835f6c84eb | 20 | int main() { |
| candre97 | 8:233e02b9e498 | 21 | initADC(); |
| candre97 | 8:233e02b9e498 | 22 | int ARR_SIZE = 8000; |
| candre97 | 1:a6835f6c84eb | 23 | vcc = 1; |
| candre97 | 7:ae902c4b8b52 | 24 | uint16_t raw_vals[ARR_SIZE]; |
| candre97 | 1:a6835f6c84eb | 25 | int i = 0; |
| candre97 | 8:233e02b9e498 | 26 | printf("Loading values...\n"); |
| candre97 | 1:a6835f6c84eb | 27 | while(1) { |
| candre97 | 1:a6835f6c84eb | 28 | memset(raw_vals, 0, ARR_SIZE * sizeof(uint16_t)); |
| candre97 | 1:a6835f6c84eb | 29 | i = 0; |
| candre97 | 1:a6835f6c84eb | 30 | for(i; i < ARR_SIZE; i++) { |
| candre97 | 6:011a31abf42a | 31 | raw_vals[i] = readADC(); |
| guoxsharon | 0:973a5bbb2a17 | 32 | } |
| candre97 | 8:233e02b9e498 | 33 | //printf("Done reading in values\n"); |
| candre97 | 1:a6835f6c84eb | 34 | wait(1); |
| candre97 | 1:a6835f6c84eb | 35 | i = 0; |
| candre97 | 1:a6835f6c84eb | 36 | for(i; i < ARR_SIZE; i++) { |
| candre97 | 1:a6835f6c84eb | 37 | printf("%u,", raw_vals[i]); |
| candre97 | 1:a6835f6c84eb | 38 | } |
| candre97 | 1:a6835f6c84eb | 39 | |
| candre97 | 1:a6835f6c84eb | 40 | while(1); |
| guoxsharon | 0:973a5bbb2a17 | 41 | } |
| guoxsharon | 0:973a5bbb2a17 | 42 | } |