Jonathan Jones
/
Radios
Radio Structures in OOP
robot.h@6:4a3dbfbc30f1, 2015-01-15 (annotated)
- Committer:
- jjones646
- Date:
- Thu Jan 15 07:15:33 2015 +0000
- Revision:
- 6:4a3dbfbc30f1
- Parent:
- 4:989d51f3e6ef
socket interface confirmed working.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jjones646 | 2:7d523bdd2f50 | 1 | #ifndef ROBOT_H // Only include once |
jjones646 | 1:c935902c73ef | 2 | #define ROBOT_H |
jjones646 | 1:c935902c73ef | 3 | |
jjones646 | 2:7d523bdd2f50 | 4 | // ** ============================= ** DEBUGGING OPTIONS ** ============================= ** |
jjones646 | 2:7d523bdd2f50 | 5 | |
jjones646 | 2:7d523bdd2f50 | 6 | // Set the debugging level for compiling. Valid levels include `0`, `1`, `2`, `3`, & `4`. |
jjones646 | 1:c935902c73ef | 7 | #define RJ_DEBUG_LEVEL 0 |
jjones646 | 1:c935902c73ef | 8 | |
jjones646 | 2:7d523bdd2f50 | 9 | /* |
jjones646 | 2:7d523bdd2f50 | 10 | This will enable/disable a `Log File` that is created at the mbed's startup. The file is written |
jjones646 | 2:7d523bdd2f50 | 11 | to the mbed's onboard flash memory and can be opened for debugging purposes if it is enabled. |
jjones646 | 2:7d523bdd2f50 | 12 | Note that you may have to disconnect and reconnect the mbed's USB connection for the file to show up |
jjones646 | 2:7d523bdd2f50 | 13 | if it is plugged into a computer during the startup process. |
jjones646 | 2:7d523bdd2f50 | 14 | */ |
jjones646 | 2:7d523bdd2f50 | 15 | #define RJ_BOOT_LOG 1 |
jjones646 | 2:7d523bdd2f50 | 16 | |
jjones646 | 2:7d523bdd2f50 | 17 | // This will check the mbed's firmware for the most known up-to-date version if enabled |
jjones646 | 2:7d523bdd2f50 | 18 | #define RJ_CHECK_FIRMWARE 1 |
jjones646 | 2:7d523bdd2f50 | 19 | |
jjones646 | 2:7d523bdd2f50 | 20 | |
jjones646 | 2:7d523bdd2f50 | 21 | // ** ============================= ** ENABLE / DISABLE ROBOT INTERFACES ** ============================= ** |
jjones646 | 2:7d523bdd2f50 | 22 | |
jjones646 | 2:7d523bdd2f50 | 23 | // Enable/Disable the `Primary Radio Interface` (915MHz band). |
jjones646 | 2:7d523bdd2f50 | 24 | #define RJ_PRIMARY_RADIO 1 |
jjones646 | 2:7d523bdd2f50 | 25 | |
jjones646 | 2:7d523bdd2f50 | 26 | // Enable/Disable the `Secondary Radio Interface` (2.4GHz band). |
jjones646 | 2:7d523bdd2f50 | 27 | #define RJ_SECONDARY_RADIO 0 |
jjones646 | 2:7d523bdd2f50 | 28 | |
jjones646 | 2:7d523bdd2f50 | 29 | // Enable/Disable the `Motion Processor Interface` (MPU-9250). |
jjones646 | 2:7d523bdd2f50 | 30 | #define RJ_MOTION_PROCESSOR 0 |
jjones646 | 2:7d523bdd2f50 | 31 | |
jjones646 | 2:7d523bdd2f50 | 32 | // The `Watchdog Timer` timeout value. The mbed will reset if the timer is not reset after the number of seconds defined here |
jjones646 | 2:7d523bdd2f50 | 33 | #define RJ_WATCHDOG_TIMER_VALUE 2 // seconds |
jjones646 | 2:7d523bdd2f50 | 34 | |
jjones646 | 2:7d523bdd2f50 | 35 | |
jjones646 | 2:7d523bdd2f50 | 36 | // ** ============================= ** PIN DECLARATIONS ** ============================= ** |
jjones646 | 2:7d523bdd2f50 | 37 | |
jjones646 | 2:7d523bdd2f50 | 38 | // This defines the pin used for the primary radio's `Chip Select` pin |
jjones646 | 1:c935902c73ef | 39 | #define RJ_PRIMARY_RADIO_CS p9 |
jjones646 | 2:7d523bdd2f50 | 40 | |
jjones646 | 2:7d523bdd2f50 | 41 | // This defines the pin used for the primary radio's `Interrupt` pin |
jjones646 | 1:c935902c73ef | 42 | #define RJ_PRIMARY_RADIO_INT p8 |
jjones646 | 2:7d523bdd2f50 | 43 | |
jjones646 | 2:7d523bdd2f50 | 44 | // This defines the pin used for the secondary radio's `Chip Enable` pin |
jjones646 | 2:7d523bdd2f50 | 45 | #define RJ_SECONDARY_RADIO_CE p10 |
jjones646 | 2:7d523bdd2f50 | 46 | |
jjones646 | 2:7d523bdd2f50 | 47 | // This defines the pin used for the secondary radio's `Chip Select` pin |
jjones646 | 2:7d523bdd2f50 | 48 | #define RJ_SECONDARY_RADIO_CS p11 |
jjones646 | 2:7d523bdd2f50 | 49 | |
jjones646 | 2:7d523bdd2f50 | 50 | // This defines the pin used for the secondary radio's `Interrupt` pin |
jjones646 | 2:7d523bdd2f50 | 51 | #define RJ_SECONDARY_RADIO_IRQ p12 |
jjones646 | 2:7d523bdd2f50 | 52 | |
jjones646 | 2:7d523bdd2f50 | 53 | // This defines the pin used for the primary radio's `GDO2` pin |
jjones646 | 2:7d523bdd2f50 | 54 | #define RJ_PRIMARY_RADIO_GDO2 p13 |
jjones646 | 2:7d523bdd2f50 | 55 | |
jjones646 | 2:7d523bdd2f50 | 56 | // This defines the speaker's audio output pin |
jjones646 | 1:c935902c73ef | 57 | #define RJ_SPEAKER_OUT p18 |
jjones646 | 2:7d523bdd2f50 | 58 | |
jjones646 | 2:7d523bdd2f50 | 59 | // This defines the ball sensor's detector pin |
jjones646 | 1:c935902c73ef | 60 | #define RJ_BALL_DETECTOR p19 |
jjones646 | 2:7d523bdd2f50 | 61 | |
jjones646 | 2:7d523bdd2f50 | 62 | // This defines the ball sensor's emitter pin |
jjones646 | 1:c935902c73ef | 63 | #define RJ_BALL_EMITTER p20 |
jjones646 | 1:c935902c73ef | 64 | |
jjones646 | 2:7d523bdd2f50 | 65 | // This defines the pin used for the secondary radio's `Chip Select` pin |
jjones646 | 2:7d523bdd2f50 | 66 | // #define RJ_SECONDARY_RADIO_CS p21 |
jjones646 | 1:c935902c73ef | 67 | |
jjones646 | 2:7d523bdd2f50 | 68 | // This defines the pin used for indicating mbed runtime activity |
jjones646 | 1:c935902c73ef | 69 | #define RJ_STATUS_LED LED1 |
jjones646 | 2:7d523bdd2f50 | 70 | |
jjones646 | 2:7d523bdd2f50 | 71 | // These pin declarations are used for showing `TX` & `RX` radio connectivity |
jjones646 | 1:c935902c73ef | 72 | #define RJ_TX_LED LED2 |
jjones646 | 1:c935902c73ef | 73 | #define RJ_RX_LED LED3 |
jjones646 | 1:c935902c73ef | 74 | |
jjones646 | 2:7d523bdd2f50 | 75 | // This defines the pin used for a miscellaneous LED |
jjones646 | 2:7d523bdd2f50 | 76 | #define RJ_MISC_LED LED4 |
jjones646 | 2:7d523bdd2f50 | 77 | |
jjones646 | 2:7d523bdd2f50 | 78 | // This defines the pins used for a `Serial Connection` over the mbed's USB port (for use with a virtual serial connection to a computer) |
jjones646 | 1:c935902c73ef | 79 | #define RJ_SERIAL_RXTX MBED_UARTUSB |
jjones646 | 2:7d523bdd2f50 | 80 | |
jjones646 | 2:7d523bdd2f50 | 81 | // This defines the mbed pins used for its `Serial Peripheral Interface` |
jjones646 | 2:7d523bdd2f50 | 82 | #define RJ_SPI_BUS p5, p6, p7 // MOSI, MISO, SCK |
jjones646 | 2:7d523bdd2f50 | 83 | |
jjones646 | 2:7d523bdd2f50 | 84 | // This defines the mbed pins used for its `I2C Interface` |
jjones646 | 2:7d523bdd2f50 | 85 | #define RJ_I2C_BUS p28, p27 // SDA, SCL |
jjones646 | 2:7d523bdd2f50 | 86 | |
jjones646 | 2:7d523bdd2f50 | 87 | // This defines the mbed pin used for reading an analog voltage for the robot's battery |
jjones646 | 2:7d523bdd2f50 | 88 | #define RJ_BATT_IN p14 |
jjones646 | 2:7d523bdd2f50 | 89 | |
jjones646 | 2:7d523bdd2f50 | 90 | // This defines the mbed pin used for communicating to one of Adafruit's `Neopixel LEDs` for the primary power LED (RGB LEB) |
jjones646 | 2:7d523bdd2f50 | 91 | #define RJ_POWER_LED p16 |
jjones646 | 2:7d523bdd2f50 | 92 | |
jjones646 | 2:7d523bdd2f50 | 93 | // This defines the mbed pin used as an `Interrupt` for the MPU-9250 |
jjones646 | 2:7d523bdd2f50 | 94 | #define RJ_MOTION_PROCESSOR_INT p17 |
jjones646 | 2:7d523bdd2f50 | 95 | |
jjones646 | 2:7d523bdd2f50 | 96 | // This defines the mbed pin used as the 'Chip Select` pin for the MPU-9250 |
jjones646 | 2:7d523bdd2f50 | 97 | #define RJ_MOTION_PROCESSOR_CS p19 |
jjones646 | 1:c935902c73ef | 98 | |
jjones646 | 2:7d523bdd2f50 | 99 | // This defines the mbed pin used as the `Chip Select` pin for the Spartan-3E FPGA |
jjones646 | 2:7d523bdd2f50 | 100 | #define RJ_FPGA_CS p24 |
jjones646 | 2:7d523bdd2f50 | 101 | |
jjones646 | 2:7d523bdd2f50 | 102 | // These two (2) pins are used for configuring the FPGA upon startup |
jjones646 | 2:7d523bdd2f50 | 103 | #define RJ_FPGA_FS0 p23 |
jjones646 | 2:7d523bdd2f50 | 104 | #define RJ_FPGA_FS1 p22 |
jjones646 | 2:7d523bdd2f50 | 105 | |
jjones646 | 2:7d523bdd2f50 | 106 | // This defines the mbed pin used as the `Chip Select` pin for the 16 pin I/O expander |
jjones646 | 2:7d523bdd2f50 | 107 | #define RJ_IO_EXPANDER_CS p29 |
jjones646 | 2:7d523bdd2f50 | 108 | |
jjones646 | 2:7d523bdd2f50 | 109 | // This defines the mbed pin used as the `Chip Select` pin for reading the kicker's voltage from an external ADC using I2C communication |
jjones646 | 2:7d523bdd2f50 | 110 | #define RJ_ADC_CS p26 |
jjones646 | 2:7d523bdd2f50 | 111 | |
jjones646 | 2:7d523bdd2f50 | 112 | // This defines the mbed pin used as the `Program` pin for the FPGA's configuration |
jjones646 | 2:7d523bdd2f50 | 113 | #define RJ_FPGA_PROG p25 |
jjones646 | 2:7d523bdd2f50 | 114 | |
jjones646 | 2:7d523bdd2f50 | 115 | // These are the leftover pins. This will be used for the finalized design - designs changes are in progress |
jjones646 | 2:7d523bdd2f50 | 116 | #define RJ_UNUSED_1 p15 |
jjones646 | 2:7d523bdd2f50 | 117 | #define RJ_UNUSED_2 p30 |
jjones646 | 2:7d523bdd2f50 | 118 | |
jjones646 | 2:7d523bdd2f50 | 119 | |
jjones646 | 2:7d523bdd2f50 | 120 | // ** ============================= ** DO NOT EDIT ANYTHING BELOW HERE ** ============================= ** |
jjones646 | 2:7d523bdd2f50 | 121 | // ** ================================================================================================= ** |
jjones646 | 1:c935902c73ef | 122 | |
jjones646 | 3:dc7e9c6bc26c | 123 | // Include the basic classes - Note: the header files included within "mbed.h" are listed here. |
jjones646 | 1:c935902c73ef | 124 | #include "mbed.h" |
jjones646 | 2:7d523bdd2f50 | 125 | /* |
jjones646 | 2:7d523bdd2f50 | 126 | #include <stdio.h> |
jjones646 | 2:7d523bdd2f50 | 127 | #include <stdlib.h> |
jjones646 | 2:7d523bdd2f50 | 128 | #include <string.h> |
jjones646 | 2:7d523bdd2f50 | 129 | #include <math.h> |
jjones646 | 2:7d523bdd2f50 | 130 | #include <time.h> |
jjones646 | 2:7d523bdd2f50 | 131 | |
jjones646 | 2:7d523bdd2f50 | 132 | #include "error.h" |
jjones646 | 2:7d523bdd2f50 | 133 | #include "mbed_interface.h" |
jjones646 | 2:7d523bdd2f50 | 134 | |
jjones646 | 2:7d523bdd2f50 | 135 | #include "DigitalIn.h" |
jjones646 | 2:7d523bdd2f50 | 136 | #include "DigitalOut.h" |
jjones646 | 2:7d523bdd2f50 | 137 | #include "DigitalInOut.h" |
jjones646 | 2:7d523bdd2f50 | 138 | #include "BusIn.h" |
jjones646 | 2:7d523bdd2f50 | 139 | #include "BusOut.h" |
jjones646 | 2:7d523bdd2f50 | 140 | #include "BusInOut.h" |
jjones646 | 2:7d523bdd2f50 | 141 | #include "PortIn.h" |
jjones646 | 2:7d523bdd2f50 | 142 | #include "PortInOut.h" |
jjones646 | 2:7d523bdd2f50 | 143 | #include "PortOut.h" |
jjones646 | 2:7d523bdd2f50 | 144 | #include "AnalogIn.h" |
jjones646 | 2:7d523bdd2f50 | 145 | #include "AnalogOut.h" |
jjones646 | 2:7d523bdd2f50 | 146 | #include "PwmOut.h" |
jjones646 | 2:7d523bdd2f50 | 147 | #include "Serial.h" |
jjones646 | 2:7d523bdd2f50 | 148 | #include "SerialHalfDuplex.h" |
jjones646 | 2:7d523bdd2f50 | 149 | #include "SPI.h" |
jjones646 | 2:7d523bdd2f50 | 150 | #include "SPISlave.h" |
jjones646 | 2:7d523bdd2f50 | 151 | #include "SPIHalfDuplex.h" |
jjones646 | 2:7d523bdd2f50 | 152 | #include "I2C.h" |
jjones646 | 2:7d523bdd2f50 | 153 | #include "I2CSlave.h" |
jjones646 | 2:7d523bdd2f50 | 154 | #include "Ethernet.h" |
jjones646 | 2:7d523bdd2f50 | 155 | #include "CAN.h" |
jjones646 | 2:7d523bdd2f50 | 156 | |
jjones646 | 2:7d523bdd2f50 | 157 | #include "Timer.h" |
jjones646 | 2:7d523bdd2f50 | 158 | #include "Ticker.h" |
jjones646 | 2:7d523bdd2f50 | 159 | #include "Timeout.h" |
jjones646 | 2:7d523bdd2f50 | 160 | #include "LocalFileSystem.h" |
jjones646 | 2:7d523bdd2f50 | 161 | #include "InterruptIn.h" |
jjones646 | 2:7d523bdd2f50 | 162 | #include "wait_api.h" |
jjones646 | 2:7d523bdd2f50 | 163 | #include "rtc_time.h" |
jjones646 | 2:7d523bdd2f50 | 164 | */ |
jjones646 | 2:7d523bdd2f50 | 165 | |
jjones646 | 3:dc7e9c6bc26c | 166 | // Include header file for the CMSIS Real Time Operating System |
jjones646 | 3:dc7e9c6bc26c | 167 | #include "cmsis_os.h" |
jjones646 | 3:dc7e9c6bc26c | 168 | |
jjones646 | 2:7d523bdd2f50 | 169 | #if RJ_CHECK_FIRMWARE |
jjones646 | 2:7d523bdd2f50 | 170 | #include "FirmwareCheck.h" |
jjones646 | 2:7d523bdd2f50 | 171 | #endif |
jjones646 | 2:7d523bdd2f50 | 172 | |
jjones646 | 2:7d523bdd2f50 | 173 | // Include the header file for the watchdog timer class |
jjones646 | 1:c935902c73ef | 174 | #include "Watchdog.h" |
jjones646 | 1:c935902c73ef | 175 | |
jjones646 | 2:7d523bdd2f50 | 176 | // Include the base classes for communication if a communication link is active |
jjones646 | 2:7d523bdd2f50 | 177 | #if RJ_PRIMARY_RADIO | RJ_SECONDARY_RADIO |
jjones646 | 4:989d51f3e6ef | 178 | #include "CommModule.h" |
jjones646 | 4:989d51f3e6ef | 179 | #include "CommLink.h" |
jjones646 | 2:7d523bdd2f50 | 180 | #endif |
jjones646 | 2:7d523bdd2f50 | 181 | |
jjones646 | 2:7d523bdd2f50 | 182 | // Include the primary radio class if 915MHz band radio [if active] |
jjones646 | 1:c935902c73ef | 183 | #if RJ_PRIMARY_RADIO |
jjones646 | 1:c935902c73ef | 184 | #include "CC1101.h" |
jjones646 | 1:c935902c73ef | 185 | #endif |
jjones646 | 1:c935902c73ef | 186 | |
jjones646 | 2:7d523bdd2f50 | 187 | // Include the secondary radio class if 2.4GHz band radio [if active] |
jjones646 | 2:7d523bdd2f50 | 188 | #if RJ_SECONDARY_RADIO |
jjones646 | 2:7d523bdd2f50 | 189 | #include "nRF24L01.h" |
jjones646 | 2:7d523bdd2f50 | 190 | #endif |
jjones646 | 1:c935902c73ef | 191 | |
jjones646 | 3:dc7e9c6bc26c | 192 | #include "Logger.h" |
jjones646 | 3:dc7e9c6bc26c | 193 | |
jjones646 | 1:c935902c73ef | 194 | #endif // ROBOT_H |