project for 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
hardware.cpp@1:10330bce85cb, 2020-10-23 (annotated)
- Committer:
- DCchico
- Date:
- Fri Oct 23 16:18:39 2020 -0400
- Revision:
- 1:10330bce85cb
- Child:
- 2:4947d6a82971
shell-code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DCchico | 1:10330bce85cb | 1 | // This header has all the (extern) declarations of the globals. |
DCchico | 1:10330bce85cb | 2 | // "extern" means "this is instantiated somewhere, but here's what the name |
DCchico | 1:10330bce85cb | 3 | // means. |
DCchico | 1:10330bce85cb | 4 | #include "globals.h" |
DCchico | 1:10330bce85cb | 5 | |
DCchico | 1:10330bce85cb | 6 | #include "hardware.h" |
DCchico | 1:10330bce85cb | 7 | |
DCchico | 1:10330bce85cb | 8 | // We need to actually instantiate all of the globals (i.e. declare them once |
DCchico | 1:10330bce85cb | 9 | // without the extern keyword). That's what this file does! |
DCchico | 1:10330bce85cb | 10 | |
DCchico | 1:10330bce85cb | 11 | // Hardware initialization: Instantiate all the things! |
DCchico | 1:10330bce85cb | 12 | uLCD_4DGL uLCD(p9,p10,p11); // LCD Screen (tx, rx, reset) |
DCchico | 1:10330bce85cb | 13 | //SDFileSystem sd(p5, p6, p7, p8, "sd"); // SD Card(mosi, miso, sck, cs) |
DCchico | 1:10330bce85cb | 14 | Serial pc(USBTX,USBRX); // USB Console (tx, rx) |
DCchico | 1:10330bce85cb | 15 | MMA8452 acc(p28, p27, 100000); // Accelerometer (sda, sdc, rate) |
DCchico | 1:10330bce85cb | 16 | DigitalIn button1(p21); // Pushbuttons (pin) |
DCchico | 1:10330bce85cb | 17 | DigitalIn button2(p22); |
DCchico | 1:10330bce85cb | 18 | DigitalIn button3(p23); |
DCchico | 1:10330bce85cb | 19 | AnalogOut DACout(p18); // Speaker (pin) |
DCchico | 1:10330bce85cb | 20 | PwmOut speaker(p26); |
DCchico | 1:10330bce85cb | 21 | wave_player waver(&DACout); |
DCchico | 1:10330bce85cb | 22 | |
DCchico | 1:10330bce85cb | 23 | |
DCchico | 1:10330bce85cb | 24 | // Some hardware also needs to have functions called before it will set up |
DCchico | 1:10330bce85cb | 25 | // properly. Do that here. |
DCchico | 1:10330bce85cb | 26 | int hardware_init() |
DCchico | 1:10330bce85cb | 27 | { |
DCchico | 1:10330bce85cb | 28 | // Crank up the speed |
DCchico | 1:10330bce85cb | 29 | uLCD.baudrate(3000000); |
DCchico | 1:10330bce85cb | 30 | pc.baud(115200); |
DCchico | 1:10330bce85cb | 31 | |
DCchico | 1:10330bce85cb | 32 | //Initialize pushbuttons |
DCchico | 1:10330bce85cb | 33 | button1.mode(PullUp); |
DCchico | 1:10330bce85cb | 34 | button2.mode(PullUp); |
DCchico | 1:10330bce85cb | 35 | button3.mode(PullUp); |
DCchico | 1:10330bce85cb | 36 | |
DCchico | 1:10330bce85cb | 37 | return ERROR_NONE; |
DCchico | 1:10330bce85cb | 38 | } |
DCchico | 1:10330bce85cb | 39 | |
DCchico | 1:10330bce85cb | 40 | GameInputs read_inputs() |
DCchico | 1:10330bce85cb | 41 | { |
DCchico | 1:10330bce85cb | 42 | GameInputs in; |
DCchico | 1:10330bce85cb | 43 | return in; |
DCchico | 1:10330bce85cb | 44 | } |