f
Dependencies: mbed 4DGL-uLCD-SE MMA8452
hardware.cpp@0:8e3b9bb1084a, 2022-03-10 (annotated)
- Committer:
- lballard9
- Date:
- Thu Mar 10 05:18:13 2022 +0000
- Revision:
- 0:8e3b9bb1084a
- Child:
- 5:077b66dfe296
shell rev b;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lballard9 | 0:8e3b9bb1084a | 1 | // This header has all the (extern) declarations of the globals. |
lballard9 | 0:8e3b9bb1084a | 2 | // "extern" means "this is instantiated somewhere, but here's what the name |
lballard9 | 0:8e3b9bb1084a | 3 | // means. |
lballard9 | 0:8e3b9bb1084a | 4 | #include "globals.h" |
lballard9 | 0:8e3b9bb1084a | 5 | |
lballard9 | 0:8e3b9bb1084a | 6 | #include "hardware.h" |
lballard9 | 0:8e3b9bb1084a | 7 | |
lballard9 | 0:8e3b9bb1084a | 8 | // We need to actually instantiate all of the globals (i.e. declare them once |
lballard9 | 0:8e3b9bb1084a | 9 | // without the extern keyword). That's what this file does! |
lballard9 | 0:8e3b9bb1084a | 10 | |
lballard9 | 0:8e3b9bb1084a | 11 | // Hardware initialization: Instantiate all the things! |
lballard9 | 0:8e3b9bb1084a | 12 | uLCD_4DGL uLCD(p9,p10,p11); // LCD Screen (tx, rx, reset) |
lballard9 | 0:8e3b9bb1084a | 13 | //SDFileSystem sd(p5, p6, p7, p8, "sd"); // SD Card(mosi, miso, sck, cs) |
lballard9 | 0:8e3b9bb1084a | 14 | Serial pc(USBTX,USBRX); // USB Console (tx, rx) |
lballard9 | 0:8e3b9bb1084a | 15 | MMA8452 acc(p28, p27, 100000); // Accelerometer (sda, sdc, rate) |
lballard9 | 0:8e3b9bb1084a | 16 | DigitalIn button1(p21); // Pushbuttons (pin) |
lballard9 | 0:8e3b9bb1084a | 17 | DigitalIn button2(p22); |
lballard9 | 0:8e3b9bb1084a | 18 | DigitalIn button3(p23); |
lballard9 | 0:8e3b9bb1084a | 19 | AnalogOut DACout(p18); // Speaker (pin) |
lballard9 | 0:8e3b9bb1084a | 20 | PwmOut speaker(p25); |
lballard9 | 0:8e3b9bb1084a | 21 | wave_player waver(&DACout); |
lballard9 | 0:8e3b9bb1084a | 22 | |
lballard9 | 0:8e3b9bb1084a | 23 | |
lballard9 | 0:8e3b9bb1084a | 24 | // Some hardware also needs to have functions called before it will set up |
lballard9 | 0:8e3b9bb1084a | 25 | // properly. Do that here. |
lballard9 | 0:8e3b9bb1084a | 26 | int hardware_init() |
lballard9 | 0:8e3b9bb1084a | 27 | { |
lballard9 | 0:8e3b9bb1084a | 28 | |
lballard9 | 0:8e3b9bb1084a | 29 | } |
lballard9 | 0:8e3b9bb1084a | 30 | /* |
lballard9 | 0:8e3b9bb1084a | 31 | * This function reads the values of the push buttons and the |
lballard9 | 0:8e3b9bb1084a | 32 | * accelerometer |
lballard9 | 0:8e3b9bb1084a | 33 | */ |
lballard9 | 0:8e3b9bb1084a | 34 | GameInputs read_inputs() |
lballard9 | 0:8e3b9bb1084a | 35 | { |
lballard9 | 0:8e3b9bb1084a | 36 | |
lballard9 | 0:8e3b9bb1084a | 37 | } |