Charles Andre
/
serialaudio
sharon look here
src/main.cpp@1:a6835f6c84eb, 2019-12-08 (annotated)
- Committer:
- candre97
- Date:
- Sun Dec 08 05:18:34 2019 +0000
- Revision:
- 1:a6835f6c84eb
- Parent:
- 0:973a5bbb2a17
sharon, look here!
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 | 1:a6835f6c84eb | 11 | |
guoxsharon | 0:973a5bbb2a17 | 12 | |
candre97 | 1:a6835f6c84eb | 13 | // PIN DEFINITIONS |
candre97 | 1:a6835f6c84eb | 14 | DigitalOut vcc(GPIO0); |
candre97 | 1:a6835f6c84eb | 15 | AnalogIn mic(PB_0); |
candre97 | 1:a6835f6c84eb | 16 | |
candre97 | 1:a6835f6c84eb | 17 | // 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 | 18 | |
candre97 | 1:a6835f6c84eb | 19 | int main() { |
candre97 | 1:a6835f6c84eb | 20 | int ARR_SIZE = 8000; |
candre97 | 1:a6835f6c84eb | 21 | vcc = 1; |
candre97 | 1:a6835f6c84eb | 22 | uint16_t raw_vals[ARR_SIZE]; |
candre97 | 1:a6835f6c84eb | 23 | int i = 0; |
candre97 | 1:a6835f6c84eb | 24 | printf("Loading values...\n"); |
candre97 | 1:a6835f6c84eb | 25 | while(1) { |
candre97 | 1:a6835f6c84eb | 26 | memset(raw_vals, 0, ARR_SIZE * sizeof(uint16_t)); |
candre97 | 1:a6835f6c84eb | 27 | i = 0; |
candre97 | 1:a6835f6c84eb | 28 | for(i; i < ARR_SIZE; i++) { |
candre97 | 1:a6835f6c84eb | 29 | raw_vals[i] = mic.read_u16(); |
guoxsharon | 0:973a5bbb2a17 | 30 | } |
candre97 | 1:a6835f6c84eb | 31 | //printf("Done reading in values\n"); |
candre97 | 1:a6835f6c84eb | 32 | wait(1); |
candre97 | 1:a6835f6c84eb | 33 | i = 0; |
candre97 | 1:a6835f6c84eb | 34 | for(i; i < ARR_SIZE; i++) { |
candre97 | 1:a6835f6c84eb | 35 | printf("%u,", raw_vals[i]); |
candre97 | 1:a6835f6c84eb | 36 | } |
candre97 | 1:a6835f6c84eb | 37 | |
candre97 | 1:a6835f6c84eb | 38 | while(1); |
guoxsharon | 0:973a5bbb2a17 | 39 | } |
guoxsharon | 0:973a5bbb2a17 | 40 | } |