Testing 1 blue pill
Dependencies: mbed mbed-rtos TextLCD
SETUP.hpp@26:83550fc299aa, 2019-02-19 (annotated)
- Committer:
- thomasmorris
- Date:
- Tue Feb 19 14:40:01 2019 +0000
- Revision:
- 26:83550fc299aa
- Parent:
- 25:9751619fa030
- Child:
- 27:22d6fd88828e
Working code (needs stepper motor and mosfet output checking
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 12:d9c133b360b0 | 1 | #ifndef SETUP_HPP//Header Guards Prevents Multiple includes |
thomasmorris | 12:d9c133b360b0 | 2 | #define SETUP_HPP |
thomasmorris | 25:9751619fa030 | 3 | |
thomasmorris | 13:c681f340909b | 4 | #include "stdio.h" |
thomasmorris | 13:c681f340909b | 5 | #include "string.h" |
thomasmorris | 13:c681f340909b | 6 | #include "mbed.h" |
thomasmorris | 13:c681f340909b | 7 | #include "rtos.h" |
thomasmorris | 13:c681f340909b | 8 | #include "TextLCD.h" |
thomasmorris | 13:c681f340909b | 9 | #include "iostream" |
thomasmorris | 12:d9c133b360b0 | 10 | #include "rtos.h" |
thomasmorris | 16:9f98ec0ededb | 11 | #include "STEPPER_MOTOR.hpp" |
thomasmorris | 16:9f98ec0ededb | 12 | #include "Interface.hpp" |
thomasmorris | 23:07a368f2cdb1 | 13 | |
thomasmorris | 26:83550fc299aa | 14 | #define Debounce_Time 100//200 works fine |
thomasmorris | 25:9751619fa030 | 15 | INTERFACE INTERFACE; |
thomasmorris | 17:68b3fdabe4c5 | 16 | //If the code compiles GET IN THE BIN |
thomasmorris | 25:9751619fa030 | 17 | |
thomasmorris | 16:9f98ec0ededb | 18 | |
thomasmorris | 13:c681f340909b | 19 | //Digital Outputs |
thomasmorris | 13:c681f340909b | 20 | DigitalOut led1(LED1); |
thomasmorris | 13:c681f340909b | 21 | DigitalOut led2(LED2); |
thomasmorris | 21:6d9f6a986647 | 22 | |
thomasmorris | 25:9751619fa030 | 23 | |
thomasmorris | 25:9751619fa030 | 24 | //Function forward declarations |
thomasmorris | 14:63998be3d43c | 25 | void up_thread_function(); |
thomasmorris | 14:63998be3d43c | 26 | void down_thread_function(); |
thomasmorris | 14:63998be3d43c | 27 | void start_thread_function(); |
thomasmorris | 14:63998be3d43c | 28 | void function_thread_function(); |
thomasmorris | 14:63998be3d43c | 29 | void select_thread_function(); |
thomasmorris | 26:83550fc299aa | 30 | void Polling_thread_function(); |
thomasmorris | 13:c681f340909b | 31 | //Thread Setups |
thomasmorris | 26:83550fc299aa | 32 | Thread polling_thread; |
thomasmorris | 13:c681f340909b | 33 | Thread lcd_thread; |
thomasmorris | 13:c681f340909b | 34 | Thread led_thread; |
thomasmorris | 14:63998be3d43c | 35 | Thread up_thread; |
thomasmorris | 14:63998be3d43c | 36 | Thread down_thread; |
thomasmorris | 14:63998be3d43c | 37 | Thread start_stop_thread; |
thomasmorris | 14:63998be3d43c | 38 | Thread function_thread; |
thomasmorris | 14:63998be3d43c | 39 | Thread select_thread; |
thomasmorris | 17:68b3fdabe4c5 | 40 | //LCD pin connections |
thomasmorris | 17:68b3fdabe4c5 | 41 | TextLCD lcd(D0,D1,D4,D5,D6,D7); // rs, e, d4-d7 |
thomasmorris | 14:63998be3d43c | 42 | |
thomasmorris | 17:68b3fdabe4c5 | 43 | //Serial Terminal setup for debugging |
thomasmorris | 13:c681f340909b | 44 | Serial pc(USBTX, USBRX); //Define serial namespace so the serial comms can be printed to |
thomasmorris | 23:07a368f2cdb1 | 45 | |
thomasmorris | 17:68b3fdabe4c5 | 46 | #endif |
thomasmorris | 13:c681f340909b | 47 | |
thomasmorris | 17:68b3fdabe4c5 | 48 | //Useful information |
thomasmorris | 17:68b3fdabe4c5 | 49 | /* |
thomasmorris | 17:68b3fdabe4c5 | 50 | Function 0 = Turn |
thomasmorris | 17:68b3fdabe4c5 | 51 | Function 1 = Anneal |
thomasmorris | 17:68b3fdabe4c5 | 52 | Function 2 = Test |
thomasmorris | 17:68b3fdabe4c5 | 53 | |
thomasmorris | 17:68b3fdabe4c5 | 54 | Black :Reset : HardWired |
thomasmorris | 17:68b3fdabe4c5 | 55 | Red :Up : D8 |
thomasmorris | 17:68b3fdabe4c5 | 56 | Orange:Down : A1 |
thomasmorris | 17:68b3fdabe4c5 | 57 | Brown :Start/Stop: D9 |
thomasmorris | 17:68b3fdabe4c5 | 58 | Green :Select : A3 |
thomasmorris | 17:68b3fdabe4c5 | 59 | Yellow:Function : A4 |
thomasmorris | 17:68b3fdabe4c5 | 60 | |
thomasmorris | 22:fc2186b610b5 | 61 | |
thomasmorris | 22:fc2186b610b5 | 62 | //Led Outputs //check the pin outs. |
thomasmorris | 22:fc2186b610b5 | 63 | static DigitalOut Led_Select_Left(D2); |
thomasmorris | 22:fc2186b610b5 | 64 | static DigitalOut Led_Select_Right(D3); |
thomasmorris | 22:fc2186b610b5 | 65 | static DigitalOut Led_Power(A3); |
thomasmorris | 22:fc2186b610b5 | 66 | |
thomasmorris | 22:fc2186b610b5 | 67 | TextLCD lcd(D0,D1,D4,D5,D6,D7); // rs, e, d4-d7 |
thomasmorris | 25:9751619fa030 | 68 | TendonPower (PWM) pin is PE_8 one below d0 |
thomasmorris | 17:68b3fdabe4c5 | 69 | STEPPER_MOTOR STEPPER_MOTOR_1(D15,D14,D13,D12) this is defined in interface.hpp |
thomasmorris | 17:68b3fdabe4c5 | 70 | */ |
thomasmorris | 17:68b3fdabe4c5 | 71 |